/*********************************************************************12(c) Copyright 2006-2010 Salman Baig and Chris Hall34This file is part of ELLFF56ELLFF is free software: you can redistribute it and/or modify7it under the terms of the GNU General Public License as published by8the Free Software Foundation, either version 3 of the License, or9(at your option) any later version.1011ELLFF is distributed in the hope that it will be useful,12but WITHOUT ANY WARRANTY; without even the implied warranty of13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14GNU General Public License for more details.1516You should have received a copy of the GNU General Public License17along with this program. If not, see <http://www.gnu.org/licenses/>.1819*********************************************************************/2021#ifndef HELPER_H22#define HELPER_H2324#include <NTL/lzz_p.h>25#include <NTL/lzz_pE.h>26#include <NTL/lzz_pX.h>27#include <NTL/lzz_pEX.h>28#include <NTL/ZZX.h>2930NTL_CLIENT3132#define NO_CARRY 033#define CARRY 13435// return a modulus appropriate for F_q=F_{p^d}3637void get_modulus(zz_pX& pi, int p, int d);3839// return moduli pi_1,pi_2 for extensions F_q/F_p,F_{q^d}/F_q and zero of pi_140void get_modulus(zz_pX& pi_1, zz_pX& pi_2, zz_pX& a, int p, int d1, int d2);4142// setup F_{p^d} with canonical irreducible in F_p[x]4344void init_NTL_ff(int p, int d, int precompute_inverses=1,45int precompute_square_roots=1, int precompute_legendre_char=1,46int precompute_pth_frobenius_map=1);47void init_NTL_ff(int p, int d1, int d2, int precompute_inverses,48int precompute_square_roots, int precompute_legendre_char,49int precompute_pth_frobenius_map);5051// compare elements in F_p[x] ordered by degree then leading coefficient5253extern long operator<(zz_pX& f, zz_pX& g);54extern inline long operator<=(zz_pX& f, zz_pX& g);55extern inline long operator>( zz_pX& f, zz_pX& g);56extern inline long operator>=(zz_pX& f, zz_pX& g);5758// compare elements of F_q5960extern long operator<(zz_pE& x, zz_pE& y);61extern inline long operator<=(zz_pE& f, zz_pE& g);62extern inline long operator>(zz_pE& f, zz_pE& g);63extern inline long operator>=(zz_pE& f, zz_pE& g);6465// convert elt of F_p[x] to int using coefficients as base-p digits66// used to determine index of elt in table6768extern unsigned long to_ulong(const zz_pX& x);69extern unsigned long to_ulong(zz_pE& x);7071extern void from_ulong(unsigned long ul, zz_pX& x);72extern void from_ulong(unsigned long ul, zz_pE& x);7374// increment polynomial as if coefficients were base-p digits of an75// integer. corresponding sequence of polynomials is a so-called lexical76// ordering.7778extern int inc(zz_pX& x, long max_deg);79extern int inc(zz_pEX& x, long max_deg);8081// replaces x with next element in 'lexical ordering' of F_q8283extern int inc(zz_pE& x);8485// evaluate polynomial f at x8687extern zz_pE eval(const zz_pX& f, const zz_pE& x);88extern ZZ eval(const ZZX& f, const ZZ& x);8990// convert a long to a string9192extern char *ltoa(long i);9394// compute x^e9596extern zz_pE operator^(const zz_pE& x, const int e);97extern zz_pEX operator^(const zz_pEX& x, const int e);9899#endif // HELPER_H100101102