diff --git a/doc/source/fmpq.rst b/doc/source/fmpq.rst index 0774fefefc..7e6e28bf69 100644 --- a/doc/source/fmpq.rst +++ b/doc/source/fmpq.rst @@ -183,6 +183,9 @@ Conversion Sets ``a``, ``b`` to the numerator and denominator of ``c`` respectively. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: void fmpq_set_si(fmpq_t res, slong p, ulong q) Sets ``res`` to the canonical form of the fraction ``p / q``. @@ -206,6 +209,9 @@ Conversion Sets the value of ``dest`` to that of the ``mpq_t`` variable ``src``. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: int fmpq_set_str(fmpq_t dest, const char * s, int base) Sets the value of ``dest`` to the value represented in the string @@ -222,6 +228,9 @@ Conversion Sets the value of ``dest`` + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: 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``, @@ -268,10 +277,16 @@ Conversion This provides a convenient function for user code, only requiring to work with the types ``fmpq_t`` and ``mpq_t``. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: void flint_mpq_clear_readonly(mpq_t z) Clears the readonly ``mpq_t`` `z`. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: void fmpq_init_set_readonly(fmpq_t f, const mpq_t z) Sets the uninitialised ``fmpq_t`` `f` to a readonly diff --git a/doc/source/fmpz.rst b/doc/source/fmpz.rst index 48f9d59bc7..fdae8a70cc 100644 --- a/doc/source/fmpz.rst +++ b/doc/source/fmpz.rst @@ -130,16 +130,35 @@ Types, macros and constants A macro which returns `1` if `f` represents an ``mpz_t``, otherwise `0` is returned. +.. macro:: MPZ_MIN_ALLOC + + A constant determining the minimum number of limbs the *fmpz* memory manager + will allocate for each *mpz*. This constant is currently 2. + .. function:: mpz_ptr _fmpz_new_mpz(void) - Initialises a new ``mpz_t`` and returns a pointer to it. This is only used - internally. + Returns a pointer to an initialised *mpz* with at least + :macro:`MPZ_MIN_ALLOC` limbs allocated. This is only used internally. + + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. .. function:: void _fmpz_clear_mpz(fmpz f) - Clears the ``mpz_t`` "pointed to" by the ``fmpz`` `f`. This is only used + Clears the *mpz* "pointed to" by the *fmpz* *f*. This is only used internally. +.. note:: + + As of FLINT 3.2.0, it is required that the *mpz* pointed to by *f* has at + least :macro:`MPZ_MIN_ALLOC` limbs allocated when :func:`_fmpz_clear_mpz` is + called. Note that GMP functions never reduce the number of allocated limbs, + apart from a bug in ``mpz_remove`` which as of GMP 6.3.0 may reduce the + number of allocated limbs in the output *mpz*. Hence, as long as + ``mpz_realloc`` never is called with a second argument less than + :macro:`MPZ_MIN_ALLOC` on an *mpz* received from :func:`_fmpz_new_mpz`, any + other usage should be fine. + .. function:: void _fmpz_cleanup_mpz_content() This function does nothing in the reentrant version of ``fmpz``. @@ -153,6 +172,9 @@ Types, macros and constants If `f` doesn't represent an ``mpz_t``, initialise one and associate it to `f`. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: mpz_ptr _fmpz_promote_val(fmpz_t f) If `f` doesn't represent an ``mpz_t``, initialise one and associate it to @@ -163,6 +185,9 @@ Types, macros and constants inconsistent state with respect to the other Flint ``fmpz`` functions such as ``fmpz_is_zero``, etc. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: void _fmpz_demote(fmpz_t f) If `f` represents an ``mpz_t`` clear it and make `f` just represent an @@ -303,10 +328,16 @@ Conversion Sets `f` to the ``mpf_t`` `x`, rounding down towards zero if the value of `x` is fractional. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: void fmpz_get_mpf(mpf_t x, const fmpz_t f) Sets the value of the ``mpf_t`` `x` to the value of `f`. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: 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 @@ -325,6 +356,9 @@ Conversion Sets the ``mpz_t`` `x` to the same value as `f`. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: int fmpz_get_mpn(nn_ptr * n, fmpz_t n_in) Sets the ``nn_ptr`` `n` to the same value as `n_{in}`. Returned @@ -412,6 +446,13 @@ Conversion 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). +.. function:: void fmpz_set_mpn_large(fmpz_t z, nn_srcptr src, slong 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. + .. function:: void fmpz_get_signed_uiui(ulong * hi, ulong * lo, const fmpz_t in) Retrieves the value of `in` modulo `2^{2 * FLINT\_BITS}` and puts the high @@ -421,6 +462,9 @@ Conversion Sets `f` to the given ``mpz_t`` value. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: int fmpz_set_str(fmpz_t f, const char * str, int b) Sets `f` to the value given in the null-terminated string ``str``, @@ -471,10 +515,16 @@ Conversion _fmpz_demote_val(f); } + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: void flint_mpz_clear_readonly(mpz_t z) Clears the readonly ``mpz_t`` `z`. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: void fmpz_init_set_readonly(fmpz_t f, const mpz_t z) Sets the uninitialised ``fmpz_t`` `f` to a readonly @@ -498,6 +548,9 @@ Conversion fmpz_clear_readonly(f); } + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: void fmpz_clear_readonly(fmpz_t f) Clears the readonly ``fmpz_t`` `f`. diff --git a/doc/source/fmpz_extras.rst b/doc/source/fmpz_extras.rst index a42090066f..bbcad16a5c 100644 --- a/doc/source/fmpz_extras.rst +++ b/doc/source/fmpz_extras.rst @@ -82,13 +82,6 @@ so these methods should not be used gratuitously. Low-level conversions ------------------------------------------------------------------------------- -.. function:: void fmpz_set_mpn_large(fmpz_t z, nn_srcptr src, slong 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. - .. macro:: FMPZ_GET_MPN_READONLY(zsign, zn, zptr, ztmp, zv) Given an *fmpz_t* *zv*, this macro sets *zptr* to a pointer to the limbs of *zv*, diff --git a/doc/source/padic.rst b/doc/source/padic.rst index 3835ce609d..f7ac874b4b 100644 --- a/doc/source/padic.rst +++ b/doc/source/padic.rst @@ -204,10 +204,16 @@ reduced to the precision of ``rop``. Sets the `p`-adic number ``rop`` to the GMP integer ``op``. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: void padic_set_mpq(padic_t rop, const mpq_t op, const padic_ctx_t ctx) Sets ``rop`` to the GMP rational ``op``. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: 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``. @@ -224,10 +230,16 @@ reduced to the precision of ``rop``. If ``op`` is not a `p`-adic integer, raises an ``abort`` signal. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: void padic_get_mpq(mpq_t rop, const padic_t op, const padic_ctx_t ctx) Sets the GMP rational ``rop`` to the value of ``op``. + **Note:** Requires that ``gmp.h`` has been included before any FLINT + header is included. + .. function:: void padic_swap(padic_t op1, padic_t op2) Swaps the two `p`-adic numbers ``op1`` and ``op2``. diff --git a/src/NTL-interface.h b/src/NTL-interface.h index 90a21f32fb..d3d315b0fa 100644 --- a/src/NTL-interface.h +++ b/src/NTL-interface.h @@ -14,6 +14,7 @@ #ifndef FLINT_NTL_INT_H #define FLINT_NTL_INT_H +#include #include #include #include diff --git a/src/arf.h b/src/arf.h index e4f4c9403b..e0af0aab9b 100644 --- a/src/arf.h +++ b/src/arf.h @@ -18,6 +18,7 @@ #define ARF_INLINE static inline #endif +#include #include "mag.h" #include "arf_types.h" diff --git a/src/arf/get.c b/src/arf/get.c index 9ad108f66a..b731b26a92 100644 --- a/src/arf/get.c +++ b/src/arf/get.c @@ -179,14 +179,12 @@ arf_get_fmpz_2exp(fmpz_t man, fmpz_t exp, const arf_t x) else { mpz_ptr z = _fmpz_promote(man); - - if (z->_mp_alloc < xn) - mpz_realloc(z, xn); + mp_ptr zptr = FLINT_MPZ_REALLOC(z, xn); if (shift == 0) - flint_mpn_copyi(z->_mp_d, xptr, xn); + flint_mpn_copyi(zptr, xptr, xn); else - mpn_rshift(z->_mp_d, xptr, xn, shift); + mpn_rshift(zptr, xptr, xn, shift); /* top limb cannot be zero */ z->_mp_size = ARF_SGNBIT(x) ? -xn : xn; @@ -321,10 +319,7 @@ arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd) zn = (exp + (rnd != ARF_RND_DOWN) + FLINT_BITS - 1) / FLINT_BITS; zz = _fmpz_promote(z); - if (zz->_mp_alloc < zn) - mpz_realloc2(zz, zn * FLINT_BITS); - - zp = zz->_mp_d; + zp = FLINT_MPZ_REALLOC(zz, zn); if (rnd == ARF_RND_DOWN) { diff --git a/src/arith/bell_number_multi_mod.c b/src/arith/bell_number_multi_mod.c index 8704fc14f7..aa170713c3 100644 --- a/src/arith/bell_number_multi_mod.c +++ b/src/arith/bell_number_multi_mod.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "nmod.h" #include "fmpz.h" #include "arith.h" diff --git a/src/arith/bell_number_size.c b/src/arith/bell_number_size.c index 23e458879c..a65c37d2a0 100644 --- a/src/arith/bell_number_size.c +++ b/src/arith/bell_number_size.c @@ -10,7 +10,7 @@ */ #include -#include "flint.h" +#include "arith.h" double arith_bell_number_size(ulong n) diff --git a/src/arith/test/main.c b/src/arith/test/main.c index 1795283af3..d31cb19772 100644 --- a/src/arith/test/main.c +++ b/src/arith/test/main.c @@ -9,6 +9,8 @@ (at your option) any later version. See . */ +#include + /* Include functions *********************************************************/ #include "t-bell_number.c" diff --git a/src/calcium.h b/src/calcium.h index 19fd0a4917..d3b1aa60aa 100644 --- a/src/calcium.h +++ b/src/calcium.h @@ -144,17 +144,7 @@ const char * calcium_func_name(calcium_func_code func); /* Flint extras */ -/* slower alternative: fmpz_fdiv_ui(x 1000000007) */ -CALCIUM_INLINE ulong calcium_fmpz_hash(const fmpz_t x) -{ - if (!COEFF_IS_MPZ(*x)) - return *x; - else - { - mpz_ptr z = COEFF_TO_PTR(*x); - return (z->_mp_size > 0) ? z->_mp_d[0] : -z->_mp_d[0]; - } -} +ulong calcium_fmpz_hash(const fmpz_t x); #ifdef __cplusplus } diff --git a/src/fmpq/get_d.c b/src/calcium/fmpz_hash.c similarity index 50% rename from src/fmpq/get_d.c rename to src/calcium/fmpz_hash.c index 0ff1420005..30e7641733 100644 --- a/src/fmpq/get_d.c +++ b/src/calcium/fmpz_hash.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2019 Daniel Schultz + Copyright (C) 2020 Fredrik Johansson This file is part of FLINT. @@ -9,14 +9,18 @@ (at your option) any later version. See . */ -#include "fmpq.h" +#include +#include "calcium.h" -double fmpq_get_d(const fmpq_t a) +/* slower alternative: fmpz_fdiv_ui(x 1000000007) */ + +ulong calcium_fmpz_hash(const fmpz_t x) { - double d; - mpq_t z; - flint_mpq_init_set_readonly(z, a); - d = mpq_get_d(z); - flint_mpq_clear_readonly(z); - return d; + if (!COEFF_IS_MPZ(*x)) + return *x; + else + { + mpz_ptr z = COEFF_TO_PTR(*x); + return (z->_mp_size > 0) ? z->_mp_d[0] : -z->_mp_d[0]; + } } diff --git a/src/d_mat/inlines.c b/src/d_mat/inlines.c index 857867fcf5..78447f0019 100644 --- a/src/d_mat/inlines.c +++ b/src/d_mat/inlines.c @@ -11,5 +11,4 @@ #define D_MAT_INLINES_C -#include "flint.h" #include "d_mat.h" diff --git a/src/d_vec/inlines.c b/src/d_vec/inlines.c index 29e6f211aa..0724be3337 100644 --- a/src/d_vec/inlines.c +++ b/src/d_vec/inlines.c @@ -11,5 +11,4 @@ #define D_VEC_INLINES_C -#include "flint.h" #include "d_vec.h" diff --git a/src/double_extras/inlines.c b/src/double_extras/inlines.c index 196daab31f..2ff11c72d6 100644 --- a/src/double_extras/inlines.c +++ b/src/double_extras/inlines.c @@ -11,5 +11,4 @@ #define DOUBLE_EXTRAS_INLINES_C -#include "flint.h" #include "double_extras.h" diff --git a/src/fft/fermat_to_mpz.c b/src/fft/fermat_to_mpz.c index 1099d46c24..d7411a4e5b 100644 --- a/src/fft/fermat_to_mpz.c +++ b/src/fft/fermat_to_mpz.c @@ -14,22 +14,23 @@ void fermat_to_mpz(mpz_t m, mp_limb_t * i, mp_size_t limbs) { - mp_limb_signed_t hi; + mp_limb_signed_t hi; + mp_ptr mptr = FLINT_MPZ_REALLOC(m, limbs + 1); - mpz_realloc(m, limbs + 1); - flint_mpn_copyi(m->_mp_d, i, limbs + 1); - hi = i[limbs]; - if (hi < WORD(0)) - { - mpn_neg(m->_mp_d, m->_mp_d, limbs + 1); - m->_mp_size = limbs + 1; - while ((m->_mp_size) && (!m->_mp_d[m->_mp_size - 1])) - m->_mp_size--; - m->_mp_size = -m->_mp_size; - } else - { - m->_mp_size = limbs + 1; - while ((m->_mp_size) && (!m->_mp_d[m->_mp_size - 1])) - m->_mp_size--; - } + flint_mpn_copyi(mptr, i, limbs + 1); + hi = i[limbs]; + if (hi < WORD(0)) + { + mpn_neg(mptr, mptr, limbs + 1); + m->_mp_size = limbs + 1; + while ((m->_mp_size) && (!mptr[m->_mp_size - 1])) + m->_mp_size--; + m->_mp_size = -m->_mp_size; + } + else + { + m->_mp_size = limbs + 1; + while ((m->_mp_size) && (!mptr[m->_mp_size - 1])) + m->_mp_size--; + } } diff --git a/src/fft/profile/p-mul_fft_main.c b/src/fft/profile/p-mul_fft_main.c index 29b42edc9e..95376dc07d 100644 --- a/src/fft/profile/p-mul_fft_main.c +++ b/src/fft/profile/p-mul_fft_main.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "mpn_extras.h" #include "fft.h" diff --git a/src/fft/profile/p-mul_mfa_truncate_sqrt2.c b/src/fft/profile/p-mul_mfa_truncate_sqrt2.c index 97b48d1a8f..604f332d83 100644 --- a/src/fft/profile/p-mul_mfa_truncate_sqrt2.c +++ b/src/fft/profile/p-mul_mfa_truncate_sqrt2.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "mpn_extras.h" #include "fft.h" diff --git a/src/fft/profile/p-mul_truncate_sqrt2.c b/src/fft/profile/p-mul_truncate_sqrt2.c index 1b6a656fc4..e4ae8563a2 100644 --- a/src/fft/profile/p-mul_truncate_sqrt2.c +++ b/src/fft/profile/p-mul_truncate_sqrt2.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "mpn_extras.h" #include "fft.h" diff --git a/src/fft/tune/tune-fft.c b/src/fft/tune/tune-fft.c index ad24818ad1..44fbf2dbaa 100644 --- a/src/fft/tune/tune-fft.c +++ b/src/fft/tune/tune-fft.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" #include "fft.h" #include "mpn_extras.h" diff --git a/src/fft_small/fmpz_poly_mul.c b/src/fft_small/fmpz_poly_mul.c index 08f1af9b11..18c2c8a51e 100644 --- a/src/fft_small/fmpz_poly_mul.c +++ b/src/fft_small/fmpz_poly_mul.c @@ -200,10 +200,9 @@ void fmpz_neg_ui_array(fmpz_t out, const ulong * in, slong in_len) else { mpz_ptr mpz = _fmpz_promote(out); - if (mpz->_mp_alloc < size) - mpz_realloc2(mpz, FLINT_BITS * size); + mp_ptr mp = FLINT_MPZ_REALLOC(mpz, size); mpz->_mp_size = -size; - flint_mpn_copyi(mpz->_mp_d, in, size); + flint_mpn_copyi(mp, in, size); } } diff --git a/src/flint.h.in b/src/flint.h.in index 8fa9fb55c6..5362e59a5e 100644 --- a/src/flint.h.in +++ b/src/flint.h.in @@ -478,10 +478,17 @@ typedef fmpq fmpq_t[1]; /* Conversions between mpz_ptr and fmpz_t */ #define PTR_TO_COEFF(x) (((ulong) (x) >> 2) | (WORD(1) << (FLINT_BITS - 2))) -#define COEFF_TO_PTR(x) ((mpz_ptr) (((ulong)x) << 2)) +#define COEFF_TO_PTR(x) ((mpz_ptr) ((ulong) (x) << 2)) #define COEFF_IS_MPZ(x) (((x) >> SMALL_FMPZ_BITCOUNT_MAX) == WORD(1)) +/* The minimum number of limbs that the fmpz collector should spit out */ +#define MPZ_MIN_ALLOC 2 + +/* NOTE: Never allocate less than MPZ_MIN_ALLOC */ +#define FLINT_MPZ_REALLOC(ptr, sz) ((int) (sz) > ((ptr)->_mp_alloc) ? (mp_ptr) mpz_realloc(ptr, sz) : (ptr)->_mp_d) +#define FLINT_MPZ_REALLOC_TIGHT(ptr, sz) ((mp_ptr) mpz_realloc(ptr, FLINT_MAX(sz, MPZ_MIN_ALLOC))) + #ifdef __cplusplus } #endif diff --git a/src/fmpq.h b/src/fmpq.h index c0ff7b5833..5ccb02f708 100644 --- a/src/fmpq.h +++ b/src/fmpq.h @@ -1,6 +1,7 @@ /* Copyright (C) 2011 Fredrik Johansson Copyright (C) 2011 Sebastian Pancratz + Copyright (C) 2024 Albin Ahlbäck This file is part of FLINT. @@ -27,6 +28,8 @@ extern "C" { #define FMPQ_RECONSTRUCT_HGCD_CUTOFF 500 +/* memory management *********************************************************/ + FMPQ_INLINE void fmpq_init(fmpq_t x) { x->num = WORD(0); @@ -39,6 +42,19 @@ FMPQ_INLINE void fmpq_clear(fmpq_t x) fmpz_clear(fmpq_denref(x)); } +FMPQ_INLINE void fmpq_swap(fmpq_t op1, fmpq_t op2) +{ + FLINT_SWAP(fmpq, *op1, *op2); +} + +void _fmpq_canonicalise(fmpz_t num, fmpz_t den); +void fmpq_canonicalise(fmpq_t res); + +int _fmpq_is_canonical(const fmpz_t num, const fmpz_t den); +int fmpq_is_canonical(const fmpq_t x); + +/* assignments ***************************************************************/ + FMPQ_INLINE void fmpq_zero(fmpq_t res) { fmpz_zero(fmpq_numref(res)); @@ -51,17 +67,54 @@ FMPQ_INLINE void fmpq_one(fmpq_t res) fmpz_one(fmpq_denref(res)); } -FMPQ_INLINE int fmpq_equal(const fmpq_t x, const fmpq_t y) +FMPQ_INLINE void fmpq_set(fmpq_t dest, const fmpq_t src) { - return fmpz_equal(fmpq_numref(x), fmpq_numref(y)) && - fmpz_equal(fmpq_denref(x), fmpq_denref(y)); + fmpz_set(fmpq_numref(dest), fmpq_numref(src)); + fmpz_set(fmpq_denref(dest), fmpq_denref(src)); } -FMPQ_INLINE int fmpq_sgn(const fmpq_t x) +#ifdef __GMP_H__ +void flint_mpq_init_set_readonly(mpq_t z, const fmpq_t f); +void flint_mpq_clear_readonly(mpq_t z); + +void fmpq_init_set_readonly(fmpq_t f, const mpq_t z); +void fmpq_clear_readonly(fmpq_t f); +#endif + +/* conversions ***************************************************************/ + +void _fmpq_set_si(fmpz_t rnum, fmpz_t rden, slong p, ulong q); +void _fmpq_set_ui(fmpz_t rnum, fmpz_t rden, ulong p, ulong q); + +void fmpq_set_si(fmpq_t res, slong p, ulong q); +void fmpq_set_ui(fmpq_t res, ulong p, ulong q); +void fmpq_set_fmpz_frac(fmpq_t res, const fmpz_t p, const fmpz_t q); +#ifdef __GMP_H__ +void fmpq_set_mpq(fmpq_t dest, const mpq_t src); +#endif + +FMPQ_INLINE void fmpq_set_fmpz(fmpq_t q, const fmpz_t n) { - return fmpz_sgn(fmpq_numref(x)); + fmpz_set(fmpq_numref(q), n); + fmpz_one(fmpq_denref(q)); } +double fmpq_get_d(const fmpq_t a); +#ifdef __GMP_H__ +void fmpq_get_mpz_frac(mpz_t a, mpz_t b, fmpq_t c); +void fmpq_get_mpq(mpq_t dest, const fmpq_t src); +#endif +#ifdef __MPFR_H +int fmpq_get_mpfr(mpfr_t r, const fmpq_t x, mpfr_rnd_t rnd); +#endif + +int fmpq_set_str(fmpq_t res, const char * str, int base); + +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); + +/* comparisons ***************************************************************/ + FMPQ_INLINE int fmpq_is_zero(const fmpq_t x) { return fmpz_is_zero(fmpq_numref(x)); @@ -77,180 +130,123 @@ FMPQ_INLINE int fmpq_is_pm1(const fmpq_t x) return fmpz_is_pm1(fmpq_numref(x)) && fmpz_is_one(fmpq_denref(x)); } -FMPQ_INLINE void fmpq_set(fmpq_t dest, const fmpq_t src) +FMPQ_INLINE int fmpq_sgn(const fmpq_t x) { - fmpz_set(fmpq_numref(dest), fmpq_numref(src)); - fmpz_set(fmpq_denref(dest), fmpq_denref(src)); + return fmpz_sgn(fmpq_numref(x)); } -FMPQ_INLINE void fmpq_swap(fmpq_t op1, fmpq_t op2) +FMPQ_INLINE int fmpq_equal_si(fmpq_t q, slong n) { - FLINT_SWAP(fmpq, *op1, *op2); + return fmpz_is_one(fmpq_denref(q)) && fmpz_equal_si(fmpq_numref(q), n); } - -FMPQ_INLINE void fmpq_neg(fmpq_t dest, const fmpq_t src) +FMPQ_INLINE int fmpq_equal_ui(fmpq_t q, ulong n) { - fmpz_neg(fmpq_numref(dest), fmpq_numref(src)); - fmpz_set(fmpq_denref(dest), fmpq_denref(src)); + return fmpz_is_one(fmpq_denref(q)) && fmpz_equal_ui(fmpq_numref(q), n); } - -FMPQ_INLINE void fmpq_abs(fmpq_t dest, const fmpq_t src) +FMPQ_INLINE int fmpq_equal(const fmpq_t x, const fmpq_t y) { - fmpz_abs(fmpq_numref(dest), fmpq_numref(src)); - fmpz_set(fmpq_denref(dest), fmpq_denref(src)); + return fmpz_equal(fmpq_numref(x), fmpq_numref(y)) && fmpz_equal(fmpq_denref(x), fmpq_denref(y)); } -int _fmpq_cmp(const fmpz_t p, const fmpz_t q, const fmpz_t r, const fmpz_t s); -int fmpq_cmp(const fmpq_t x, const fmpq_t y); - -int _fmpq_cmp_fmpz(const fmpz_t p, const fmpz_t q, const fmpz_t r); -int fmpq_cmp_fmpz(const fmpq_t x, const fmpz_t y); - +int _fmpq_cmp_si(const fmpz_t p, const fmpz_t q, slong c); int _fmpq_cmp_ui(const fmpz_t p, const fmpz_t q, ulong c); -int fmpq_cmp_ui(const fmpq_t x, ulong c); +int _fmpq_cmp_fmpz(const fmpz_t p, const fmpz_t q, const fmpz_t r); +int _fmpq_cmp(const fmpz_t p, const fmpz_t q, const fmpz_t r, const fmpz_t s); -int _fmpq_cmp_si(const fmpz_t p, const fmpz_t q, slong c); int fmpq_cmp_si(const fmpq_t x, slong c); +int fmpq_cmp_ui(const fmpq_t x, ulong c); +int fmpq_cmp_fmpz(const fmpq_t x, const fmpz_t y); +int fmpq_cmp(const fmpq_t x, const fmpq_t y); -void _fmpq_canonicalise(fmpz_t num, fmpz_t den); -void fmpq_canonicalise(fmpq_t res); - -int _fmpq_is_canonical(const fmpz_t num, const fmpz_t den); -int fmpq_is_canonical(const fmpq_t x); - -void _fmpq_set_ui(fmpz_t rnum, fmpz_t rden, ulong p, ulong q); -void fmpq_set_ui(fmpq_t res, ulong p, ulong q); - -void _fmpq_set_si(fmpz_t rnum, fmpz_t rden, slong p, ulong q); -void fmpq_set_si(fmpq_t res, slong p, ulong q); - -FMPQ_INLINE int fmpq_equal_ui(fmpq_t q, ulong n) -{ - return fmpz_equal_ui(fmpq_numref(q), n) && q->den == WORD(1); -} - -FMPQ_INLINE int fmpq_equal_si(fmpq_t q, slong n) -{ - return fmpz_equal_si(fmpq_numref(q), n) && q->den == WORD(1); -} - -FMPQ_INLINE void fmpq_set_fmpz(fmpq_t q, const fmpz_t n) -{ - fmpz_set(fmpq_numref(q), n); - fmpz_one(fmpq_denref(q)); -} +flint_bitcnt_t fmpq_height_bits(const fmpq_t x); -void fmpq_set_fmpz_frac(fmpq_t res, const fmpz_t p, const fmpz_t q); +void fmpq_height(fmpz_t height, const fmpq_t x); -int fmpq_set_str(fmpq_t res, const char * str, int base); +/* arithmetic ****************************************************************/ -FMPQ_INLINE void fmpq_set_mpq(fmpq_t dest, const mpq_t src) +FMPQ_INLINE void fmpq_neg(fmpq_t dest, const fmpq_t src) { - fmpz_set_mpz(fmpq_numref(dest), mpq_numref(src)); - fmpz_set_mpz(fmpq_denref(dest), mpq_denref(src)); + fmpz_neg(fmpq_numref(dest), fmpq_numref(src)); + fmpz_set(fmpq_denref(dest), fmpq_denref(src)); } -FMPQ_INLINE void fmpq_get_mpq(mpq_t dest, const fmpq_t src) +FMPQ_INLINE void fmpq_abs(fmpq_t dest, const fmpq_t src) { - fmpz_get_mpz(mpq_numref(dest), fmpq_numref(src)); - fmpz_get_mpz(mpq_denref(dest), fmpq_denref(src)); + fmpz_abs(fmpq_numref(dest), fmpq_numref(src)); + fmpz_set(fmpq_denref(dest), fmpq_denref(src)); } -double fmpq_get_d(const fmpq_t a); - -#ifdef __MPFR_H -int fmpq_get_mpfr(mpfr_t r, const fmpq_t x, mpfr_rnd_t rnd); -#endif - -void fmpq_get_mpz_frac(mpz_t a, mpz_t b, fmpq_t c); - -void flint_mpq_init_set_readonly(mpq_t z, const fmpq_t f); - -void flint_mpq_clear_readonly(mpq_t z); - -void fmpq_init_set_readonly(fmpq_t f, const mpq_t z); - -void fmpq_clear_readonly(fmpq_t f); - -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); - -#ifdef FLINT_HAVE_FILE -int _fmpq_fprint(FILE * file, const fmpz_t num, const fmpz_t den); -int fmpq_fprint(FILE * file, const fmpq_t x); -#endif - -int _fmpq_print(const fmpz_t num, const fmpz_t den); -int fmpq_print(const fmpq_t x); - -void _fmpq_randtest(fmpz_t num, fmpz_t den, flint_rand_t state, flint_bitcnt_t bits); -void fmpq_randtest(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); - -void _fmpq_randbits(fmpz_t num, fmpz_t den, flint_rand_t state, flint_bitcnt_t bits); -void fmpq_randbits(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits); - +void _fmpq_add_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_add_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r); void _fmpq_add_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); - 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_add(fmpq_t res, const fmpq_t op1, const fmpq_t op2); -void _fmpq_add_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r); void fmpq_add_si(fmpq_t res, const fmpq_t op1, slong c); - -void _fmpq_add_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r); void fmpq_add_ui(fmpq_t res, const fmpq_t op1, ulong c); - -void _fmpq_add_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r); void fmpq_add_fmpz(fmpq_t res, const fmpq_t op1, const fmpz_t c); +void fmpq_add(fmpq_t res, const fmpq_t op1, const fmpq_t op2); +void _fmpq_sub_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r); +void _fmpq_sub_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong 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_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_sub(fmpq_t res, const fmpq_t op1, const fmpq_t op2); -void _fmpq_sub_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r); void fmpq_sub_si(fmpq_t res, const fmpq_t op1, slong c); - -void _fmpq_sub_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r); void fmpq_sub_ui(fmpq_t res, const fmpq_t op1, ulong c); - -void _fmpq_sub_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r); void fmpq_sub_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_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, slong c); - 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, ulong c); - +void _fmpq_mul_small(fmpz_t rnum, fmpz_t rden, slong p1, ulong q1, slong p2, ulong q2); 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_mul(fmpq_t res, const fmpq_t op1, const fmpq_t op2); +void fmpq_mul_si(fmpq_t res, const fmpq_t op1, slong c); +void fmpq_mul_ui(fmpq_t res, const fmpq_t op1, ulong c); void fmpq_mul_fmpz(fmpq_t res, const fmpq_t op, const fmpz_t x); +void fmpq_mul_2exp(fmpq_t res, const fmpq_t x, flint_bitcnt_t exp); +void fmpq_mul(fmpq_t res, const fmpq_t op1, const fmpq_t op2); + +void fmpq_inv(fmpq_t dest, const fmpq_t src); + +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_div_fmpz(fmpq_t res, const fmpq_t op, const fmpz_t x); +void fmpq_div_2exp(fmpq_t res, const fmpq_t x, flint_bitcnt_t exp); +void fmpq_div(fmpq_t res, const fmpq_t op1, const fmpq_t op2); 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 rop, const fmpq_t op, slong e); +void fmpq_pow_si(fmpq_t rop, const fmpq_t op, slong e); int fmpq_pow_fmpz(fmpq_t a, const fmpq_t b, const fmpz_t e); 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_addmul(fmpq_t res, const fmpq_t op1, const fmpq_t op2); - 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(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_inv(fmpq_t dest, const fmpq_t src); +/* I/O ***********************************************************************/ -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_div(fmpq_t res, const fmpq_t op1, const fmpq_t op2); +#ifdef FLINT_HAVE_FILE +int _fmpq_fprint(FILE * file, const fmpz_t num, const fmpz_t den); +int fmpq_fprint(FILE * file, const fmpq_t x); +#endif -void fmpq_div_fmpz(fmpq_t res, const fmpq_t op, const fmpz_t x); +int _fmpq_print(const fmpz_t num, const fmpz_t den); +int fmpq_print(const fmpq_t x); -void fmpq_mul_2exp(fmpq_t res, const fmpq_t x, flint_bitcnt_t exp); +/* randomisation *************************************************************/ -void fmpq_div_2exp(fmpq_t res, const fmpq_t x, flint_bitcnt_t exp); +void _fmpq_randtest(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); + +void fmpq_randtest(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); +void fmpq_randbits(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits); + +/* modular arithmetic ********************************************************/ 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); @@ -268,9 +264,7 @@ int _fmpq_reconstruct_fmpz_2_naive(fmpz_t n, fmpz_t d, const fmpz_t a, const fmp 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); -flint_bitcnt_t fmpq_height_bits(const fmpq_t x); - -void fmpq_height(fmpz_t height, const fmpq_t x); +/* rational enumeration ******************************************************/ 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); @@ -289,6 +283,8 @@ void fmpq_farey_neighbors(fmpq_t left, fmpq_t right, const fmpq_t mid, const fmp void _fmpq_simplest_between(fmpz_t mid_num, fmpz_t mid_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 mid, const fmpq_t l, const fmpq_t r); +/* continued fractions *******************************************************/ + slong fmpq_get_cfrac_naive(fmpz * c, fmpq_t rem, const fmpq_t x, slong n); slong fmpq_get_cfrac(fmpz * c, fmpq_t rem, const fmpq_t x, slong n); @@ -296,6 +292,8 @@ void fmpq_set_cfrac(fmpq_t x, const fmpz * c, slong n); slong fmpq_cfrac_bound(const fmpq_t x); +/* miscellaneous *************************************************************/ + 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); @@ -319,7 +317,6 @@ typedef struct { typedef _ui_mat22_struct _ui_mat22_t[1]; void _fmpz_mat22_init(_fmpz_mat22_t M); - void _fmpz_mat22_clear(_fmpz_mat22_t M); void _fmpz_mat22_one(_fmpz_mat22_t M); @@ -329,22 +326,16 @@ int _fmpz_mat22_is_one(_fmpz_mat22_t M); flint_bitcnt_t _fmpz_mat22_bits(const _fmpz_mat22_t N); void _fmpz_mat22_rmul(_fmpz_mat22_t M, const _fmpz_mat22_t N); - -void _fmpz_mat22_addmul_inv_vec(fmpz_t ya, fmpz_t yb, - _fmpz_mat22_t N, fmpz_t xa, fmpz_t xb); - -void _fmpz_mat22_addmul_inv_mat(fmpz_t A11, fmpz_t A12, fmpz_t A21, fmpz_t A22, - _fmpz_mat22_t M, fmpz_t B11, fmpz_t B12, fmpz_t B21, fmpz_t B22); - void _fmpz_mat22_rmul_ui(_fmpz_mat22_t M, const _ui_mat22_t N); - void _fmpz_mat22_rmul_inv_ui(_fmpz_mat22_t M, const _ui_mat22_t N); void _fmpz_mat22_rmul_elem(_fmpz_mat22_t M, const fmpz_t q); +void _fmpz_mat22_lmul_elem(_fmpz_mat22_t M, const fmpz_t q); void _fmpz_mat22_rmul_inv_elem(_fmpz_mat22_t M, const fmpz_t q); -void _fmpz_mat22_lmul_elem(_fmpz_mat22_t M, const fmpz_t q); +void _fmpz_mat22_addmul_inv_vec(fmpz_t ya, fmpz_t yb, _fmpz_mat22_t N, fmpz_t xa, fmpz_t xb); +void _fmpz_mat22_addmul_inv_mat(fmpz_t A11, fmpz_t A12, fmpz_t A21, fmpz_t A22, _fmpz_mat22_t M, fmpz_t B11, fmpz_t B12, fmpz_t B21, fmpz_t B22); /******** resizable integer vector specific to cfrac functionality ***********/ @@ -361,13 +352,11 @@ typedef struct typedef _fmpq_cfrac_list_struct _fmpq_cfrac_list_t[1]; void _fmpq_cfrac_list_init(_fmpq_cfrac_list_t v); - void _fmpq_cfrac_list_clear(_fmpq_cfrac_list_t v); void _fmpq_cfrac_list_fit_length(_fmpq_cfrac_list_t v, slong len); void _fmpq_cfrac_list_push_back(_fmpq_cfrac_list_t v, const fmpz_t a); - void _fmpq_cfrac_list_push_back_zero(_fmpq_cfrac_list_t v); void _fmpq_cfrac_list_append_ui(_fmpq_cfrac_list_t v, const ulong * a, slong n); @@ -382,7 +371,6 @@ typedef struct { typedef _fmpq_ball_struct _fmpq_ball_t[1]; void _fmpq_ball_init(_fmpq_ball_t x); - void _fmpq_ball_clear(_fmpq_ball_t x); FLINT_FORCE_INLINE void _fmpq_ball_swap(_fmpq_ball_t x, _fmpq_ball_t y) @@ -404,8 +392,6 @@ fmpz * fmpq_numerator_ptr(fmpq_t q); fmpz * fmpq_denominator_ptr(fmpq_t q); int fmpq_equal_fmpz(fmpq_t q, fmpz_t n); -#define fmpq_init_set_mpz_frac_readonly _Pragma("GCC error \"'fmpq_init_set_mpz_frac_readonly' is deprecated.\"") - #ifdef __cplusplus } #endif diff --git a/src/fmpq/get_mpfr.c b/src/fmpq/get.c similarity index 66% rename from src/fmpq/get_mpfr.c rename to src/fmpq/get.c index 84bbad9aa4..b9f5967f15 100644 --- a/src/fmpq/get_mpfr.c +++ b/src/fmpq/get.c @@ -1,5 +1,7 @@ /* Copyright (C) 2011 Fredrik Johansson + Copyright (C) 2015 William Hart + Copyright (C) 2019 Daniel Schultz This file is part of FLINT. @@ -9,9 +11,31 @@ (at your option) any later version. See . */ -#include "mpfr.h" +#include #include "fmpq.h" +double fmpq_get_d(const fmpq_t a) +{ + double d; + mpq_t z; + flint_mpq_init_set_readonly(z, a); + d = mpq_get_d(z); + flint_mpq_clear_readonly(z); + return d; +} + +void fmpq_get_mpz_frac(mpz_t a, mpz_t b, fmpq_t c) +{ + fmpz_get_mpz(a, fmpq_numref(c)); + fmpz_get_mpz(b, fmpq_denref(c)); +} + +void fmpq_get_mpq(mpq_t dest, const fmpq_t src) +{ + fmpz_get_mpz(mpq_numref(dest), fmpq_numref(src)); + fmpz_get_mpz(mpq_denref(dest), fmpq_denref(src)); +} + int fmpq_get_mpfr(mpfr_t r, const fmpq_t x, mpfr_rnd_t rnd) { diff --git a/src/fmpq/get_mpz_frac.c b/src/fmpq/get_mpz_frac.c deleted file mode 100644 index 551436f8f7..0000000000 --- a/src/fmpq/get_mpz_frac.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - Copyright (C) 2015 William Hart - - This file is part of FLINT. - - FLINT is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. See . -*/ - -#include "fmpz.h" -#include "fmpq.h" - -void fmpq_get_mpz_frac(mpz_t a, mpz_t b, fmpq_t c) -{ - fmpz_get_mpz(a, fmpq_numref(c)); - fmpz_get_mpz(b, fmpq_denref(c)); -} diff --git a/src/fmpq/init_set_readonly.c b/src/fmpq/init_set_readonly.c index e3f821ac0a..1a36c230f3 100644 --- a/src/fmpq/init_set_readonly.c +++ b/src/fmpq/init_set_readonly.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpq.h" void fmpq_init_set_readonly(fmpq_t f, const mpq_t z) diff --git a/src/fmpq/inlines.c b/src/fmpq/inlines.c index 2ce0e3b1ea..8a329819d0 100644 --- a/src/fmpq/inlines.c +++ b/src/fmpq/inlines.c @@ -11,7 +11,6 @@ #define FMPQ_INLINES_C -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fmpq.h" diff --git a/src/fmpq/mpq_clear_readonly.c b/src/fmpq/mpq_clear_readonly.c index ffe2fe6e9c..cbcd2326f1 100644 --- a/src/fmpq/mpq_clear_readonly.c +++ b/src/fmpq/mpq_clear_readonly.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpq.h" void flint_mpq_clear_readonly(mpq_t z) diff --git a/src/fmpq/mpq_init_set_readonly.c b/src/fmpq/mpq_init_set_readonly.c index af2c6101bb..28743524a5 100644 --- a/src/fmpq/mpq_init_set_readonly.c +++ b/src/fmpq/mpq_init_set_readonly.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpq.h" void flint_mpq_init_set_readonly(mpq_t z, const fmpq_t f) diff --git a/src/fmpq/set_fmpz_frac.c b/src/fmpq/set.c similarity index 53% rename from src/fmpq/set_fmpz_frac.c rename to src/fmpq/set.c index 8c118a5fd6..5144d7c5d4 100644 --- a/src/fmpq/set_fmpz_frac.c +++ b/src/fmpq/set.c @@ -1,5 +1,7 @@ /* + Copyright (C) 2011 Fredrik Johansson Copyright (C) 2011 Sebastian Pancratz + Copyright (C) 2020 William Hart This file is part of FLINT. @@ -9,8 +11,59 @@ (at your option) any later version. See . */ +#include +#include "ulong_extras.h" #include "fmpq.h" +void _fmpq_set_si(fmpz_t rnum, fmpz_t rden, slong p, ulong q) +{ + if (q == 1 || p == 0) + { + fmpz_set_si(rnum, p); + fmpz_one(rden); + } + else + { + ulong r = n_gcd(p < 0 ? (-(ulong) p) : (ulong) p, q); + + if (p < 0) + { + fmpz_set_ui(rnum, (-(ulong) p) / r); + fmpz_neg(rnum, rnum); + } + else + fmpz_set_si(rnum, p / r); + + fmpz_set_ui(rden, q / r); + } +} + +void fmpq_set_si(fmpq_t res, slong p, ulong q) +{ + _fmpq_set_si(fmpq_numref(res), fmpq_denref(res), p, q); +} + +void _fmpq_set_ui(fmpz_t rnum, fmpz_t rden, ulong p, ulong q) +{ + if (q == 1 || p == 0) + { + fmpz_set_ui(rnum, p); + fmpz_one(rden); + } + else + { + ulong r = n_gcd(p, q); + + fmpz_set_ui(rnum, p / r); + fmpz_set_ui(rden, q / r); + } +} + +void fmpq_set_ui(fmpq_t res, ulong p, ulong q) +{ + _fmpq_set_ui(fmpq_numref(res), fmpq_denref(res), p, q); +} + void fmpq_set_fmpz_frac(fmpq_t res, const fmpz_t p, const fmpz_t q) { @@ -58,3 +111,9 @@ fmpq_set_fmpz_frac(fmpq_t res, const fmpz_t p, const fmpz_t q) fmpz_clear(t); } } + +void fmpq_set_mpq(fmpq_t dest, const mpq_t src) +{ + fmpz_set_mpz(fmpq_numref(dest), mpq_numref(src)); + fmpz_set_mpz(fmpq_denref(dest), mpq_denref(src)); +} diff --git a/src/fmpq/set_si.c b/src/fmpq/set_si.c deleted file mode 100644 index 2b040ea511..0000000000 --- a/src/fmpq/set_si.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2011 Fredrik Johansson - - This file is part of FLINT. - - FLINT is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. See . -*/ - -#include "ulong_extras.h" -#include "fmpq.h" - -void _fmpq_set_si(fmpz_t rnum, fmpz_t rden, slong p, ulong q) -{ - if (q == 1 || p == 0) - { - fmpz_set_si(rnum, p); - fmpz_one(rden); - } - else - { - ulong r = n_gcd(p < 0 ? (-(ulong) p) : (ulong) p, q); - - if (p < 0) - { - fmpz_set_ui(rnum, (-(ulong) p) / r); - fmpz_neg(rnum, rnum); - } - else - fmpz_set_si(rnum, p / r); - - fmpz_set_ui(rden, q / r); - } -} - -void fmpq_set_si(fmpq_t res, slong p, ulong q) -{ - _fmpq_set_si(fmpq_numref(res), fmpq_denref(res), p, q); -} diff --git a/src/fmpq/set_str.c b/src/fmpq/set_str.c index dee5d93117..3b975ea88b 100644 --- a/src/fmpq/set_str.c +++ b/src/fmpq/set_str.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpq.h" int fmpq_set_str(fmpq_t x, const char *str, int base) diff --git a/src/fmpq/set_ui.c b/src/fmpq/set_ui.c deleted file mode 100644 index f11757dd98..0000000000 --- a/src/fmpq/set_ui.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 2011 Fredrik Johansson - Copyright (C) 2020 William Hart - - This file is part of FLINT. - - FLINT is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. See . -*/ - -#include "ulong_extras.h" -#include "fmpq.h" - -void _fmpq_set_ui(fmpz_t rnum, fmpz_t rden, ulong p, ulong q) -{ - if (q == 1 || p == 0) - { - fmpz_set_ui(rnum, p); - fmpz_one(rden); - } - else - { - ulong r = n_gcd(p, q); - - fmpz_set_ui(rnum, p / r); - fmpz_set_ui(rden, q / r); - } -} - -void fmpq_set_ui(fmpq_t res, ulong p, ulong q) -{ - _fmpq_set_ui(fmpq_numref(res), fmpq_denref(res), p, q); -} diff --git a/src/fmpq_mpoly_factor/inlines.c b/src/fmpq_mpoly_factor/inlines.c index e231839ba6..cde49ce6f2 100644 --- a/src/fmpq_mpoly_factor/inlines.c +++ b/src/fmpq_mpoly_factor/inlines.c @@ -11,6 +11,5 @@ #define FMPQ_MPOLY_FACTOR_INLINES_C -#include "flint.h" #include "ulong_extras.h" #include "fmpq_mpoly_factor.h" diff --git a/src/fmpq_poly/exp_series.c b/src/fmpq_poly/exp_series.c index 7618040f20..827d6b23f8 100644 --- a/src/fmpq_poly/exp_series.c +++ b/src/fmpq_poly/exp_series.c @@ -10,6 +10,7 @@ (at your option) any later version. See . */ +#include #include "ulong_extras.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpq_poly/integral.c b/src/fmpq_poly/integral.c index 1c12bf8257..a6b7266e54 100644 --- a/src/fmpq_poly/integral.c +++ b/src/fmpq_poly/integral.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "ulong_extras.h" #include "fmpz.h" #include "fmpq_poly.h" diff --git a/src/fmpq_poly/test/t-scalar_mul_fmpq.c b/src/fmpq_poly/test/t-scalar_mul_fmpq.c index ff62a48e61..858f2c504a 100644 --- a/src/fmpq_poly/test/t-scalar_mul_fmpq.c +++ b/src/fmpq_poly/test/t-scalar_mul_fmpq.c @@ -38,16 +38,12 @@ TEST_FUNCTION_START(fmpq_poly_scalar_mul_fmpq, state) cflags |= fmpq_poly_is_canonical(b) ? 0 : 2; result = (fmpq_poly_equal(a, b) && !cflags); if (!result) - { - flint_printf("FAIL (aliasing):\n\n"); - flint_printf("a = "), fmpq_poly_debug(a), flint_printf("\n\n"); - flint_printf("b = "), fmpq_poly_debug(b), flint_printf("\n\n"); - flint_printf("z = "), fmpq_print(z), flint_printf("\n\n"); - gmp_printf("z = %Qd\n\n", z); - flint_printf("cflags = %wu\n\n", cflags); - fflush(stdout); - flint_abort(); - } + TEST_FUNCTION_FAIL( + "a = %{fmpq_poly}\n" + "b = %{fmpq_poly}\n" + "z = %{fmpq}\n" + "cflags = %{ulong}\n", + a, b, z, cflags); fmpq_clear(z); fmpq_poly_clear(a); @@ -82,18 +78,15 @@ TEST_FUNCTION_START(fmpq_poly_scalar_mul_fmpq, state) cflags |= fmpq_poly_is_canonical(rhs) ? 0 : 2; result = (fmpq_poly_equal(lhs, rhs) && !cflags); if (!result) - { - flint_printf("FAIL (a * n1 * n2):\n"); - fmpq_poly_debug(a), flint_printf("\n\n"); - flint_printf("z1 = "), fmpq_print(z1), flint_printf("\n\n"); - flint_printf("z2 = "), fmpq_print(z2), flint_printf("\n\n"); - flint_printf("z = "), fmpq_print(z), flint_printf("\n\n"); - fmpq_poly_debug(lhs), flint_printf("\n\n"); - fmpq_poly_debug(rhs), flint_printf("\n\n"); - flint_printf("cflags = %wu\n\n", cflags); - fflush(stdout); - flint_abort(); - } + TEST_FUNCTION_FAIL( + "a = %{fmpq_poly}\n" + "z1 = %{fmpq}\n" + "z2 = %{fmpq}\n" + "z = %{fmpq}\n" + "lhs = %{fmpq_poly}\n" + "rhs = %{fmpq_poly}\n" + "cflags = %{ulong}\n", + a, z1, z2, z, lhs, rhs, cflags); fmpq_clear(z1); fmpq_clear(z2); @@ -130,17 +123,14 @@ TEST_FUNCTION_START(fmpq_poly_scalar_mul_fmpq, state) cflags |= fmpq_poly_is_canonical(rhs) ? 0 : 2; result = (fmpq_poly_equal(lhs, rhs) && !cflags); if (!result) - { - flint_printf("FAIL ((a + b) / n):\n"); - fmpq_poly_debug(a), flint_printf("\n\n"); - fmpq_poly_debug(b), flint_printf("\n\n"); - flint_printf("z = "), fmpq_print(z), flint_printf("\n\n"); - fmpq_poly_debug(lhs), flint_printf("\n\n"); - fmpq_poly_debug(rhs), flint_printf("\n\n"); - flint_printf("cflags = %wu\n\n", cflags); - fflush(stdout); - flint_abort(); - } + TEST_FUNCTION_FAIL( + "a = %{fmpq_poly}\n" + "b = %{fmpq_poly}\n" + "z = %{fmpq}\n" + "lhs = %{fmpq_poly}\n" + "rhs = %{fmpq_poly}\n" + "cflags = %{ulong}\n", + a, b, z, lhs, rhs, cflags); fmpq_clear(z); fmpq_poly_clear(a); diff --git a/src/fmpq_vec/dot.c b/src/fmpq_vec/dot.c index 2b28514400..6818f58782 100644 --- a/src/fmpq_vec/dot.c +++ b/src/fmpq_vec/dot.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpq.h" #include "fmpq_vec.h" diff --git a/src/fmpq_vec/init.c b/src/fmpq_vec/init.c index 6ba8ba969f..c682188261 100644 --- a/src/fmpq_vec/init.c +++ b/src/fmpq_vec/init.c @@ -11,7 +11,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpq.h" #include "fmpq_vec.h" diff --git a/src/fmpq_vec/randtest.c b/src/fmpq_vec/randtest.c index 9550fb3c87..e98e12d68d 100644 --- a/src/fmpq_vec/randtest.c +++ b/src/fmpq_vec/randtest.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpq.h" #include "fmpq_vec.h" diff --git a/src/fmpz.h b/src/fmpz.h index 12848a7bdb..3eb3f7a8f7 100644 --- a/src/fmpz.h +++ b/src/fmpz.h @@ -18,25 +18,33 @@ #define FMPZ_INLINE static inline #endif -#include #include "fmpz_types.h" #include "longlong.h" #ifdef __cplusplus - extern "C" { +extern "C" { #endif /* Memory management *********************************************************/ +#if defined(__GMP_H__) mpz_ptr _fmpz_new_mpz(void); +mpz_ptr _fmpz_promote(fmpz_t f); +mpz_ptr _fmpz_promote_val(fmpz_t f); + +void _fmpz_init_readonly_mpz(fmpz_t f, const mpz_t z); +void flint_mpz_init_set_readonly(mpz_t z, const fmpz_t f); +void fmpz_init_set_readonly(fmpz_t f, const mpz_t z); + +void flint_mpz_clear_readonly(mpz_t z); +void _fmpz_clear_readonly_mpz(mpz_t); +#endif + void _fmpz_clear_mpz(fmpz f); void _fmpz_cleanup_mpz_content(void); void _fmpz_cleanup(void); -mpz_ptr _fmpz_promote(fmpz_t f); -mpz_ptr _fmpz_promote_val(fmpz_t f); - FMPZ_INLINE void _fmpz_demote(fmpz_t f) { @@ -57,9 +65,13 @@ void fmpz_init2(fmpz_t f, ulong limbs); void _fmpz_promote_set_ui(fmpz_t f, ulong v); void _fmpz_promote_set_si(fmpz_t f, slong v); void _fmpz_promote_neg_ui(fmpz_t f, ulong v); +void _fmpz_promote_set_uiui(fmpz_t f, ulong hi, ulong lo); +void _fmpz_promote_neg_uiui(fmpz_t f, ulong hi, ulong lo); void _fmpz_init_promote_set_ui(fmpz_t f, ulong v); void _fmpz_init_promote_set_si(fmpz_t f, slong v); +void fmpz_set(fmpz_t f, const fmpz_t g); + FMPZ_INLINE void fmpz_init_set(fmpz_t f, const fmpz_t g) { @@ -69,10 +81,8 @@ void fmpz_init_set(fmpz_t f, const fmpz_t g) } else { - mpz_ptr ptr; - ptr = _fmpz_new_mpz(); - *f = PTR_TO_COEFF(ptr); - mpz_set(ptr, COEFF_TO_PTR(*g)); + *f = 0; + fmpz_set(f, g); } } @@ -94,12 +104,6 @@ void fmpz_init_set_si(fmpz_t f, slong g) _fmpz_init_promote_set_si(f, g); } -void _fmpz_init_readonly_mpz(fmpz_t f, const mpz_t z); -void flint_mpz_init_set_readonly(mpz_t z, const fmpz_t f); -void fmpz_init_set_readonly(fmpz_t f, const mpz_t z); - -void flint_mpz_clear_readonly(mpz_t z); -void _fmpz_clear_readonly_mpz(mpz_t); void fmpz_clear_readonly(fmpz_t f); int _fmpz_is_canonical(const fmpz_t x); @@ -134,7 +138,6 @@ void fmpz_one(fmpz_t f) *f = WORD(1); } -void fmpz_set(fmpz_t f, const fmpz_t g); FMPZ_INLINE void fmpz_swap(fmpz_t f, fmpz_t g) { FLINT_SWAP(fmpz, *f, *g); } slong fmpz_get_si(const fmpz_t f); @@ -179,8 +182,7 @@ fmpz_neg_ui(fmpz_t f, ulong val) _fmpz_promote_neg_ui(f, val); } -FMPZ_INLINE void -fmpz_get_uiui(ulong * hi, ulong * low, const fmpz_t f) +FMPZ_INLINE void fmpz_get_uiui(ulong * hi, ulong * low, const fmpz_t f) { if (!COEFF_IS_MPZ(*f)) { @@ -189,46 +191,26 @@ fmpz_get_uiui(ulong * hi, ulong * low, const fmpz_t f) } else { - mpz_ptr mpz = COEFF_TO_PTR(*f); - *low = mpz->_mp_d[0]; - *hi = mpz->_mp_size == 2 ? mpz->_mp_d[1] : 0; + zz_srcptr zf = FMPZ_TO_ZZ(*f); + *low = zf->ptr[0]; + *hi = zf->size == 2 ? zf->ptr[1] : 0; } } -FMPZ_INLINE void -fmpz_set_uiui(fmpz_t f, ulong hi, ulong lo) +FMPZ_INLINE void fmpz_set_uiui(fmpz_t f, ulong hi, ulong lo) { if (hi == 0) - { fmpz_set_ui(f, lo); - } else - { - mpz_ptr z = _fmpz_promote(f); - if (z->_mp_alloc < 2) - mpz_realloc2(z, 2 * FLINT_BITS); - z->_mp_d[0] = lo; - z->_mp_d[1] = hi; - z->_mp_size = 2; - } + _fmpz_promote_set_uiui(f, hi, lo); } -FMPZ_INLINE void -fmpz_neg_uiui(fmpz_t f, ulong hi, ulong lo) +FMPZ_INLINE void fmpz_neg_uiui(fmpz_t f, ulong hi, ulong lo) { if (hi == 0) - { fmpz_neg_ui(f, lo); - } else - { - mpz_ptr z = _fmpz_promote(f); - if (z->_mp_alloc < 2) - mpz_realloc2(z, 2 * FLINT_BITS); - z->_mp_d[0] = lo; - z->_mp_d[1] = hi; - z->_mp_size = -2; - } + _fmpz_promote_neg_uiui(f, hi, lo); } void fmpz_get_signed_uiui(ulong * hi, ulong * lo, const fmpz_t x); @@ -256,16 +238,20 @@ void fmpz_set_ui_array(fmpz_t out, const ulong * in, slong n); void fmpz_get_signed_ui_array(ulong * out, slong n, const fmpz_t in); void fmpz_set_signed_ui_array(fmpz_t out, const ulong * in, slong n); -void fmpz_get_mpz(mpz_t x, const fmpz_t f); -void fmpz_set_mpz(fmpz_t f, const mpz_t x); +void fmpz_set_mpn_large(fmpz_t z, nn_srcptr src, slong n, int negative); ulong fmpz_get_nmod(const fmpz_t f, nmod_t mod); double fmpz_get_d(const fmpz_t f); void fmpz_set_d(fmpz_t f, double c); +#if defined(__GMP_H__) +void fmpz_get_mpz(mpz_t x, const fmpz_t f); +void fmpz_set_mpz(fmpz_t f, const mpz_t x); + void fmpz_get_mpf(mpf_t x, const fmpz_t f); void fmpz_set_mpf(fmpz_t f, const mpf_t x); +#endif #ifdef __MPFR_H void fmpz_get_mpfr(mpfr_t x, const fmpz_t f, mpfr_rnd_t rnd); @@ -298,7 +284,7 @@ int fmpz_is_even(const fmpz_t f) if (!COEFF_IS_MPZ(*f)) return !((*f) & WORD(1)); else - return mpz_even_p(COEFF_TO_PTR(*f)); + return !(FMPZ_TO_ZZ(*f)->ptr[0] & 1); } FMPZ_INLINE @@ -307,7 +293,7 @@ int fmpz_is_odd(const fmpz_t f) if (!COEFF_IS_MPZ(*f)) return ((*f) & WORD(1)); else - return mpz_odd_p(COEFF_TO_PTR(*f)); + return (FMPZ_TO_ZZ(*f)->ptr[0] & 1); } int fmpz_sgn(const fmpz_t f); @@ -765,25 +751,6 @@ int fmpz_moebius_mu(const fmpz_t n); void fmpz_divisor_sigma(fmpz_t res, ulong k, const fmpz_t n); -/* Declare dead functions ****************************************************/ - -#define __new_fmpz _Pragma("GCC error \"'__new_fmpz' is deprecated.\"") -#define __free_fmpz _Pragma("GCC error \"'__free_fmpz' is deprecated.\"") -#define __fmpz_lt _Pragma("GCC error \"'__fmpz_lt' is deprecated.\"") -#define __fmpz_gt _Pragma("GCC error \"'__fmpz_gt' is deprecated.\"") -#define __fmpz_lte _Pragma("GCC error \"'__fmpz_lte' is deprecated.\"") -#define __fmpz_gte _Pragma("GCC error \"'__fmpz_gte' is deprecated.\"") -#define __fmpz_neq _Pragma("GCC error \"'__fmpz_neq' is deprecated.\"") - -#define __fmpz_init _Pragma("GCC error \"'__fmpz_init' is deprecated. Use 'fmpz_init' instead.\"") -#define __fmpz_init_set _Pragma("GCC error \"'__fmpz_init_set' is deprecated. Use 'fmpz_init_set' instead.\"") -#define __fmpz_init_set_ui _Pragma("GCC error \"'__fmpz_init_set_ui' is deprecated. Use 'fmpz_init_set_ui' instead.\"") -#define __fmpz_clear _Pragma("GCC error \"'__fmpz_clear' is deprecated. Use 'fmpz_clear' instead.\"") -#define __fmpz_set_si _Pragma("GCC error \"'__fmpz_set_si' is deprecated. Use 'fmpz_set_si' instead.\"") -#define __fmpz_set_ui _Pragma("GCC error \"'__fmpz_set_ui' is deprecated. Use 'fmpz_set_ui' instead.\"") -#define __fmpz_eq _Pragma("GCC error \"'__fmpz_eq' is deprecated. Use 'fmpz_equal' instead.\"") -#define __fmpz_neg _Pragma("GCC error \"'__fmpz_neg' is deprecated. Use 'fmpz_neg' instead.\"") - #ifdef __cplusplus } #endif diff --git a/src/fmpz/abs.c b/src/fmpz/abs.c index 279f90e5be..0dcd8b398e 100644 --- a/src/fmpz/abs.c +++ b/src/fmpz/abs.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/abs_fits_ui.c b/src/fmpz/abs_fits_ui.c index 64246fc96d..2c9e24581f 100644 --- a/src/fmpz/abs_fits_ui.c +++ b/src/fmpz/abs_fits_ui.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/abs_lbound_ui_2exp.c b/src/fmpz/abs_lbound_ui_2exp.c index 3a7cd10913..61309066d8 100644 --- a/src/fmpz/abs_lbound_ui_2exp.c +++ b/src/fmpz/abs_lbound_ui_2exp.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/abs_ubound_ui_2exp.c b/src/fmpz/abs_ubound_ui_2exp.c index 174711f56c..05fe6d2d65 100644 --- a/src/fmpz/abs_ubound_ui_2exp.c +++ b/src/fmpz/abs_ubound_ui_2exp.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/add.c b/src/fmpz/add.c index 7dbfb1c211..e4b4985606 100644 --- a/src/fmpz/add.c +++ b/src/fmpz/add.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/addmul.c b/src/fmpz/addmul.c index 3cea76e55f..a485ed22f4 100644 --- a/src/fmpz/addmul.c +++ b/src/fmpz/addmul.c @@ -16,12 +16,6 @@ #include "ulong_extras.h" #include "fmpz.h" -#define MPZ_FIT_SIZE(z, nlimbs) \ - do { \ - if (z->_mp_alloc < nlimbs) \ - _mpz_realloc(z, nlimbs); \ - } while (0) - /* Will not get called with x or y small. */ void _flint_mpz_addmul_large(mpz_ptr z, mpz_srcptr x, mpz_srcptr y, int negate) @@ -122,8 +116,7 @@ _flint_mpz_addmul_large(mpz_ptr z, mpz_srcptr x, mpz_srcptr y, int negate) tn -= (top == 0); alloc = FLINT_MAX(tn, zn) + 1; - MPZ_FIT_SIZE(z, alloc); - zd = z->_mp_d; + zd = FLINT_MPZ_REALLOC(z, alloc); if (sgn >= 0) { diff --git a/src/fmpz/aors_ui.c b/src/fmpz/aors_ui.c index 8feee147f4..ef445ffaf0 100644 --- a/src/fmpz/aors_ui.c +++ b/src/fmpz/aors_ui.c @@ -11,7 +11,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "fmpz.h" @@ -70,10 +69,7 @@ fmpz_add_ui(fmpz_t res, const fmpz_t x, ulong y) else rp = _fmpz_promote_val(res); - if (rp->_mp_alloc < xn + 1) - _mpz_realloc(rp, xn + 1); - - rd = rp->_mp_d; + rd = FLINT_MPZ_REALLOC(rp, xn + 1); xd = xp->_mp_d; if (xn_signed >= 0) /* positive + nonnegative */ @@ -183,10 +179,7 @@ fmpz_sub_ui(fmpz_t res, const fmpz_t x, ulong y) else rp = _fmpz_promote_val(res); - if (rp->_mp_alloc < xn + 1) - _mpz_realloc(rp, xn + 1); - - rd = rp->_mp_d; + rd = FLINT_MPZ_REALLOC(rp, xn + 1); xd = xp->_mp_d; if (xn_signed <= 0) /* positive + nonnegative */ diff --git a/src/fmpz/bin_uiui.c b/src/fmpz/bin_uiui.c index ba40ed4fd4..cc139db758 100644 --- a/src/fmpz/bin_uiui.c +++ b/src/fmpz/bin_uiui.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/bit_unpack.c b/src/fmpz/bit_unpack.c index e6b5f19486..b2481cb3da 100644 --- a/src/fmpz/bit_unpack.c +++ b/src/fmpz/bit_unpack.c @@ -77,8 +77,7 @@ fmpz_bit_unpack(fmpz_t coeff, nn_srcptr arr, flint_bitcnt_t shift, b = bits % FLINT_BITS; /* allocate space for l limbs only */ - mpz_realloc(mcoeff, l); - p = mcoeff->_mp_d; + p = FLINT_MPZ_REALLOC_TIGHT(mcoeff, l); /* shift in l limbs */ if (shift) @@ -175,8 +174,7 @@ fmpz_bit_unpack_unsigned(fmpz_t coeff, nn_srcptr arr, b = bits % FLINT_BITS; /* allocate space for l limbs only */ - mpz_realloc(mcoeff, l); - p = mcoeff->_mp_d; + p = FLINT_MPZ_REALLOC_TIGHT(mcoeff, l); /* shift in l limbs */ if (shift) diff --git a/src/fmpz/bits.c b/src/fmpz/bits.c index 6a2bc8a929..5df9b6e27d 100644 --- a/src/fmpz/bits.c +++ b/src/fmpz/bits.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/clear_readonly.c b/src/fmpz/clear_readonly.c index 2fae86e18d..1f1817590e 100644 --- a/src/fmpz/clear_readonly.c +++ b/src/fmpz/clear_readonly.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "fmpz.h" void fmpz_clear_readonly(fmpz_t f) @@ -18,7 +18,8 @@ void fmpz_clear_readonly(fmpz_t f) { mpz_ptr ptr = COEFF_TO_PTR(*f); - mpz_init(ptr); + /* NOTE: Do not feed the collector anything less than two limbs! */ + mpz_init2(ptr, 2 * FLINT_BITS); _fmpz_clear_mpz(*f); *f = WORD(0); } diff --git a/src/fmpz/div_newton.c b/src/fmpz/div_newton.c index 834a2c16eb..cbee7686d6 100644 --- a/src/fmpz/div_newton.c +++ b/src/fmpz/div_newton.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/divides.c b/src/fmpz/divides.c index b8ca0b09ff..47009b2c73 100644 --- a/src/fmpz/divides.c +++ b/src/fmpz/divides.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/divides_mod_list.c b/src/fmpz/divides_mod_list.c index 5f52f7fe76..9903e35b94 100644 --- a/src/fmpz/divides_mod_list.c +++ b/src/fmpz/divides_mod_list.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/divisor_in_residue_class_lenstra.c b/src/fmpz/divisor_in_residue_class_lenstra.c index 020de00451..de76d1a42a 100644 --- a/src/fmpz/divisor_in_residue_class_lenstra.c +++ b/src/fmpz/divisor_in_residue_class_lenstra.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz/dlog.c b/src/fmpz/dlog.c index cca19a3a3c..1882c1a732 100644 --- a/src/fmpz/dlog.c +++ b/src/fmpz/dlog.c @@ -10,6 +10,7 @@ */ #include +#include #include "fmpz.h" double diff --git a/src/fmpz/fac_ui.c b/src/fmpz/fac_ui.c index f39d1336a9..7bbed2f239 100644 --- a/src/fmpz/fac_ui.c +++ b/src/fmpz/fac_ui.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/fdiv.c b/src/fmpz/fdiv.c index a9e8324bf5..3742ecddb8 100644 --- a/src/fmpz/fdiv.c +++ b/src/fmpz/fdiv.c @@ -202,8 +202,7 @@ void _mpz_tdiv_qr_preinvn(mpz_ptr q, mpz_ptr r, nn_ptr qp, rp, ap, dp, tp, sp; - if ((ulong) r->_mp_alloc < usize1 + nm) - mpz_realloc2(r, (usize1 + nm)*FLINT_BITS); + rp = FLINT_MPZ_REALLOC(r, usize1 + nm); if (usize1 < usize2) /* special case preinv code can't deal with */ { @@ -213,13 +212,9 @@ void _mpz_tdiv_qr_preinvn(mpz_ptr q, mpz_ptr r, return; } - if ((ulong) q->_mp_alloc < qsize + nm) - mpz_realloc2(q, (qsize + nm)*FLINT_BITS); - dp = d->_mp_d; ap = a->_mp_d; - qp = q->_mp_d; - rp = r->_mp_d; + qp = FLINT_MPZ_REALLOC(q, qsize + nm); TMP_START; if ((r == d || q == d) && !nm) /* we have alias with d */ diff --git a/src/fmpz/fib_ui.c b/src/fmpz/fib_ui.c index c318628e6a..800ab4ddb1 100644 --- a/src/fmpz/fib_ui.c +++ b/src/fmpz/fib_ui.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/fits_si.c b/src/fmpz/fits_si.c index 0bdf96e397..16f0b2b2cb 100644 --- a/src/fmpz/fits_si.c +++ b/src/fmpz/fits_si.c @@ -19,7 +19,6 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "flint.h" #include "gmpcompat.h" #include "fmpz.h" diff --git a/src/fmpz/gcdinv.c b/src/fmpz/gcdinv.c index 83a983fc83..9f1778431c 100644 --- a/src/fmpz/gcdinv.c +++ b/src/fmpz/gcdinv.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" @@ -21,7 +21,7 @@ void fmpz_gcdinv(fmpz_t d, fmpz_t a, const fmpz_t f, const fmpz_t g) { fmpz_set(d, g); fmpz_set_ui(a, 0); - return; + return; } if (!COEFF_IS_MPZ(*g)) /* g is small, hence f is small */ @@ -37,12 +37,9 @@ void fmpz_gcdinv(fmpz_t d, fmpz_t a, const fmpz_t f, const fmpz_t g) } else /* g is large */ { - mpz_t atemp, dtemp; + mpz_ptr atemp = _fmpz_new_mpz(), dtemp = _fmpz_new_mpz(); - mpz_init(atemp); - mpz_init(dtemp); - - _fmpz_promote_val(d); + _fmpz_promote_val(d); _fmpz_promote_val(a); if (!COEFF_IS_MPZ(*f)) /* f is small */ @@ -54,22 +51,22 @@ void fmpz_gcdinv(fmpz_t d, fmpz_t a, const fmpz_t f, const fmpz_t g) fptr->_mp_d = (ulong *) f; mpz_gcdext(dtemp, atemp, NULL, - fptr, COEFF_TO_PTR(*g)); + fptr, COEFF_TO_PTR(*g)); } else /* f is large */ { mpz_gcdext(dtemp, atemp, NULL, - COEFF_TO_PTR(*f), COEFF_TO_PTR(*g)); + COEFF_TO_PTR(*f), COEFF_TO_PTR(*g)); } - if (mpz_cmp_ui(atemp, 0) < 0) - mpz_add(atemp, atemp, COEFF_TO_PTR(*g)); + if (mpz_cmp_ui(atemp, 0) < 0) + mpz_add(atemp, atemp, COEFF_TO_PTR(*g)); - mpz_swap(COEFF_TO_PTR(*d), dtemp); - mpz_swap(COEFF_TO_PTR(*a), atemp); + _fmpz_clear_mpz(*d); + _fmpz_clear_mpz(*a); - mpz_clear(atemp); - mpz_clear(dtemp); + *d = PTR_TO_COEFF(dtemp); + *a = PTR_TO_COEFF(atemp); _fmpz_demote_val(d); _fmpz_demote_val(a); diff --git a/src/fmpz/init2.c b/src/fmpz/init2.c index fbb5e635b2..14c51b407f 100644 --- a/src/fmpz/init2.c +++ b/src/fmpz/init2.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" @@ -20,7 +20,7 @@ fmpz_init2(fmpz_t f, ulong limbs) { mpz_ptr mf = _fmpz_new_mpz(); *f = PTR_TO_COEFF(mf); - _mpz_realloc(mf, limbs); + FLINT_MPZ_REALLOC(mf, limbs); } else { diff --git a/src/fmpz/init_set_readonly.c b/src/fmpz/init_set_readonly.c index 49442b4ebd..5b53a5a599 100644 --- a/src/fmpz/init_set_readonly.c +++ b/src/fmpz/init_set_readonly.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "fmpz.h" void fmpz_init_set_readonly(fmpz_t f, const mpz_t z) diff --git a/src/fmpz/inlines.c b/src/fmpz/inlines.c index e3712be06f..3911cfa75a 100644 --- a/src/fmpz/inlines.c +++ b/src/fmpz/inlines.c @@ -11,38 +11,61 @@ #define FMPZ_INLINES_C -#include "gmpcompat.h" +#include #include "fmpz.h" +/* NOTE: Herein we rely on that the fmpz collector never assigns an mpz with + less than two limbs. */ void _fmpz_promote_set_ui(fmpz_t f, ulong v) { - mpz_ptr z = _fmpz_promote(f); - flint_mpz_set_ui(z, v); + mpz_ptr zf = _fmpz_promote(f); + zf->_mp_d[0] = v; + zf->_mp_size = 1; } void _fmpz_promote_neg_ui(fmpz_t f, ulong v) { - mpz_ptr z = _fmpz_promote(f); - flint_mpz_set_ui(z, v); - mpz_neg(z, z); + mpz_ptr zf = _fmpz_promote(f); + zf->_mp_d[0] = v; + zf->_mp_size = -1; } void _fmpz_promote_set_si(fmpz_t f, slong v) { - mpz_ptr z = _fmpz_promote(f); - flint_mpz_set_si(z, v); + mpz_ptr zf = _fmpz_promote(f); + zf->_mp_d[0] = FLINT_ABS(v); + zf->_mp_size = (v < 0) ? -1 : 1; } void _fmpz_init_promote_set_ui(fmpz_t f, ulong v) { - mpz_ptr z = _fmpz_new_mpz(); - *f = PTR_TO_COEFF(z); - flint_mpz_set_ui(z, v); + mpz_ptr zf = _fmpz_new_mpz(); + *f = PTR_TO_COEFF(zf); + zf->_mp_d[0] = v; + zf->_mp_size = 1; } void _fmpz_init_promote_set_si(fmpz_t f, slong v) { - mpz_ptr z = _fmpz_new_mpz(); - *f = PTR_TO_COEFF(z); - flint_mpz_set_si(z, v); + mpz_ptr zf = _fmpz_new_mpz(); + *f = PTR_TO_COEFF(zf); + zf->_mp_d[0] = FLINT_ABS(v); + zf->_mp_size = (v < 0) ? -1 : 1; +} + +/* NOTE: We assume that hi != 0 for the following two functions. */ +void _fmpz_promote_set_uiui(fmpz_t f, ulong hi, ulong lo) +{ + mpz_ptr zf = _fmpz_promote(f); + zf->_mp_d[0] = lo; + zf->_mp_d[1] = hi; + zf->_mp_size = 2; +} + +void _fmpz_promote_neg_uiui(fmpz_t f, ulong hi, ulong lo) +{ + mpz_ptr zf = _fmpz_promote(f); + zf->_mp_d[0] = lo; + zf->_mp_d[1] = hi; + zf->_mp_size = -2; } diff --git a/src/fmpz/invmod.c b/src/fmpz/invmod.c index 2ac1b9512a..956a6f66b1 100644 --- a/src/fmpz/invmod.c +++ b/src/fmpz/invmod.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/io.c b/src/fmpz/io.c index 2fbf1f9595..06949b461a 100644 --- a/src/fmpz/io.c +++ b/src/fmpz/io.c @@ -12,6 +12,7 @@ */ #include +#include #include "fmpz.h" /* printing *******************************************************************/ diff --git a/src/fmpz/is_canonical.c b/src/fmpz/is_canonical.c index f4036dc267..62fae2eda6 100644 --- a/src/fmpz/is_canonical.c +++ b/src/fmpz/is_canonical.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpz.h" int _fmpz_is_canonical(const fmpz_t x) diff --git a/src/fmpz/is_perfect_power.c b/src/fmpz/is_perfect_power.c index 275ea918f1..e6f6dfc824 100644 --- a/src/fmpz/is_perfect_power.c +++ b/src/fmpz/is_perfect_power.c @@ -41,7 +41,7 @@ MA 02110-1301, USA. */ arithmetic for computing possible roots. */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/is_prime_pseudosquare.c b/src/fmpz/is_prime_pseudosquare.c index b46489fc90..451a0a09db 100644 --- a/src/fmpz/is_prime_pseudosquare.c +++ b/src/fmpz/is_prime_pseudosquare.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/is_probabprime_BPSW.c b/src/fmpz/is_probabprime_BPSW.c index 459b111bbd..2eea8acef1 100644 --- a/src/fmpz/is_probabprime_BPSW.c +++ b/src/fmpz/is_probabprime_BPSW.c @@ -9,12 +9,7 @@ (at your option) any later version. See . */ -#include -#include -#include "flint.h" -#include "ulong_extras.h" #include "fmpz.h" -#include "fmpz_vec.h" int fmpz_is_probabprime_BPSW(const fmpz_t n) { diff --git a/src/fmpz/is_probabprime_lucas.c b/src/fmpz/is_probabprime_lucas.c index 4ba2161d5a..be90897848 100644 --- a/src/fmpz/is_probabprime_lucas.c +++ b/src/fmpz/is_probabprime_lucas.c @@ -9,12 +9,7 @@ (at your option) any later version. See . */ -#include -#include -#include "flint.h" -#include "ulong_extras.h" #include "fmpz.h" -#include "fmpz_vec.h" int fmpz_is_probabprime_lucas(const fmpz_t n) { diff --git a/src/fmpz/is_square.c b/src/fmpz/is_square.c index 98cd558b73..98732fa707 100644 --- a/src/fmpz/is_square.c +++ b/src/fmpz/is_square.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/is_strong_probabprime.c b/src/fmpz/is_strong_probabprime.c index 5054fe107b..bd56476435 100644 --- a/src/fmpz/is_strong_probabprime.c +++ b/src/fmpz/is_strong_probabprime.c @@ -9,12 +9,7 @@ (at your option) any later version. See . */ -#include -#include -#include "flint.h" -#include "ulong_extras.h" #include "fmpz.h" -#include "fmpz_vec.h" int fmpz_is_strong_probabprime(const fmpz_t n, const fmpz_t base) { diff --git a/src/fmpz/jacobi.c b/src/fmpz/jacobi.c index e5f90b35c5..ac6eb87af5 100644 --- a/src/fmpz/jacobi.c +++ b/src/fmpz/jacobi.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/kronecker.c b/src/fmpz/kronecker.c index 4323d19a87..b1081338ba 100644 --- a/src/fmpz/kronecker.c +++ b/src/fmpz/kronecker.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "long_extras.h" #include "fmpz.h" diff --git a/src/fmpz/lcm.c b/src/fmpz/lcm.c index 72285d2aa9..1708b957c1 100644 --- a/src/fmpz/lcm.c +++ b/src/fmpz/lcm.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" void diff --git a/src/fmpz/link/fmpz_gc.c b/src/fmpz/link/fmpz_gc.c index 13ccfcf79f..6591047542 100644 --- a/src/fmpz/link/fmpz_gc.c +++ b/src/fmpz/link/fmpz_gc.c @@ -22,6 +22,10 @@ pthread_mutex_t fmpz_lock; /* Always free larger mpz's to avoid wasting too much heap space */ #define FLINT_MPZ_MAX_CACHE_LIMBS 64 +#if FLINT_MPZ_MAX_CACHE_LIMBS < MPZ_MIN_ALLOC +# error +#endif + /* The number of new mpz's allocated at a time */ #define MPZ_BLOCK 64 @@ -57,12 +61,12 @@ mpz_ptr _fmpz_new_mpz(void) if (mpz_num == mpz_alloc) /* store pointer to prevent gc cleanup */ { - mpz_alloc = FLINT_MAX(64, mpz_alloc * 2); + mpz_alloc = FLINT_MAX(MPZ_BLOCK, 2 * mpz_alloc); mpz_arr = flint_realloc(mpz_arr, mpz_alloc * sizeof(mpz_ptr)); } mpz_arr[mpz_num++] = z; - mpz_init(z); + mpz_init2(z, MPZ_MIN_ALLOC * FLINT_BITS); } #if FLINT_USES_PTHREAD @@ -76,8 +80,10 @@ void _fmpz_clear_mpz(fmpz f) { mpz_ptr ptr = COEFF_TO_PTR(f); + FLINT_ASSERT(ptr->_mp_alloc >= MPZ_MIN_ALLOC); + if (ptr->_mp_alloc > FLINT_MPZ_MAX_CACHE_LIMBS) - mpz_realloc2(ptr, 1); + mpz_realloc(ptr, MPZ_MIN_ALLOC); #if FLINT_USES_PTHREAD pthread_mutex_lock(&fmpz_lock); @@ -85,7 +91,7 @@ void _fmpz_clear_mpz(fmpz f) if (mpz_free_num == mpz_free_alloc) { - mpz_free_alloc = FLINT_MAX(64, mpz_free_alloc * 2); + mpz_free_alloc = FLINT_MAX(MPZ_BLOCK, 2 * mpz_free_alloc); mpz_free_arr = flint_realloc(mpz_free_arr, mpz_free_alloc * sizeof(mpz_ptr)); } @@ -177,19 +183,18 @@ void _fmpz_demote_val(fmpz_t f) void _fmpz_init_readonly_mpz(fmpz_t f, const mpz_t z) { - mpz_ptr ptr; - *f = WORD(0); - ptr = _fmpz_promote(f); + mpz_ptr ptr; + *f = WORD(0); + ptr = _fmpz_promote(f); - mpz_clear(ptr); - *ptr = *z; + mpz_clear(ptr); + *ptr = *z; } void _fmpz_clear_readonly_mpz(mpz_t z) { - if (((z->_mp_size == 1 || z->_mp_size == -1) && (z->_mp_d[0] <= COEFF_MAX)) - || (z->_mp_size == 0)) - { + int size = z->_mp_size; + + if (size == 0 || ((size == 1 || size == -1) && (z->_mp_d[0] <= COEFF_MAX))) mpz_clear(z); - } } diff --git a/src/fmpz/link/fmpz_reentrant.c b/src/fmpz/link/fmpz_reentrant.c index ea0fc1786c..8eda73be00 100644 --- a/src/fmpz/link/fmpz_reentrant.c +++ b/src/fmpz/link/fmpz_reentrant.c @@ -15,14 +15,18 @@ mpz_ptr _fmpz_new_mpz(void) { mpz_ptr mf = flint_malloc(sizeof(__mpz_struct)); - mpz_init2(mf, 2*FLINT_BITS); + mpz_init2(mf, MPZ_MIN_ALLOC * FLINT_BITS); return mf; } void _fmpz_clear_mpz(fmpz f) { - mpz_clear(COEFF_TO_PTR(f)); - flint_free(COEFF_TO_PTR(f)); + mpz_ptr ptr = COEFF_TO_PTR(f); + + FLINT_ASSERT(ptr->_mp_alloc >= MPZ_MIN_ALLOC); + + mpz_clear(ptr); + flint_free(ptr); } void _fmpz_cleanup_mpz_content(void) @@ -85,16 +89,15 @@ void _fmpz_demote_val(fmpz_t f) void _fmpz_init_readonly_mpz(fmpz_t f, const mpz_t z) { - mpz_ptr mf = flint_malloc(sizeof(__mpz_struct)); + mpz_ptr mf = flint_malloc(sizeof(__mpz_struct)); *f = PTR_TO_COEFF(mf); *mf = *z; } void _fmpz_clear_readonly_mpz(mpz_t z) { - if (((z->_mp_size == 1 || z->_mp_size == -1) && (z->_mp_d[0] <= COEFF_MAX)) - || (z->_mp_size == 0)) - { + int size = z->_mp_size; + + if (size == 0 || ((size == 1 || size == -1) && (z->_mp_d[0] <= COEFF_MAX))) mpz_clear(z); - } } diff --git a/src/fmpz/link/fmpz_single.c b/src/fmpz/link/fmpz_single.c index 690bd9cdd7..4cfddbfb70 100644 --- a/src/fmpz/link/fmpz_single.c +++ b/src/fmpz/link/fmpz_single.c @@ -44,6 +44,10 @@ typedef struct /* Always free larger mpz's to avoid wasting too much heap space */ #define FLINT_MPZ_MAX_CACHE_LIMBS 64 +#if FLINT_MPZ_MAX_CACHE_LIMBS < MPZ_MIN_ALLOC +# error +#endif + #define PAGES_PER_BLOCK 16 /* The number of new mpz's allocated at a time */ @@ -117,7 +121,7 @@ mpz_ptr _fmpz_new_mpz(void) for (j = skip; j < num; j++) { - mpz_init2(page_ptr + j, 2*FLINT_BITS); + mpz_init2(page_ptr + j, MPZ_MIN_ALLOC * FLINT_BITS); /* Cannot be lifted from loop due to possibility of @@ -125,7 +129,7 @@ mpz_ptr _fmpz_new_mpz(void) */ if (mpz_free_num >= mpz_free_alloc) { - mpz_free_alloc = FLINT_MAX(mpz_free_num + 1, mpz_free_alloc * 2); + mpz_free_alloc = FLINT_MAX(mpz_free_num + 1, 2 * mpz_free_alloc); mpz_free_arr = flint_realloc(mpz_free_arr, mpz_free_alloc * sizeof(mpz_ptr)); } @@ -141,6 +145,8 @@ void _fmpz_clear_mpz(fmpz f) { mpz_ptr ptr = COEFF_TO_PTR(f); + FLINT_ASSERT(ptr->_mp_alloc >= MPZ_MIN_ALLOC); + /* check free count for block is zero, else this mpz came from a thread */ fmpz_block_header_s * header_ptr = (fmpz_block_header_s *)((slong) ptr & flint_page_mask); @@ -168,11 +174,11 @@ void _fmpz_clear_mpz(fmpz f) } else { if (ptr->_mp_alloc > FLINT_MPZ_MAX_CACHE_LIMBS) - mpz_realloc2(ptr, 2*FLINT_BITS); + mpz_realloc(ptr, MPZ_MIN_ALLOC); if (mpz_free_num == mpz_free_alloc) { - mpz_free_alloc = FLINT_MAX(64, mpz_free_alloc * 2); + mpz_free_alloc = FLINT_MAX(MPZ_BLOCK, 2 * mpz_free_alloc); mpz_free_arr = flint_realloc(mpz_free_arr, mpz_free_alloc * sizeof(mpz_ptr)); } @@ -267,19 +273,18 @@ void _fmpz_demote_val(fmpz_t f) void _fmpz_init_readonly_mpz(fmpz_t f, const mpz_t z) { - mpz_ptr ptr; - *f = WORD(0); - ptr = _fmpz_promote(f); + mpz_ptr ptr; + *f = WORD(0); + ptr = _fmpz_promote(f); - mpz_clear(ptr); - *ptr = *z; + mpz_clear(ptr); + *ptr = *z; } void _fmpz_clear_readonly_mpz(mpz_t z) { - if (((z->_mp_size == 1 || z->_mp_size == -1) && (z->_mp_d[0] <= COEFF_MAX)) - || (z->_mp_size == 0)) - { + int size = z->_mp_size; + + if (size == 0 || ((size == 1 || size == -1) && (z->_mp_d[0] <= COEFF_MAX))) mpz_clear(z); - } } diff --git a/src/fmpz/mod.c b/src/fmpz/mod.c index a593512bab..9c5d353480 100644 --- a/src/fmpz/mod.c +++ b/src/fmpz/mod.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/mul.c b/src/fmpz/mul.c index 1a039ddd1b..88c4bcfd97 100644 --- a/src/fmpz/mul.c +++ b/src/fmpz/mul.c @@ -48,9 +48,7 @@ flint_mpz_mul(mpz_ptr z, mpz_srcptr x, mpz_srcptr y) } zn = xn + yn; - if (z->_mp_alloc < zn) - _mpz_realloc(z, zn); - zd = z->_mp_d; + zd = FLINT_MPZ_REALLOC(z, zn); /* Important: read after possibly resizing z, so that the pointers are valid in case of aliasing. */ xd = x->_mp_d; diff --git a/src/fmpz/mul_2exp.c b/src/fmpz/mul_2exp.c index 949b85e804..60ac96e9bb 100644 --- a/src/fmpz/mul_2exp.c +++ b/src/fmpz/mul_2exp.c @@ -10,15 +10,15 @@ (at your option) any later version. See . */ -#include "fmpz.h" #include +#include +#include "fmpz.h" void fmpz_mul_2exp(fmpz_t f, const fmpz_t g, ulong exp) { slong c1 = *g; ulong c1abs, c1bits; - mpz_ptr mf; if (c1 == 0) { @@ -41,23 +41,10 @@ fmpz_mul_2exp(fmpz_t f, const fmpz_t g, ulong exp) ulong expred = exp % FLINT_BITS; int alloc = 1 + exp / FLINT_BITS + ((c1bits + expred) > FLINT_BITS); ulong * limbs; + mpz_ptr mf; - /* Ensure enough limbs are allocated for f */ - if (!COEFF_IS_MPZ(*f)) - { - /* TODO: Initialize the new mpz with alloc limbs instead of - * reallocating them. */ - mf = _fmpz_new_mpz(); - *f = PTR_TO_COEFF(mf); - _mpz_realloc(mf, alloc); - } - else - { - mf = COEFF_TO_PTR(*f); - if (mf->_mp_alloc < alloc) - _mpz_realloc(mf, alloc); - } - limbs = mf->_mp_d; + mf = _fmpz_promote(f); + limbs = FLINT_MPZ_REALLOC(mf, alloc); mf->_mp_size = (c1 > 0) ? alloc : -alloc; memset(limbs, 0, sizeof(ulong) * alloc); @@ -75,17 +62,6 @@ fmpz_mul_2exp(fmpz_t f, const fmpz_t g, ulong exp) { mpz_ptr mg = COEFF_TO_PTR(c1); - if (!COEFF_IS_MPZ(*f)) - { - /* TODO: Initialize the new mpz with alloc limbs instead of - * reallocating them. */ - mf = _fmpz_new_mpz(); - *f = PTR_TO_COEFF(mf); - _mpz_realloc(mf, FLINT_ABS(mg->_mp_size) + exp / FLINT_BITS + 1); - } - else - mf = COEFF_TO_PTR(*f); - - mpz_mul_2exp(mf, mg, exp); + mpz_mul_2exp(_fmpz_promote(f), mg, exp); } } diff --git a/src/fmpz/mul_si_tdiv_q_2exp.c b/src/fmpz/mul_si_tdiv_q_2exp.c index 140d7d17a1..10f46df511 100644 --- a/src/fmpz/mul_si_tdiv_q_2exp.c +++ b/src/fmpz/mul_si_tdiv_q_2exp.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/mul_tdiv_q_2exp.c b/src/fmpz/mul_tdiv_q_2exp.c index 1aaeb2b935..641d800419 100644 --- a/src/fmpz/mul_tdiv_q_2exp.c +++ b/src/fmpz/mul_tdiv_q_2exp.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/ndiv_qr.c b/src/fmpz/ndiv_qr.c index 8daa360651..9771575a38 100644 --- a/src/fmpz/ndiv_qr.c +++ b/src/fmpz/ndiv_qr.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" /* b aliases neither q nor r */ diff --git a/src/fmpz/neg.c b/src/fmpz/neg.c index bb7260723d..ae649fc95f 100644 --- a/src/fmpz/neg.c +++ b/src/fmpz/neg.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "fmpz.h" void diff --git a/src/fmpz/nextprime.c b/src/fmpz/nextprime.c index cf74d76afd..cabe474213 100644 --- a/src/fmpz/nextprime.c +++ b/src/fmpz/nextprime.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "fmpz.h" #include "ulong_extras.h" diff --git a/src/fmpz/one_2exp.c b/src/fmpz/one_2exp.c index b8257197ae..e113a529bb 100644 --- a/src/fmpz/one_2exp.c +++ b/src/fmpz/one_2exp.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/powmod2_fmpz_preinv.c b/src/fmpz/powmod2_fmpz_preinv.c index f1aa4054e2..ae2d7611b7 100644 --- a/src/fmpz/powmod2_fmpz_preinv.c +++ b/src/fmpz/powmod2_fmpz_preinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/primorial.c b/src/fmpz/primorial.c index ed81714af4..0310928536 100644 --- a/src/fmpz/primorial.c +++ b/src/fmpz/primorial.c @@ -10,9 +10,9 @@ (at your option) any later version. See . */ -#include "fmpz.h" -#include "mpn_extras.h" #include "ulong_extras.h" +#include "mpn_extras.h" +#include "fmpz.h" #if FLINT64 #define LARGEST_ULONG_PRIMORIAL 52 @@ -136,6 +136,7 @@ fmpz_primorial(fmpz_t res, ulong n) slong len, pi; ulong bits; mpz_ptr mres; + mp_ptr rp; const ulong * primes; if (n <= LARGEST_ULONG_PRIMORIAL) @@ -153,8 +154,8 @@ fmpz_primorial(fmpz_t res, ulong n) bits = FLINT_BIT_COUNT(primes[pi - 1]); mres = _fmpz_promote(res); - mpz_realloc2(mres, pi*bits); + rp = FLINT_MPZ_REALLOC(mres, (pi * bits) / FLINT_BITS + 1); - len = mpn_prod_limbs(mres->_mp_d, primes, pi, bits); + len = mpn_prod_limbs(rp, primes, pi, bits); mres->_mp_size = len; } diff --git a/src/fmpz/profile/p-addmul.c b/src/fmpz/profile/p-addmul.c index 37ac284dcf..9f6e3eb336 100644 --- a/src/fmpz/profile/p-addmul.c +++ b/src/fmpz/profile/p-addmul.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "profiler.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz/profile/p-aors_ui.c b/src/fmpz/profile/p-aors_ui.c index 496c8c55db..ffcde7c701 100644 --- a/src/fmpz/profile/p-aors_ui.c +++ b/src/fmpz/profile/p-aors_ui.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "profiler.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz/profile/p-crt.c b/src/fmpz/profile/p-crt.c index 54b552e19a..6ee5850f4e 100644 --- a/src/fmpz/profile/p-crt.c +++ b/src/fmpz/profile/p-crt.c @@ -1,3 +1,4 @@ +#include #include "fmpz.h" #include "ulong_extras.h" #include "profiler.h" diff --git a/src/fmpz/profile/p-div_qr.c b/src/fmpz/profile/p-div_qr.c index 052100abb2..d120831e78 100644 --- a/src/fmpz/profile/p-div_qr.c +++ b/src/fmpz/profile/p-div_qr.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" #include "profiler.h" diff --git a/src/fmpz/profile/p-fdiv_qr_preinvn.c b/src/fmpz/profile/p-fdiv_qr_preinvn.c index 93a2aa575f..48b944f219 100644 --- a/src/fmpz/profile/p-fdiv_qr_preinvn.c +++ b/src/fmpz/profile/p-fdiv_qr_preinvn.c @@ -11,7 +11,6 @@ #include #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/profile/p-fmma.c b/src/fmpz/profile/p-fmma.c index 9be88850b8..b993482084 100644 --- a/src/fmpz/profile/p-fmma.c +++ b/src/fmpz/profile/p-fmma.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "profiler.h" diff --git a/src/fmpz/profile/p-gcd.c b/src/fmpz/profile/p-gcd.c index b20a9524d8..96b20257ee 100644 --- a/src/fmpz/profile/p-gcd.c +++ b/src/fmpz/profile/p-gcd.c @@ -10,7 +10,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" #include "profiler.h" diff --git a/src/fmpz/profile/p-is_prime_bench.c b/src/fmpz/profile/p-is_prime_bench.c index 9ea2430038..4bb801a153 100644 --- a/src/fmpz/profile/p-is_prime_bench.c +++ b/src/fmpz/profile/p-is_prime_bench.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "fmpz.h" #include "fmpz_factor.h" #include "ulong_extras.h" diff --git a/src/fmpz/profile/p-is_probabprime_bench.c b/src/fmpz/profile/p-is_probabprime_bench.c index c753fab516..9f549135dc 100644 --- a/src/fmpz/profile/p-is_probabprime_bench.c +++ b/src/fmpz/profile/p-is_probabprime_bench.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "fmpz.h" #include "fmpz_factor.h" #include "ulong_extras.h" diff --git a/src/fmpz/profile/p-mul.c b/src/fmpz/profile/p-mul.c index ff81d772ee..c58a6a5572 100644 --- a/src/fmpz/profile/p-mul.c +++ b/src/fmpz/profile/p-mul.c @@ -10,9 +10,9 @@ */ #include "profiler.h" +#include "gmpcompat.h" #include "fmpz.h" #include "fmpz_vec.h" -#include "gmpcompat.h" #define ntests 30 diff --git a/src/fmpz/profile/p-mul_2exp.c b/src/fmpz/profile/p-mul_2exp.c index 24d2a50d27..85eb30bf29 100644 --- a/src/fmpz/profile/p-mul_2exp.c +++ b/src/fmpz/profile/p-mul_2exp.c @@ -10,8 +10,8 @@ */ #include "profiler.h" -#include "fmpz.h" #include "gmpcompat.h" +#include "fmpz.h" #define ntests 1000 diff --git a/src/fmpz/profile/p-mul_ui.c b/src/fmpz/profile/p-mul_ui.c index b49a80c009..03a02caa70 100644 --- a/src/fmpz/profile/p-mul_ui.c +++ b/src/fmpz/profile/p-mul_ui.c @@ -9,9 +9,10 @@ (at your option) any later version. See . */ +#include #include "profiler.h" -#include "fmpz.h" #include "ulong_extras.h" +#include "fmpz.h" #define ntests 2000 diff --git a/src/fmpz/profile/p-xgcd.c b/src/fmpz/profile/p-xgcd.c index e346811358..5715ef73e5 100644 --- a/src/fmpz/profile/p-xgcd.c +++ b/src/fmpz/profile/p-xgcd.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "profiler.h" diff --git a/src/fmpz/rand.c b/src/fmpz/rand.c index 359d5a5ec3..dfdedce336 100644 --- a/src/fmpz/rand.c +++ b/src/fmpz/rand.c @@ -13,6 +13,7 @@ (at your option) any later version. See . */ +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/remove.c b/src/fmpz/remove.c index eb4c37f3e3..9d5fe080f1 100644 --- a/src/fmpz/remove.c +++ b/src/fmpz/remove.c @@ -9,11 +9,15 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "fmpz.h" #include "ulong_extras.h" +/* NOTE: mpz_remove has an allocation bug, at least in GMP 6.3.1, which may lead + to the output having a reduced number of limbs allocated as compared to prior + to the call. Hence, in order to not recycle too small mpzs, we have to check + the number of allocated limbs after the call. */ + slong _fmpz_remove(fmpz_t x, const fmpz_t f, double finv) { fmpz y = *x; @@ -72,6 +76,8 @@ slong _fmpz_remove(fmpz_t x, const fmpz_t f, double finv) flint_mpz_init_set_ui(r, q); e = 2 + mpz_remove(z, z, r); mpz_clear(r); + if (z->_mp_alloc < MPZ_MIN_ALLOC) + mpz_realloc(z, MPZ_MIN_ALLOC); _fmpz_demote_val(x); return e; @@ -80,7 +86,7 @@ slong _fmpz_remove(fmpz_t x, const fmpz_t f, double finv) } else /* f is large */ { - mpz_ptr r = COEFF_TO_PTR(q); + mpz_srcptr r = COEFF_TO_PTR(q); if (!mpz_divisible_p(z, r)) { @@ -92,6 +98,8 @@ slong _fmpz_remove(fmpz_t x, const fmpz_t f, double finv) mpz_divexact(z, z, r); e = 1 + mpz_remove(z, z, r); + if (z->_mp_alloc < MPZ_MIN_ALLOC) + mpz_realloc(z, MPZ_MIN_ALLOC); _fmpz_demote_val(x); return e; } diff --git a/src/fmpz/root.c b/src/fmpz/root.c index 51fe8dbe59..d1bc53b779 100644 --- a/src/fmpz/root.c +++ b/src/fmpz/root.c @@ -9,8 +9,7 @@ (at your option) any later version. See . */ - -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/set.c b/src/fmpz/set.c index 6494440bd1..8ddd0f50e7 100644 --- a/src/fmpz/set.c +++ b/src/fmpz/set.c @@ -102,34 +102,14 @@ fmpz_set_mpz(fmpz_t f, const mpz_t x) { int size = (slong) x->_mp_size; - if (size == 0) /* x is zero */ - { + if (size == 0) fmpz_zero(f); - } - else if (size == 1) /* x is positive and 1 limb */ - { + else if (size == 1) fmpz_set_ui(f, flint_mpz_get_ui(x)); - } - else if (size == -1) /* x is negative and 1 limb */ - { - ulong uval = flint_mpz_get_ui(x); - if (uval <= COEFF_MAX) /* x is small */ - { - _fmpz_demote(f); - *f = -uval; - } - else /* x is large but one limb */ - { - mpz_ptr mf = _fmpz_promote(f); - flint_mpz_set_ui(mf, uval); - mpz_neg(mf, mf); - } - } - else /* x is more than one limb */ - { - mpz_ptr mf = _fmpz_promote(f); - mpz_set(mf, x); - } + else if (size == -1) + fmpz_neg_ui(f, flint_mpz_get_ui(x)); + else + mpz_set(_fmpz_promote(f), x); } /* @@ -207,11 +187,10 @@ fmpz_set_signed_uiuiui(fmpz_t r, ulong hi, ulong mid, ulong lo) else { mpz_ptr z = _fmpz_promote(r); - if (z->_mp_alloc < 3) - mpz_realloc2(z, 3 * FLINT_BITS); - z->_mp_d[0] = lo; - z->_mp_d[1] = mid; - z->_mp_d[2] = hi; + mp_ptr zp = FLINT_MPZ_REALLOC(z, 3); + zp[0] = lo; + zp[1] = mid; + zp[2] = hi; z->_mp_size = negate ? -3 : 3; } } @@ -237,9 +216,23 @@ void fmpz_set_ui_array(fmpz_t out, const ulong * in, slong in_len) else { mpz_ptr mpz = _fmpz_promote(out); - if (mpz->_mp_alloc < size) - mpz_realloc2(mpz, FLINT_BITS * size); + mp_ptr mp = FLINT_MPZ_REALLOC(mpz, size); mpz->_mp_size = size; - flint_mpn_copyi(mpz->_mp_d, in, size); + flint_mpn_copyi(mp, in, size); } } + +void fmpz_set_mpn_large(fmpz_t z, nn_srcptr src, slong n, int negative) +{ + mpz_ptr zz; + mp_ptr zp; + slong i; + + zz = _fmpz_promote(z); + zp = FLINT_MPZ_REALLOC(zz, n); + + for (i = 0; i < n; i++) + zp[i] = src[i]; + + zz->_mp_size = negative ? -n : n; +} diff --git a/src/fmpz/set_str.c b/src/fmpz/set_str.c index 7a43c03fe0..0271755ca9 100644 --- a/src/fmpz/set_str.c +++ b/src/fmpz/set_str.c @@ -12,11 +12,11 @@ #include #include +#include +#include "thread_pool.h" +#include "thread_support.h" #include "fmpz.h" #include "fmpz_vec.h" -#include "thread_support.h" -#include "thread_pool.h" -#include "profiler.h" #define BASECASE_CUTOFF 24000 diff --git a/src/fmpz/setbit.c b/src/fmpz/setbit.c index 3f218fefd5..3f4d7f5c52 100644 --- a/src/fmpz/setbit.c +++ b/src/fmpz/setbit.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpz.h" void fmpz_setbit(fmpz_t f, ulong i) diff --git a/src/fmpz/sgn.c b/src/fmpz/sgn.c index e1aa2bc925..5990bc4381 100644 --- a/src/fmpz/sgn.c +++ b/src/fmpz/sgn.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/size.c b/src/fmpz/size.c index 2221d3a7e7..3227026ef4 100644 --- a/src/fmpz/size.c +++ b/src/fmpz/size.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/sizeinbase.c b/src/fmpz/sizeinbase.c index 2a152b28e4..ae5ed0af61 100644 --- a/src/fmpz/sizeinbase.c +++ b/src/fmpz/sizeinbase.c @@ -9,9 +9,9 @@ (at your option) any later version. See . */ -#include "flint.h" -#include "fmpz.h" +#include #include "long_extras.h" +#include "fmpz.h" size_t fmpz_sizeinbase(const fmpz_t f, int b) { diff --git a/src/fmpz/sqrt.c b/src/fmpz/sqrt.c index acbcd598a0..b15324001c 100644 --- a/src/fmpz/sqrt.c +++ b/src/fmpz/sqrt.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/sqrtmod.c b/src/fmpz/sqrtmod.c index f132cf7861..2cdbe4deec 100644 --- a/src/fmpz/sqrtmod.c +++ b/src/fmpz/sqrtmod.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "fmpz.h" #include "ulong_extras.h" @@ -176,8 +175,8 @@ int fmpz_sqrtmod(fmpz_t b, const fmpz_t a, const fmpz_t p) else /* p is large */ { int ans; - mpz_t t; - mpz_ptr bptr; + mpz_ptr t; + mpz_srcptr bptr; if (fmpz_is_even(p)) return 0; @@ -187,10 +186,10 @@ int fmpz_sqrtmod(fmpz_t b, const fmpz_t a, const fmpz_t p) bptr = _fmpz_promote_val(b); - mpz_init(t); + t = _fmpz_new_mpz(); ans = _fmpz_sqrtmod(t, bptr, COEFF_TO_PTR(*p)); - mpz_swap(bptr, t); - mpz_clear(t); + _fmpz_clear_mpz(PTR_TO_COEFF(bptr)); + *b = PTR_TO_COEFF(t); _fmpz_demote_val(b); diff --git a/src/fmpz/sqrtrem.c b/src/fmpz/sqrtrem.c index 41e5b83c5c..3d21bb431e 100644 --- a/src/fmpz/sqrtrem.c +++ b/src/fmpz/sqrtrem.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/sub.c b/src/fmpz/sub.c index ead45a69f9..a1bba7a222 100644 --- a/src/fmpz/sub.c +++ b/src/fmpz/sub.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "gmpcompat.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/test/t-init_set_readonly.c b/src/fmpz/test/t-init_set_readonly.c index ba4e460d21..0a99b1a02e 100644 --- a/src/fmpz/test/t-init_set_readonly.c +++ b/src/fmpz/test/t-init_set_readonly.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "test_helpers.h" #include "long_extras.h" #include "fmpz.h" @@ -77,12 +78,11 @@ TEST_FUNCTION_START(fmpz_init_set_readonly, state) fmpz_set_mpz(h, z); if (!fmpz_equal(g, h) || !_fmpz_is_canonical(h)) - { - flint_printf("FAIL:\n\n"); - flint_printf("g = "), fmpz_print(g), flint_printf("\n"); - flint_printf("h = "), fmpz_print(h), flint_printf("\n"); - gmp_printf("z = %Zd\n", z); - } + TEST_FUNCTION_FAIL( + "g = %{fmpz}\n" + "h = %{fmpz}\n" + "z = %{mpz}\n", + g, h, z); fmpz_clear_readonly(g); fmpz_clear(h); diff --git a/src/fmpz/tstbit.c b/src/fmpz/tstbit.c index 223cd51f6a..b618d0bf20 100644 --- a/src/fmpz/tstbit.c +++ b/src/fmpz/tstbit.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpz.h" int fmpz_tstbit(const fmpz_t f, ulong i) diff --git a/src/fmpz/val2.c b/src/fmpz/val2.c index 32169542d0..113eca3472 100644 --- a/src/fmpz/val2.c +++ b/src/fmpz/val2.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz/xgcd.c b/src/fmpz/xgcd.c index dfcdf58cb2..61db587c71 100644 --- a/src/fmpz/xgcd.c +++ b/src/fmpz/xgcd.c @@ -10,6 +10,7 @@ (at your option) any later version. See . */ +#include #include "fmpz.h" void diff --git a/src/fmpz/xgcd_partial.c b/src/fmpz/xgcd_partial.c index 336f429feb..28213283c9 100644 --- a/src/fmpz/xgcd_partial.c +++ b/src/fmpz/xgcd_partial.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/fmpz_extras.h b/src/fmpz_extras.h index 5cf6413816..420d7d6033 100644 --- a/src/fmpz_extras.h +++ b/src/fmpz_extras.h @@ -93,22 +93,6 @@ fmpz_add2_fmpz_si_inline(fmpz_t z, const fmpz_t x, const fmpz_t y, slong c) fmpz_add_si(z, z, c); } -static inline void -fmpz_set_mpn_large(fmpz_t z, nn_srcptr src, slong n, int negative) -{ - mpz_ptr zz; - slong i; - zz = _fmpz_promote(z); - - if (zz->_mp_alloc < n) - mpz_realloc2(zz, n * FLINT_BITS); - - for (i = 0; i < n; i++) - zz->_mp_d[i] = src[i]; - - zz->_mp_size = negative ? -n : n; -} - static inline void fmpz_adiv_q_2exp(fmpz_t z, const fmpz_t x, flint_bitcnt_t exp) { @@ -150,7 +134,7 @@ _fmpz_size(const fmpz_t f) if (!COEFF_IS_MPZ(d)) return 1; else - return mpz_size(COEFF_TO_PTR(d)); + return FLINT_ABS(FMPZ_TO_ZZ(d)->size); } static inline void @@ -208,7 +192,7 @@ static inline slong fmpz_allocated_bytes(const fmpz_t x) { if (COEFF_IS_MPZ(*x)) - return sizeof(__mpz_struct) + COEFF_TO_PTR(*x)->_mp_alloc * sizeof(ulong); + return sizeof(zz_struct) + FMPZ_TO_ZZ(*x)->alloc * sizeof(ulong); else return 0; } diff --git a/src/fmpz_extras/lshift_mpn.c b/src/fmpz_extras/lshift_mpn.c index 41cd4ce601..cf8cf75402 100644 --- a/src/fmpz_extras/lshift_mpn.c +++ b/src/fmpz_extras/lshift_mpn.c @@ -26,10 +26,7 @@ fmpz_lshift_mpn(fmpz_t z, nn_srcptr d, slong dn, int sgnbit, flint_bitcnt_t shif shift_bits = shift % FLINT_BITS; zn = dn + shift_limbs + (shift_bits != 0); - if (zmpz->_mp_alloc < zn) - mpz_realloc2(zmpz, zn * FLINT_BITS); - - zp = zmpz->_mp_d; + zp = FLINT_MPZ_REALLOC(zmpz, zn); flint_mpn_zero(zp, shift_limbs); if (shift_bits == 0) diff --git a/src/fmpz_extras/test/t-lshift_mpn.c b/src/fmpz_extras/test/t-lshift_mpn.c index 7a6bfffeae..554ad5dbc1 100644 --- a/src/fmpz_extras/test/t-lshift_mpn.c +++ b/src/fmpz_extras/test/t-lshift_mpn.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "test_helpers.h" #include "fmpz_extras.h" diff --git a/src/fmpz_factor/ecm.c b/src/fmpz_factor/ecm.c index 3cced3c9f2..1c13c3d3d1 100644 --- a/src/fmpz_factor/ecm.c +++ b/src/fmpz_factor/ecm.c @@ -98,8 +98,12 @@ fmpz_factor_ecm(fmpz_t f, ulong curves, ulong B1, ulong B2, fmpz_sub_ui(nm8, n_in, 8); ret = 0; + /* FIXME: Wait to promote f until after stage 2 precomputations? */ fac = _fmpz_promote(f); - mpz_realloc(fac, fmpz_size(n_in)); + { + int alloc = fmpz_size(n_in); + FLINT_MPZ_REALLOC(fac, alloc); + } /************************ STAGE I PRECOMPUTATIONS ************************/ diff --git a/src/fmpz_factor/factor_pp1.c b/src/fmpz_factor/factor_pp1.c index 655e4d6c64..3e756fad8e 100644 --- a/src/fmpz_factor/factor_pp1.c +++ b/src/fmpz_factor/factor_pp1.c @@ -335,14 +335,14 @@ int fmpz_factor_pp1(fmpz_t fac, const fmpz_t n_in, ulong B1, ulong B2sqrt, ulong for (i = 0; (ulong) i < num_roots; i++) { mpz_ptr m = _fmpz_promote(roots + i); - mpz_realloc(m, nn); + FLINT_MPZ_REALLOC(m, nn); } roots2 = _fmpz_vec_init(num_roots); for (i = 0; (ulong) i < num_roots; i++) { mpz_ptr m = _fmpz_promote(roots2 + i); - mpz_realloc(m, nn); + FLINT_MPZ_REALLOC(m, nn); } evals = _fmpz_vec_init(num_roots); @@ -551,8 +551,8 @@ int fmpz_factor_pp1(fmpz_t fac, const fmpz_t n_in, ulong B1, ulong B2sqrt, ulong if (ret) { mpz_ptr fm = _fmpz_promote(fac); - mpz_realloc(fm, r); - flint_mpn_copyi(fm->_mp_d, factor, r); + mp_ptr fp = FLINT_MPZ_REALLOC(fm, r); + flint_mpn_copyi(fp, factor, r); fm->_mp_size = r; _fmpz_demote_val(fac); } diff --git a/src/fmpz_factor/pollard_brent.c b/src/fmpz_factor/pollard_brent.c index ff0f34d986..8540e3a0f8 100644 --- a/src/fmpz_factor/pollard_brent.c +++ b/src/fmpz_factor/pollard_brent.c @@ -72,7 +72,7 @@ fmpz_factor_pollard_brent(fmpz_t p_factor, flint_rand_t state, fmpz_t n_in, flint_mpn_preinvn(ninv, n, n_size); fac = _fmpz_promote(p_factor); - mpz_realloc2(fac, n_size * FLINT_BITS); + FLINT_MPZ_REALLOC(fac, n_size); fac->_mp_size = n_size; while (max_tries--) diff --git a/src/fmpz_factor/pollard_brent_single.c b/src/fmpz_factor/pollard_brent_single.c index 9fb1d81f87..601331a23a 100644 --- a/src/fmpz_factor/pollard_brent_single.c +++ b/src/fmpz_factor/pollard_brent_single.c @@ -224,7 +224,7 @@ fmpz_factor_pollard_brent_single(fmpz_t p_factor, fmpz_t n_in, fmpz_t yi, flint_mpn_preinvn(ninv, n, n_size); fac = _fmpz_promote(p_factor); - mpz_realloc2(fac, n_size * FLINT_BITS); + FLINT_MPZ_REALLOC(fac, n_size); fac->_mp_size = n_size; mpn_zero(a, n_size); diff --git a/src/fmpz_factor/profile/p-factor_bench.c b/src/fmpz_factor/profile/p-factor_bench.c index 04e3b66624..55b45fe556 100644 --- a/src/fmpz_factor/profile/p-factor_bench.c +++ b/src/fmpz_factor/profile/p-factor_bench.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "fmpz.h" #include "fmpz_factor.h" #include "ulong_extras.h" diff --git a/src/fmpz_factor/profile/p-factor_pp1.c b/src/fmpz_factor/profile/p-factor_pp1.c index 125dd4f4eb..2ec6423cd1 100644 --- a/src/fmpz_factor/profile/p-factor_pp1.c +++ b/src/fmpz_factor/profile/p-factor_pp1.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "fmpz.h" #include "fmpz_factor.h" #include "ulong_extras.h" diff --git a/src/fmpz_factor/test/main.c b/src/fmpz_factor/test/main.c index 33bc8454ca..8a09a8519f 100644 --- a/src/fmpz_factor/test/main.c +++ b/src/fmpz_factor/test/main.c @@ -9,6 +9,8 @@ (at your option) any later version. See . */ +#include + /* Include functions *********************************************************/ #include "t-ecm.c" diff --git a/src/fmpz_lll/lll_mpf2.c b/src/fmpz_lll/lll_mpf2.c index 978ec3f9f5..859c57e5bd 100644 --- a/src/fmpz_lll/lll_mpf2.c +++ b/src/fmpz_lll/lll_mpf2.c @@ -12,6 +12,7 @@ */ #include +#include #include "fmpz.h" #include "fmpz_vec.h" #include "fmpz_mat.h" diff --git a/src/fmpz_lll/lll_mpf2_with_removal.c b/src/fmpz_lll/lll_mpf2_with_removal.c index bc01550f31..4401ad399a 100644 --- a/src/fmpz_lll/lll_mpf2_with_removal.c +++ b/src/fmpz_lll/lll_mpf2_with_removal.c @@ -12,6 +12,7 @@ */ #include +#include #include "fmpz.h" #include "fmpz_vec.h" #include "fmpz_mat.h" diff --git a/src/fmpz_lll/profile/p-lll.c b/src/fmpz_lll/profile/p-lll.c index b6c36b3526..12bb97b204 100644 --- a/src/fmpz_lll/profile/p-lll.c +++ b/src/fmpz_lll/profile/p-lll.c @@ -12,7 +12,6 @@ */ #include "profiler.h" -#include "flint.h" #include "fmpz.h" #include "fmpz_mat.h" #include "fmpz_lll.h" diff --git a/src/fmpz_lll/storjohann_ulll.c b/src/fmpz_lll/storjohann_ulll.c index 2128b830f8..dc0a01a1a0 100644 --- a/src/fmpz_lll/storjohann_ulll.c +++ b/src/fmpz_lll/storjohann_ulll.c @@ -11,6 +11,7 @@ (at your option) any later version. See . */ +#include #include "fmpz_mat.h" #include "fmpq.h" #include "fmpz_lll.h" diff --git a/src/fmpz_mat/is_reduced.c b/src/fmpz_mat/is_reduced.c index 27f55265e4..599f7f0aaa 100644 --- a/src/fmpz_mat/is_reduced.c +++ b/src/fmpz_mat/is_reduced.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpz_mat.h" #include "fmpq.h" #include "fmpq_vec.h" diff --git a/src/fmpz_mat/is_reduced_gram.c b/src/fmpz_mat/is_reduced_gram.c index e8f3768948..37dfb1a9f6 100644 --- a/src/fmpz_mat/is_reduced_gram.c +++ b/src/fmpz_mat/is_reduced_gram.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpz_mat.h" #include "fmpq.h" #include "fmpq_vec.h" diff --git a/src/fmpz_mat/is_reduced_gram_with_removal.c b/src/fmpz_mat/is_reduced_gram_with_removal.c index 89f71ecf15..d1d6508d74 100644 --- a/src/fmpz_mat/is_reduced_gram_with_removal.c +++ b/src/fmpz_mat/is_reduced_gram_with_removal.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpz_mat.h" #include "fmpq.h" #include "fmpq_vec.h" diff --git a/src/fmpz_mat/is_reduced_with_removal.c b/src/fmpz_mat/is_reduced_with_removal.c index 22bd7695ff..01bfca04f9 100644 --- a/src/fmpz_mat/is_reduced_with_removal.c +++ b/src/fmpz_mat/is_reduced_with_removal.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpz_mat.h" #include "fmpq.h" #include "fmpq_vec.h" diff --git a/src/fmpz_mat/mul_blas.c b/src/fmpz_mat/mul_blas.c index 74e295d6a2..ea2b39d741 100644 --- a/src/fmpz_mat/mul_blas.c +++ b/src/fmpz_mat/mul_blas.c @@ -17,11 +17,12 @@ #if FLINT_USES_BLAS && FLINT_BITS == 64 #include +#include +#include #include "nmod.h" #include "fmpz.h" #include "thread_pool.h" #include "thread_support.h" -#include "cblas.h" typedef struct { slong m; diff --git a/src/fmpz_mat/mul_multi_mod.c b/src/fmpz_mat/mul_multi_mod.c index 48872a253e..9a5ea4a30c 100644 --- a/src/fmpz_mat/mul_multi_mod.c +++ b/src/fmpz_mat/mul_multi_mod.c @@ -10,6 +10,7 @@ (at your option) any later version. See . */ +#include #include "thread_pool.h" #include "thread_support.h" #include "nmod.h" diff --git a/src/fmpz_mat/next_col_van_hoeij.c b/src/fmpz_mat/next_col_van_hoeij.c index 5022763cab..e8aff151f7 100644 --- a/src/fmpz_mat/next_col_van_hoeij.c +++ b/src/fmpz_mat/next_col_van_hoeij.c @@ -10,6 +10,7 @@ (at your option) any later version. See . */ +#include #include "fmpz.h" #include "fmpz_mat.h" diff --git a/src/fmpz_mat/profile/p-big_mul.c b/src/fmpz_mat/profile/p-big_mul.c index 3acf70186f..441cd9c605 100644 --- a/src/fmpz_mat/profile/p-big_mul.c +++ b/src/fmpz_mat/profile/p-big_mul.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "fmpz_mat.h" #include "fmpz.h" #include "ulong_extras.h" diff --git a/src/fmpz_mat/profile/p-det.c b/src/fmpz_mat/profile/p-det.c index 1021635e4d..3dce95cf57 100644 --- a/src/fmpz_mat/profile/p-det.c +++ b/src/fmpz_mat/profile/p-det.c @@ -11,7 +11,6 @@ */ #include "profiler.h" -#include "flint.h" #include "fmpz_mat.h" #include "fmpz.h" #include "ulong_extras.h" diff --git a/src/fmpz_mat/profile/p-mul.c b/src/fmpz_mat/profile/p-mul.c index 532b612351..ec408f22cc 100644 --- a/src/fmpz_mat/profile/p-mul.c +++ b/src/fmpz_mat/profile/p-mul.c @@ -13,7 +13,6 @@ #include #include #include "profiler.h" -#include "flint.h" #include "fmpz_mat.h" #include "fmpz.h" #include "ulong_extras.h" diff --git a/src/fmpz_mat/profile/p-mul_blas_v_mul.c b/src/fmpz_mat/profile/p-mul_blas_v_mul.c index 280b5c7e7c..60b6dbd530 100644 --- a/src/fmpz_mat/profile/p-mul_blas_v_mul.c +++ b/src/fmpz_mat/profile/p-mul_blas_v_mul.c @@ -10,12 +10,11 @@ */ #include "flint.h" -#include "fmpz_mat.h" -#include "profiler.h" #if FLINT_USES_BLAS - -#include "cblas.h" +#include +#include "fmpz_mat.h" +#include "profiler.h" int main(void) { @@ -98,10 +97,8 @@ int main(void) } #else - int main(void) { return 0; } - #endif diff --git a/src/fmpz_mat/profile/p-mul_double_word.c b/src/fmpz_mat/profile/p-mul_double_word.c index 4630b054a5..6b5640e361 100644 --- a/src/fmpz_mat/profile/p-mul_double_word.c +++ b/src/fmpz_mat/profile/p-mul_double_word.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_mat.h" #include "profiler.h" diff --git a/src/fmpz_mat/profile/p-mul_double_word_v_mul_multi_mod.c b/src/fmpz_mat/profile/p-mul_double_word_v_mul_multi_mod.c index 90d1cfc480..ba52b62961 100644 --- a/src/fmpz_mat/profile/p-mul_double_word_v_mul_multi_mod.c +++ b/src/fmpz_mat/profile/p-mul_double_word_v_mul_multi_mod.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_mat.h" #include "profiler.h" diff --git a/src/fmpz_mat/profile/p-mul_fft.c b/src/fmpz_mat/profile/p-mul_fft.c index e9cfb45217..affeab5b9f 100644 --- a/src/fmpz_mat/profile/p-mul_fft.c +++ b/src/fmpz_mat/profile/p-mul_fft.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "fmpz_mat.h" #include "fmpz.h" #include "ulong_extras.h" diff --git a/src/fmpz_mat/profile/p-mul_multi_mod.c b/src/fmpz_mat/profile/p-mul_multi_mod.c index fc61127259..b717067b2b 100644 --- a/src/fmpz_mat/profile/p-mul_multi_mod.c +++ b/src/fmpz_mat/profile/p-mul_multi_mod.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_mat.h" #include "profiler.h" diff --git a/src/fmpz_mat/profile/p-mul_small.c b/src/fmpz_mat/profile/p-mul_small.c index 927c268ea0..6ce5ea25fc 100644 --- a/src/fmpz_mat/profile/p-mul_small.c +++ b/src/fmpz_mat/profile/p-mul_small.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_mat.h" #include "profiler.h" diff --git a/src/fmpz_mat/profile/p-mul_small_v_mul_multi_mod.c b/src/fmpz_mat/profile/p-mul_small_v_mul_multi_mod.c index b3bc7a86ff..d2577fc0af 100644 --- a/src/fmpz_mat/profile/p-mul_small_v_mul_multi_mod.c +++ b/src/fmpz_mat/profile/p-mul_small_v_mul_multi_mod.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_mat.h" #include "profiler.h" diff --git a/src/fmpz_mat/profile/p-sqr.c b/src/fmpz_mat/profile/p-sqr.c index d9f7550676..0db5ee5508 100644 --- a/src/fmpz_mat/profile/p-sqr.c +++ b/src/fmpz_mat/profile/p-sqr.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "fmpz_mat.h" #include "fmpz.h" #include "ulong_extras.h" diff --git a/src/fmpz_mod_poly/profile/p-gcd.c b/src/fmpz_mod_poly/profile/p-gcd.c index 39442100bc..a868544e16 100644 --- a/src/fmpz_mod_poly/profile/p-gcd.c +++ b/src/fmpz_mod_poly/profile/p-gcd.c @@ -11,7 +11,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "fmpz_mod.h" diff --git a/src/fmpz_mod_poly/profile/p-invert.c b/src/fmpz_mod_poly/profile/p-invert.c index 14a8036f25..92bc091a55 100644 --- a/src/fmpz_mod_poly/profile/p-invert.c +++ b/src/fmpz_mod_poly/profile/p-invert.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fmpz_mod.h" #include "fmpz_mod_poly.h" diff --git a/src/fmpz_mod_poly/profile/p-minpoly.c b/src/fmpz_mod_poly/profile/p-minpoly.c index 0f7d873dd3..05a8a14fc2 100644 --- a/src/fmpz_mod_poly/profile/p-minpoly.c +++ b/src/fmpz_mod_poly/profile/p-minpoly.c @@ -13,7 +13,6 @@ ******************************************************************************/ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" #include "fmpz_mod.h" diff --git a/src/fmpz_mod_poly/profile/p-mul.c b/src/fmpz_mod_poly/profile/p-mul.c index 23f3ea1618..887c348403 100644 --- a/src/fmpz_mod_poly/profile/p-mul.c +++ b/src/fmpz_mod_poly/profile/p-mul.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fmpz_mod.h" #include "fmpz_mod_poly.h" diff --git a/src/fmpz_mod_poly/profile/p-tree.c b/src/fmpz_mod_poly/profile/p-tree.c index 141b9bf46e..f3713799c8 100644 --- a/src/fmpz_mod_poly/profile/p-tree.c +++ b/src/fmpz_mod_poly/profile/p-tree.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" #include "fmpz_mod.h" diff --git a/src/fmpz_mod_poly_factor/profile/p-factor.c b/src/fmpz_mod_poly_factor/profile/p-factor.c index 68550de97c..e0a9e08f4e 100644 --- a/src/fmpz_mod_poly_factor/profile/p-factor.c +++ b/src/fmpz_mod_poly_factor/profile/p-factor.c @@ -13,7 +13,6 @@ #include #include -#include "flint.h" #include "gmpcompat.h" #include "fmpz.h" #include "fmpz_mod.h" diff --git a/src/fmpz_mpoly/misc.c b/src/fmpz_mpoly/misc.c index 871e69bd2e..e0ef191275 100644 --- a/src/fmpz_mpoly/misc.c +++ b/src/fmpz_mpoly/misc.c @@ -10,6 +10,7 @@ (at your option) any later version. See . */ +#include #include "fmpz.h" #include "fmpz_mpoly.h" diff --git a/src/fmpz_poly/CLD_bound.c b/src/fmpz_poly/CLD_bound.c index 42d2858bca..18c14bf2a0 100644 --- a/src/fmpz_poly/CLD_bound.c +++ b/src/fmpz_poly/CLD_bound.c @@ -13,7 +13,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "double_extras.h" diff --git a/src/fmpz_poly/bit_pack.c b/src/fmpz_poly/bit_pack.c index 96dc5cf673..4d08b9f459 100644 --- a/src/fmpz_poly/bit_pack.c +++ b/src/fmpz_poly/bit_pack.c @@ -47,6 +47,7 @@ fmpz_poly_bit_pack(fmpz_t f, const fmpz_poly_t poly, mpz_ptr mpz; slong i, d; int negate; + mp_ptr ptr; len = fmpz_poly_length(poly); @@ -57,21 +58,21 @@ fmpz_poly_bit_pack(fmpz_t f, const fmpz_poly_t poly, } mpz = _fmpz_promote(f); - mpz_realloc2(mpz, len * bit_size); - d = mpz->_mp_alloc; + d = (len * bit_size - 1) / FLINT_BITS + 1; + ptr = FLINT_MPZ_REALLOC(mpz, d); - flint_mpn_zero(mpz->_mp_d, d); + flint_mpn_zero(ptr, d); if (fmpz_sgn(fmpz_poly_lead(poly)) < 0) negate = -1; else negate = 0; - _fmpz_poly_bit_pack(mpz->_mp_d, poly->coeffs, len, bit_size, negate); + _fmpz_poly_bit_pack(ptr, poly->coeffs, len, bit_size, negate); for (i = d - 1; i >= 0; i--) { - if (mpz->_mp_d[i] != 0) + if (ptr[i] != 0) break; } d = i + 1; diff --git a/src/fmpz_poly/gcd_subresultant.c b/src/fmpz_poly/gcd_subresultant.c index 4d955393fa..8fd601283e 100644 --- a/src/fmpz_poly/gcd_subresultant.c +++ b/src/fmpz_poly/gcd_subresultant.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" #include "fmpz_poly.h" diff --git a/src/fmpz_poly/get_str.c b/src/fmpz_poly/get_str.c index 44fd219778..168184b305 100644 --- a/src/fmpz_poly/get_str.c +++ b/src/fmpz_poly/get_str.c @@ -11,6 +11,7 @@ #include #include +#include #include "fmpz.h" #include "fmpz_poly.h" diff --git a/src/fmpz_poly/profile/bm-div_divconquer.c b/src/fmpz_poly/profile/bm-div_divconquer.c index 758c7ef2ad..0d7d61a364 100644 --- a/src/fmpz_poly/profile/bm-div_divconquer.c +++ b/src/fmpz_poly/profile/bm-div_divconquer.c @@ -11,7 +11,7 @@ #include #include -#include "flint.h" +#include #include "fmpz.h" #include "fmpz_poly.h" diff --git a/src/fmpz_poly/profile/p-compose.c b/src/fmpz_poly/profile/p-compose.c index d1970e5f95..db17eda3f5 100644 --- a/src/fmpz_poly/profile/p-compose.c +++ b/src/fmpz_poly/profile/p-compose.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "ulong_extras.h" diff --git a/src/fmpz_poly/profile/p-div_preinv.c b/src/fmpz_poly/profile/p-div_preinv.c index 0acbece64c..0020711c43 100644 --- a/src/fmpz_poly/profile/p-div_preinv.c +++ b/src/fmpz_poly/profile/p-div_preinv.c @@ -11,7 +11,6 @@ #include #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fmpz_poly.h" diff --git a/src/fmpz_poly/profile/p-gcd.c b/src/fmpz_poly/profile/p-gcd.c index c121046653..2b2f6e6b8f 100644 --- a/src/fmpz_poly/profile/p-gcd.c +++ b/src/fmpz_poly/profile/p-gcd.c @@ -11,7 +11,6 @@ #include #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fmpz_poly.h" diff --git a/src/fmpz_poly/profile/p-mul.c b/src/fmpz_poly/profile/p-mul.c index a043b2c7a4..592bc58e3b 100644 --- a/src/fmpz_poly/profile/p-mul.c +++ b/src/fmpz_poly/profile/p-mul.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "ulong_extras.h" diff --git a/src/fmpz_poly/profile/p-mul_triangle.c b/src/fmpz_poly/profile/p-mul_triangle.c index e743ac34f2..486e81a2a3 100644 --- a/src/fmpz_poly/profile/p-mul_triangle.c +++ b/src/fmpz_poly/profile/p-mul_triangle.c @@ -12,7 +12,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "ulong_extras.h" diff --git a/src/fmpz_poly/profile/p-pow.c b/src/fmpz_poly/profile/p-pow.c index 3f63cce5c5..3d6a5317e7 100644 --- a/src/fmpz_poly/profile/p-pow.c +++ b/src/fmpz_poly/profile/p-pow.c @@ -11,7 +11,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "ulong_extras.h" diff --git a/src/fmpz_poly/profile/p-pow_binomial.c b/src/fmpz_poly/profile/p-pow_binomial.c index 54bc8e6228..292aaf63b2 100644 --- a/src/fmpz_poly/profile/p-pow_binomial.c +++ b/src/fmpz_poly/profile/p-pow_binomial.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "ulong_extras.h" diff --git a/src/fmpz_poly/profile/p-rem_powers_precomp.c b/src/fmpz_poly/profile/p-rem_powers_precomp.c index 87daf0b5d3..e98f2e0082 100644 --- a/src/fmpz_poly/profile/p-rem_powers_precomp.c +++ b/src/fmpz_poly/profile/p-rem_powers_precomp.c @@ -11,7 +11,6 @@ #include #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fmpz_poly.h" diff --git a/src/fmpz_poly/scale_2exp.c b/src/fmpz_poly/scale_2exp.c index 7a2e31e946..429438e4a9 100644 --- a/src/fmpz_poly/scale_2exp.c +++ b/src/fmpz_poly/scale_2exp.c @@ -23,7 +23,7 @@ void _fmpz_poly_scale_2exp(fmpz * pol, slong len, slong k) else if (k > 0) { if (fmpz_is_zero(pol)) - z = ULONG_MAX; + z = UWORD_MAX; else z = fmpz_val2(pol); @@ -40,7 +40,7 @@ void _fmpz_poly_scale_2exp(fmpz * pol, slong len, slong k) else { if (fmpz_is_zero(pol + len - 1)) - z = ULONG_MAX; + z = UWORD_MAX; else z = fmpz_val2(pol + len - 1); diff --git a/src/fmpz_poly/sqrt_KS.c b/src/fmpz_poly/sqrt_KS.c index 9df33b5ebd..5b671da35f 100644 --- a/src/fmpz_poly/sqrt_KS.c +++ b/src/fmpz_poly/sqrt_KS.c @@ -10,6 +10,7 @@ (at your option) any later version. See . */ +#include #include "fmpz.h" #include "fmpz_vec.h" #include "fmpz_poly.h" diff --git a/src/fmpz_poly/taylor_shift_horner.c b/src/fmpz_poly/taylor_shift_horner.c index 3adbb6d05a..b48e9e568d 100644 --- a/src/fmpz_poly/taylor_shift_horner.c +++ b/src/fmpz_poly/taylor_shift_horner.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpz.h" #include "fmpz_vec.h" #include "fmpz_poly.h" diff --git a/src/fmpz_poly_factor/factor_cubic.c b/src/fmpz_poly_factor/factor_cubic.c index 4dd44063a3..05c208a0da 100644 --- a/src/fmpz_poly_factor/factor_cubic.c +++ b/src/fmpz_poly_factor/factor_cubic.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "nmod.h" #include "fmpz.h" #include "fmpz_poly.h" diff --git a/src/fmpz_poly_factor/profile/p-factor_quadratic_cubic.c b/src/fmpz_poly_factor/profile/p-factor_quadratic_cubic.c index 3f3f856c33..6dfa35495f 100644 --- a/src/fmpz_poly_factor/profile/p-factor_quadratic_cubic.c +++ b/src/fmpz_poly_factor/profile/p-factor_quadratic_cubic.c @@ -7,7 +7,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "fmpz_poly_factor.h" diff --git a/src/fmpz_poly_mat/add.c b/src/fmpz_poly_mat/add.c index aae727224f..027c1e8feb 100644 --- a/src/fmpz_poly_mat/add.c +++ b/src/fmpz_poly_mat/add.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/clear.c b/src/fmpz_poly_mat/clear.c index ca72480ce7..68aa4b8f50 100644 --- a/src/fmpz_poly_mat/clear.c +++ b/src/fmpz_poly_mat/clear.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/det.c b/src/fmpz_poly_mat/det.c index 944f0f79fd..a491b36d0e 100644 --- a/src/fmpz_poly_mat/det.c +++ b/src/fmpz_poly_mat/det.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/det_fflu.c b/src/fmpz_poly_mat/det_fflu.c index 6ddf04b29d..b485fcde57 100644 --- a/src/fmpz_poly_mat/det_fflu.c +++ b/src/fmpz_poly_mat/det_fflu.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" #include "perm.h" diff --git a/src/fmpz_poly_mat/equal.c b/src/fmpz_poly_mat/equal.c index 1db3544489..3f9e6fbb03 100644 --- a/src/fmpz_poly_mat/equal.c +++ b/src/fmpz_poly_mat/equal.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/evaluate_fmpz.c b/src/fmpz_poly_mat/evaluate_fmpz.c index 5ab5cbf0e8..a627f9e327 100644 --- a/src/fmpz_poly_mat/evaluate_fmpz.c +++ b/src/fmpz_poly_mat/evaluate_fmpz.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_mat.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/fflu.c b/src/fmpz_poly_mat/fflu.c index 25965f35b1..985acdb90b 100644 --- a/src/fmpz_poly_mat/fflu.c +++ b/src/fmpz_poly_mat/fflu.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/find_pivot_any.c b/src/fmpz_poly_mat/find_pivot_any.c index 2145c4ae75..04d1689918 100644 --- a/src/fmpz_poly_mat/find_pivot_any.c +++ b/src/fmpz_poly_mat/find_pivot_any.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/find_pivot_partial.c b/src/fmpz_poly_mat/find_pivot_partial.c index 39c1eba19d..0df3720eb7 100644 --- a/src/fmpz_poly_mat/find_pivot_partial.c +++ b/src/fmpz_poly_mat/find_pivot_partial.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/inlines.c b/src/fmpz_poly_mat/inlines.c index 51d10c7ebd..b46fe9fd47 100644 --- a/src/fmpz_poly_mat/inlines.c +++ b/src/fmpz_poly_mat/inlines.c @@ -11,5 +11,4 @@ #define FMPZ_POLY_MAT_INLINES_C -#include "flint.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/inv.c b/src/fmpz_poly_mat/inv.c index 3a3e085452..6494030f6f 100644 --- a/src/fmpz_poly_mat/inv.c +++ b/src/fmpz_poly_mat/inv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/is_one.c b/src/fmpz_poly_mat/is_one.c index ff77e528bf..498c4a9e63 100644 --- a/src/fmpz_poly_mat/is_one.c +++ b/src/fmpz_poly_mat/is_one.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/is_zero.c b/src/fmpz_poly_mat/is_zero.c index 8a81faa44c..749ea4262c 100644 --- a/src/fmpz_poly_mat/is_zero.c +++ b/src/fmpz_poly_mat/is_zero.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/max_bits.c b/src/fmpz_poly_mat/max_bits.c index 10243f93b0..bc120f4e51 100644 --- a/src/fmpz_poly_mat/max_bits.c +++ b/src/fmpz_poly_mat/max_bits.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/max_length.c b/src/fmpz_poly_mat/max_length.c index 3a10927743..24f1ea4512 100644 --- a/src/fmpz_poly_mat/max_length.c +++ b/src/fmpz_poly_mat/max_length.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/mul.c b/src/fmpz_poly_mat/mul.c index c43041674a..fac8425590 100644 --- a/src/fmpz_poly_mat/mul.c +++ b/src/fmpz_poly_mat/mul.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/mul_classical.c b/src/fmpz_poly_mat/mul_classical.c index 4f5996cdac..a01e5f1aaf 100644 --- a/src/fmpz_poly_mat/mul_classical.c +++ b/src/fmpz_poly_mat/mul_classical.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/mullow.c b/src/fmpz_poly_mat/mullow.c index c4f7e1f84c..ce1c6fb375 100644 --- a/src/fmpz_poly_mat/mullow.c +++ b/src/fmpz_poly_mat/mullow.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/neg.c b/src/fmpz_poly_mat/neg.c index da8d29bdcc..61ac1a0427 100644 --- a/src/fmpz_poly_mat/neg.c +++ b/src/fmpz_poly_mat/neg.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/nullspace.c b/src/fmpz_poly_mat/nullspace.c index 66de41f71d..58bfde114d 100644 --- a/src/fmpz_poly_mat/nullspace.c +++ b/src/fmpz_poly_mat/nullspace.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/one.c b/src/fmpz_poly_mat/one.c index 781736800f..27f3dea6d1 100644 --- a/src/fmpz_poly_mat/one.c +++ b/src/fmpz_poly_mat/one.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/print.c b/src/fmpz_poly_mat/print.c index edd7983f11..543425edbb 100644 --- a/src/fmpz_poly_mat/print.c +++ b/src/fmpz_poly_mat/print.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/prod.c b/src/fmpz_poly_mat/prod.c index a091c2e632..f73f40ae59 100644 --- a/src/fmpz_poly_mat/prod.c +++ b/src/fmpz_poly_mat/prod.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/rank.c b/src/fmpz_poly_mat/rank.c index 99dd84d703..1d6c256fb8 100644 --- a/src/fmpz_poly_mat/rank.c +++ b/src/fmpz_poly_mat/rank.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/rref.c b/src/fmpz_poly_mat/rref.c index dfa95e11d8..a7da6a1e34 100644 --- a/src/fmpz_poly_mat/rref.c +++ b/src/fmpz_poly_mat/rref.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/set.c b/src/fmpz_poly_mat/set.c index 144f4f2fbb..32ed2d2dce 100644 --- a/src/fmpz_poly_mat/set.c +++ b/src/fmpz_poly_mat/set.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/solve.c b/src/fmpz_poly_mat/solve.c index a09ef4edd3..a68c1d4e64 100644 --- a/src/fmpz_poly_mat/solve.c +++ b/src/fmpz_poly_mat/solve.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/solve_fflu.c b/src/fmpz_poly_mat/solve_fflu.c index 80486c6db3..596d961cc7 100644 --- a/src/fmpz_poly_mat/solve_fflu.c +++ b/src/fmpz_poly_mat/solve_fflu.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/solve_fflu_precomp.c b/src/fmpz_poly_mat/solve_fflu_precomp.c index ff8dcb0526..71e693e4a2 100644 --- a/src/fmpz_poly_mat/solve_fflu_precomp.c +++ b/src/fmpz_poly_mat/solve_fflu_precomp.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/sqr.c b/src/fmpz_poly_mat/sqr.c index ce2aea1fb0..55faec8732 100644 --- a/src/fmpz_poly_mat/sqr.c +++ b/src/fmpz_poly_mat/sqr.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/sqr_classical.c b/src/fmpz_poly_mat/sqr_classical.c index af47c616fe..15af9039ba 100644 --- a/src/fmpz_poly_mat/sqr_classical.c +++ b/src/fmpz_poly_mat/sqr_classical.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/sqrlow.c b/src/fmpz_poly_mat/sqrlow.c index 95e318d7cc..033bb1ea40 100644 --- a/src/fmpz_poly_mat/sqrlow.c +++ b/src/fmpz_poly_mat/sqrlow.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/sub.c b/src/fmpz_poly_mat/sub.c index 4df9715366..0aa48ab22a 100644 --- a/src/fmpz_poly_mat/sub.c +++ b/src/fmpz_poly_mat/sub.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/swap.c b/src/fmpz_poly_mat/swap.c index 3ebb4dec72..717e9b2316 100644 --- a/src/fmpz_poly_mat/swap.c +++ b/src/fmpz_poly_mat/swap.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/trace.c b/src/fmpz_poly_mat/trace.c index 6fb824cf2e..f5455a8fce 100644 --- a/src/fmpz_poly_mat/trace.c +++ b/src/fmpz_poly_mat/trace.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/truncate.c b/src/fmpz_poly_mat/truncate.c index 72daaea108..dd96484e17 100644 --- a/src/fmpz_poly_mat/truncate.c +++ b/src/fmpz_poly_mat/truncate.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_mat/zero.c b/src/fmpz_poly_mat/zero.c index e588ddd335..a794ef780d 100644 --- a/src/fmpz_poly_mat/zero.c +++ b/src/fmpz_poly_mat/zero.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz_poly.h" #include "fmpz_poly_mat.h" diff --git a/src/fmpz_poly_q/inlines.c b/src/fmpz_poly_q/inlines.c index 10f5f237d8..61a12f96e9 100644 --- a/src/fmpz_poly_q/inlines.c +++ b/src/fmpz_poly_q/inlines.c @@ -11,5 +11,4 @@ #define FMPZ_POLY_Q_INLINES_C -#include "flint.h" #include "fmpz_poly_q.h" diff --git a/src/fmpz_poly_q/test/t-scalar_div_fmpq.c b/src/fmpz_poly_q/test/t-scalar_div_fmpq.c index 24e40df0f5..8fd01db4f4 100644 --- a/src/fmpz_poly_q/test/t-scalar_div_fmpq.c +++ b/src/fmpz_poly_q/test/t-scalar_div_fmpq.c @@ -97,7 +97,7 @@ TEST_FUNCTION_START(fmpz_poly_q_scalar_div_fmpq, state) flint_printf("b = "), fmpz_poly_q_print(b), flint_printf("\n\n"); flint_printf("c = "), fmpz_poly_q_print(c), flint_printf("\n\n"); flint_printf("d = "), fmpz_poly_q_print(d), flint_printf("\n\n"); - gmp_printf("y = %Qd\n\n", y); + flint_printf("y = %{fmpq}\n\n", y); fflush(stdout); flint_abort(); } diff --git a/src/fmpz_types.h b/src/fmpz_types.h index fec885dd82..727b747a33 100644 --- a/src/fmpz_types.h +++ b/src/fmpz_types.h @@ -18,6 +18,17 @@ extern "C" { #endif +typedef struct +{ + int alloc; + int size; + nn_ptr ptr; +} zz_struct; + +typedef zz_struct * zz_ptr; +typedef const zz_struct * zz_srcptr; +#define FMPZ_TO_ZZ(x) ((zz_ptr) ((ulong) (x) << 2)) + typedef struct { int sign; diff --git a/src/fmpz_vec/add.c b/src/fmpz_vec/add.c index 1ddf0be0fc..a6efa37a71 100644 --- a/src/fmpz_vec/add.c +++ b/src/fmpz_vec/add.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/clear.c b/src/fmpz_vec/clear.c index 664078f991..0b0cdc29d5 100644 --- a/src/fmpz_vec/clear.c +++ b/src/fmpz_vec/clear.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/content.c b/src/fmpz_vec/content.c index fd5807a32c..d6e761c4eb 100644 --- a/src/fmpz_vec/content.c +++ b/src/fmpz_vec/content.c @@ -11,7 +11,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/equal.c b/src/fmpz_vec/equal.c index c7fee805c4..3210ee5683 100644 --- a/src/fmpz_vec/equal.c +++ b/src/fmpz_vec/equal.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/get_nmod_vec.c b/src/fmpz_vec/get_nmod_vec.c index ca1ca2c968..70319a99cb 100644 --- a/src/fmpz_vec/get_nmod_vec.c +++ b/src/fmpz_vec/get_nmod_vec.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" #include "fmpz_poly.h" diff --git a/src/fmpz_vec/height.c b/src/fmpz_vec/height.c index 2ef426975b..f7e1cad071 100644 --- a/src/fmpz_vec/height.c +++ b/src/fmpz_vec/height.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/height_index.c b/src/fmpz_vec/height_index.c index 642ab044d3..32fb5082d9 100644 --- a/src/fmpz_vec/height_index.c +++ b/src/fmpz_vec/height_index.c @@ -9,7 +9,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/inlines.c b/src/fmpz_vec/inlines.c index 3aa7658206..5fa9f76e2d 100644 --- a/src/fmpz_vec/inlines.c +++ b/src/fmpz_vec/inlines.c @@ -11,5 +11,4 @@ #define FMPZ_VEC_INLINES_C -#include "flint.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/is_zero.c b/src/fmpz_vec/is_zero.c index 4b973c97e6..38a06fe177 100644 --- a/src/fmpz_vec/is_zero.c +++ b/src/fmpz_vec/is_zero.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/lcm.c b/src/fmpz_vec/lcm.c index 785322c595..037e40eee0 100644 --- a/src/fmpz_vec/lcm.c +++ b/src/fmpz_vec/lcm.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/max_bits.c b/src/fmpz_vec/max_bits.c index 0e014043f4..4b3985f27a 100644 --- a/src/fmpz_vec/max_bits.c +++ b/src/fmpz_vec/max_bits.c @@ -10,6 +10,7 @@ (at your option) any later version. See . */ +#include #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/max_limbs.c b/src/fmpz_vec/max_limbs.c index 2fed677d6a..6a336adb52 100644 --- a/src/fmpz_vec/max_limbs.c +++ b/src/fmpz_vec/max_limbs.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/neg.c b/src/fmpz_vec/neg.c index 4151ed76e8..621e048cdd 100644 --- a/src/fmpz_vec/neg.c +++ b/src/fmpz_vec/neg.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/prod.c b/src/fmpz_vec/prod.c index be1c0bba2a..8ac19e645f 100644 --- a/src/fmpz_vec/prod.c +++ b/src/fmpz_vec/prod.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/randtest.c b/src/fmpz_vec/randtest.c index ef1f55dc97..606c7bae94 100644 --- a/src/fmpz_vec/randtest.c +++ b/src/fmpz_vec/randtest.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/set.c b/src/fmpz_vec/set.c index 41ebc4897a..83837fb09f 100644 --- a/src/fmpz_vec/set.c +++ b/src/fmpz_vec/set.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/set_nmod_vec.c b/src/fmpz_vec/set_nmod_vec.c index b4ecb86dd5..6a38bdbf95 100644 --- a/src/fmpz_vec/set_nmod_vec.c +++ b/src/fmpz_vec/set_nmod_vec.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" #include "fmpz_poly.h" diff --git a/src/fmpz_vec/sort.c b/src/fmpz_vec/sort.c index 3ec0742d56..cb0ca4b4ad 100644 --- a/src/fmpz_vec/sort.c +++ b/src/fmpz_vec/sort.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/sub.c b/src/fmpz_vec/sub.c index a9fc5880e1..411f2e61df 100644 --- a/src/fmpz_vec/sub.c +++ b/src/fmpz_vec/sub.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/sum.c b/src/fmpz_vec/sum.c index e7ccbbaaad..3eb7eaf45a 100644 --- a/src/fmpz_vec/sum.c +++ b/src/fmpz_vec/sum.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/swap.c b/src/fmpz_vec/swap.c index bf67cc5b1a..fe9110af1f 100644 --- a/src/fmpz_vec/swap.c +++ b/src/fmpz_vec/swap.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/test/main.c b/src/fmpz_vec/test/main.c index 2d96f8555a..d2051eaf19 100644 --- a/src/fmpz_vec/test/main.c +++ b/src/fmpz_vec/test/main.c @@ -9,6 +9,8 @@ (at your option) any later version. See . */ +#include + /* Include functions *********************************************************/ #include "t-add.c" diff --git a/src/fmpz_vec/test/t-scalar_fdiv_q_fmpz.c b/src/fmpz_vec/test/t-scalar_fdiv_q_fmpz.c index 5667bf9172..a0c4578566 100644 --- a/src/fmpz_vec/test/t-scalar_fdiv_q_fmpz.c +++ b/src/fmpz_vec/test/t-scalar_fdiv_q_fmpz.c @@ -10,6 +10,7 @@ (at your option) any later version. See . */ +#include #include "test_helpers.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpz_vec/zero.c b/src/fmpz_vec/zero.c index 27646b0cfe..139b5446b4 100644 --- a/src/fmpz_vec/zero.c +++ b/src/fmpz_vec/zero.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" diff --git a/src/fmpzi/bits.c b/src/fmpzi/bits.c index dde339de1e..89101bc836 100644 --- a/src/fmpzi/bits.c +++ b/src/fmpzi/bits.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpzi.h" slong fmpzi_bits(const fmpzi_t x) diff --git a/src/fmpzi/divexact.c b/src/fmpzi/divexact.c index 2ae9ab89ee..6e5b4cc05b 100644 --- a/src/fmpzi/divexact.c +++ b/src/fmpzi/divexact.c @@ -10,6 +10,7 @@ */ #include +#include #include "double_extras.h" #include "fmpzi.h" diff --git a/src/fmpzi/divrem.c b/src/fmpzi/divrem.c index b5da6c594a..0829f8dfa9 100644 --- a/src/fmpzi/divrem.c +++ b/src/fmpzi/divrem.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpzi.h" void diff --git a/src/fmpzi/sqr.c b/src/fmpzi/sqr.c index 7a62c93a1d..f7f2025d16 100644 --- a/src/fmpzi/sqr.c +++ b/src/fmpzi/sqr.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpzi.h" void diff --git a/src/fmpzi/test/t-divrem.c b/src/fmpzi/test/t-divrem.c index 31c7cf3cb5..c2f8909e57 100644 --- a/src/fmpzi/test/t-divrem.c +++ b/src/fmpzi/test/t-divrem.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "test_helpers.h" #include "fmpzi.h" diff --git a/src/fq/profile/p-inv.c b/src/fq/profile/p-inv.c index 463ce3ba59..63f88026af 100644 --- a/src/fq/profile/p-inv.c +++ b/src/fq/profile/p-inv.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fq.h" diff --git a/src/fq/profile/p-mul.c b/src/fq/profile/p-mul.c index cd9667dbf9..272d4fbf00 100644 --- a/src/fq/profile/p-mul.c +++ b/src/fq/profile/p-mul.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fq.h" diff --git a/src/fq/profile/p-reduce.c b/src/fq/profile/p-reduce.c index ead618a22b..f6a2a79152 100644 --- a/src/fq/profile/p-reduce.c +++ b/src/fq/profile/p-reduce.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fmpz_poly.h" diff --git a/src/fq_default_mat/inlines.c b/src/fq_default_mat/inlines.c index fc1a67ce41..0ca1f50448 100644 --- a/src/fq_default_mat/inlines.c +++ b/src/fq_default_mat/inlines.c @@ -11,7 +11,6 @@ #define FQ_DEFAULT_MAT_INLINES_C -#include "flint.h" #include "ulong_extras.h" #include "fq_default.h" #include "fq_default_mat.h" diff --git a/src/fq_default_poly/inlines.c b/src/fq_default_poly/inlines.c index d439774e4a..7a2a32201d 100644 --- a/src/fq_default_poly/inlines.c +++ b/src/fq_default_poly/inlines.c @@ -11,7 +11,6 @@ #define FQ_DEFAULT_POLY_INLINES_C -#include "flint.h" #include "ulong_extras.h" #include "fq_default.h" #include "fq_default_poly.h" diff --git a/src/fq_default_poly_factor/inlines.c b/src/fq_default_poly_factor/inlines.c index 1a01f7246c..14259f240f 100644 --- a/src/fq_default_poly_factor/inlines.c +++ b/src/fq_default_poly_factor/inlines.c @@ -11,7 +11,6 @@ #define FQ_DEFAULT_POLY_FACTOR_INLINES_C -#include "flint.h" #include "ulong_extras.h" #include "fq_default.h" #include "fq_default_poly.h" diff --git a/src/fq_mat_templates/lu_classical.c b/src/fq_mat_templates/lu_classical.c index 27904d8c9e..1a7647c647 100644 --- a/src/fq_mat_templates/lu_classical.c +++ b/src/fq_mat_templates/lu_classical.c @@ -14,7 +14,6 @@ #include "templates.h" -#include "flint.h" #include "ulong_extras.h" static inline int diff --git a/src/fq_mat_templates/profile/p-mul.c b/src/fq_mat_templates/profile/p-mul.c index 06dbe7da7f..ec3a79dd99 100644 --- a/src/fq_mat_templates/profile/p-mul.c +++ b/src/fq_mat_templates/profile/p-mul.c @@ -13,7 +13,6 @@ #include -#include "flint.h" #include "fmpz.h" #include "templates.h" diff --git a/src/fq_mat_templates/randpermdiag.c b/src/fq_mat_templates/randpermdiag.c index 07b3a7a968..d09400be68 100644 --- a/src/fq_mat_templates/randpermdiag.c +++ b/src/fq_mat_templates/randpermdiag.c @@ -14,7 +14,6 @@ #include "templates.h" -#include "flint.h" #include "ulong_extras.h" #include "perm.h" diff --git a/src/fq_mat_templates/rref.c b/src/fq_mat_templates/rref.c index 98992ea781..1d0363ddd9 100644 --- a/src/fq_mat_templates/rref.c +++ b/src/fq_mat_templates/rref.c @@ -14,7 +14,6 @@ #include "templates.h" -#include "flint.h" #include "perm.h" slong diff --git a/src/fq_nmod_poly/profile/p-factor_kaltofen_shoup_vs_fq_poly.c b/src/fq_nmod_poly/profile/p-factor_kaltofen_shoup_vs_fq_poly.c index b8af57e4da..1684017973 100644 --- a/src/fq_nmod_poly/profile/p-factor_kaltofen_shoup_vs_fq_poly.c +++ b/src/fq_nmod_poly/profile/p-factor_kaltofen_shoup_vs_fq_poly.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "ulong_extras.h" #include "profiler.h" diff --git a/src/fq_nmod_poly/profile/p-mul_univariate.c b/src/fq_nmod_poly/profile/p-mul_univariate.c index 94a08182ed..bcbf177fec 100644 --- a/src/fq_nmod_poly/profile/p-mul_univariate.c +++ b/src/fq_nmod_poly/profile/p-mul_univariate.c @@ -1,5 +1,4 @@ #include -#include "flint.h" #include "fmpz.h" #include "fq_nmod.h" #include "fq_nmod_poly.h" diff --git a/src/fq_nmod_poly_factor/inlines.c b/src/fq_nmod_poly_factor/inlines.c index 4418dac905..a502570acd 100644 --- a/src/fq_nmod_poly_factor/inlines.c +++ b/src/fq_nmod_poly_factor/inlines.c @@ -11,7 +11,6 @@ #define FQ_NMOD_POLY_FACTOR_INLINES_C -#include "flint.h" #include "ulong_extras.h" #include "fq_nmod.h" #include "fq_nmod_poly.h" diff --git a/src/fq_poly/profile/p-compose_mod.c b/src/fq_poly/profile/p-compose_mod.c index 064ed40847..e958a563de 100644 --- a/src/fq_poly/profile/p-compose_mod.c +++ b/src/fq_poly/profile/p-compose_mod.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fq.h" #include "fq_poly.h" diff --git a/src/fq_poly/profile/p-compose_mod_preinv.c b/src/fq_poly/profile/p-compose_mod_preinv.c index 3d283a1c72..28f4c15369 100644 --- a/src/fq_poly/profile/p-compose_mod_preinv.c +++ b/src/fq_poly/profile/p-compose_mod_preinv.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fq.h" #include "fq_poly.h" diff --git a/src/fq_poly/profile/p-factor_xnpxp1.c b/src/fq_poly/profile/p-factor_xnpxp1.c index 3bae55af2e..b782fac518 100644 --- a/src/fq_poly/profile/p-factor_xnpxp1.c +++ b/src/fq_poly/profile/p-factor_xnpxp1.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fq.h" #include "fq_poly.h" diff --git a/src/fq_poly/profile/p-is_irreducible.c b/src/fq_poly/profile/p-is_irreducible.c index 1ec6f6ffae..fcc0a4fa49 100644 --- a/src/fq_poly/profile/p-is_irreducible.c +++ b/src/fq_poly/profile/p-is_irreducible.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fq.h" #include "fq_poly.h" diff --git a/src/fq_poly/profile/p-iterated_frobenius.c b/src/fq_poly/profile/p-iterated_frobenius.c index fca3873f8d..395ba6d65b 100644 --- a/src/fq_poly/profile/p-iterated_frobenius.c +++ b/src/fq_poly/profile/p-iterated_frobenius.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fq.h" diff --git a/src/fq_poly/profile/p-iterated_frobenius_table.c b/src/fq_poly/profile/p-iterated_frobenius_table.c index f0771693ef..949abc4216 100644 --- a/src/fq_poly/profile/p-iterated_frobenius_table.c +++ b/src/fq_poly/profile/p-iterated_frobenius_table.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fq.h" diff --git a/src/fq_poly/profile/p-mul_univariate.c b/src/fq_poly/profile/p-mul_univariate.c index f3c24d34a7..86e09e49d1 100644 --- a/src/fq_poly/profile/p-mul_univariate.c +++ b/src/fq_poly/profile/p-mul_univariate.c @@ -1,5 +1,4 @@ #include -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fq.h" diff --git a/src/fq_poly/profile/p-mulmod.c b/src/fq_poly/profile/p-mulmod.c index 8d85ac2b97..d30b093d68 100644 --- a/src/fq_poly/profile/p-mulmod.c +++ b/src/fq_poly/profile/p-mulmod.c @@ -12,7 +12,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "fq.h" #include "fq_poly.h" diff --git a/src/fq_poly_factor/inlines.c b/src/fq_poly_factor/inlines.c index 7c258a1a20..8ea9d54b3b 100644 --- a/src/fq_poly_factor/inlines.c +++ b/src/fq_poly_factor/inlines.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fq.h" #include "fq_poly.h" diff --git a/src/fq_poly_factor_templates/clear.c b/src/fq_poly_factor_templates/clear.c index d953031bb0..83866f8907 100644 --- a/src/fq_poly_factor_templates/clear.c +++ b/src/fq_poly_factor_templates/clear.c @@ -18,7 +18,6 @@ #include "templates.h" -#include "flint.h" void TEMPLATE(T, poly_factor_clear) (TEMPLATE(T, poly_factor_t) fac, const TEMPLATE(T, ctx_t) ctx) diff --git a/src/fq_poly_factor_templates/realloc.c b/src/fq_poly_factor_templates/realloc.c index b91a490c3c..7607d68e44 100644 --- a/src/fq_poly_factor_templates/realloc.c +++ b/src/fq_poly_factor_templates/realloc.c @@ -15,7 +15,6 @@ #include "templates.h" -#include "flint.h" void TEMPLATE(T, poly_factor_realloc) (TEMPLATE(T, poly_factor_t) fac, slong alloc, const TEMPLATE(T, ctx_t) ctx) diff --git a/src/fq_poly_templates/compose_mod.c b/src/fq_poly_templates/compose_mod.c index 2a255f8d09..56c3f746a1 100644 --- a/src/fq_poly_templates/compose_mod.c +++ b/src/fq_poly_templates/compose_mod.c @@ -15,7 +15,6 @@ #include "templates.h" -#include "flint.h" #include "ulong_extras.h" void _TEMPLATE(T, poly_compose_mod) (TEMPLATE(T, struct) * res, diff --git a/src/fq_poly_templates/compose_mod_brent_kung_precomp_preinv.c b/src/fq_poly_templates/compose_mod_brent_kung_precomp_preinv.c index 7b7c70a170..215187cabc 100644 --- a/src/fq_poly_templates/compose_mod_brent_kung_precomp_preinv.c +++ b/src/fq_poly_templates/compose_mod_brent_kung_precomp_preinv.c @@ -15,7 +15,6 @@ #include "templates.h" -#include "flint.h" #include "ulong_extras.h" void diff --git a/src/fq_poly_templates/compose_mod_horner.c b/src/fq_poly_templates/compose_mod_horner.c index 8edf7a95f9..f9ed31cbfd 100644 --- a/src/fq_poly_templates/compose_mod_horner.c +++ b/src/fq_poly_templates/compose_mod_horner.c @@ -15,7 +15,6 @@ #include "templates.h" -#include "flint.h" #include "ulong_extras.h" void _TEMPLATE(T, poly_compose_mod_horner) ( diff --git a/src/fq_poly_templates/compose_mod_horner_preinv.c b/src/fq_poly_templates/compose_mod_horner_preinv.c index b5b013f1f9..8b61ebc3e2 100644 --- a/src/fq_poly_templates/compose_mod_horner_preinv.c +++ b/src/fq_poly_templates/compose_mod_horner_preinv.c @@ -15,7 +15,6 @@ #include "templates.h" -#include "flint.h" #include "ulong_extras.h" void _TEMPLATE(T, poly_compose_mod_horner_preinv) ( diff --git a/src/fq_poly_templates/compose_mod_preinv.c b/src/fq_poly_templates/compose_mod_preinv.c index 3e7e5aa95d..cf41021551 100644 --- a/src/fq_poly_templates/compose_mod_preinv.c +++ b/src/fq_poly_templates/compose_mod_preinv.c @@ -15,7 +15,6 @@ #include "templates.h" -#include "flint.h" #include "ulong_extras.h" void _TEMPLATE(T, poly_compose_mod_preinv) ( diff --git a/src/fq_poly_templates/powmod_fmpz_binexp.c b/src/fq_poly_templates/powmod_fmpz_binexp.c index 3a1abaa500..8719a12943 100644 --- a/src/fq_poly_templates/powmod_fmpz_binexp.c +++ b/src/fq_poly_templates/powmod_fmpz_binexp.c @@ -14,7 +14,6 @@ #include "templates.h" -#include "flint.h" void _TEMPLATE(T, poly_powmod_fmpz_binexp) ( TEMPLATE(T, struct) * res, diff --git a/src/fq_poly_templates/powmod_ui_binexp.c b/src/fq_poly_templates/powmod_ui_binexp.c index f227172a6b..421e59d505 100644 --- a/src/fq_poly_templates/powmod_ui_binexp.c +++ b/src/fq_poly_templates/powmod_ui_binexp.c @@ -14,7 +14,6 @@ #include "templates.h" -#include "flint.h" #include "ulong_extras.h" void _TEMPLATE(T, poly_powmod_ui_binexp) (TEMPLATE(T, struct) * res, diff --git a/src/fq_poly_templates/profile/p-factor_xnpxp1.c b/src/fq_poly_templates/profile/p-factor_xnpxp1.c index 45a5b29de7..843de80994 100644 --- a/src/fq_poly_templates/profile/p-factor_xnpxp1.c +++ b/src/fq_poly_templates/profile/p-factor_xnpxp1.c @@ -11,7 +11,6 @@ #ifdef T -#include "flint.h" #include "templates.h" #include "profiler.h" diff --git a/src/fq_poly_templates/profile/p-is_irreducible.c b/src/fq_poly_templates/profile/p-is_irreducible.c index 5d8e30b6af..5fdc39df99 100644 --- a/src/fq_poly_templates/profile/p-is_irreducible.c +++ b/src/fq_poly_templates/profile/p-is_irreducible.c @@ -11,7 +11,6 @@ #ifdef T -#include "flint.h" #include "templates.h" #include "profiler.h" diff --git a/src/fq_poly_templates/profile/p-iterated_frobenius.c b/src/fq_poly_templates/profile/p-iterated_frobenius.c index 84fe5fcb90..57a5f8fb0c 100644 --- a/src/fq_poly_templates/profile/p-iterated_frobenius.c +++ b/src/fq_poly_templates/profile/p-iterated_frobenius.c @@ -11,7 +11,6 @@ #ifdef T -#include "flint.h" #include "templates.h" #include diff --git a/src/fq_poly_templates/profile/p-iterated_frobenius_table.c b/src/fq_poly_templates/profile/p-iterated_frobenius_table.c index fcb081b645..3fca92a61e 100644 --- a/src/fq_poly_templates/profile/p-iterated_frobenius_table.c +++ b/src/fq_poly_templates/profile/p-iterated_frobenius_table.c @@ -11,7 +11,6 @@ #ifdef T -#include "flint.h" #include "templates.h" #include diff --git a/src/fq_poly_templates/profile/p-mullow.c b/src/fq_poly_templates/profile/p-mullow.c index 299ede8737..d5259c2541 100644 --- a/src/fq_poly_templates/profile/p-mullow.c +++ b/src/fq_poly_templates/profile/p-mullow.c @@ -11,7 +11,6 @@ #ifdef T -#include "flint.h" #include "templates.h" #include "profiler.h" diff --git a/src/fq_poly_templates/profile/p-sqr.c b/src/fq_poly_templates/profile/p-sqr.c index 2908907409..26f4200939 100644 --- a/src/fq_poly_templates/profile/p-sqr.c +++ b/src/fq_poly_templates/profile/p-sqr.c @@ -11,7 +11,6 @@ #ifdef T -#include "flint.h" #include "templates.h" #include "profiler.h" diff --git a/src/fq_zech_poly/inlines.c b/src/fq_zech_poly/inlines.c index 47faf044b4..a1d237a442 100644 --- a/src/fq_zech_poly/inlines.c +++ b/src/fq_zech_poly/inlines.c @@ -11,5 +11,4 @@ #define FQ_ZECH_POLY_INLINES_C -#include "flint.h" #include "fq_zech_poly.h" diff --git a/src/fq_zech_poly/profile/p-factor_kaltofen_shoup_vs_fq_nmod_poly.c b/src/fq_zech_poly/profile/p-factor_kaltofen_shoup_vs_fq_nmod_poly.c index b9652ff64e..a011e7d8b2 100644 --- a/src/fq_zech_poly/profile/p-factor_kaltofen_shoup_vs_fq_nmod_poly.c +++ b/src/fq_zech_poly/profile/p-factor_kaltofen_shoup_vs_fq_nmod_poly.c @@ -11,7 +11,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "ulong_extras.h" #include "profiler.h" diff --git a/src/fq_zech_poly/profile/p-factor_vs_fq_nmod.c b/src/fq_zech_poly/profile/p-factor_vs_fq_nmod.c index 0c1ff4c9a9..1b6b5c662c 100644 --- a/src/fq_zech_poly/profile/p-factor_vs_fq_nmod.c +++ b/src/fq_zech_poly/profile/p-factor_vs_fq_nmod.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fq_zech.h" #include "fq_zech_poly.h" diff --git a/src/fq_zech_poly/profile/p-factor_xnpxp1.c b/src/fq_zech_poly/profile/p-factor_xnpxp1.c index 623f4fdda8..41d3dc2286 100644 --- a/src/fq_zech_poly/profile/p-factor_xnpxp1.c +++ b/src/fq_zech_poly/profile/p-factor_xnpxp1.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fq_zech.h" #include "fq_zech_poly.h" diff --git a/src/fq_zech_poly/profile/p-is_irreducible.c b/src/fq_zech_poly/profile/p-is_irreducible.c index 139aba5246..feba82f8b9 100644 --- a/src/fq_zech_poly/profile/p-is_irreducible.c +++ b/src/fq_zech_poly/profile/p-is_irreducible.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "fmpz.h" #include "fq_zech.h" #include "fq_zech_poly.h" diff --git a/src/fq_zech_poly_factor/inlines.c b/src/fq_zech_poly_factor/inlines.c index c390eeb34a..4550f12971 100644 --- a/src/fq_zech_poly_factor/inlines.c +++ b/src/fq_zech_poly_factor/inlines.c @@ -11,7 +11,6 @@ #define FQ_ZECH_POLY_FACTOR_INLINES_C -#include "flint.h" #include "ulong_extras.h" #include "fq_zech.h" #include "fq_zech_poly.h" diff --git a/src/gmpcompat-longlong.h.in b/src/gmpcompat-longlong.h.in index 7eb489a172..1a3524fb8f 100644 --- a/src/gmpcompat-longlong.h.in +++ b/src/gmpcompat-longlong.h.in @@ -15,11 +15,6 @@ #include #include "longlong.h" -#define FLINT_MPZ_REALLOC(z, len) \ - ((len) > ((z)->_mp_alloc) \ - ? (mp_ptr) _mpz_realloc(z, len) \ - : ((z)->_mp_d)) - static inline void flint_mpz_add_uiui(mpz_ptr a, mpz_srcptr b, ulong c1, ulong c0) { @@ -110,7 +105,7 @@ void flint_mpz_set_si(mpz_ptr r, slong s) (in older GMP versions, this code is simply never triggered) */ if (r->_mp_alloc == 0) { - r->_mp_d = (mp_ptr) flint_malloc(sizeof(mp_limb_t)); + r->_mp_d = (mp_ptr) flint_malloc(2 * sizeof(mp_limb_t)); r->_mp_alloc = 1; } @@ -130,7 +125,7 @@ void flint_mpz_set_ui(mpz_ptr r, ulong u) (in older GMP versions, this code is simply never triggered) */ if (r->_mp_alloc == 0) { - r->_mp_d = (mp_ptr) flint_malloc(sizeof(mp_limb_t)); + r->_mp_d = (mp_ptr) flint_malloc(2 * sizeof(mp_limb_t)); r->_mp_alloc = 1; } @@ -141,7 +136,7 @@ void flint_mpz_set_ui(mpz_ptr r, ulong u) static inline void flint_mpz_init_set_si(mpz_ptr r, slong s) { - r->_mp_d = (mp_ptr) flint_malloc(sizeof(mp_limb_t)); + r->_mp_d = (mp_ptr) flint_malloc(2 * sizeof(mp_limb_t)); r->_mp_alloc = 1; if (s < 0) { @@ -156,7 +151,7 @@ void flint_mpz_init_set_si(mpz_ptr r, slong s) static inline void flint_mpz_init_set_ui(mpz_ptr r, ulong u) { - r->_mp_d = (mp_ptr) flint_malloc(sizeof(mp_limb_t)); + r->_mp_d = (mp_ptr) flint_malloc(2 * sizeof(mp_limb_t)); r->_mp_alloc = 1; r->_mp_d[0] = u; diff --git a/src/gmpcompat.h.in b/src/gmpcompat.h.in index 2973ee9f3d..215685fc36 100644 --- a/src/gmpcompat.h.in +++ b/src/gmpcompat.h.in @@ -15,11 +15,6 @@ #include #include "longlong.h" -#define FLINT_MPZ_REALLOC(z, len) \ - ((len) > ((z)->_mp_alloc) \ - ? (mp_ptr) _mpz_realloc(z, len) \ - : ((z)->_mp_d)) - static inline void flint_mpz_add_uiui(mpz_ptr a, mpz_srcptr b, ulong c1, ulong c0) { diff --git a/src/gr/fmpz.c b/src/gr/fmpz.c index 744e6ba5a7..0046abfafa 100644 --- a/src/gr/fmpz.c +++ b/src/gr/fmpz.c @@ -10,6 +10,7 @@ */ #include +#include #include "fexpr.h" #include "qqbar.h" #include "fmpz_factor.h" diff --git a/src/gr_generic/generic_pow.c b/src/gr_generic/generic_pow.c index d2158962f4..9f50c8f6d2 100644 --- a/src/gr_generic/generic_pow.c +++ b/src/gr_generic/generic_pow.c @@ -10,6 +10,7 @@ (at your option) any later version. See . */ +#include #include "fmpz.h" #include "gr.h" #include "gr_generic.h" diff --git a/src/gr_poly/test/t-nth_derivative.c b/src/gr_poly/test/t-nth_derivative.c index 4ae133d69b..c590e4589a 100644 --- a/src/gr_poly/test/t-nth_derivative.c +++ b/src/gr_poly/test/t-nth_derivative.c @@ -10,7 +10,6 @@ */ #include "test_helpers.h" -#include "flint.h" #include "gr_poly.h" #include "ulong_extras.h" diff --git a/src/gr_special/fib.c b/src/gr_special/fib.c index 1de4ed81de..49688b9b46 100644 --- a/src/gr_special/fib.c +++ b/src/gr_special/fib.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpz.h" #include "gr_special.h" diff --git a/src/long_extras/inlines.c b/src/long_extras/inlines.c index 7bc42cb670..8ca98ceb08 100644 --- a/src/long_extras/inlines.c +++ b/src/long_extras/inlines.c @@ -11,5 +11,4 @@ #define LONG_EXTRAS_INLINES_C -#include "flint.h" #include "long_extras.h" diff --git a/src/long_extras/kronecker.c b/src/long_extras/kronecker.c index a5adf64e57..4d55dd032e 100644 --- a/src/long_extras/kronecker.c +++ b/src/long_extras/kronecker.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "long_extras.h" #include "ulong_extras.h" diff --git a/src/long_extras/randint.c b/src/long_extras/randint.c index 95121c603a..2b83b9dc5c 100644 --- a/src/long_extras/randint.c +++ b/src/long_extras/randint.c @@ -12,7 +12,6 @@ #include -#include "flint.h" #include "ulong_extras.h" #include "long_extras.h" diff --git a/src/long_extras/randtest.c b/src/long_extras/randtest.c index 6aa99f44ea..4a34cc8eef 100644 --- a/src/long_extras/randtest.c +++ b/src/long_extras/randtest.c @@ -11,7 +11,6 @@ #include -#include "flint.h" #include "fmpz.h" #include "ulong_extras.h" #include "long_extras.h" diff --git a/src/long_extras/sizeinbase.c b/src/long_extras/sizeinbase.c index a852bf8628..c8cbe1929c 100644 --- a/src/long_extras/sizeinbase.c +++ b/src/long_extras/sizeinbase.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "long_extras.h" size_t z_sizeinbase(slong n, int b) diff --git a/src/mag/pow_fmpz.c b/src/mag/pow_fmpz.c index 19de88968f..d22137ebe8 100644 --- a/src/mag/pow_fmpz.c +++ b/src/mag/pow_fmpz.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "mag.h" void diff --git a/src/mpfr_mat/clear.c b/src/mpfr_mat/clear.c index 0f35570b66..1d5d112959 100644 --- a/src/mpfr_mat/clear.c +++ b/src/mpfr_mat/clear.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "mpfr_mat.h" void diff --git a/src/mpfr_mat/equal.c b/src/mpfr_mat/equal.c index 52b61ff3f2..5063909f56 100644 --- a/src/mpfr_mat/equal.c +++ b/src/mpfr_mat/equal.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpfr_vec.h" #include "mpfr_mat.h" diff --git a/src/mpfr_mat/randtest.c b/src/mpfr_mat/randtest.c index fa40c1317b..f91bbecb0c 100644 --- a/src/mpfr_mat/randtest.c +++ b/src/mpfr_mat/randtest.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpfr_mat.h" void diff --git a/src/mpfr_mat/set.c b/src/mpfr_mat/set.c index b112638fca..bc409e7259 100644 --- a/src/mpfr_mat/set.c +++ b/src/mpfr_mat/set.c @@ -11,7 +11,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpfr_vec.h" #include "mpfr_mat.h" diff --git a/src/mpfr_mat/zero.c b/src/mpfr_mat/zero.c index 59cc22dd79..f0b88ad2c0 100644 --- a/src/mpfr_mat/zero.c +++ b/src/mpfr_mat/zero.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpfr_vec.h" #include "mpfr_mat.h" diff --git a/src/mpfr_vec/clear.c b/src/mpfr_vec/clear.c index 3aeb473b17..4d968eb510 100644 --- a/src/mpfr_vec/clear.c +++ b/src/mpfr_vec/clear.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "mpfr_vec.h" void diff --git a/src/mpfr_vec/equal.c b/src/mpfr_vec/equal.c index 01f7f9bdd5..4c82222eb0 100644 --- a/src/mpfr_vec/equal.c +++ b/src/mpfr_vec/equal.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpfr_vec.h" int diff --git a/src/mpfr_vec/init.c b/src/mpfr_vec/init.c index 0037197885..18fb317706 100644 --- a/src/mpfr_vec/init.c +++ b/src/mpfr_vec/init.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "mpfr_vec.h" mpfr_ptr diff --git a/src/mpfr_vec/set.c b/src/mpfr_vec/set.c index 37313dd0f1..9cd5d0b70c 100644 --- a/src/mpfr_vec/set.c +++ b/src/mpfr_vec/set.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "mpfr_vec.h" void diff --git a/src/mpfr_vec/zero.c b/src/mpfr_vec/zero.c index 8118666098..e256ddeda0 100644 --- a/src/mpfr_vec/zero.c +++ b/src/mpfr_vec/zero.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "mpfr_vec.h" void diff --git a/src/mpn_extras/debug.c b/src/mpn_extras/debug.c index f67193cb33..8d022eeab8 100644 --- a/src/mpn_extras/debug.c +++ b/src/mpn_extras/debug.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpn_extras.h" diff --git a/src/mpn_extras/divides.c b/src/mpn_extras/divides.c index 7c18ed2eb1..c6623c3bf5 100644 --- a/src/mpn_extras/divides.c +++ b/src/mpn_extras/divides.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "mpn_extras.h" diff --git a/src/mpn_extras/divrem_preinv1.c b/src/mpn_extras/divrem_preinv1.c index 3a7e278f2d..0c18349051 100644 --- a/src/mpn_extras/divrem_preinv1.c +++ b/src/mpn_extras/divrem_preinv1.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpn_extras.h" #if !defined(_MSC_VER) diff --git a/src/mpn_extras/divrem_preinvn.c b/src/mpn_extras/divrem_preinvn.c index db7e5f78df..9d5515d554 100644 --- a/src/mpn_extras/divrem_preinvn.c +++ b/src/mpn_extras/divrem_preinvn.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpn_extras.h" /* diff --git a/src/mpn_extras/factor_trial.c b/src/mpn_extras/factor_trial.c index af073c86bc..88f3a37d92 100644 --- a/src/mpn_extras/factor_trial.c +++ b/src/mpn_extras/factor_trial.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #include "mpn_extras.h" diff --git a/src/mpn_extras/fmms1.c b/src/mpn_extras/fmms1.c index f9a36bd521..9ebb78a347 100644 --- a/src/mpn_extras/fmms1.c +++ b/src/mpn_extras/fmms1.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "mpn_extras.h" diff --git a/src/mpn_extras/gcd_full.c b/src/mpn_extras/gcd_full.c index 38d0e66f6d..fc1c4a2264 100644 --- a/src/mpn_extras/gcd_full.c +++ b/src/mpn_extras/gcd_full.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "mpn_extras.h" diff --git a/src/mpn_extras/get_str.c b/src/mpn_extras/get_str.c index f7f5310a59..1e348ddefa 100644 --- a/src/mpn_extras/get_str.c +++ b/src/mpn_extras/get_str.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "mpn_extras.h" diff --git a/src/mpn_extras/mod_preinvn.c b/src/mpn_extras/mod_preinvn.c index 36780db498..864440f37b 100644 --- a/src/mpn_extras/mod_preinvn.c +++ b/src/mpn_extras/mod_preinvn.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpn_extras.h" /* diff --git a/src/mpn_extras/mulmod_2expp1_basecase.c b/src/mpn_extras/mulmod_2expp1_basecase.c index bc1c11c1e0..0e670d01c9 100644 --- a/src/mpn_extras/mulmod_2expp1_basecase.c +++ b/src/mpn_extras/mulmod_2expp1_basecase.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpn_extras.h" /* ret + (xp,n) = (yp,n)*(zp,n) % 2^b+1 diff --git a/src/mpn_extras/mulmod_preinv1.c b/src/mpn_extras/mulmod_preinv1.c index 54fa340a6e..afca0e5651 100644 --- a/src/mpn_extras/mulmod_preinv1.c +++ b/src/mpn_extras/mulmod_preinv1.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpn_extras.h" #if !defined(_MSC_VER) diff --git a/src/mpn_extras/mulmod_preinvn.c b/src/mpn_extras/mulmod_preinvn.c index 707b94e2a0..be69f5772f 100644 --- a/src/mpn_extras/mulmod_preinvn.c +++ b/src/mpn_extras/mulmod_preinvn.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpn_extras.h" /* diff --git a/src/mpn_extras/preinv1.c b/src/mpn_extras/preinv1.c index eca55211de..29dc8c49ea 100644 --- a/src/mpn_extras/preinv1.c +++ b/src/mpn_extras/preinv1.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpn_extras.h" mp_limb_t flint_mpn_preinv1(mp_limb_t d1, mp_limb_t d2) diff --git a/src/mpn_extras/preinvn.c b/src/mpn_extras/preinvn.c index a30d6dc08e..5173869ea7 100644 --- a/src/mpn_extras/preinvn.c +++ b/src/mpn_extras/preinvn.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpn_extras.h" void flint_mpn_preinvn(mp_ptr dinv, mp_srcptr d, mp_size_t n) diff --git a/src/mpn_extras/profile/p-mul_n.c b/src/mpn_extras/profile/p-mul_n.c index 689605f876..c39627c1ca 100644 --- a/src/mpn_extras/profile/p-mul_n.c +++ b/src/mpn_extras/profile/p-mul_n.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpn_extras.h" #include "profiler.h" diff --git a/src/mpn_extras/profile/p-mulmod_preinvn.c b/src/mpn_extras/profile/p-mulmod_preinvn.c index 1d3e82ad8c..d677bc92eb 100644 --- a/src/mpn_extras/profile/p-mulmod_preinvn.c +++ b/src/mpn_extras/profile/p-mulmod_preinvn.c @@ -11,7 +11,6 @@ #include #include "profiler.h" -#include "flint.h" #include "mpn_extras.h" #include "ulong_extras.h" diff --git a/src/mpn_extras/remove_2exp.c b/src/mpn_extras/remove_2exp.c index 0ebe9b47c5..d6fd1910ce 100644 --- a/src/mpn_extras/remove_2exp.c +++ b/src/mpn_extras/remove_2exp.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpn_extras.h" diff --git a/src/mpn_extras/remove_power.c b/src/mpn_extras/remove_power.c index 5625cd6d63..fff45c0d89 100644 --- a/src/mpn_extras/remove_power.c +++ b/src/mpn_extras/remove_power.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "mpn_extras.h" diff --git a/src/mpoly/get_monomial_var.c b/src/mpoly/get_monomial_var.c index 37865a3469..2c2dd3448b 100644 --- a/src/mpoly/get_monomial_var.c +++ b/src/mpoly/get_monomial_var.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpoly.h" /* this file does not need to change with new orderings */ diff --git a/src/mpoly/monomial_exists.c b/src/mpoly/monomial_exists.c index 3025a7a2ae..c24ebe6731 100644 --- a/src/mpoly/monomial_exists.c +++ b/src/mpoly/monomial_exists.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpoly.h" int mpoly_monomial_exists1(slong * index, const ulong * poly_exps, diff --git a/src/mpoly/pack_monomials_tight.c b/src/mpoly/pack_monomials_tight.c index 45885014b8..8afebe0c5c 100644 --- a/src/mpoly/pack_monomials_tight.c +++ b/src/mpoly/pack_monomials_tight.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpoly.h" void mpoly_pack_monomials_tight(ulong * exp1, const ulong * exp2, diff --git a/src/mpoly/profile/p-test_irreducible.c b/src/mpoly/profile/p-test_irreducible.c index a178984692..7673d5d427 100644 --- a/src/mpoly/profile/p-test_irreducible.c +++ b/src/mpoly/profile/p-test_irreducible.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "mpoly.h" diff --git a/src/mpoly/unpack_monomials_tight.c b/src/mpoly/unpack_monomials_tight.c index 3341f6356f..8bdf07e6d6 100644 --- a/src/mpoly/unpack_monomials_tight.c +++ b/src/mpoly/unpack_monomials_tight.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "mpoly.h" void mpoly_unpack_monomials_tight(ulong * e1, ulong * e2, slong len, diff --git a/src/mpoly/unpack_vec.c b/src/mpoly/unpack_vec.c index 934ba040e1..066acdc93b 100644 --- a/src/mpoly/unpack_vec.c +++ b/src/mpoly/unpack_vec.c @@ -100,10 +100,9 @@ void mpoly_unpack_vec_fmpz(fmpz * exp1, const ulong * exp2, flint_bitcnt_t bits, else { mpz_ptr mpz = _fmpz_promote(exp1); - if ((ulong) mpz->_mp_alloc < words_per_field) - mpz_realloc2(mpz, bits); + mp_ptr zp = FLINT_MPZ_REALLOC(mpz, words_per_field); mpz->_mp_size = size; - flint_mpn_copyi(mpz->_mp_d, exp2, size); + flint_mpn_copyi(zp, exp2, size); } exp1++; } diff --git a/src/n_poly/n_fq_pow_cache.c b/src/n_poly/n_fq_pow_cache.c index 196455514d..b698c4dfb3 100644 --- a/src/n_poly/n_fq_pow_cache.c +++ b/src/n_poly/n_fq_pow_cache.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpz.h" #include "fq_nmod.h" #include "n_poly.h" diff --git a/src/n_poly/nmod_pow_cache.c b/src/n_poly/nmod_pow_cache.c index b99f58e8b7..d0555c00ae 100644 --- a/src/n_poly/nmod_pow_cache.c +++ b/src/n_poly/nmod_pow_cache.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "nmod.h" #include "fmpz.h" #include "n_poly.h" diff --git a/src/nf_elem/pow.c b/src/nf_elem/pow.c index 325ede9469..ae7625de90 100644 --- a/src/nf_elem/pow.c +++ b/src/nf_elem/pow.c @@ -12,7 +12,6 @@ #include "nf_elem.h" -#include "flint.h" #include "fmpz.h" #include "fmpz_vec.h" #include "fmpz_poly.h" diff --git a/src/nf_elem/profile/p-mul.c b/src/nf_elem/profile/p-mul.c index a8265e2fc9..916fa3a91a 100644 --- a/src/nf_elem/profile/p-mul.c +++ b/src/nf_elem/profile/p-mul.c @@ -11,7 +11,6 @@ #include #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fmpz_poly.h" diff --git a/src/nf_elem/profile/p-norm.c b/src/nf_elem/profile/p-norm.c index 2f5674ff99..4064dbed81 100644 --- a/src/nf_elem/profile/p-norm.c +++ b/src/nf_elem/profile/p-norm.c @@ -11,7 +11,6 @@ #include #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fmpz_poly.h" diff --git a/src/nf_elem/profile/p-trace.c b/src/nf_elem/profile/p-trace.c index 4b27dccd0d..54dbe0f181 100644 --- a/src/nf_elem/profile/p-trace.c +++ b/src/nf_elem/profile/p-trace.c @@ -11,7 +11,6 @@ #include #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fmpz_poly.h" diff --git a/src/nmod/inlines.c b/src/nmod/inlines.c index eeef961d6a..873324278f 100644 --- a/src/nmod/inlines.c +++ b/src/nmod/inlines.c @@ -11,5 +11,4 @@ #define NMOD_INLINES_C -#include "flint.h" #include "nmod.h" diff --git a/src/nmod_mat/mul.c b/src/nmod_mat/mul.c index 245a536ad5..23ba3a75da 100644 --- a/src/nmod_mat/mul.c +++ b/src/nmod_mat/mul.c @@ -15,8 +15,8 @@ #include "thread_support.h" #if FLINT_USES_BLAS +# include # include "longlong.h" -# include "cblas.h" #endif void diff --git a/src/nmod_mat/mul_blas.c b/src/nmod_mat/mul_blas.c index 15c6b67e64..b55ae896b7 100644 --- a/src/nmod_mat/mul_blas.c +++ b/src/nmod_mat/mul_blas.c @@ -9,15 +9,17 @@ (at your option) any later version. See . */ -#include "nmod_mat.h" +#include "nmod_types.h" #if FLINT_USES_BLAS && FLINT_BITS == 64 +#include +#include #include "thread_pool.h" #include "thread_support.h" #include "nmod.h" +#include "nmod_mat.h" #include "fmpz.h" -#include "cblas.h" /* This code is on the edge of disaster. Blas is used for dot products diff --git a/src/nmod_mat/profile/p-lu.c b/src/nmod_mat/profile/p-lu.c index 4720c1b007..026b219c2a 100644 --- a/src/nmod_mat/profile/p-lu.c +++ b/src/nmod_mat/profile/p-lu.c @@ -12,7 +12,6 @@ */ #include "profiler.h" -#include "flint.h" #include "nmod_mat.h" #include "ulong_extras.h" #include "thread_support.h" diff --git a/src/nmod_mat/profile/p-mul.c b/src/nmod_mat/profile/p-mul.c index 93ca29d1bd..e8a59df0f0 100644 --- a/src/nmod_mat/profile/p-mul.c +++ b/src/nmod_mat/profile/p-mul.c @@ -12,13 +12,12 @@ */ #include "profiler.h" -#include "flint.h" #include "nmod_mat.h" #include "ulong_extras.h" #include "thread_support.h" -#if FLINT_HAVE_BLAS -#include "cblas.h" +#if FLINT_USES_BLAS +# include #endif typedef struct diff --git a/src/nmod_poly/bit_pack.c b/src/nmod_poly/bit_pack.c index c20cf56bb0..89dd8b4348 100644 --- a/src/nmod_poly/bit_pack.c +++ b/src/nmod_poly/bit_pack.c @@ -130,6 +130,7 @@ nmod_poly_bit_pack(fmpz_t f, const nmod_poly_t poly, { slong len, limbs; mpz_ptr mpz; + mp_ptr mp; slong i; len = nmod_poly_length(poly); @@ -141,15 +142,14 @@ nmod_poly_bit_pack(fmpz_t f, const nmod_poly_t poly, } mpz = _fmpz_promote(f); - mpz_realloc2(mpz, len * bit_size); - limbs = (len * bit_size - 1) / FLINT_BITS + 1; + mp = FLINT_MPZ_REALLOC(mpz, limbs); - _nmod_poly_bit_pack(mpz->_mp_d, poly->coeffs, len, bit_size); + _nmod_poly_bit_pack(mp, poly->coeffs, len, bit_size); for (i = limbs - 1; i >= 0; i--) { - if (mpz->_mp_d[i] != 0) + if (mp[i] != 0) break; } diff --git a/src/nmod_poly/profile/p-evaluate_mat.c b/src/nmod_poly/profile/p-evaluate_mat.c index 9c2d3e0f55..13a4832cbe 100644 --- a/src/nmod_poly/profile/p-evaluate_mat.c +++ b/src/nmod_poly/profile/p-evaluate_mat.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/nmod_poly/profile/p-gcd.c b/src/nmod_poly/profile/p-gcd.c index 5942725465..2e2931e782 100644 --- a/src/nmod_poly/profile/p-gcd.c +++ b/src/nmod_poly/profile/p-gcd.c @@ -13,7 +13,6 @@ #include #include -#include "flint.h" #include "nmod_poly.h" /* diff --git a/src/nmod_poly/profile/p-mul.c b/src/nmod_poly/profile/p-mul.c index 820cdb06f1..18ddfd650c 100644 --- a/src/nmod_poly/profile/p-mul.c +++ b/src/nmod_poly/profile/p-mul.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "nmod_poly.h" diff --git a/src/nmod_poly/profile/p-mulmod.c b/src/nmod_poly/profile/p-mulmod.c index 5ffce8e522..d5ae10189b 100644 --- a/src/nmod_poly/profile/p-mulmod.c +++ b/src/nmod_poly/profile/p-mulmod.c @@ -11,7 +11,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "nmod_poly.h" diff --git a/src/nmod_poly/test/t-bit_pack.c b/src/nmod_poly/test/t-bit_pack.c index 5dfd5108c7..d2ac795d6b 100644 --- a/src/nmod_poly/test/t-bit_pack.c +++ b/src/nmod_poly/test/t-bit_pack.c @@ -27,17 +27,15 @@ TEST_FUNCTION_START(nmod_poly_bit_pack, state) nn_ptr mpn; do - { n = n_randtest_not_zero(state); - } while (n == 1); + while (n == 1); bits = 2 * FLINT_BIT_COUNT(n) + n_randint(state, FLINT_BITS); nmod_poly_init(a, n); nmod_poly_init(b, n); do - { nmod_poly_randtest(a, state, n_randint(state, 100)); - } while (a->length == 0); + while (a->length == 0); mpn = flint_malloc(sizeof(ulong) * @@ -50,13 +48,10 @@ TEST_FUNCTION_START(nmod_poly_bit_pack, state) result = (nmod_poly_equal(a, b)); if (!result) - { - flint_printf("FAIL:\n"); - nmod_poly_print(a), flint_printf("\n\n"); - nmod_poly_print(b), flint_printf("\n\n"); - fflush(stdout); - flint_abort(); - } + TEST_FUNCTION_FAIL( + "a = %{nmod_poly}\n" + "b = %{nmod_poly}\n", + a, b); nmod_poly_clear(a); nmod_poly_clear(b); @@ -71,9 +66,8 @@ TEST_FUNCTION_START(nmod_poly_bit_pack, state) ulong n; do - { n = n_randtest_not_zero(state); - } while (n == 1); + while (n == 1); fmpz_init(f); nmod_poly_init(A, n); @@ -87,22 +81,11 @@ TEST_FUNCTION_START(nmod_poly_bit_pack, state) nmod_poly_bit_unpack(B, f, b); if (!nmod_poly_equal(A, B)) - { - mpz_t zz; - flint_printf("FAIL:\n"); - flint_printf("INPUT: "); - nmod_poly_print(A); - flint_printf("\n"); - mpz_init(zz); fmpz_get_mpz(zz, f); - flint_printf("PACKED: "); - mpz_out_str(stdout, 2, zz); - flint_printf("\n"); - flint_printf("OUTPUT: "); - nmod_poly_print(B); - flint_printf("\n\n"); - fflush(stdout); - flint_abort(); - } + TEST_FUNCTION_FAIL( + "Input polynomial: %{nmod_poly}\n" + "Bit-packed integer: %{fmpz}\n" + "Output polynomial: %{nmod_poly}\n", + A, f, B); fmpz_clear(f); nmod_poly_clear(A); diff --git a/src/nmod_poly_factor/profile/p-factor.c b/src/nmod_poly_factor/profile/p-factor.c index 078d5f8ed9..ec3b393d7c 100644 --- a/src/nmod_poly_factor/profile/p-factor.c +++ b/src/nmod_poly_factor/profile/p-factor.c @@ -13,7 +13,6 @@ #include #include -#include "flint.h" #include "ulong_extras.h" #include "nmod_poly.h" #include "nmod_poly_factor.h" diff --git a/src/nmod_poly_factor/profile/p-factorbench.c b/src/nmod_poly_factor/profile/p-factorbench.c index 6de0040382..70a725d576 100644 --- a/src/nmod_poly_factor/profile/p-factorbench.c +++ b/src/nmod_poly_factor/profile/p-factorbench.c @@ -13,7 +13,6 @@ #include #include -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_factor.h" diff --git a/src/nmod_poly_mat/add.c b/src/nmod_poly_mat/add.c index 9dd16d2303..7983c00468 100644 --- a/src/nmod_poly_mat/add.c +++ b/src/nmod_poly_mat/add.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/clear.c b/src/nmod_poly_mat/clear.c index 88378fbdf1..a37a4ea41a 100644 --- a/src/nmod_poly_mat/clear.c +++ b/src/nmod_poly_mat/clear.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/evaluate_nmod.c b/src/nmod_poly_mat/evaluate_nmod.c index c63ebb968f..afd10b9b29 100644 --- a/src/nmod_poly_mat/evaluate_nmod.c +++ b/src/nmod_poly_mat/evaluate_nmod.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_mat.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/fflu.c b/src/nmod_poly_mat/fflu.c index 344fda0f2a..f8d24cac7c 100644 --- a/src/nmod_poly_mat/fflu.c +++ b/src/nmod_poly_mat/fflu.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/find_pivot_any.c b/src/nmod_poly_mat/find_pivot_any.c index 2cb86418b4..b404598b37 100644 --- a/src/nmod_poly_mat/find_pivot_any.c +++ b/src/nmod_poly_mat/find_pivot_any.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/find_pivot_partial.c b/src/nmod_poly_mat/find_pivot_partial.c index 45b846901b..add7fab72f 100644 --- a/src/nmod_poly_mat/find_pivot_partial.c +++ b/src/nmod_poly_mat/find_pivot_partial.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/init_set.c b/src/nmod_poly_mat/init_set.c index 89d2cb7c54..419f2005ba 100644 --- a/src/nmod_poly_mat/init_set.c +++ b/src/nmod_poly_mat/init_set.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/inlines.c b/src/nmod_poly_mat/inlines.c index d49a81b4ef..0acb588c9b 100644 --- a/src/nmod_poly_mat/inlines.c +++ b/src/nmod_poly_mat/inlines.c @@ -11,5 +11,4 @@ #define NMOD_POLY_MAT_INLINES_C -#include "flint.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/inv.c b/src/nmod_poly_mat/inv.c index bf82352658..4e80b2e113 100644 --- a/src/nmod_poly_mat/inv.c +++ b/src/nmod_poly_mat/inv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" #include "perm.h" diff --git a/src/nmod_poly_mat/is_one.c b/src/nmod_poly_mat/is_one.c index 428b3e7a59..1943350643 100644 --- a/src/nmod_poly_mat/is_one.c +++ b/src/nmod_poly_mat/is_one.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/is_zero.c b/src/nmod_poly_mat/is_zero.c index 6ad83df8cb..a6813b4535 100644 --- a/src/nmod_poly_mat/is_zero.c +++ b/src/nmod_poly_mat/is_zero.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/max_length.c b/src/nmod_poly_mat/max_length.c index 96e672774d..31a6cfe169 100644 --- a/src/nmod_poly_mat/max_length.c +++ b/src/nmod_poly_mat/max_length.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/mul_KS.c b/src/nmod_poly_mat/mul_KS.c index b220babd13..9d8d354ca3 100644 --- a/src/nmod_poly_mat/mul_KS.c +++ b/src/nmod_poly_mat/mul_KS.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" #include "fmpz.h" diff --git a/src/nmod_poly_mat/mul_classical.c b/src/nmod_poly_mat/mul_classical.c index 726972981d..e25cf5da93 100644 --- a/src/nmod_poly_mat/mul_classical.c +++ b/src/nmod_poly_mat/mul_classical.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/neg.c b/src/nmod_poly_mat/neg.c index 75df242cf9..6bcf4f1427 100644 --- a/src/nmod_poly_mat/neg.c +++ b/src/nmod_poly_mat/neg.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/nullspace.c b/src/nmod_poly_mat/nullspace.c index b0b9935177..f1eea63ab4 100644 --- a/src/nmod_poly_mat/nullspace.c +++ b/src/nmod_poly_mat/nullspace.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/one.c b/src/nmod_poly_mat/one.c index 0c350824f7..1574b00921 100644 --- a/src/nmod_poly_mat/one.c +++ b/src/nmod_poly_mat/one.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/print.c b/src/nmod_poly_mat/print.c index 052bebe53a..f02515a848 100644 --- a/src/nmod_poly_mat/print.c +++ b/src/nmod_poly_mat/print.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/rank.c b/src/nmod_poly_mat/rank.c index 7ac66da083..c61a84c59e 100644 --- a/src/nmod_poly_mat/rank.c +++ b/src/nmod_poly_mat/rank.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/rref.c b/src/nmod_poly_mat/rref.c index 0d8605b975..b6591e1a85 100644 --- a/src/nmod_poly_mat/rref.c +++ b/src/nmod_poly_mat/rref.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/solve.c b/src/nmod_poly_mat/solve.c index e8f1f35931..202da4105a 100644 --- a/src/nmod_poly_mat/solve.c +++ b/src/nmod_poly_mat/solve.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" #include "perm.h" diff --git a/src/nmod_poly_mat/solve_fflu.c b/src/nmod_poly_mat/solve_fflu.c index 29917fffb4..0f2aed32b2 100644 --- a/src/nmod_poly_mat/solve_fflu.c +++ b/src/nmod_poly_mat/solve_fflu.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" #include "perm.h" diff --git a/src/nmod_poly_mat/solve_fflu_precomp.c b/src/nmod_poly_mat/solve_fflu_precomp.c index 623a10dda2..d8dbb8d1a1 100644 --- a/src/nmod_poly_mat/solve_fflu_precomp.c +++ b/src/nmod_poly_mat/solve_fflu_precomp.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" #include "perm.h" diff --git a/src/nmod_poly_mat/sub.c b/src/nmod_poly_mat/sub.c index 7f7ed375b0..8080bd07f1 100644 --- a/src/nmod_poly_mat/sub.c +++ b/src/nmod_poly_mat/sub.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/trace.c b/src/nmod_poly_mat/trace.c index e0fbc4ee51..0d92b94d3e 100644 --- a/src/nmod_poly_mat/trace.c +++ b/src/nmod_poly_mat/trace.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_poly_mat/zero.c b/src/nmod_poly_mat/zero.c index 54718f3f85..0eefa5be26 100644 --- a/src/nmod_poly_mat/zero.c +++ b/src/nmod_poly_mat/zero.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" diff --git a/src/nmod_vec/profile/p-add_sub_neg.c b/src/nmod_vec/profile/p-add_sub_neg.c index 98408f563a..61ff9bc225 100644 --- a/src/nmod_vec/profile/p-add_sub_neg.c +++ b/src/nmod_vec/profile/p-add_sub_neg.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "nmod.h" #include "nmod_vec.h" diff --git a/src/nmod_vec/profile/p-mul.c b/src/nmod_vec/profile/p-mul.c index 4132a52856..854a173094 100644 --- a/src/nmod_vec/profile/p-mul.c +++ b/src/nmod_vec/profile/p-mul.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "nmod.h" #include "nmod_vec.h" diff --git a/src/nmod_vec/profile/p-reduce.c b/src/nmod_vec/profile/p-reduce.c index 5fd57267cd..617a846dce 100644 --- a/src/nmod_vec/profile/p-reduce.c +++ b/src/nmod_vec/profile/p-reduce.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "nmod.h" #include "nmod_vec.h" diff --git a/src/nmod_vec/profile/p-scalar_addmul.c b/src/nmod_vec/profile/p-scalar_addmul.c index fd61a7a24b..dbf67f923f 100644 --- a/src/nmod_vec/profile/p-scalar_addmul.c +++ b/src/nmod_vec/profile/p-scalar_addmul.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "nmod.h" #include "nmod_vec.h" diff --git a/src/nmod_vec/profile/p-scalar_mul.c b/src/nmod_vec/profile/p-scalar_mul.c index 49d24db385..f6bea5bcbe 100644 --- a/src/nmod_vec/profile/p-scalar_mul.c +++ b/src/nmod_vec/profile/p-scalar_mul.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "nmod.h" #include "nmod_vec.h" diff --git a/src/padic.h b/src/padic.h index 9a7f16ab72..7f8db223eb 100644 --- a/src/padic.h +++ b/src/padic.h @@ -53,9 +53,7 @@ slong padic_get_prec(const padic_t x) /* Context *******************************************************************/ -void padic_ctx_init(padic_ctx_t ctx, const fmpz_t p, slong min, slong max, - enum padic_print_mode mode); - +void padic_ctx_init(padic_ctx_t ctx, const fmpz_t p, slong min, slong max, enum padic_print_mode mode); void padic_ctx_clear(padic_ctx_t ctx); PADIC_INLINE @@ -100,9 +98,7 @@ void padic_ctx_pow_ui(fmpz_t rop, ulong e, const padic_ctx_t ctx) /* Memory management *********************************************************/ void padic_init(padic_t rop); - void padic_init2(padic_t rop, slong N); - void padic_clear(padic_t rop); PADIC_INLINE void _padic_canonicalise(padic_t rop, const padic_ctx_t ctx) @@ -118,42 +114,32 @@ PADIC_INLINE void _padic_canonicalise(padic_t rop, const padic_ctx_t ctx) } void _padic_reduce(padic_t rop, const padic_ctx_t ctx); - void padic_reduce(padic_t rop, const padic_ctx_t ctx); /* 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); +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); /* 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); - void padic_set_fmpz(padic_t rop, const fmpz_t op, const padic_ctx_t ctx); - void padic_set_fmpq(padic_t rop, const fmpq_t op, const padic_ctx_t ctx); - +#ifdef __GMP_H__ void padic_set_mpz(padic_t rop, const mpz_t op, const padic_ctx_t ctx); - void padic_set_mpq(padic_t rop, const mpq_t op, const padic_ctx_t ctx); +#endif +void padic_set(padic_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); - void padic_get_fmpq(fmpq_t rop, const padic_t op, const padic_ctx_t ctx); - +#ifdef __GMP_H__ void padic_get_mpz(mpz_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); +#endif PADIC_INLINE void padic_swap(padic_t op1, padic_t op2) { @@ -174,9 +160,7 @@ PADIC_INLINE void padic_one(padic_t rop) padic_val(rop) = 0; } else - { padic_zero(rop); - } } /* Comparison ****************************************************************/ @@ -203,36 +187,28 @@ 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_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_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_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); - void _padic_inv_clear(padic_inv_t 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); void padic_inv(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); -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); /* Exponential ***************************************************************/ @@ -263,19 +239,15 @@ int padic_log_balanced(padic_t rop, const padic_t op, const padic_ctx_t ctx); /* 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); - void padic_val_fac(fmpz_t rop, const fmpz_t op, const fmpz_t p); /* Input and output **********************************************************/ char * _padic_get_str(char * str, const padic_t op, const fmpz_t p, enum padic_print_mode mode); - char * padic_get_str(char * str, const padic_t op, const padic_ctx_t ctx); #ifdef FLINT_HAVE_FILE diff --git a/src/padic/get_mpq.c b/src/padic/get_mpq.c index 0a0825a69f..c2528ea2aa 100644 --- a/src/padic/get_mpq.c +++ b/src/padic/get_mpq.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpq.h" #include "padic.h" diff --git a/src/padic/get_mpz.c b/src/padic/get_mpz.c index 905cd4618c..7eced86b15 100644 --- a/src/padic/get_mpz.c +++ b/src/padic/get_mpz.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "padic.h" void padic_get_mpz(mpz_t rop, const padic_t op, const padic_ctx_t ctx) diff --git a/src/padic/inlines.c b/src/padic/inlines.c index a106b7f365..6d097aef4b 100644 --- a/src/padic/inlines.c +++ b/src/padic/inlines.c @@ -11,7 +11,6 @@ #define PADIC_INLINES_C -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "fmpz_poly.h" diff --git a/src/padic/log.c b/src/padic/log.c index 413093b0c4..9c54d61c86 100644 --- a/src/padic/log.c +++ b/src/padic/log.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "padic.h" #include "ulong_extras.h" diff --git a/src/padic/log_satoh.c b/src/padic/log_satoh.c index 4f25cea916..235785525a 100644 --- a/src/padic/log_satoh.c +++ b/src/padic/log_satoh.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "fmpz.h" #include "padic.h" #include "ulong_extras.h" diff --git a/src/padic/profile/p-exp_balanced_2.c b/src/padic/profile/p-exp_balanced_2.c index 6897fcbd73..949a1336eb 100644 --- a/src/padic/profile/p-exp_balanced_2.c +++ b/src/padic/profile/p-exp_balanced_2.c @@ -20,7 +20,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "padic.h" diff --git a/src/padic/profile/p-exp_balanced_p.c b/src/padic/profile/p-exp_balanced_p.c index 5cdfd358a4..03fc023d78 100644 --- a/src/padic/profile/p-exp_balanced_p.c +++ b/src/padic/profile/p-exp_balanced_p.c @@ -20,7 +20,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "padic.h" diff --git a/src/padic/profile/p-exp_rectangular.c b/src/padic/profile/p-exp_rectangular.c index d1e5fec605..f8e19707ad 100644 --- a/src/padic/profile/p-exp_rectangular.c +++ b/src/padic/profile/p-exp_rectangular.c @@ -20,7 +20,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "padic.h" diff --git a/src/padic/profile/p-inv.c b/src/padic/profile/p-inv.c index cd1f2b1e2e..63760017d6 100644 --- a/src/padic/profile/p-inv.c +++ b/src/padic/profile/p-inv.c @@ -20,7 +20,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "padic.h" diff --git a/src/padic/profile/p-log_balanced.c b/src/padic/profile/p-log_balanced.c index 1416b06933..6a6db1647c 100644 --- a/src/padic/profile/p-log_balanced.c +++ b/src/padic/profile/p-log_balanced.c @@ -20,7 +20,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "padic.h" diff --git a/src/padic/profile/p-log_rectangular.c b/src/padic/profile/p-log_rectangular.c index ac39aefacf..572fc81e78 100644 --- a/src/padic/profile/p-log_rectangular.c +++ b/src/padic/profile/p-log_rectangular.c @@ -20,7 +20,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "padic.h" diff --git a/src/padic/profile/p-mul.c b/src/padic/profile/p-mul.c index 7d812994f9..5b66c975fe 100644 --- a/src/padic/profile/p-mul.c +++ b/src/padic/profile/p-mul.c @@ -20,7 +20,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "padic.h" diff --git a/src/padic/profile/p-sqrt.c b/src/padic/profile/p-sqrt.c index 37bceee4df..3888c668e3 100644 --- a/src/padic/profile/p-sqrt.c +++ b/src/padic/profile/p-sqrt.c @@ -20,7 +20,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "padic.h" diff --git a/src/padic/profile/p-teichmuller.c b/src/padic/profile/p-teichmuller.c index 588d5d7350..5699bd82a3 100644 --- a/src/padic/profile/p-teichmuller.c +++ b/src/padic/profile/p-teichmuller.c @@ -20,7 +20,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "padic.h" diff --git a/src/padic/set_mpq.c b/src/padic/set_mpq.c index 5c329d6450..b9d04db67e 100644 --- a/src/padic/set_mpq.c +++ b/src/padic/set_mpq.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpq.h" #include "padic.h" diff --git a/src/padic/set_mpz.c b/src/padic/set_mpz.c index 427660cd7d..be3c3f81da 100644 --- a/src/padic/set_mpz.c +++ b/src/padic/set_mpz.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "padic.h" void padic_set_mpz(padic_t rop, const mpz_t op, const padic_ctx_t ctx) diff --git a/src/padic/test/main.c b/src/padic/test/main.c index 59560c2f8a..f473a74895 100644 --- a/src/padic/test/main.c +++ b/src/padic/test/main.c @@ -9,6 +9,9 @@ (at your option) any later version. See . */ +#include +#include + /* Include functions *********************************************************/ #include "t-add.c" diff --git a/src/padic_poly/fit_length.c b/src/padic_poly/fit_length.c index c69bb89966..42800b8a44 100644 --- a/src/padic_poly/fit_length.c +++ b/src/padic_poly/fit_length.c @@ -10,7 +10,7 @@ (at your option) any later version. See . */ - +#include #include "fmpz.h" #include "padic_poly.h" diff --git a/src/padic_poly/inlines.c b/src/padic_poly/inlines.c index b47cf9fdc5..560a91c0d0 100644 --- a/src/padic_poly/inlines.c +++ b/src/padic_poly/inlines.c @@ -11,5 +11,4 @@ #define PADIC_POLY_INLINES_C -#include "flint.h" #include "padic_poly.h" diff --git a/src/padic_poly/inv_series.c b/src/padic_poly/inv_series.c index 5058696b56..2343543a5c 100644 --- a/src/padic_poly/inv_series.c +++ b/src/padic_poly/inv_series.c @@ -10,6 +10,7 @@ (at your option) any later version. See . */ +#include #include "fmpz_vec.h" #include "fmpz_poly.h" #include "padic.h" diff --git a/src/padic_poly/realloc.c b/src/padic_poly/realloc.c index 00ac62aa62..f0481bc0fb 100644 --- a/src/padic_poly/realloc.c +++ b/src/padic_poly/realloc.c @@ -10,7 +10,7 @@ (at your option) any later version. See . */ -#include "flint.h" +#include #include "fmpz.h" #include "padic_poly.h" diff --git a/src/padic_poly/set_coeff_padic.c b/src/padic_poly/set_coeff_padic.c index f161efeff7..8ee1224d4f 100644 --- a/src/padic_poly/set_coeff_padic.c +++ b/src/padic_poly/set_coeff_padic.c @@ -9,6 +9,7 @@ (at your option) any later version. See . */ +#include #include "fmpz_vec.h" #include "padic.h" #include "padic_poly.h" diff --git a/src/perm/inlines.c b/src/perm/inlines.c index 844967dfb5..0baf84bb74 100644 --- a/src/perm/inlines.c +++ b/src/perm/inlines.c @@ -11,5 +11,4 @@ #define PERM_INLINES_C -#include "flint.h" #include "perm.h" diff --git a/src/perm/randtest.c b/src/perm/randtest.c index bd9b8c6313..5e00520fb5 100644 --- a/src/perm/randtest.c +++ b/src/perm/randtest.c @@ -11,7 +11,6 @@ */ #include "perm.h" -#include "flint.h" #include "ulong_extras.h" int _perm_randtest(slong *vec, slong n, flint_rand_t state) diff --git a/src/profile/p-invert_limb.c b/src/profile/p-invert_limb.c index 4098c97933..c72d2eef0e 100644 --- a/src/profile/p-invert_limb.c +++ b/src/profile/p-invert_limb.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" typedef struct diff --git a/src/profile/p-udiv_qrnnd.c b/src/profile/p-udiv_qrnnd.c index 8779855c85..a2ac9c2e02 100644 --- a/src/profile/p-udiv_qrnnd.c +++ b/src/profile/p-udiv_qrnnd.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" void sample(void * arg, ulong count) diff --git a/src/profile/p-udiv_qrnnd_preinv.c b/src/profile/p-udiv_qrnnd_preinv.c index 7872209107..e08b4f370c 100644 --- a/src/profile/p-udiv_qrnnd_preinv.c +++ b/src/profile/p-udiv_qrnnd_preinv.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" void sample(void * arg, ulong count) diff --git a/src/qadic/inlines.c b/src/qadic/inlines.c index f706dbb127..5b1e4385ce 100644 --- a/src/qadic/inlines.c +++ b/src/qadic/inlines.c @@ -11,5 +11,4 @@ #define QADIC_INLINES_C -#include "flint.h" #include "qadic.h" diff --git a/src/qadic/profile/p-exp_balanced.c b/src/qadic/profile/p-exp_balanced.c index 656fcc75d8..f6256aea0c 100644 --- a/src/qadic/profile/p-exp_balanced.c +++ b/src/qadic/profile/p-exp_balanced.c @@ -22,7 +22,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "qadic.h" diff --git a/src/qadic/profile/p-exp_rectangular.c b/src/qadic/profile/p-exp_rectangular.c index c6e47c356f..c0a4d06d30 100644 --- a/src/qadic/profile/p-exp_rectangular.c +++ b/src/qadic/profile/p-exp_rectangular.c @@ -22,7 +22,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "qadic.h" diff --git a/src/qadic/profile/p-frobenius.c b/src/qadic/profile/p-frobenius.c index bf569f3e34..379702e8fb 100644 --- a/src/qadic/profile/p-frobenius.c +++ b/src/qadic/profile/p-frobenius.c @@ -22,7 +22,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "qadic.h" diff --git a/src/qadic/profile/p-inv.c b/src/qadic/profile/p-inv.c index 51f18e1969..6c48981f22 100644 --- a/src/qadic/profile/p-inv.c +++ b/src/qadic/profile/p-inv.c @@ -22,7 +22,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "qadic.h" diff --git a/src/qadic/profile/p-log_balanced.c b/src/qadic/profile/p-log_balanced.c index 927fe90a1f..39550124e4 100644 --- a/src/qadic/profile/p-log_balanced.c +++ b/src/qadic/profile/p-log_balanced.c @@ -22,7 +22,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "qadic.h" diff --git a/src/qadic/profile/p-log_rectangular.c b/src/qadic/profile/p-log_rectangular.c index a8d7e2d2b4..2e30686ff8 100644 --- a/src/qadic/profile/p-log_rectangular.c +++ b/src/qadic/profile/p-log_rectangular.c @@ -22,7 +22,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "qadic.h" diff --git a/src/qadic/profile/p-mul.c b/src/qadic/profile/p-mul.c index 349ed07fb1..67e0880d67 100644 --- a/src/qadic/profile/p-mul.c +++ b/src/qadic/profile/p-mul.c @@ -23,7 +23,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "qadic.h" diff --git a/src/qadic/profile/p-norm_analytic.c b/src/qadic/profile/p-norm_analytic.c index a268d7ac40..9ef1186a72 100644 --- a/src/qadic/profile/p-norm_analytic.c +++ b/src/qadic/profile/p-norm_analytic.c @@ -22,7 +22,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "qadic.h" diff --git a/src/qadic/profile/p-norm_resultant.c b/src/qadic/profile/p-norm_resultant.c index 9d4905b24e..224d76ccb7 100644 --- a/src/qadic/profile/p-norm_resultant.c +++ b/src/qadic/profile/p-norm_resultant.c @@ -22,7 +22,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "qadic.h" diff --git a/src/qadic/profile/p-sqrt.c b/src/qadic/profile/p-sqrt.c index 47d87e9ba8..2d1081195b 100644 --- a/src/qadic/profile/p-sqrt.c +++ b/src/qadic/profile/p-sqrt.c @@ -22,7 +22,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "qadic.h" diff --git a/src/qadic/profile/p-teichmuller.c b/src/qadic/profile/p-teichmuller.c index 7f9b849de5..f6eee2ff35 100644 --- a/src/qadic/profile/p-teichmuller.c +++ b/src/qadic/profile/p-teichmuller.c @@ -22,7 +22,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "qadic.h" diff --git a/src/qadic/profile/p-trace.c b/src/qadic/profile/p-trace.c index ebcdb22a6d..c82ea04078 100644 --- a/src/qadic/profile/p-trace.c +++ b/src/qadic/profile/p-trace.c @@ -22,7 +22,6 @@ #include #include -#include "flint.h" #include "fmpz.h" #include "qadic.h" diff --git a/src/qfb/exponent.c b/src/qfb/exponent.c index 733914ab45..93d94601a5 100644 --- a/src/qfb/exponent.c +++ b/src/qfb/exponent.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "qfb.h" diff --git a/src/qfb/is_reduced.c b/src/qfb/is_reduced.c index bdc0f6b79c..e823ad6677 100644 --- a/src/qfb/is_reduced.c +++ b/src/qfb/is_reduced.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "qfb.h" diff --git a/src/qfb/nudupl.c b/src/qfb/nudupl.c index 00205cde81..f85e738485 100644 --- a/src/qfb/nudupl.c +++ b/src/qfb/nudupl.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "qfb.h" diff --git a/src/qfb/pow.c b/src/qfb/pow.c index 9d71933078..9b4a44486e 100644 --- a/src/qfb/pow.c +++ b/src/qfb/pow.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "qfb.h" diff --git a/src/qfb/prime_form.c b/src/qfb/prime_form.c index 872493c72a..49e2d3a7ee 100644 --- a/src/qfb/prime_form.c +++ b/src/qfb/prime_form.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "qfb.h" diff --git a/src/qfb/profile/p-exponent_element_grh.c b/src/qfb/profile/p-exponent_element_grh.c index 8ccf6678e4..1f01c07c36 100644 --- a/src/qfb/profile/p-exponent_element_grh.c +++ b/src/qfb/profile/p-exponent_element_grh.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "qfb.h" diff --git a/src/qfb/profile/p-factor_qfb.c b/src/qfb/profile/p-factor_qfb.c index 51cc0ae67f..7b362a0c01 100644 --- a/src/qfb/profile/p-factor_qfb.c +++ b/src/qfb/profile/p-factor_qfb.c @@ -11,7 +11,6 @@ #include #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "qfb.h" diff --git a/src/qfb/profile/p-factor_qfb_simple.c b/src/qfb/profile/p-factor_qfb_simple.c index d56e1bd7b4..4f2e6694bf 100644 --- a/src/qfb/profile/p-factor_qfb_simple.c +++ b/src/qfb/profile/p-factor_qfb_simple.c @@ -11,7 +11,6 @@ #include #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "qfb.h" diff --git a/src/qsieve/large_prime_variant.c b/src/qsieve/large_prime_variant.c index 94fb4d7627..767e83917a 100644 --- a/src/qsieve/large_prime_variant.c +++ b/src/qsieve/large_prime_variant.c @@ -13,15 +13,11 @@ #include #include #include +#include +#include #include "fmpz.h" #include "qsieve.h" -#ifdef __GNUC__ -# define memset __builtin_memset -#else -# include -#endif - #define HASH_MULT (2654435761U) /* hash function, taken from 'msieve' */ #define HASH(a) ((ulong)((((unsigned int) a) * HASH_MULT) >> (12))) @@ -299,13 +295,12 @@ relation_t qsieve_parse_relation(qs_t qs_inf) else { mpz_ptr mY = _fmpz_new_mpz(); + mp_ptr ptr; mY->_mp_size = Ysz; + ptr = FLINT_MPZ_REALLOC(mY, FLINT_ABS(Ysz)); - if (mY->_mp_alloc < FLINT_ABS(Ysz)) - _mpz_realloc(mY, FLINT_ABS(Ysz)); - - fread(mY->_mp_d, sizeof(ulong), FLINT_ABS(Ysz), (FILE *) qs_inf->siqs); + fread(ptr, sizeof(ulong), FLINT_ABS(Ysz), (FILE *) qs_inf->siqs); *rel.Y = PTR_TO_COEFF(mY); } diff --git a/src/qsieve/test/t-primes_init.c b/src/qsieve/test/t-primes_init.c index 3761302be6..cd7c1e94f3 100644 --- a/src/qsieve/test/t-primes_init.c +++ b/src/qsieve/test/t-primes_init.c @@ -10,7 +10,6 @@ */ #include "test_helpers.h" -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #include "qsieve.h" diff --git a/src/test/t-memory_manager.c b/src/test/t-memory_manager.c index dcd01627c5..e811aadb86 100644 --- a/src/test/t-memory_manager.c +++ b/src/test/t-memory_manager.c @@ -12,7 +12,6 @@ #include #include #include "test_helpers.h" -#include "flint.h" TEST_FUNCTION_START(memory_manager, state) { diff --git a/src/thread_support/thread_support.c b/src/thread_support/thread_support.c index 0ac7b41ee6..c50f0879b5 100644 --- a/src/thread_support/thread_support.c +++ b/src/thread_support/thread_support.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "thread_pool.h" #include "thread_support.h" diff --git a/src/ulong_extras/CRT.c b/src/ulong_extras/CRT.c index fbbb3e9fed..2636d34a83 100644 --- a/src/ulong_extras/CRT.c +++ b/src/ulong_extras/CRT.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/ulong_extras/discrete_log_bsgs.c b/src/ulong_extras/discrete_log_bsgs.c index 085bc24697..5d8f178ed0 100644 --- a/src/ulong_extras/discrete_log_bsgs.c +++ b/src/ulong_extras/discrete_log_bsgs.c @@ -13,7 +13,6 @@ #include #include -#include "flint.h" #include "ulong_extras.h" typedef struct apow { diff --git a/src/ulong_extras/div2_preinv.c b/src/ulong_extras/div2_preinv.c index aa749d834f..70a7690144 100644 --- a/src/ulong_extras/div2_preinv.c +++ b/src/ulong_extras/div2_preinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" /* diff --git a/src/ulong_extras/divides.c b/src/ulong_extras/divides.c index 8d770f952c..3eda5b5922 100644 --- a/src/ulong_extras/divides.c +++ b/src/ulong_extras/divides.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" int n_divides(ulong * q, ulong n, ulong p) diff --git a/src/ulong_extras/divrem2_precomp.c b/src/ulong_extras/divrem2_precomp.c index a2d3444062..fe3e34004f 100644 --- a/src/ulong_extras/divrem2_precomp.c +++ b/src/ulong_extras/divrem2_precomp.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong diff --git a/src/ulong_extras/divrem2_preinv.c b/src/ulong_extras/divrem2_preinv.c index 248c7c0ec6..ee7c865e5b 100644 --- a/src/ulong_extras/divrem2_preinv.c +++ b/src/ulong_extras/divrem2_preinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" /* diff --git a/src/ulong_extras/euler_phi.c b/src/ulong_extras/euler_phi.c index bce0e9896e..2b82843ba9 100644 --- a/src/ulong_extras/euler_phi.c +++ b/src/ulong_extras/euler_phi.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong n_euler_phi(ulong n) diff --git a/src/ulong_extras/factor.c b/src/ulong_extras/factor.c index 95b8767516..e22e3f958d 100644 --- a/src/ulong_extras/factor.c +++ b/src/ulong_extras/factor.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" static int is_prime(ulong n, int proved) diff --git a/src/ulong_extras/factor_lehman.c b/src/ulong_extras/factor_lehman.c index bf5646e2ed..676f349c7a 100644 --- a/src/ulong_extras/factor_lehman.c +++ b/src/ulong_extras/factor_lehman.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" ulong n_factor_lehman(ulong n) diff --git a/src/ulong_extras/factor_one_line.c b/src/ulong_extras/factor_one_line.c index 79c0f91786..f552badcbb 100644 --- a/src/ulong_extras/factor_one_line.c +++ b/src/ulong_extras/factor_one_line.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #define FLINT_ONE_LINE_MULTIPLIER 480 diff --git a/src/ulong_extras/factor_partial.c b/src/ulong_extras/factor_partial.c index 39a9a9c906..fef4b0faa4 100644 --- a/src/ulong_extras/factor_partial.c +++ b/src/ulong_extras/factor_partial.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" int is_prime2(ulong n, int proved) diff --git a/src/ulong_extras/factor_pollard_brent.c b/src/ulong_extras/factor_pollard_brent.c index 4ee44bae8d..5f2a787dc7 100644 --- a/src/ulong_extras/factor_pollard_brent.c +++ b/src/ulong_extras/factor_pollard_brent.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong diff --git a/src/ulong_extras/factor_power235.c b/src/ulong_extras/factor_power235.c index 9f1aa22034..a9449c6e9b 100644 --- a/src/ulong_extras/factor_power235.c +++ b/src/ulong_extras/factor_power235.c @@ -11,7 +11,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" ulong n_factor_power235(ulong * exp, ulong n) diff --git a/src/ulong_extras/factorial_fast_mod2_preinv.c b/src/ulong_extras/factorial_fast_mod2_preinv.c index 8c0650e59b..c6097a78fb 100644 --- a/src/ulong_extras/factorial_fast_mod2_preinv.c +++ b/src/ulong_extras/factorial_fast_mod2_preinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #include "nmod.h" #include "nmod_vec.h" diff --git a/src/ulong_extras/factorial_mod2_preinv.c b/src/ulong_extras/factorial_mod2_preinv.c index 0b8e9d3a53..b19e608fd2 100644 --- a/src/ulong_extras/factorial_mod2_preinv.c +++ b/src/ulong_extras/factorial_mod2_preinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" diff --git a/src/ulong_extras/flog.c b/src/ulong_extras/flog.c index 3f9b09b6c7..eb02955425 100644 --- a/src/ulong_extras/flog.c +++ b/src/ulong_extras/flog.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong n_flog(ulong n, ulong b) diff --git a/src/ulong_extras/gcdinv.c b/src/ulong_extras/gcdinv.c index e145188bf0..0ae711ca86 100644 --- a/src/ulong_extras/gcdinv.c +++ b/src/ulong_extras/gcdinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong diff --git a/src/ulong_extras/inlines.c b/src/ulong_extras/inlines.c index 374e0a50ac..967e3c73ca 100644 --- a/src/ulong_extras/inlines.c +++ b/src/ulong_extras/inlines.c @@ -11,5 +11,4 @@ #define ULONG_EXTRAS_INLINES_C -#include "flint.h" #include "ulong_extras.h" diff --git a/src/ulong_extras/is_perfect_power.c b/src/ulong_extras/is_perfect_power.c index 3ae46b83c1..5a71ab3179 100644 --- a/src/ulong_extras/is_perfect_power.c +++ b/src/ulong_extras/is_perfect_power.c @@ -11,7 +11,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" int n_is_perfect_power(ulong * root, ulong n) diff --git a/src/ulong_extras/is_perfect_power235.c b/src/ulong_extras/is_perfect_power235.c index 2c9d4a5991..3a9af8a4b3 100644 --- a/src/ulong_extras/is_perfect_power235.c +++ b/src/ulong_extras/is_perfect_power235.c @@ -11,7 +11,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" int n_is_perfect_power235(ulong n) diff --git a/src/ulong_extras/is_square.c b/src/ulong_extras/is_square.c index 0b0444ca4b..8ffe61964e 100644 --- a/src/ulong_extras/is_square.c +++ b/src/ulong_extras/is_square.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" int mod64[64] = {1,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0, diff --git a/src/ulong_extras/is_squarefree.c b/src/ulong_extras/is_squarefree.c index f4a4e0a59a..5fc665c06e 100644 --- a/src/ulong_extras/is_squarefree.c +++ b/src/ulong_extras/is_squarefree.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" int n_is_squarefree(ulong n) diff --git a/src/ulong_extras/is_strong_probabprime_precomp.c b/src/ulong_extras/is_strong_probabprime_precomp.c index ea7b6001fa..ee94f8c57c 100644 --- a/src/ulong_extras/is_strong_probabprime_precomp.c +++ b/src/ulong_extras/is_strong_probabprime_precomp.c @@ -11,7 +11,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" int diff --git a/src/ulong_extras/jacobi.c b/src/ulong_extras/jacobi.c index 976c635c30..ae5774d313 100644 --- a/src/ulong_extras/jacobi.c +++ b/src/ulong_extras/jacobi.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" /* return (x|y)*(-1)^tstbit(r,1) */ diff --git a/src/ulong_extras/ll_mod_preinv.c b/src/ulong_extras/ll_mod_preinv.c index b903552af7..5f27956781 100644 --- a/src/ulong_extras/ll_mod_preinv.c +++ b/src/ulong_extras/ll_mod_preinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" /* diff --git a/src/ulong_extras/lll_mod_preinv.c b/src/ulong_extras/lll_mod_preinv.c index bd69204990..460daf1930 100644 --- a/src/ulong_extras/lll_mod_preinv.c +++ b/src/ulong_extras/lll_mod_preinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" /* diff --git a/src/ulong_extras/mod2_precomp.c b/src/ulong_extras/mod2_precomp.c index f07dca26b4..2470d98bf0 100644 --- a/src/ulong_extras/mod2_precomp.c +++ b/src/ulong_extras/mod2_precomp.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong diff --git a/src/ulong_extras/mod2_preinv.c b/src/ulong_extras/mod2_preinv.c index 21f24f3bbd..fb03b06b98 100644 --- a/src/ulong_extras/mod2_preinv.c +++ b/src/ulong_extras/mod2_preinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" /* diff --git a/src/ulong_extras/mod_precomp.c b/src/ulong_extras/mod_precomp.c index 6d80277d35..a496044e88 100644 --- a/src/ulong_extras/mod_precomp.c +++ b/src/ulong_extras/mod_precomp.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong n_mod_precomp(ulong a, ulong n, double npre) diff --git a/src/ulong_extras/moebius_mu.c b/src/ulong_extras/moebius_mu.c index 27d706b408..3937a72c41 100644 --- a/src/ulong_extras/moebius_mu.c +++ b/src/ulong_extras/moebius_mu.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #define FLINT_MU_LOOKUP_CUTOFF 1024 diff --git a/src/ulong_extras/mulmod_precomp_shoup.c b/src/ulong_extras/mulmod_precomp_shoup.c index cd6d5daf95..cb8d8d6633 100644 --- a/src/ulong_extras/mulmod_precomp_shoup.c +++ b/src/ulong_extras/mulmod_precomp_shoup.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" /* Computes the W' = [w * b / p] (b = ulong power) */ diff --git a/src/ulong_extras/mulmod_preinv.c b/src/ulong_extras/mulmod_preinv.c index b0693b7522..be4511d9a1 100644 --- a/src/ulong_extras/mulmod_preinv.c +++ b/src/ulong_extras/mulmod_preinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong diff --git a/src/ulong_extras/nextprime.c b/src/ulong_extras/nextprime.c index 89a1dad4f4..7a9adfdd3d 100644 --- a/src/ulong_extras/nextprime.c +++ b/src/ulong_extras/nextprime.c @@ -12,7 +12,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" static unsigned int nextmod30[] = diff --git a/src/ulong_extras/powmod2_preinv.c b/src/ulong_extras/powmod2_preinv.c index 45143f92b9..eeb6663c75 100644 --- a/src/ulong_extras/powmod2_preinv.c +++ b/src/ulong_extras/powmod2_preinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong diff --git a/src/ulong_extras/powmod2_ui_preinv.c b/src/ulong_extras/powmod2_ui_preinv.c index 75fb804691..14d875cfe3 100644 --- a/src/ulong_extras/powmod2_ui_preinv.c +++ b/src/ulong_extras/powmod2_ui_preinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong diff --git a/src/ulong_extras/powmod_precomp.c b/src/ulong_extras/powmod_precomp.c index 09a50711a8..d842eb0e9d 100644 --- a/src/ulong_extras/powmod_precomp.c +++ b/src/ulong_extras/powmod_precomp.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong diff --git a/src/ulong_extras/powmod_ui_preinv.c b/src/ulong_extras/powmod_ui_preinv.c index 6ddf45f336..70fc165223 100644 --- a/src/ulong_extras/powmod_ui_preinv.c +++ b/src/ulong_extras/powmod_ui_preinv.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong diff --git a/src/ulong_extras/preinvert_limb.c b/src/ulong_extras/preinvert_limb.c index 16ecf27c33..c0f682cdac 100644 --- a/src/ulong_extras/preinvert_limb.c +++ b/src/ulong_extras/preinvert_limb.c @@ -12,7 +12,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" #if FLINT_BITS == 32 diff --git a/src/ulong_extras/prime_inverses_arr_readonly.c b/src/ulong_extras/prime_inverses_arr_readonly.c index 70e22375ba..fc142c0dae 100644 --- a/src/ulong_extras/prime_inverses_arr_readonly.c +++ b/src/ulong_extras/prime_inverses_arr_readonly.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" const double * n_prime_inverses_arr_readonly(ulong num_primes) diff --git a/src/ulong_extras/prime_pi.c b/src/ulong_extras/prime_pi.c index c77cbf2397..cceee31764 100644 --- a/src/ulong_extras/prime_pi.c +++ b/src/ulong_extras/prime_pi.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" const unsigned char FLINT_PRIME_PI_ODD_LOOKUP[] = diff --git a/src/ulong_extras/prime_pi_bounds.c b/src/ulong_extras/prime_pi_bounds.c index d9434af7c3..771817d13c 100644 --- a/src/ulong_extras/prime_pi_bounds.c +++ b/src/ulong_extras/prime_pi_bounds.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" FLINT_DLL extern const unsigned char FLINT_PRIME_PI_ODD_LOOKUP[]; diff --git a/src/ulong_extras/primes_extend_small.c b/src/ulong_extras/primes_extend_small.c index d68706a709..e7513b39d4 100644 --- a/src/ulong_extras/primes_extend_small.c +++ b/src/ulong_extras/primes_extend_small.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" void diff --git a/src/ulong_extras/primitive_root_prime.c b/src/ulong_extras/primitive_root_prime.c index 22137b20f1..259f43a2d4 100644 --- a/src/ulong_extras/primitive_root_prime.c +++ b/src/ulong_extras/primitive_root_prime.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong n_primitive_root_prime_prefactor(ulong p, n_factor_t * factors) diff --git a/src/ulong_extras/profile/p-factor.c b/src/ulong_extras/profile/p-factor.c index f1d9df02fc..35a83f7aa9 100644 --- a/src/ulong_extras/profile/p-factor.c +++ b/src/ulong_extras/profile/p-factor.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #define ITERS 1000 diff --git a/src/ulong_extras/profile/p-factor_pp1.c b/src/ulong_extras/profile/p-factor_pp1.c index 20cdcdae8f..6de7f89737 100644 --- a/src/ulong_extras/profile/p-factor_pp1.c +++ b/src/ulong_extras/profile/p-factor_pp1.c @@ -1,5 +1,4 @@ #include -#include "flint.h" #include "ulong_extras.h" #include "profiler.h" diff --git a/src/ulong_extras/profile/p-gcd.c b/src/ulong_extras/profile/p-gcd.c index 0768fd6703..b1f7cbf2ed 100644 --- a/src/ulong_extras/profile/p-gcd.c +++ b/src/ulong_extras/profile/p-gcd.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" #define ITERS 1000 diff --git a/src/ulong_extras/profile/p-is_probabprime_BPSW.c b/src/ulong_extras/profile/p-is_probabprime_BPSW.c index 1face901d0..681ca1ca67 100644 --- a/src/ulong_extras/profile/p-is_probabprime_BPSW.c +++ b/src/ulong_extras/profile/p-is_probabprime_BPSW.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" typedef struct diff --git a/src/ulong_extras/profile/p-lll_mod_preinv.c b/src/ulong_extras/profile/p-lll_mod_preinv.c index 466d5b33e5..b23c0279c7 100644 --- a/src/ulong_extras/profile/p-lll_mod_preinv.c +++ b/src/ulong_extras/profile/p-lll_mod_preinv.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" typedef struct diff --git a/src/ulong_extras/profile/p-mod2_precomp.c b/src/ulong_extras/profile/p-mod2_precomp.c index 970bca6f00..2158ded1a5 100644 --- a/src/ulong_extras/profile/p-mod2_precomp.c +++ b/src/ulong_extras/profile/p-mod2_precomp.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" void sample(void * arg, ulong count) diff --git a/src/ulong_extras/profile/p-mod2_preinv.c b/src/ulong_extras/profile/p-mod2_preinv.c index d6e512b88f..301f57bc36 100644 --- a/src/ulong_extras/profile/p-mod2_preinv.c +++ b/src/ulong_extras/profile/p-mod2_preinv.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" typedef struct diff --git a/src/ulong_extras/profile/p-mod_precomp.c b/src/ulong_extras/profile/p-mod_precomp.c index dcde871780..7c05ad1264 100644 --- a/src/ulong_extras/profile/p-mod_precomp.c +++ b/src/ulong_extras/profile/p-mod_precomp.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" void sample(void * arg, ulong count) diff --git a/src/ulong_extras/profile/p-mulmod2_preinv.c b/src/ulong_extras/profile/p-mulmod2_preinv.c index 1752dd0b22..473db89e4b 100644 --- a/src/ulong_extras/profile/p-mulmod2_preinv.c +++ b/src/ulong_extras/profile/p-mulmod2_preinv.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" void sample(void * arg, ulong count) diff --git a/src/ulong_extras/profile/p-mulmod_precomp.c b/src/ulong_extras/profile/p-mulmod_precomp.c index 9e77104685..6918fe23dc 100644 --- a/src/ulong_extras/profile/p-mulmod_precomp.c +++ b/src/ulong_extras/profile/p-mulmod_precomp.c @@ -10,7 +10,6 @@ */ #include "profiler.h" -#include "flint.h" #include "ulong_extras.h" void sample(void * arg, ulong count) diff --git a/src/ulong_extras/remove.c b/src/ulong_extras/remove.c index de4d863026..9de9dc8118 100644 --- a/src/ulong_extras/remove.c +++ b/src/ulong_extras/remove.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" int diff --git a/src/ulong_extras/remove2_precomp.c b/src/ulong_extras/remove2_precomp.c index 20580c8603..461a9c7ea4 100644 --- a/src/ulong_extras/remove2_precomp.c +++ b/src/ulong_extras/remove2_precomp.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" int diff --git a/src/ulong_extras/root.c b/src/ulong_extras/root.c index 543de4ff70..fa8aa25e5e 100644 --- a/src/ulong_extras/root.c +++ b/src/ulong_extras/root.c @@ -12,7 +12,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" /* A table of precomputed inverses of values from 1 to 64 diff --git a/src/ulong_extras/root_estimate.c b/src/ulong_extras/root_estimate.c index a19736234c..eed5c8d1eb 100644 --- a/src/ulong_extras/root_estimate.c +++ b/src/ulong_extras/root_estimate.c @@ -12,7 +12,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" diff --git a/src/ulong_extras/rootrem.c b/src/ulong_extras/rootrem.c index 470c530b36..33cc448c3b 100644 --- a/src/ulong_extras/rootrem.c +++ b/src/ulong_extras/rootrem.c @@ -12,7 +12,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" #include "fmpz.h" diff --git a/src/ulong_extras/sizeinbase.c b/src/ulong_extras/sizeinbase.c index 39a739682b..1c6e91ae15 100644 --- a/src/ulong_extras/sizeinbase.c +++ b/src/ulong_extras/sizeinbase.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" int n_sizeinbase(ulong n, int base) diff --git a/src/ulong_extras/sqrt.c b/src/ulong_extras/sqrt.c index 3083feac37..0a6c321545 100644 --- a/src/ulong_extras/sqrt.c +++ b/src/ulong_extras/sqrt.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" ulong n_sqrt(ulong a) diff --git a/src/ulong_extras/sqrtmod.c b/src/ulong_extras/sqrtmod.c index 3a61751bdd..44d710fdc9 100644 --- a/src/ulong_extras/sqrtmod.c +++ b/src/ulong_extras/sqrtmod.c @@ -10,7 +10,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong n_sqrtmod(ulong a, ulong p) diff --git a/src/ulong_extras/sqrtrem.c b/src/ulong_extras/sqrtrem.c index 854f5f37c9..5661ccfcf5 100644 --- a/src/ulong_extras/sqrtrem.c +++ b/src/ulong_extras/sqrtrem.c @@ -10,7 +10,6 @@ */ #include -#include "flint.h" #include "ulong_extras.h" ulong n_sqrtrem(ulong * r, ulong a) diff --git a/src/ulong_extras/xgcd.c b/src/ulong_extras/xgcd.c index 3e71728c6e..18f19e6eba 100644 --- a/src/ulong_extras/xgcd.c +++ b/src/ulong_extras/xgcd.c @@ -9,7 +9,6 @@ (at your option) any later version. See . */ -#include "flint.h" #include "ulong_extras.h" ulong