Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241782 views
1
/*********************************************************************
2
3
(c) Copyright 2006-2010 Salman Baig and Chris Hall
4
5
This file is part of ELLFF
6
7
ELLFF is free software: you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation, either version 3 of the License, or
10
(at your option) any later version.
11
12
ELLFF is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20
*********************************************************************/
21
22
#ifndef HELPER_H
23
#define HELPER_H
24
25
#include <NTL/lzz_p.h>
26
#include <NTL/lzz_pE.h>
27
#include <NTL/lzz_pX.h>
28
#include <NTL/lzz_pEX.h>
29
#include <NTL/ZZX.h>
30
31
NTL_CLIENT
32
33
#define NO_CARRY 0
34
#define CARRY 1
35
36
// return a modulus appropriate for F_q=F_{p^d}
37
38
void get_modulus(zz_pX& pi, int p, int d);
39
40
// return moduli pi_1,pi_2 for extensions F_q/F_p,F_{q^d}/F_q and zero of pi_1
41
void get_modulus(zz_pX& pi_1, zz_pX& pi_2, zz_pX& a, int p, int d1, int d2);
42
43
// setup F_{p^d} with canonical irreducible in F_p[x]
44
45
void init_NTL_ff(int p, int d, int precompute_inverses=1,
46
int precompute_square_roots=1, int precompute_legendre_char=1,
47
int precompute_pth_frobenius_map=1);
48
void init_NTL_ff(int p, int d1, int d2, int precompute_inverses,
49
int precompute_square_roots, int precompute_legendre_char,
50
int precompute_pth_frobenius_map);
51
52
// compare elements in F_p[x] ordered by degree then leading coefficient
53
54
extern long operator<(zz_pX& f, zz_pX& g);
55
extern inline long operator<=(zz_pX& f, zz_pX& g);
56
extern inline long operator>( zz_pX& f, zz_pX& g);
57
extern inline long operator>=(zz_pX& f, zz_pX& g);
58
59
// compare elements of F_q
60
61
extern long operator<(zz_pE& x, zz_pE& y);
62
extern inline long operator<=(zz_pE& f, zz_pE& g);
63
extern inline long operator>(zz_pE& f, zz_pE& g);
64
extern inline long operator>=(zz_pE& f, zz_pE& g);
65
66
// convert elt of F_p[x] to int using coefficients as base-p digits
67
// used to determine index of elt in table
68
69
extern unsigned long to_ulong(const zz_pX& x);
70
extern unsigned long to_ulong(zz_pE& x);
71
72
extern void from_ulong(unsigned long ul, zz_pX& x);
73
extern void from_ulong(unsigned long ul, zz_pE& x);
74
75
// increment polynomial as if coefficients were base-p digits of an
76
// integer. corresponding sequence of polynomials is a so-called lexical
77
// ordering.
78
79
extern int inc(zz_pX& x, long max_deg);
80
extern int inc(zz_pEX& x, long max_deg);
81
82
// replaces x with next element in 'lexical ordering' of F_q
83
84
extern int inc(zz_pE& x);
85
86
// evaluate polynomial f at x
87
88
extern zz_pE eval(const zz_pX& f, const zz_pE& x);
89
extern ZZ eval(const ZZX& f, const ZZ& x);
90
91
// convert a long to a string
92
93
extern char *ltoa(long i);
94
95
// compute x^e
96
97
extern zz_pE operator^(const zz_pE& x, const int e);
98
extern zz_pEX operator^(const zz_pEX& x, const int e);
99
100
#endif // HELPER_H
101
102