simplify equality tests

This commit is contained in:
Pascal 2016-09-14 19:35:45 +02:00
parent bf717dafb3
commit be38425f4e
5 changed files with 25 additions and 12 deletions

View file

@ -103,7 +103,12 @@ acb_dirichlet_conrey_copy(acb_dirichlet_conrey_t x, const acb_dirichlet_group_t
x->log[k] = y->log[k];
}
int acb_dirichlet_conrey_eq(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x, const acb_dirichlet_conrey_t y);
ACB_DIRICHLET_INLINE int
acb_dirichlet_conrey_eq(const acb_dirichlet_conrey_t x, const acb_dirichlet_conrey_t y)
{
return (x->n == y->n);
}
int acb_dirichlet_conrey_eq_deep(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x, const acb_dirichlet_conrey_t y);
int acb_dirichlet_conrey_parity(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x);
ulong acb_dirichlet_conrey_conductor(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x);
ulong acb_dirichlet_conrey_order(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x);
@ -166,7 +171,12 @@ void acb_dirichlet_char_init(acb_dirichlet_char_t chi, const acb_dirichlet_group
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);
int acb_dirichlet_char_eq(const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi1, const acb_dirichlet_char_t chi2);
ACB_DIRICHLET_INLINE int
acb_dirichlet_char_eq(const acb_dirichlet_char_t chi1, const acb_dirichlet_char_t chi2)
{
return (chi1->q == chi2->q && chi1->x->n == chi2->x->n);
}
int acb_dirichlet_char_eq_deep(const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi1, const acb_dirichlet_char_t chi2);
ACB_DIRICHLET_INLINE int
acb_dirichlet_char_is_principal(const acb_dirichlet_char_t chi)
{

View file

@ -12,7 +12,7 @@
#include "acb_dirichlet.h"
int
acb_dirichlet_char_eq(const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi1, const acb_dirichlet_char_t chi2)
acb_dirichlet_char_eq_deep(const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi1, const acb_dirichlet_char_t chi2)
{
acb_dirichlet_conrey_t x, y;
@ -25,13 +25,13 @@ acb_dirichlet_char_eq(const acb_dirichlet_group_t G, const acb_dirichlet_char_t
if (chi1->conductor != chi2->conductor)
return 0;
if (!acb_dirichlet_conrey_eq(G, chi1->x, chi2->x))
if (!acb_dirichlet_conrey_eq_deep(G, chi1->x, chi2->x))
return 0;
x->n = y->n = 1;
x->log = chi1->expo;
y->log = chi2->expo;
if (!acb_dirichlet_conrey_eq(G, x, y))
if (!acb_dirichlet_conrey_eq_deep(G, x, y))
return 0;
return 1;

View file

@ -12,7 +12,7 @@
#include "acb_dirichlet.h"
int
acb_dirichlet_conrey_eq(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x, const acb_dirichlet_conrey_t y)
acb_dirichlet_conrey_eq_deep(const acb_dirichlet_group_t G, const acb_dirichlet_conrey_t x, const acb_dirichlet_conrey_t y)
{
slong k;

View file

@ -43,7 +43,7 @@ int main()
{
int par;
ulong m, n;
ulong order, chim1, pairing, cond;
ulong order, chim1, pairing, cn, cm, cond;
do
m = n_randint(state, q);
@ -53,7 +53,7 @@ int main()
acb_dirichlet_conrey_log(x, G, m);
acb_dirichlet_char_conrey(chi2, G, x);
if (!acb_dirichlet_char_eq(G, chi, chi2))
if (!acb_dirichlet_char_eq_deep(G, chi, chi2))
{
flint_printf("FAIL: init char\n\n");
flint_printf("q = %wu\n\n", q);
@ -107,15 +107,18 @@ int main()
acb_dirichlet_char(chi2, G, n);
pairing = acb_dirichlet_ui_pairing(G, m, n);
cn = acb_dirichlet_ui_chi(G, chi, n) * (G->expo / chi->order.n);
cm = acb_dirichlet_ui_chi(G, chi2, m) * (G->expo / chi2->order.n);
if (pairing != acb_dirichlet_ui_chi(G, chi, n) * (G->expo / chi->order.n)
|| pairing != acb_dirichlet_ui_chi(G, chi2, m) * (G->expo / chi2->order.n))
if (pairing != cn || pairing != cm)
{
flint_printf("FAIL: pairing\n\n");
flint_printf("q = %wu\n\n", q);
flint_printf("m = %wu\n\n", m);
flint_printf("n = %wu\n\n", n);
flint_printf("chi(m,n) = %wu\n\n", pairing);
flint_printf("chi(m)(n) = %wu\n\n", cn);
flint_printf("chi(n)(m) = %wu\n\n", cm);
abort();
}
@ -123,7 +126,7 @@ int main()
acb_dirichlet_char_next(chi, G);
acb_dirichlet_char_conrey(chi2, G, x);
if (!acb_dirichlet_char_eq(G, chi, chi2))
if (!acb_dirichlet_char_eq_deep(G, chi, chi2))
{
flint_printf("FAIL: next char\n\n");
flint_printf("q = %wu\n\n", q);

View file

@ -120,7 +120,7 @@ int main()
m = acb_dirichlet_conrey_exp(x, G);
acb_dirichlet_conrey_log(y, G, m);
if (!acb_dirichlet_conrey_eq(G, x, y))
if (!acb_dirichlet_conrey_eq_deep(G, x, y))
{
flint_printf("FAIL: conrey exp and log\n\n");
flint_printf("q = %wu\n\n", q);