diff --git a/dirichlet.h b/dirichlet.h index 316ed036..6d24988b 100644 --- a/dirichlet.h +++ b/dirichlet.h @@ -144,6 +144,12 @@ dirichlet_char_is_real(const dirichlet_group_t G, const dirichlet_char_t chi) return G->q <= 4 || (nmod_mul(chi->n, chi->n, G->mod) == 1); } +DIRICHLET_INLINE int +dirichlet_char_is_primitive(const dirichlet_group_t G, const dirichlet_char_t chi) +{ + return (dirichlet_conductor_char(G, chi) == G->q); +} + ulong dirichlet_chi(const dirichlet_group_t G, const dirichlet_char_t chi, ulong n); void dirichlet_vec_set_null(ulong *v, const dirichlet_group_t G, slong nv); diff --git a/doc/source/dirichlet.rst b/doc/source/dirichlet.rst index c66d4078..f0d329f5 100644 --- a/doc/source/dirichlet.rst +++ b/doc/source/dirichlet.rst @@ -224,6 +224,10 @@ level of *number* and *char* object. Both case require no discrete log computati Returns 1 if *chi* is a real character (iff it has order `\leq 2`). +.. function:: int dirichlet_char_is_primitive(const dirichlet_group_t G, const dirichlet_char_t chi) + + Returns 1 if *chi* is primitive (iff its conductor is exactly *q*). + Character evaluation -------------------------------------------------------------------------------