int main() { slong iter; flint_rand_t state; flint_printf("psl2z_inv...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 10000; iter++) { psl2z_t f, g, h, i; psl2z_init(f); psl2z_init(g); psl2z_init(h); psl2z_init(i); psl2z_randtest(f, state, n_randint(state, 100)); psl2z_randtest(g, state, n_randint(state, 100)); psl2z_randtest(h, state, n_randint(state, 100)); psl2z_inv(g, f); psl2z_mul(h, f, g); psl2z_one(i); if (!psl2z_equal(h, i) || !psl2z_is_correct(g)) { flint_printf("FAIL\n"); flint_printf("f = "); psl2z_print(f); flint_printf("\n"); flint_printf("g = "); psl2z_print(g); flint_printf("\n"); flint_printf("h = "); psl2z_print(h); flint_printf("\n"); flint_printf("i = "); psl2z_print(i); flint_printf("\n"); abort(); } psl2z_inv(f, f); if (!psl2z_equal(f, g) || !psl2z_is_correct(f)) { flint_printf("FAIL (aliasing)\n"); flint_printf("f = "); psl2z_print(f); flint_printf("\n"); flint_printf("g = "); psl2z_print(g); flint_printf("\n"); abort(); } psl2z_clear(f); psl2z_clear(g); psl2z_clear(h); psl2z_clear(i); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("fundamental_domain_approx...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++) { fmpq_t x, y; psl2z_t g; arf_t one_minus_eps, tol; acb_t z, w, w2; arb_t t; slong prec; 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 */ fmpq_randtest(x, state, 1 + n_randint(state, 500)); do { fmpq_randtest(y, state, 1 + n_randint(state, 500)); } while (fmpz_sgn(fmpq_numref(y)) <= 0); /* pick a tolerance */ arf_set_ui_2exp_si(tol, 1, -(slong) n_randint(state, 500)); /* now increase the precision until convergence */ for (prec = 32; ; prec *= 2) { if (prec > 16384) { 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"); abort(); } 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)) { 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"); abort(); } /* 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)) { 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"); abort(); } 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(); flint_printf("PASS\n"); return EXIT_SUCCESS; }