From 0d96be37f81f192e5031b5a0153f128212c70e02 Mon Sep 17 00:00:00 2001 From: Pascal Date: Wed, 23 Mar 2016 18:23:19 +0100 Subject: [PATCH] add parity in char (simpler to have on logs) --- acb_dirichlet.h | 24 ++++++++++++++++++- acb_dirichlet/char_conrey.c | 3 ++- .../{char_is_odd.c => conrey_parity.c} | 6 ++--- acb_dirichlet/test/t-thetanull.c | 2 +- 4 files changed, 29 insertions(+), 6 deletions(-) rename acb_dirichlet/{char_is_odd.c => conrey_parity.c} (89%) diff --git a/acb_dirichlet.h b/acb_dirichlet.h index 3279cd39..fb1e7c2a 100644 --- a/acb_dirichlet.h +++ b/acb_dirichlet.h @@ -1,6 +1,7 @@ /* Copyright (C) 2015 Jonathan Bober Copyright (C) 2016 Fredrik Johansson + Copyright (C) 2016 Pascal Molin This file is part of Arb. @@ -13,6 +14,12 @@ #ifndef ACB_DIRICHLET_H #define ACB_DIRICHLET_H +#ifdef ACB_INLINES_C +#define ACB_INLINE +#else +#define ACB_INLINE static __inline__ +#endif + #include "acb.h" #include "dlog.h" @@ -59,11 +66,14 @@ void acb_dirichlet_eta(acb_t res, const acb_t s, slong prec); void acb_dirichlet_group_init(acb_dirichlet_group_t G, ulong q); void acb_dirichlet_group_clear(acb_dirichlet_group_t G); +void acb_dirichlet_group_dlog_precompute(acb_dirichlet_group_t G, ulong num); + void acb_dirichlet_conrey_init(acb_dirichlet_conrey_t x, const acb_dirichlet_group_t G); void acb_dirichlet_conrey_clear(acb_dirichlet_conrey_t x); void acb_dirichlet_conrey_print(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x); +int acb_dirichlet_conrey_parity(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x); void acb_dirichlet_conrey_log(acb_dirichlet_conrey_t x, const acb_dirichlet_group_t G, ulong m); void acb_dirichlet_conrey_one(acb_dirichlet_conrey_t x, const acb_dirichlet_group_t G); @@ -89,11 +99,24 @@ typedef struct ulong n; /* number */ ulong order; /* order */ ulong * expo; /* reduced exponents ( order * log[k] / gcd( ) ) */ + int parity; /* 0 for even char, 1 for odd */ } acb_dirichlet_char_struct; typedef acb_dirichlet_char_struct acb_dirichlet_char_t[1]; +ACB_INLINE int +acb_dirichlet_char_order(const acb_dirichlet_char_t chi) +{ + return chi->order; +} + +ACB_INLINE int +acb_dirichlet_char_parity(const acb_dirichlet_char_t chi) +{ + return chi->parity; +} + void acb_dirichlet_char_init(acb_dirichlet_char_t chi, const acb_dirichlet_group_t G); void acb_dirichlet_char_clear(acb_dirichlet_char_t chi); void acb_dirichlet_char_print(const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi); @@ -129,4 +152,3 @@ void acb_dirichlet_arb_quadratic_powers(arb_ptr v, slong nv, const arb_t x, slon #endif #endif - diff --git a/acb_dirichlet/char_conrey.c b/acb_dirichlet/char_conrey.c index 8414534f..c295c011 100644 --- a/acb_dirichlet/char_conrey.c +++ b/acb_dirichlet/char_conrey.c @@ -33,9 +33,10 @@ acb_dirichlet_char_conrey(acb_dirichlet_char_t chi, const acb_dirichlet_group_t ulong k; chi->q = G->q; chi->n = x->n; + chi->parity = acb_dirichlet_conrey_parity(G, x); for (k = 0; k < G->num; k++) - chi->expo[k] = (x->log[k] * G->PHI[k]) % G->expo; + chi->expo[k] = (x->log[k] * G->PHI[k]) % G->expo; /* optional: divide by gcd to obtain true order */ acb_dirichlet_char_normalize(chi, G); diff --git a/acb_dirichlet/char_is_odd.c b/acb_dirichlet/conrey_parity.c similarity index 89% rename from acb_dirichlet/char_is_odd.c rename to acb_dirichlet/conrey_parity.c index cb5d0502..ede8aaf6 100644 --- a/acb_dirichlet/char_is_odd.c +++ b/acb_dirichlet/conrey_parity.c @@ -26,14 +26,14 @@ #include "acb_dirichlet.h" int -acb_dirichlet_char_is_odd(const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi) +acb_dirichlet_conrey_parity(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x) { - slong k, odd = 0; + int k, odd = 0; for (k = 0; k < G->num; k++) { if (k == 1 && G->neven == 2) continue; - if (chi->expo[k] % 2 == 1) + if (x->log[k] % 2) odd = 1 - odd; } return odd; diff --git a/acb_dirichlet/test/t-thetanull.c b/acb_dirichlet/test/t-thetanull.c index dc7ca96a..e57889a2 100644 --- a/acb_dirichlet/test/t-thetanull.c +++ b/acb_dirichlet/test/t-thetanull.c @@ -100,7 +100,7 @@ int main() /* flint_printf("Theta(chi_%wu(%wu)) (m=%wu)\n", q, chi->n, m); */ - tt = acb_dirichlet_char_is_odd(G, chi) ? kt : t; + tt = acb_dirichlet_char_parity(chi) ? kt : t; for (k = 1; k < nv; k++) if (v[k] != CHI_NULL) acb_addmul_arb(sum, z + (v[k] * m), tt + k, prec);