2016-04-26 17:20:05 +02:00
|
|
|
/*
|
2016-02-21 23:23:51 +01:00
|
|
|
Copyright (C) 2016 Fredrik Johansson
|
|
|
|
|
2016-04-26 17:20:05 +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-02-21 23:23:51 +01:00
|
|
|
|
|
|
|
#include "acb_dirichlet.h"
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
slong iter;
|
|
|
|
flint_rand_t state;
|
|
|
|
|
2016-02-22 11:47:12 +01:00
|
|
|
flint_printf("chi....");
|
2016-02-21 23:23:51 +01:00
|
|
|
fflush(stdout);
|
|
|
|
flint_randinit(state);
|
|
|
|
|
2016-04-10 17:24:58 +02:00
|
|
|
for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
|
2016-02-21 23:23:51 +01:00
|
|
|
{
|
|
|
|
acb_t zn1, zn2, zn1n2, zn1zn2;
|
|
|
|
acb_dirichlet_group_t G;
|
2016-03-22 11:29:21 +01:00
|
|
|
acb_dirichlet_char_t chi;
|
2016-02-21 23:23:51 +01:00
|
|
|
ulong q, m, n1, n2, iter2;
|
2016-02-23 00:46:04 +01:00
|
|
|
int res;
|
2016-02-21 23:23:51 +01:00
|
|
|
|
|
|
|
q = 1 + n_randint(state, 1000);
|
|
|
|
|
|
|
|
acb_dirichlet_group_init(G, q);
|
2016-03-22 11:29:21 +01:00
|
|
|
acb_dirichlet_char_init(chi, G);
|
2016-02-21 23:23:51 +01:00
|
|
|
acb_init(zn1);
|
|
|
|
acb_init(zn2);
|
|
|
|
acb_init(zn1n2);
|
|
|
|
acb_init(zn1zn2);
|
|
|
|
|
2016-02-23 00:46:04 +01:00
|
|
|
/* check chi(n1) chi(n2) = chi(n1 n2) */
|
2016-02-21 23:23:51 +01:00
|
|
|
for (iter2 = 0; iter2 < 10; iter2++)
|
|
|
|
{
|
2016-02-21 23:27:28 +01:00
|
|
|
do {
|
|
|
|
m = 1 + n_randint(state, q);
|
|
|
|
} while (n_gcd(q, m) != 1);
|
|
|
|
|
2016-03-22 11:29:21 +01:00
|
|
|
acb_dirichlet_char(chi, G, m);
|
|
|
|
|
2016-02-21 23:27:28 +01:00
|
|
|
n1 = n_randint(state, 1000);
|
|
|
|
n2 = n_randint(state, 1000);
|
|
|
|
|
2016-03-22 11:29:21 +01:00
|
|
|
acb_dirichlet_acb_chi(zn1, G, chi, n1, 53);
|
|
|
|
acb_dirichlet_acb_pairing(zn2, G, m, n1, 53);
|
|
|
|
if (!acb_overlaps(zn1, zn2))
|
|
|
|
{
|
|
|
|
acb_dirichlet_conrey_t x;
|
|
|
|
flint_printf("FAIL: overlap\n\n");
|
|
|
|
flint_printf("q = %wu\n\n", q);
|
|
|
|
flint_printf("m = %wu\n\n", m);
|
|
|
|
flint_printf("n = %wu\n\n", n1);
|
|
|
|
flint_printf("char = "); acb_printd(zn1, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("pairing = "); acb_printd(zn2, 15); flint_printf("\n\n");
|
|
|
|
acb_dirichlet_char_print(G, chi);
|
|
|
|
acb_dirichlet_conrey_init(x, G);
|
|
|
|
acb_dirichlet_conrey_log(x, G, m);
|
|
|
|
flint_printf("log(m) = "); acb_dirichlet_conrey_print(G, x);
|
|
|
|
acb_dirichlet_conrey_log(x, G, n1);
|
|
|
|
flint_printf("log(n1) = "); acb_dirichlet_conrey_print(G, x);
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
acb_dirichlet_acb_pairing(zn2, G, m, n2, 53);
|
|
|
|
acb_dirichlet_acb_pairing(zn1n2, G, m, n1 * n2, 53);
|
2016-02-21 23:23:51 +01:00
|
|
|
acb_mul(zn1zn2, zn1, zn2, 53);
|
|
|
|
|
|
|
|
if (!acb_overlaps(zn1n2, zn1zn2))
|
|
|
|
{
|
|
|
|
flint_printf("FAIL: overlap\n\n");
|
|
|
|
flint_printf("q = %wu\n\n", q);
|
|
|
|
flint_printf("m = %wu\n\n", m);
|
|
|
|
flint_printf("n1 = %wu\n\n", n1);
|
|
|
|
flint_printf("n2 = %wu\n\n", n2);
|
|
|
|
flint_printf("zn1 = "); acb_printd(zn1, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("zn2 = "); acb_printd(zn2, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("zn1n2 = "); acb_printd(zn1n2, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("zn1zn2 = "); acb_printd(zn1zn2, 15); flint_printf("\n\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-23 00:46:04 +01:00
|
|
|
if (iter % 10 == 0)
|
|
|
|
{
|
|
|
|
/* check orthogonality */
|
|
|
|
acb_zero(zn1);
|
|
|
|
n1 = n_randint(state, 1000);
|
|
|
|
for (m = 1; m <= q; m++)
|
|
|
|
{
|
|
|
|
if (n_gcd(q, m) == 1)
|
|
|
|
{
|
2016-03-22 11:29:21 +01:00
|
|
|
acb_dirichlet_acb_pairing(zn2, G, m, n1, 53);
|
2016-02-23 00:46:04 +01:00
|
|
|
acb_add(zn1, zn1, zn2, 53);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n1 % q == 1 % q)
|
|
|
|
res = arb_contains_si(acb_realref(zn1), n_euler_phi(q)) &&
|
|
|
|
arb_contains_zero(acb_imagref(zn1));
|
|
|
|
else
|
|
|
|
res = acb_contains_zero(zn1);
|
|
|
|
|
|
|
|
if (!res)
|
|
|
|
{
|
|
|
|
flint_printf("FAIL: orthogonality\n\n");
|
|
|
|
flint_printf("q = %wu\n\n", q);
|
|
|
|
flint_printf("phi = %wu\n\n", n_euler_phi(q));
|
|
|
|
flint_printf("n1 = %wu\n\n", n1);
|
|
|
|
flint_printf("zn1 = "); acb_printd(zn1, 15); flint_printf("\n\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-21 23:23:51 +01:00
|
|
|
acb_dirichlet_group_clear(G);
|
|
|
|
acb_clear(zn1);
|
|
|
|
acb_clear(zn2);
|
|
|
|
acb_clear(zn1n2);
|
|
|
|
acb_clear(zn1zn2);
|
|
|
|
}
|
|
|
|
|
|
|
|
flint_randclear(state);
|
|
|
|
flint_cleanup();
|
|
|
|
flint_printf("PASS\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|