speed up acb_elliptic_rf slightly by precomputing optimal denominators

This commit is contained in:
Fredrik Johansson 2017-08-21 03:07:24 +02:00
parent 2fb86a0383
commit a275e740b3

View file

@ -11,6 +11,41 @@
#include "acb_elliptic.h"
static const unsigned short den_ratio_tab[512] = {
1,1,10,7,12,11,26,1,136,19,2,23,20,1,58,31,
16,1,74,1,164,43,2,47,56,1,106,1,4,59,122,1,
32,67,2,71,292,1,2,79,24,83,2,1,356,1,2,1,
1552,1,202,103,4,107,218,1,904,1,2,1,44,1,10,127,
64,131,2,1,548,139,2,1,8,1,298,151,4,1,314,1,
16,163,2,167,52,1,346,1,8,179,362,1,4,1,2,191,
6176,1,394,199,4,1,2,1,8,211,2,1,4,1,2,223,
16,227,458,1,932,1,2,239,1928,1,2,1,4,251,2,1,
32896,1,2,263,4,1,538,271,8,1,554,1,1124,283,2,1,
272,1,586,1,4,1,2,1,8,307,2,311,1252,1,634,1,
32,1,2,1,4,331,2,1,2696,1,2,7,4,347,698,1,
5648,1,2,359,76,1,2,367,8,1,746,1,4,379,2,383,
64,1,778,1,4,1,794,1,3208,1,2,1,1636,1,2,1,
16,419,842,1,4,1,2,431,3464,1,2,439,4,443,2,1,
14368,1,2,1,1828,1,922,463,8,467,2,1,4,1,2,479,
16,1,2,487,4,491,2,1,8,499,2,503,4,1,1018,1,
256,1,2,1,2084,523,2,1,184,1,2,1,4,1,1082,1,
16,547,2,1,4,1,1114,1,8,563,2,1,2276,571,2,1,
18464,1,2,1,4,587,2,1,4744,1,2,599,2404,1,2,607,
16,1,1226,1,2468,619,2,1,40,1,2,631,4,1,2,1,
41024,643,2,647,4,1,1306,1,8,659,1322,1,4,1,2,1,
10768,1,1354,1,4,683,2,1,8,691,2,1,4,1,1402,1,
32,1,1418,1,4,1,2,719,8,1,2,727,12,1,1466,1,
16,739,2,743,4,1,2,751,8,1,1514,1,3044,1,2,2,
49216,1,1546,1,4,1,2,1,8,787,2,1,4,1,1594,1,
16,1,2,1,3236,811,2,1,8,1,1642,823,4,827,1658,1,
32,1,2,839,116,1,2,1,8,1,1706,1,3428,859,2,863,
16,1,2,1,4,1,1754,1,7048,883,2,887,4,1,2,1,
64,1,2,1,4,907,2,911,8,1,2,919,4,1,2,1,
14864,1,2,1,3748,1,1882,1,8,947,2,1,3812,1,2,1,
992,1,2,967,4,971,2,1,7816,1,2,983,4,1,2,991,
16,1,1994,1,4,1,2,1,8072,1,2026,1,4,1019,2042,1,
};
void
acb_elliptic_rf_taylor_sum(acb_t res, const acb_t E2, const acb_t E3, slong nterms, slong prec)
{
@ -44,11 +79,10 @@ acb_elliptic_rf_taylor_sum(acb_t res, const acb_t E2, const acb_t E3, slong nter
_acb_vec_set_powers(E2pow, E2, XMAX + 1, prec);
}
/* Compute universal denominator (could tighten this?). */
/* Compute universal denominator. */
fmpz_one(den);
for (x = 3; x <= 2 * NMAX + 1; x += 2)
fmpz_mul_ui(den, den, x);
fmpz_mul_2exp(den, den, NMAX);
for (N = 1; N <= NMAX; N++)
fmpz_mul_ui(den, den, den_ratio_tab[N]);
/* Compute initial coefficient rf(1/2,y) / y! */
fmpz_set(c, den);
@ -195,7 +229,7 @@ acb_elliptic_rf(acb_t res, const acb_t x, const acb_t y, const acb_t z,
wp = prec + 10 + FLINT_BIT_COUNT(prec);
if (acb_is_real(xx) && acb_is_real(yy) && acb_is_real(zz))
order = 2.0 * pow(prec, 0.4);
order = 2.1 * pow(prec, 0.4);
else
order = 2.5 * pow(prec, 0.4);
order = FLINT_MIN(order, 500);