2016-04-26 17:20:05 +02:00
|
|
|
/*
|
2014-10-01 19:12:18 +02:00
|
|
|
Copyright (C) 2014 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/>.
|
|
|
|
*/
|
2014-10-01 19:12:18 +02:00
|
|
|
|
|
|
|
#include "acb_modular.h"
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2015-11-05 17:49:06 +00:00
|
|
|
slong iter;
|
2014-10-01 19:12:18 +02:00
|
|
|
flint_rand_t state;
|
|
|
|
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("fundamental_domain_approx....");
|
2014-10-01 19:12:18 +02:00
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
flint_randinit(state);
|
|
|
|
|
2016-04-10 17:24:58 +02:00
|
|
|
for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
|
2014-10-01 19:12:18 +02:00
|
|
|
{
|
|
|
|
fmpq_t x, y;
|
|
|
|
psl2z_t g;
|
|
|
|
arf_t one_minus_eps, tol;
|
|
|
|
acb_t z, w, w2;
|
|
|
|
arb_t t;
|
2015-11-05 17:49:06 +00:00
|
|
|
slong prec;
|
2014-10-01 19:12:18 +02:00
|
|
|
|
|
|
|
fmpq_init(x);
|
|
|
|
fmpq_init(y);
|
|
|
|
|
|
|
|
psl2z_init(g);
|
|
|
|
acb_init(z);
|
|
|
|
acb_init(w);
|
|
|
|
acb_init(w2);
|
|
|
|
arf_init(one_minus_eps);
|
|
|
|
arf_init(tol);
|
|
|
|
arb_init(t);
|
|
|
|
|
|
|
|
/* pick an exact point in the upper half plane */
|
2014-10-02 11:46:27 +02:00
|
|
|
fmpq_randtest(x, state, 1 + n_randint(state, 500));
|
2014-10-01 19:12:18 +02:00
|
|
|
do {
|
2014-10-02 11:46:27 +02:00
|
|
|
fmpq_randtest(y, state, 1 + n_randint(state, 500));
|
2014-10-01 19:12:18 +02:00
|
|
|
} while (fmpz_sgn(fmpq_numref(y)) <= 0);
|
|
|
|
|
|
|
|
/* pick a tolerance */
|
2015-11-05 17:49:06 +00:00
|
|
|
arf_set_ui_2exp_si(tol, 1, -(slong) n_randint(state, 500));
|
2014-10-01 19:12:18 +02:00
|
|
|
|
|
|
|
/* now increase the precision until convergence */
|
|
|
|
for (prec = 32; ; prec *= 2)
|
|
|
|
{
|
|
|
|
if (prec > 16384)
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL (no convergence)\n");
|
|
|
|
flint_printf("x = "); fmpq_print(x); flint_printf("\n\n");
|
|
|
|
flint_printf("y = "); fmpq_print(y); flint_printf("\n\n");
|
|
|
|
flint_printf("z = "); acb_printd(z, 50); flint_printf("\n\n");
|
|
|
|
flint_printf("w = "); acb_printd(w, 50); flint_printf("\n\n");
|
|
|
|
flint_printf("w2 = "); acb_printd(w2, 50); flint_printf("\n\n");
|
|
|
|
flint_printf("g = "); psl2z_print(g); flint_printf("\n\n");
|
2017-02-28 16:50:03 +01:00
|
|
|
flint_abort();
|
2014-10-01 19:12:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
arb_set_fmpq(acb_realref(z), x, prec);
|
|
|
|
arb_set_fmpq(acb_imagref(z), y, prec);
|
|
|
|
|
|
|
|
arf_set_ui_2exp_si(one_minus_eps, 1, -prec / 4);
|
|
|
|
arf_sub_ui(one_minus_eps, one_minus_eps, 1, prec, ARF_RND_DOWN);
|
|
|
|
arf_neg(one_minus_eps, one_minus_eps);
|
|
|
|
|
|
|
|
acb_modular_fundamental_domain_approx(w, g, z, one_minus_eps, prec);
|
|
|
|
acb_modular_transform(w2, g, z, prec);
|
|
|
|
|
|
|
|
if (!psl2z_is_correct(g) || !acb_overlaps(w, w2))
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL (incorrect transformation)\n");
|
|
|
|
flint_printf("x = "); fmpq_print(x); flint_printf("\n\n");
|
|
|
|
flint_printf("y = "); fmpq_print(y); flint_printf("\n\n");
|
|
|
|
flint_printf("z = "); acb_printd(z, 50); flint_printf("\n\n");
|
|
|
|
flint_printf("w = "); acb_printd(w, 50); flint_printf("\n\n");
|
|
|
|
flint_printf("w2 = "); acb_printd(w2, 50); flint_printf("\n\n");
|
|
|
|
flint_printf("g = "); psl2z_print(g); flint_printf("\n\n");
|
2017-02-28 16:50:03 +01:00
|
|
|
flint_abort();
|
2014-10-01 19:12:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* success */
|
|
|
|
if (acb_modular_is_in_fundamental_domain(w, tol, prec))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check that g^(-1) * w contains x+yi */
|
|
|
|
psl2z_inv(g, g);
|
|
|
|
acb_modular_transform(w2, g, w, 2 + n_randint(state, 1000));
|
|
|
|
if (!arb_contains_fmpq(acb_realref(w2), x) ||
|
|
|
|
!arb_contains_fmpq(acb_imagref(w2), y))
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL (inverse containment)\n");
|
|
|
|
flint_printf("x = "); fmpq_print(x); flint_printf("\n\n");
|
|
|
|
flint_printf("y = "); fmpq_print(y); flint_printf("\n\n");
|
|
|
|
flint_printf("z = "); acb_printd(z, 50); flint_printf("\n\n");
|
|
|
|
flint_printf("w = "); acb_printd(w, 50); flint_printf("\n\n");
|
|
|
|
flint_printf("w2 = "); acb_printd(w2, 50); flint_printf("\n\n");
|
|
|
|
flint_printf("g = "); psl2z_print(g); flint_printf("\n\n");
|
2017-02-28 16:50:03 +01:00
|
|
|
flint_abort();
|
2014-10-01 19:12:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fmpq_clear(x);
|
|
|
|
fmpq_clear(y);
|
|
|
|
|
|
|
|
psl2z_clear(g);
|
|
|
|
acb_clear(z);
|
|
|
|
acb_clear(w);
|
|
|
|
acb_clear(w2);
|
|
|
|
arf_clear(one_minus_eps);
|
|
|
|
arf_clear(tol);
|
|
|
|
arb_clear(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
flint_randclear(state);
|
|
|
|
flint_cleanup();
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("PASS\n");
|
2014-10-01 19:12:18 +02:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|