arb/acb_dirichlet/test/t-gauss.c

82 lines
2.1 KiB
C
Raw Normal View History

2016-09-06 15:43:12 +02:00
/*
2016-04-12 15:07:04 +02:00
Copyright (C) 2016 Pascal Molin
2016-09-06 15:43:12 +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 Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
2016-04-12 15:07:04 +02:00
#include "acb_dirichlet.h"
int main()
{
slong prec = 128;
ulong q;
flint_printf("gauss....");
fflush(stdout);
/* check Gauss sums */
2016-07-05 13:16:29 +02:00
for (q = 3; q < 250; q ++)
2016-04-12 15:07:04 +02:00
{
2016-10-06 14:19:39 +02:00
dirichlet_group_t G;
dirichlet_char_t chi;
2016-04-12 15:07:04 +02:00
2016-07-13 15:54:45 +02:00
acb_t s1, s2, s3, s4;
2016-04-12 15:07:04 +02:00
2016-10-06 14:19:39 +02:00
dirichlet_group_init(G, q);
dirichlet_char_init(chi, G);
2016-04-12 15:07:04 +02:00
acb_init(s1);
acb_init(s2);
acb_init(s3);
2016-07-13 15:54:45 +02:00
acb_init(s4);
2016-10-08 17:22:19 +02:00
dirichlet_char_one(chi, G);
2016-04-12 15:07:04 +02:00
while (1) {
acb_dirichlet_gauss_sum_naive(s1, G, chi, prec);
acb_dirichlet_gauss_sum(s2, G, chi, prec);
2016-07-13 15:54:45 +02:00
acb_dirichlet_gauss_sum_factor(s3, G, chi, prec);
2016-10-08 17:22:19 +02:00
if (dirichlet_conductor_char(G, chi) == G->q)
2016-07-13 15:54:45 +02:00
acb_dirichlet_gauss_sum_theta(s4, G, chi, prec);
else
2016-07-13 15:54:45 +02:00
acb_set(s4, s1);
2016-04-12 15:07:04 +02:00
if (!acb_overlaps(s1, s2)
2016-07-13 15:54:45 +02:00
|| !acb_overlaps(s1, s3)
|| !acb_overlaps(s1, s4))
2016-04-12 15:07:04 +02:00
{
2016-10-08 17:22:19 +02:00
flint_printf("FAIL: G(chi_%wu(%wu))\n\n", q, chi->n);
flint_printf("\nnaive ");
2016-04-12 15:07:04 +02:00
acb_printd(s1, 25);
2016-10-08 17:22:19 +02:00
flint_printf("\ndefault ");
acb_printd(s2, 25);
2016-10-08 17:22:19 +02:00
flint_printf("\nfactor ");
2016-04-12 15:07:04 +02:00
acb_printd(s3, 25);
2016-10-08 17:22:19 +02:00
flint_printf("\ntheta ");
2016-07-13 15:54:45 +02:00
acb_printd(s4, 25);
flint_abort();
2016-04-12 15:07:04 +02:00
}
2016-10-08 17:22:19 +02:00
if (dirichlet_char_next(chi, G) < 0)
2016-04-12 15:07:04 +02:00
break;
}
acb_clear(s1);
acb_clear(s2);
acb_clear(s3);
2016-07-13 15:54:45 +02:00
acb_clear(s4);
2016-04-12 15:07:04 +02:00
2016-10-06 14:19:39 +02:00
dirichlet_group_clear(G);
dirichlet_char_clear(chi);
2016-04-12 15:07:04 +02:00
}
flint_cleanup();
flint_printf("PASS\n");
return EXIT_SUCCESS;
}