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 LZZ_PEEXTRA_H
23
#define LZZ_PEEXTRA_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
class zz_pEExtraInfoT {
34
private:
35
zz_pEExtraInfoT(); // do not use
36
37
zz_pE non_square;
38
39
public:
40
// table of multiplicative inverses
41
class invTable {
42
public:
43
invTable(long q);
44
~invTable();
45
46
zz_pE *table;
47
};
48
49
// table of square roots
50
class rootTable {
51
public:
52
rootTable(long q);
53
~rootTable();
54
55
zz_pE *table;
56
};
57
58
zz_pE square_root(zz_pE& x);
59
60
// Legendre character
61
class legendreChar {
62
public:
63
legendreChar(long q);
64
~legendreChar();
65
66
char *table;
67
};
68
69
int legendre_char(zz_pE& x);
70
71
// Frobenius map
72
class frobeniusMap {
73
public:
74
frobeniusMap(long q);
75
~frobeniusMap();
76
77
unsigned long *map;
78
};
79
80
void frobenius(zz_pE& x, zz_pE& y);
81
unsigned long frobenius(unsigned long x);
82
83
zz_pE *frob_of_basis;
84
85
public:
86
long ref_count; // for garbage collection
87
88
long q;
89
90
zz_pEExtraInfoT(int precompute_inverses,
91
int precompute_square_roots,
92
int precompute_legendre_char,
93
int precompute_pth_frobenius_map);
94
95
~zz_pEExtraInfoT();
96
97
invTable *inv_table;
98
rootTable *root_table;
99
legendreChar *legendre_table;
100
frobeniusMap *frob_map;
101
};
102
103
typedef zz_pEExtraInfoT* zz_pEExtraInfoPtr;
104
105
class zz_pEExtraContext {
106
private:
107
zz_pEExtraInfoPtr ptr;
108
109
public:
110
void save();
111
void restore() const;
112
113
zz_pEExtraContext() { ptr = NULL; }
114
zz_pEExtraContext(int precompute_inverses,
115
int precompute_square_roots,
116
int precompute_legendre_char,
117
int precompute_pth_frobenius_map);
118
119
zz_pEExtraContext(const zz_pEExtraContext&);
120
121
zz_pEExtraContext& operator=(const zz_pEExtraContext&);
122
123
~zz_pEExtraContext();
124
};
125
126
extern zz_pEExtraInfoPtr zz_pEExtraInfo;
127
128
#endif // LZZ_PEEXTRA_H
129
130