#ifdef T
#include "templates.h"
int TEMPLATE(T, is_square)(const TEMPLATE(T, t) op,
const TEMPLATE(T, ctx_t) ctx)
{
fmpz_t ord;
TEMPLATE(T, t) pow;
int is_square = 0;
#if defined(FQ_NMOD_H) || defined(FQ_ZECH_H)
if (TEMPLATE(T, is_zero)(op, ctx) || TEMPLATE(T, is_one)(op, ctx) ||
TEMPLATE(T, ctx_prime)(ctx) == 2)
#else
if (TEMPLATE(T, is_zero)(op, ctx) || TEMPLATE(T, is_one)(op, ctx) ||
fmpz_cmp_ui(TEMPLATE(T, ctx_prime)(ctx), 2) == 0)
#endif
{
return 1;
}
fmpz_init(ord);
TEMPLATE(T, init)(pow, ctx);
TEMPLATE(T, ctx_order)(ord, ctx);
fmpz_sub_ui(ord, ord, 1);
fmpz_tdiv_q_2exp(ord, ord, 1);
TEMPLATE(T, pow)(pow, op, ord, ctx);
is_square = TEMPLATE(T, is_one)(pow, ctx);
fmpz_clear(ord);
TEMPLATE(T, clear)(pow, ctx);
return is_square;
}
#endif