static void check(fmpz_t x, int expected) { if (fmpz_fits_si(x) != expected) { printf("FAIL:\n\n"); printf("x = "), fmpz_print(x), printf("\n"); printf("fmpz_fits_si(x) = %d\n", fmpz_fits_si(x)); printf("LONG_MIN = %ld\n", LONG_MIN); abort(); } }
slong hypgeom_root_norm(const fmpz_poly_t P) { slong res, i, p; fmpz_t t, A; fmpz_init(A); fmpz_init(t); p = fmpz_poly_degree(P); fmpz_zero(A); for (i = 1; i <= p; i++) { fmpz_cdiv_abs_q(t, P->coeffs + p - i, P->coeffs + p); fmpz_root(t, t, i); fmpz_add_ui(t, t, 1); if (fmpz_cmp(t, A) > 0) fmpz_swap(t, A); } if (!fmpz_fits_si(A)) abort(); res = fmpz_get_si(A); fmpz_clear(A); fmpz_clear(t); return res; }
static void _padic_log_bsplit(fmpz_t z, const fmpz_t y, long v, const fmpz_t p, long N) { fmpz_t P, B, T; long n; if (fmpz_fits_si(p)) n = _padic_log_bound(v, N, fmpz_get_si(p)); else n = (N - 1) / v; n = FLINT_MAX(n, 2); fmpz_init(P); fmpz_init(B); fmpz_init(T); _padic_log_bsplit_series(P, B, T, y, 1, n); n = fmpz_remove(B, B, p); fmpz_pow_ui(P, p, n); fmpz_divexact(T, T, P); _padic_inv(B, B, p, N); fmpz_mul(z, T, B); fmpz_clear(P); fmpz_clear(B); fmpz_clear(T); }
slong fmpr_get_si(const fmpr_t x, fmpr_rnd_t rnd) { fmpz_t t; slong v; fmpz_init(t); fmpr_get_fmpz(t, x, rnd); if (!fmpz_fits_si(t)) { flint_printf("fmpr_get_si: result does not fit in a signed slong\n"); abort(); } v = fmpz_get_si(t); fmpz_clear(t); return v; }
static void set_loops(gamma_t * l, slong n, fmpz * row, slong m1, slong len) { slong i, j; /* coeff k * (m-1) + s -> gamma_k^s */ for (i = 0, j = 0; i < n; i++) { for (; fmpz_is_zero(row + j); j++); if (!fmpz_fits_si(row + j)) { flint_printf("error: coefficient too large in basis\n"); abort(); } l[i].coeff = fmpz_get_si(row + j); l[i].shift = j % m1; l[i].index = j / m1; } }