arb/arb_poly/test/t-zeta_series.c

136 lines
4.2 KiB
C
Raw Normal View History

2014-06-13 22:08:25 +02: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 "arb_poly.h"
int main()
{
slong iter;
2014-06-13 22:08:25 +02:00
flint_rand_t state;
flint_printf("zeta_series....");
2014-06-13 22:08:25 +02:00
fflush(stdout);
flint_randinit(state);
for (iter = 0; iter < 500; iter++)
{
slong m, n1, n2, bits1, bits2, bits3;
2014-06-13 22:08:25 +02:00
int deflate;
arb_poly_t S, A, B, C, D, E, F;
arb_t a, a1;
bits1 = 2 + n_randint(state, 300);
bits2 = 2 + n_randint(state, 300);
bits3 = 2 + n_randint(state, 300);
m = 1 + n_randint(state, 30);
n1 = 1 + n_randint(state, 30);
n2 = 1 + n_randint(state, 30);
arb_poly_init(S);
arb_poly_init(A);
arb_poly_init(B);
arb_poly_init(C);
arb_poly_init(D);
arb_poly_init(E);
arb_poly_init(F);
arb_init(a);
arb_init(a1);
deflate = n_randint(state, 2);
arb_poly_randtest(S, state, m, bits1, 3);
arb_randtest_precise(a, state, bits1, 3);
arb_poly_set_coeff_arb(S, 0, a);
if (n_randint(state, 2))
arb_randtest(a, state, bits1, 3);
else
arb_one(a);
arb_poly_zeta_series(A, S, a, deflate, n1, bits2);
arb_poly_zeta_series(B, S, a, deflate, n2, bits3);
arb_poly_set(C, A);
arb_poly_truncate(C, FLINT_MIN(n1, n2));
arb_poly_truncate(B, FLINT_MIN(n1, n2));
if (!arb_poly_overlaps(B, C))
{
flint_printf("FAIL\n\n");
flint_printf("S = "); arb_poly_printd(S, 15); flint_printf("\n\n");
flint_printf("a = "); arb_printd(a, 15); flint_printf("\n\n");
flint_printf("A = "); arb_poly_printd(A, 15); flint_printf("\n\n");
flint_printf("B = "); arb_poly_printd(B, 15); flint_printf("\n\n");
2014-06-13 22:08:25 +02:00
abort();
}
/* check zeta(s,a) = zeta(s,a+1) + a^(-s) */
arb_poly_set_arb(D, a);
arb_poly_log_series(D, D, n1, bits2);
arb_poly_mullow(D, D, S, n1, bits2);
arb_poly_neg(D, D);
arb_poly_exp_series(D, D, n1, bits2);
arb_add_ui(a1, a, 1, bits2);
arb_poly_zeta_series(E, S, a1, deflate, n1, bits2);
arb_poly_add(E, E, D, bits2);
if (!arb_poly_overlaps(A, E))
{
flint_printf("FAIL (functional equation)\n\n");
flint_printf("S = "); arb_poly_printd(S, 15); flint_printf("\n\n");
flint_printf("a = "); arb_printd(a, 15); flint_printf("\n\n");
flint_printf("A = "); arb_poly_printd(A, 15); flint_printf("\n\n");
flint_printf("E = "); arb_poly_printd(A, 15); flint_printf("\n\n");
2014-06-13 22:08:25 +02:00
abort();
}
arb_poly_zeta_series(S, S, a, deflate, n1, bits2);
if (!arb_poly_overlaps(A, S))
{
flint_printf("FAIL (aliasing)\n\n");
2014-06-13 22:08:25 +02:00
abort();
}
arb_poly_clear(S);
arb_poly_clear(A);
arb_poly_clear(B);
arb_poly_clear(C);
arb_poly_clear(D);
arb_poly_clear(E);
arb_poly_clear(F);
arb_clear(a);
arb_clear(a1);
}
flint_randclear(state);
flint_cleanup();
flint_printf("PASS\n");
2014-06-13 22:08:25 +02:00
return EXIT_SUCCESS;
}