Beispiel #1
0
static __inline__ 
long _zeta_function(const fmpz_t p, long a, 
    long n, long d)
{
    const long b = gmc_basis_size(n, d);
    long i, N;

    fmpz_t f, g, max;

    fmpz_init(f);
    fmpz_init(g);
    fmpz_init(max);

    if (n == 3 && fmpz_cmp_ui(p, 2) != 0)
    {
        fmpz_bin_uiui(f, d-1, 3);
        fmpz_bin_uiui(g, b, b / 2);
        fmpz_mul_ui(g, g, 2);
        N = a * (*f) + fmpz_clog(g, p);
    }
    else if (n % 2L == 0)  /* n even implies b even */
    {
        fmpz_bin_uiui(f, b, b / 2);
        fmpz_pow_ui(g, p, (a * (b / 2) * (n - 1) + 1) / 2);
        fmpz_mul(f, f, g);
        fmpz_mul_ui(f, f, 2);

        N = fmpz_flog(f, p) + 1;
    }
    else
    {
        for (i = b / 2; i <= b; i++)
        {
            fmpz_bin_uiui(f, b, i);
            fmpz_pow_ui(g, p, (a * i * (n - 1) + 1) / 2);
            fmpz_mul(f, f, g);
            fmpz_mul_ui(f, f, 2);

            if (fmpz_cmp(max, f) < 0)
                fmpz_swap(max, f);
        }

        N = fmpz_flog(max, p) + 1;
    }

    fmpz_clear(f);
    fmpz_clear(g);
    fmpz_clear(max);

    return N;
}
/* The coefficients in 2^d * \prod_{i=1}^d (x - cos(a_i)) are
   easily bounded using the binomial theorem. */
static slong
magnitude_bound(slong d)
{
    slong res;
    fmpz_t t;
    fmpz_init(t);
    fmpz_bin_uiui(t, d, d / 2);
    res = fmpz_bits(t);
    fmpz_clear(t);
    return FLINT_ABS(res) + d;
}
Beispiel #3
0
void
rising_difference_polynomial(fmpz * s, fmpz * c, ulong m)
{
    long i, j, k;
    fmpz_t t;

    fmpz_init(t);

    arith_stirling_number_1u_vec(s, m, m + 1);

    for (k = 0; k < m; k++)
    {
        for (i = 0; i <= m - k - 1; i++)
        {
            fmpz_zero(c + m * k + i);

            for (j = i + 1; j + k <= m; j++)
            {
                if (j == i + 1)
                {
                    fmpz_bin_uiui(t, 1+i+k, k);
                    fmpz_mul_ui(t, t, m * (i+1));
                }
                else
                {
                    fmpz_mul_ui(t, t, m * (k + j));
                    fmpz_divexact_ui(t, t, j - i);
                }

                fmpz_addmul(c + m * k + i, s + j + k, t);
            }
        }
    }

    fmpz_clear(t);
}