2015-01-22 14:43:52 +01:00
|
|
|
/*=============================================================================
|
|
|
|
|
|
|
|
This file is part of ARB.
|
|
|
|
|
|
|
|
ARB is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
ARB is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with ARB; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
=============================================================================*/
|
|
|
|
/******************************************************************************
|
|
|
|
|
|
|
|
Copyright (C) 2013 Fredrik Johansson
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include "acb_poly.h"
|
2016-04-19 15:27:53 -04:00
|
|
|
#include "acb_hypgeom.h"
|
2015-01-22 14:43:52 +01:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2015-11-05 17:51:23 +00:00
|
|
|
slong iter;
|
2015-01-22 14:43:52 +01:00
|
|
|
flint_rand_t state;
|
|
|
|
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("gamma_upper_series....");
|
2015-01-22 14:43:52 +01:00
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
flint_randinit(state);
|
|
|
|
|
2016-04-10 17:24:58 +02:00
|
|
|
for (iter = 0; iter < 1000 * arb_test_multiplier(); iter++)
|
2015-01-22 14:43:52 +01:00
|
|
|
{
|
2015-11-05 17:51:23 +00:00
|
|
|
slong m, n1, n2, bits1, bits2, bits3;
|
2015-01-22 14:43:52 +01:00
|
|
|
acb_poly_t S, A, B, C;
|
2016-04-20 17:43:59 -04:00
|
|
|
acb_t s, t, c;
|
|
|
|
int regularized;
|
|
|
|
|
|
|
|
regularized = n_randint(state, 3);
|
2015-01-22 14:43:52 +01:00
|
|
|
|
|
|
|
bits1 = 2 + n_randint(state, 200);
|
|
|
|
bits2 = 2 + n_randint(state, 200);
|
|
|
|
bits3 = 2 + n_randint(state, 200);
|
|
|
|
|
|
|
|
m = 1 + n_randint(state, 10);
|
|
|
|
n1 = 1 + n_randint(state, 10);
|
|
|
|
n2 = 1 + n_randint(state, 10);
|
|
|
|
|
|
|
|
acb_poly_init(S);
|
|
|
|
acb_poly_init(A);
|
|
|
|
acb_poly_init(B);
|
|
|
|
acb_poly_init(C);
|
|
|
|
acb_init(s);
|
|
|
|
acb_init(t);
|
2016-04-20 17:43:59 -04:00
|
|
|
acb_init(c);
|
2015-01-22 14:43:52 +01:00
|
|
|
|
|
|
|
acb_poly_randtest(S, state, m, bits1, 3);
|
|
|
|
acb_poly_randtest(A, state, m, bits1, 3);
|
|
|
|
acb_poly_randtest(B, state, m, bits1, 3);
|
|
|
|
acb_randtest(s, state, bits1, 3);
|
|
|
|
|
2016-04-20 17:43:59 -04:00
|
|
|
acb_hypgeom_gamma_upper_series(A, s, S, n1, regularized, bits2);
|
|
|
|
acb_hypgeom_gamma_upper_series(B, s, S, n2, regularized, bits3);
|
2015-01-22 14:43:52 +01:00
|
|
|
|
|
|
|
acb_poly_set(C, A);
|
|
|
|
acb_poly_truncate(C, FLINT_MIN(n1, n2));
|
|
|
|
acb_poly_truncate(B, FLINT_MIN(n1, n2));
|
|
|
|
|
|
|
|
if (!acb_poly_overlaps(B, C))
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL (consistency)\n\n");
|
2016-04-20 17:43:59 -04:00
|
|
|
flint_printf("regularized = %d\n\n", regularized);
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("S = "); acb_poly_printd(S, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("A = "); acb_poly_printd(A, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("B = "); acb_poly_printd(B, 15); flint_printf("\n\n");
|
2016-04-20 17:43:59 -04:00
|
|
|
flint_printf("C = "); acb_poly_printd(C, 15); flint_printf("\n\n");
|
2015-01-22 14:43:52 +01:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2016-04-20 17:43:59 -04:00
|
|
|
/* f(h(x)) = -exp(-h(x)) h(x)^(s-1) */
|
|
|
|
acb_poly_neg(C, S);
|
|
|
|
acb_poly_exp_series(C, C, n1, bits2);
|
2015-01-22 14:43:52 +01:00
|
|
|
acb_sub_ui(t, s, 1, bits2);
|
|
|
|
acb_poly_pow_acb_series(B, S, t, n1, bits2);
|
|
|
|
acb_poly_mullow(C, C, B, n1, bits2);
|
|
|
|
acb_poly_neg(C, C);
|
2016-04-20 17:43:59 -04:00
|
|
|
|
|
|
|
if (regularized == 0)
|
|
|
|
{
|
|
|
|
/* integral(f(h(x)) h'(x))' = f(h(x)) h'(x) */
|
|
|
|
acb_poly_derivative(B, S, bits2);
|
|
|
|
acb_poly_mullow(C, C, B, n1, bits2);
|
|
|
|
|
|
|
|
acb_poly_truncate(C, n1 - 1);
|
|
|
|
}
|
|
|
|
else if (regularized == 1)
|
|
|
|
{
|
|
|
|
/* (integral(f(h(x)) h'(x)) / c)' = (f(h(x)) h'(x)) / c */
|
|
|
|
acb_poly_derivative(B, S, bits2);
|
|
|
|
acb_poly_mullow(C, C, B, n1, bits2);
|
|
|
|
|
|
|
|
acb_gamma(c, s, bits2);
|
|
|
|
_acb_vec_scalar_div(C->coeffs, C->coeffs, C->length, c, bits2);
|
|
|
|
|
|
|
|
acb_poly_truncate(C, n1 - 1);
|
|
|
|
}
|
|
|
|
else if (regularized == 2)
|
|
|
|
{
|
|
|
|
/* (exp(-h(x)) integral(f(h(x)) h'(x)))' =
|
|
|
|
* exp(-h(x)) (f(h(x)) - integral(f(h(x)) h'(x))) h'(x) */
|
|
|
|
acb_poly_t D;
|
|
|
|
acb_poly_init(D);
|
|
|
|
|
|
|
|
acb_poly_derivative(B, S, bits2);
|
|
|
|
acb_poly_mullow(D, C, B, n1, bits2);
|
|
|
|
acb_poly_integral(D, D, bits2);
|
|
|
|
acb_poly_sub(D, C, D, bits2);
|
|
|
|
|
|
|
|
acb_poly_neg(B, S);
|
|
|
|
acb_poly_exp_series(B, B, n1, bits2);
|
|
|
|
|
|
|
|
acb_poly_mullow(C, D, B, n1, bits2);
|
|
|
|
|
|
|
|
acb_poly_derivative(B, S, bits2);
|
|
|
|
acb_poly_mullow(C, C, B, n1, bits2);
|
|
|
|
|
|
|
|
acb_poly_truncate(C, n1 - 1);
|
|
|
|
|
|
|
|
acb_poly_clear(D);
|
|
|
|
}
|
2015-01-22 14:43:52 +01:00
|
|
|
|
|
|
|
acb_poly_derivative(B, A, bits2);
|
|
|
|
|
|
|
|
if (!acb_poly_overlaps(B, C))
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL (derivative)\n\n");
|
2016-04-20 17:43:59 -04:00
|
|
|
flint_printf("regularized = %d\n\n", regularized);
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("S = "); acb_poly_printd(S, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("A = "); acb_poly_printd(A, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("B = "); acb_poly_printd(B, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("C = "); acb_poly_printd(C, 15); flint_printf("\n\n");
|
2015-01-22 14:43:52 +01:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2016-04-20 17:43:59 -04:00
|
|
|
acb_hypgeom_gamma_upper_series(S, s, S, n1, regularized, bits2);
|
2015-01-22 14:43:52 +01:00
|
|
|
|
|
|
|
if (!acb_poly_overlaps(A, S))
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL (aliasing)\n\n");
|
2016-04-20 17:43:59 -04:00
|
|
|
flint_printf("regularized = %d\n\n", regularized);
|
|
|
|
flint_printf("S = "); acb_poly_printd(S, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("A = "); acb_poly_printd(A, 15); flint_printf("\n\n");
|
2015-01-22 14:43:52 +01:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
acb_poly_clear(S);
|
|
|
|
acb_poly_clear(A);
|
|
|
|
acb_poly_clear(B);
|
|
|
|
acb_poly_clear(C);
|
|
|
|
acb_clear(s);
|
|
|
|
acb_clear(t);
|
2016-04-20 17:43:59 -04:00
|
|
|
acb_clear(c);
|
2015-01-22 14:43:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
flint_randclear(state);
|
|
|
|
flint_cleanup();
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("PASS\n");
|
2015-01-22 14:43:52 +01:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|