Пример #1
0
void _fmpz_poly_sqrlow(fmpz * res, const fmpz * poly, long len, long n)
{
    mp_size_t limbs;

    if (n < 7)
    {
        _fmpz_poly_sqrlow_classical(res, poly, len, n);
        return;
    }

    limbs = _fmpz_vec_max_limbs(poly, len);

    if (n < 16 && limbs > 12)
    {
        int i;
        fmpz *copy;

        copy = flint_malloc(n * sizeof(fmpz));
        for (i = 0; i < len; i++)
            copy[i] = poly[i];
        mpn_zero((mp_ptr) copy + len, n - len);

        _fmpz_poly_sqrlow_karatsuba_n(res, copy, n);

        flint_free(copy);
    }
    else if (limbs <= 4)
        _fmpz_poly_sqrlow_KS(res, poly, len, n);
    else if (limbs/2048 > len)
        _fmpz_poly_sqrlow_KS(res, poly, len, n);
    else if (limbs*FLINT_BITS*4 < len)
       _fmpz_poly_sqrlow_KS(res, poly, len, n);
    else
       _fmpz_poly_mullow_SS(res, poly, len, poly, len, n);
}
Пример #2
0
void
_fmpz_poly_pow(fmpz * res, const fmpz * poly, long len, ulong e)
{
    if (e < 5UL)
        _fmpz_poly_pow_small(res, poly, len, e);
    else if (len == 2)
        _fmpz_poly_pow_binomial(res, poly, e);
    else
    {
        ulong limbs = (ulong) _fmpz_vec_max_limbs(poly, len);
        
        if (limbs < ((3UL * e) / 2UL + 150UL) / (ulong) len)
            _fmpz_poly_pow_multinomial(res, poly, len, e);
        else
            _fmpz_poly_pow_binexp(res, poly, len, e);
    }
}