1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
Copyright (C) 2014 Fredrik Johansson
This file is part of FLINT.
FLINT 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 3 of the License, or
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/
#include "acb.h"
#include "acb_modular.h"
int
acb_modular_is_in_fundamental_domain(const acb_t z, const arf_t tol, slong prec)
{
arb_t t;
arb_init(t);
/* require re(w) + 1/2 >= 0 */
arb_set_ui(t, 1);
arb_mul_2exp_si(t, t, -1);
arb_add(t, t, acb_realref(z), prec);
arb_add_arf(t, t, tol, prec);
if (!arb_is_nonnegative(t))
{
arb_clear(t);
return 0;
}
/* require re(w) - 1/2 <= 0 */
arb_set_ui(t, 1);
arb_mul_2exp_si(t, t, -1);
arb_sub(t, acb_realref(z), t, prec);
arb_sub_arf(t, t, tol, prec);
if (!arb_is_nonpositive(t))
{
arb_clear(t);
return 0;
}
/* require |w| >= 1 - tol, i.e. |w| - 1 + tol >= 0 */
acb_abs(t, z, prec);
arb_sub_ui(t, t, 1, prec);
arb_add_arf(t, t, tol, prec);
if (!arb_is_nonnegative(t))
{
arb_clear(t);
return 0;
}
arb_clear(t);
return 1;
}