2016-04-26 17:20:05 +02:00
|
|
|
/*
|
2016-02-21 23:23:51 +01:00
|
|
|
Copyright (C) 2015 Jonathan Bober
|
2016-02-15 16:31:15 +01:00
|
|
|
Copyright (C) 2016 Fredrik Johansson
|
2016-03-23 18:23:19 +01:00
|
|
|
Copyright (C) 2016 Pascal Molin
|
2016-02-15 16:31:15 +01:00
|
|
|
|
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-15 16:31:15 +01:00
|
|
|
|
|
|
|
#ifndef ACB_DIRICHLET_H
|
|
|
|
#define ACB_DIRICHLET_H
|
|
|
|
|
2016-03-29 14:04:08 +01:00
|
|
|
#ifdef ACB_DIRICHLET_INLINES_C
|
|
|
|
#define ACB_DIRICHLET_INLINE
|
2016-03-23 18:23:19 +01:00
|
|
|
#else
|
2016-03-29 14:04:08 +01:00
|
|
|
#define ACB_DIRICHLET_INLINE static __inline__
|
2016-03-23 18:23:19 +01:00
|
|
|
#endif
|
|
|
|
|
2016-02-15 16:31:15 +01:00
|
|
|
#include "acb.h"
|
2016-03-22 11:29:21 +01:00
|
|
|
#include "dlog.h"
|
2016-02-15 16:31:15 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-02-21 23:23:51 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ulong q; /* modulus */
|
2016-03-23 12:53:08 +01:00
|
|
|
nmod_t mod; /* modulus with precomputed inverse */
|
2016-02-21 23:23:51 +01:00
|
|
|
ulong q_even; /* even part of modulus */
|
|
|
|
ulong q_odd; /* odd part of modulus */
|
2016-02-24 11:06:49 +01:00
|
|
|
ulong phi_q; /* phi(q) = group size */
|
|
|
|
ulong expo; /* group exponent = lcm(phi(q_even), phi(p[k]^e[k]) ) */
|
2016-02-26 16:49:26 +01:00
|
|
|
slong neven; /* number of even components (in 0,1,2)*/
|
2016-02-24 11:06:49 +01:00
|
|
|
slong num; /* number of prime components (even + odd) */
|
|
|
|
ulong * primes; /* primes p[k] */
|
2016-02-21 23:23:51 +01:00
|
|
|
ulong * exponents; /* exponents e[k] */
|
2016-02-26 16:49:26 +01:00
|
|
|
ulong * primepowers; /* powers p[k]^[k] */
|
|
|
|
ulong * generators; /* generator for each prime p[k] lifted mod q */
|
2016-02-24 11:06:49 +01:00
|
|
|
ulong * phi; /* phi(k) = phi(p[k]^e[k]) */
|
|
|
|
ulong * PHI; /* PHI(k) = expo / phi(k) */
|
2016-03-23 12:53:08 +01:00
|
|
|
dlog_precomp_t * dlog; /* precomputed data for discrete log mod p^e */
|
2016-02-21 23:23:51 +01:00
|
|
|
}
|
|
|
|
acb_dirichlet_group_struct;
|
|
|
|
|
|
|
|
typedef acb_dirichlet_group_struct acb_dirichlet_group_t[1];
|
|
|
|
|
2016-06-15 11:33:01 +02:00
|
|
|
ACB_DIRICHLET_INLINE ulong
|
|
|
|
acb_dirichlet_group_size(const acb_dirichlet_group_t G)
|
|
|
|
{
|
|
|
|
return G->phi_q;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2016-06-15 12:23:24 +02:00
|
|
|
/* properties of elements without log */
|
|
|
|
|
|
|
|
ulong acb_dirichlet_number_primitive(const acb_dirichlet_group_t G);
|
|
|
|
ulong acb_dirichlet_conductor_ui(const acb_dirichlet_group_t G, ulong a);
|
2016-06-15 14:04:27 +02:00
|
|
|
int acb_dirichlet_parity_ui(const acb_dirichlet_group_t G, ulong a);
|
2016-06-15 12:23:24 +02:00
|
|
|
/*
|
|
|
|
ulong acb_dirichlet_order_ui(const acb_dirichlet_groupt_t G, ulong a);
|
|
|
|
*/
|
|
|
|
|
2016-02-24 11:06:49 +01:00
|
|
|
/* elements of the group, keep both number and log */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ulong n; /* number */
|
|
|
|
ulong * log; /* s.t. prod generators[k]^log[k] = number */
|
|
|
|
}
|
2016-03-22 11:29:21 +01:00
|
|
|
acb_dirichlet_conrey_struct;
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-03-22 11:29:21 +01:00
|
|
|
typedef acb_dirichlet_conrey_struct acb_dirichlet_conrey_t[1];
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-02-16 02:55:12 +01:00
|
|
|
void _acb_dirichlet_euler_product_real_ui(arb_t res, ulong s,
|
|
|
|
const signed char * chi, int mod, int reciprocal, slong prec);
|
|
|
|
|
2016-02-15 16:31:15 +01:00
|
|
|
void acb_dirichlet_eta(acb_t res, const acb_t s, slong prec);
|
|
|
|
|
2016-03-22 11:29:21 +01:00
|
|
|
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);
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-03-23 18:23:19 +01:00
|
|
|
int acb_dirichlet_conrey_parity(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x);
|
2016-06-15 11:33:01 +02:00
|
|
|
ulong acb_dirichlet_conrey_conductor(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x);
|
2016-03-22 11:29:21 +01:00
|
|
|
void acb_dirichlet_conrey_log(acb_dirichlet_conrey_t x, const acb_dirichlet_group_t G, ulong m);
|
2016-02-26 16:49:26 +01:00
|
|
|
|
2016-03-22 11:29:21 +01:00
|
|
|
void acb_dirichlet_conrey_one(acb_dirichlet_conrey_t x, const acb_dirichlet_group_t G);
|
|
|
|
void acb_dirichlet_conrey_first_primitive(acb_dirichlet_conrey_t x, const acb_dirichlet_group_t G);
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-03-22 11:29:21 +01:00
|
|
|
int acb_dirichlet_conrey_next(acb_dirichlet_conrey_t x, const acb_dirichlet_group_t G);
|
|
|
|
int acb_dirichlet_conrey_next_primitive(acb_dirichlet_conrey_t x, const acb_dirichlet_group_t G);
|
2016-02-29 00:13:58 +01:00
|
|
|
|
2016-06-15 11:33:01 +02:00
|
|
|
void acb_dirichlet_conrey_mul(acb_dirichlet_conrey_t c, const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t a, const acb_dirichlet_conrey_t b);
|
|
|
|
void acb_dirichlet_conrey_pow(acb_dirichlet_conrey_t c, const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t a, ulong n);
|
|
|
|
|
2016-03-29 14:04:08 +01:00
|
|
|
#define ACB_DIRICHLET_CHI_NULL UWORD_MAX
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-04-05 12:18:39 +02:00
|
|
|
ulong acb_dirichlet_ui_pairing_conrey(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t a, const acb_dirichlet_conrey_t b);
|
|
|
|
ulong acb_dirichlet_ui_pairing(const acb_dirichlet_group_t G, ulong m, ulong n);
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-04-05 12:18:39 +02:00
|
|
|
void acb_dirichlet_pairing_conrey(acb_t res, const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t a, const acb_dirichlet_conrey_t b, slong prec);
|
|
|
|
void acb_dirichlet_pairing(acb_t res, const acb_dirichlet_group_t G, ulong m, ulong n, slong prec);
|
2016-02-21 23:23:51 +01:00
|
|
|
|
2016-02-24 11:06:49 +01:00
|
|
|
/* introducing character type */
|
|
|
|
|
2016-06-15 11:33:01 +02:00
|
|
|
/* character = reduced exponents, keep order, number and conductor */
|
2016-02-24 11:06:49 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2016-03-29 14:37:21 +01:00
|
|
|
ulong q; /* modulus */
|
2016-04-05 11:55:04 +02:00
|
|
|
/*? acb_dirichet_conrey_struct n; */
|
2016-03-29 14:37:21 +01:00
|
|
|
ulong n; /* number */
|
|
|
|
ulong order; /* order */
|
|
|
|
ulong * expo; /* reduced exponents ( order * log[k] / gcd( ) ) */
|
|
|
|
int parity; /* 0 for even char, 1 for odd */
|
2016-06-15 11:33:01 +02:00
|
|
|
ulong conductor;
|
2016-02-24 11:06:49 +01:00
|
|
|
}
|
|
|
|
acb_dirichlet_char_struct;
|
|
|
|
|
|
|
|
typedef acb_dirichlet_char_struct acb_dirichlet_char_t[1];
|
|
|
|
|
2016-04-05 11:55:04 +02:00
|
|
|
ACB_DIRICHLET_INLINE ulong
|
2016-03-23 18:23:19 +01:00
|
|
|
acb_dirichlet_char_order(const acb_dirichlet_char_t chi)
|
|
|
|
{
|
|
|
|
return chi->order;
|
|
|
|
}
|
|
|
|
|
2016-03-29 14:04:08 +01:00
|
|
|
ACB_DIRICHLET_INLINE int
|
2016-03-23 18:23:19 +01:00
|
|
|
acb_dirichlet_char_parity(const acb_dirichlet_char_t chi)
|
|
|
|
{
|
|
|
|
return chi->parity;
|
|
|
|
}
|
|
|
|
|
2016-02-24 11:06:49 +01:00
|
|
|
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);
|
2016-03-22 11:29:21 +01:00
|
|
|
void acb_dirichlet_char_print(const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi);
|
2016-02-24 11:06:49 +01:00
|
|
|
|
|
|
|
void acb_dirichlet_char(acb_dirichlet_char_t chi, const acb_dirichlet_group_t G, ulong n);
|
2016-03-22 11:29:21 +01:00
|
|
|
void acb_dirichlet_char_conrey(acb_dirichlet_char_t chi, const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x);
|
|
|
|
void acb_dirichlet_char_normalize(acb_dirichlet_char_t chi, const acb_dirichlet_group_t G);
|
|
|
|
void acb_dirichlet_char_denormalize(acb_dirichlet_char_t chi, const acb_dirichlet_group_t G);
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-03-23 12:53:08 +01:00
|
|
|
ulong acb_dirichlet_char_conductor(const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi);
|
|
|
|
|
2016-03-22 11:29:21 +01:00
|
|
|
void acb_dirichlet_char_one(acb_dirichlet_char_t chi, const acb_dirichlet_group_t G);
|
|
|
|
void acb_dirichlet_char_first_primitive(acb_dirichlet_char_t chi, const acb_dirichlet_group_t G);
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-04-12 15:07:04 +02:00
|
|
|
ulong acb_dirichlet_ui_chi_conrey(const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, const acb_dirichlet_conrey_t x);
|
2016-04-05 12:18:39 +02:00
|
|
|
ulong acb_dirichlet_ui_chi(const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, ulong n);
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-04-05 12:18:39 +02:00
|
|
|
void acb_dirichlet_ui_vec_set_null(ulong *v, const acb_dirichlet_group_t G, slong nv);
|
|
|
|
void acb_dirichlet_ui_chi_vec_loop(ulong *v, const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, slong nv);
|
|
|
|
void acb_dirichlet_ui_chi_vec_primeloop(ulong *v, const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, slong nv);
|
|
|
|
void acb_dirichlet_ui_chi_vec_sieve(ulong *v, const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, slong nv);
|
|
|
|
void acb_dirichlet_ui_chi_vec(ulong *v, const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, slong nv);
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-04-12 15:07:04 +02:00
|
|
|
/* precompute powers of a root of unity */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ulong order;
|
|
|
|
acb_ptr z;
|
|
|
|
ulong m;
|
|
|
|
ulong M;
|
|
|
|
acb_ptr Z;
|
|
|
|
}
|
|
|
|
acb_dirichlet_powers_struct;
|
|
|
|
|
|
|
|
typedef acb_dirichlet_powers_struct acb_dirichlet_powers_t[1];
|
|
|
|
|
|
|
|
void acb_dirichlet_powers_init(acb_dirichlet_powers_t t, ulong order, slong num, slong prec);
|
|
|
|
void acb_dirichlet_powers_clear(acb_dirichlet_powers_t t);
|
|
|
|
void acb_dirichlet_power(acb_t z, const acb_dirichlet_powers_t t, ulong n, slong prec);
|
|
|
|
|
2016-04-05 12:18:39 +02:00
|
|
|
void acb_dirichlet_nth_root(acb_t res, ulong order, slong prec);
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-04-05 12:18:39 +02:00
|
|
|
void acb_dirichlet_chi(acb_t res, const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, ulong n, slong prec);
|
2016-04-12 15:07:04 +02:00
|
|
|
void acb_dirichlet_chi_vec(acb_ptr v, const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, slong nv, slong prec);
|
2016-03-23 12:53:08 +01:00
|
|
|
|
|
|
|
void acb_dirichlet_arb_quadratic_powers(arb_ptr v, slong nv, const arb_t x, slong prec);
|
2016-04-12 15:07:04 +02:00
|
|
|
|
|
|
|
ulong acb_dirichlet_theta_length_d(ulong q, double x, slong prec);
|
|
|
|
ulong acb_dirichlet_theta_length(ulong q, const arb_t x, slong prec);
|
|
|
|
void acb_dirichlet_chi_theta(acb_t res, const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, const arb_t x, slong prec);
|
|
|
|
|
|
|
|
void acb_dirichlet_gauss_sum_naive(acb_t res, const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, slong prec);
|
|
|
|
void acb_dirichlet_gauss_sum_theta(acb_t res, const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, slong prec);
|
|
|
|
void acb_dirichlet_gauss_sum(acb_t res, const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, slong prec);
|
2016-03-23 12:53:08 +01:00
|
|
|
|
2016-02-15 16:31:15 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|