FAAST  0.2.1
Types.hpp
1 /*
2  This file is part of the FAAST library.
3 
4  Copyright (c) 2009 Luca De Feo and Éric Schost.
5 
6  The most recent version of FAAST is available at http://www.lix.polytechnique.fr/~defeo/FAAST
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 2
11  of the License, or (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; see file COPYING. If not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 #ifndef TYPES_H_
23 #define TYPES_H_
24 
25 #include <NTL/ZZ.h>
26 #include <NTL/lzz_p.h>
27 #include <NTL/lzz_pE.h>
28 #include <NTL/lzz_pX.h>
29 #include <NTL/lzz_pEX.h>
30 #include <NTL/mat_lzz_p.h>
31 #include <NTL/ZZ_p.h>
32 #include <NTL/ZZ_pE.h>
33 #include <NTL/ZZ_pX.h>
34 #include <NTL/ZZ_pEX.h>
35 #include <NTL/mat_ZZ_p.h>
36 #include <NTL/GF2.h>
37 #include <NTL/GF2E.h>
38 #include <NTL/GF2X.h>
39 #include <NTL/GF2EX.h>
40 #include <NTL/mat_GF2.h>
41 #include "NTLhacks.hpp"
42 
43 NTL_CLIENT
44 
45 namespace FAAST {
47  struct Constants {
48  mutable long HalfGCD_CROSSOVER;
49  Constants(const long h) : HalfGCD_CROSSOVER(h) {}
50  };
51 
66  class ZZ_auto : public ZZ {
67  public:
68  ZZ_auto() {}
69  ZZ_auto(const long i) : ZZ(to_ZZ(i)) {}
70  ZZ_auto(const ZZ& i) : ZZ(i) {}
71  ZZ_auto& operator=(const ZZ_auto& i) { ZZ::operator=(i); return *this; }
72  ZZ_auto& operator=(const ZZ& i) { ZZ::operator=(i); return *this; }
73  ZZ_auto& operator=(const long i) { ZZ::operator=(i); return *this; }
74  operator long() const {
75  return to_long(*this);
76  }
77  };
78 
144  struct zz_p_Algebra {
146  typedef zz_p GFp;
148  typedef mat_zz_p MatGFp;
150  typedef vec_zz_p VecGFp;
152  typedef zz_pX GFpX;
154  typedef zz_pE GFpE;
156  typedef zz_pEX GFpEX;
158  typedef long BigInt;
165  typedef struct {
167  zz_pContext p;
169  zz_pEContext P;
170  } Context;
172  typedef zz_pXModulus GFpXModulus;
174  typedef zz_pXMultiplier GFpXMultiplier;
175 
177  static const Constants consts;
179  static char const * const name;
180  };
181 
188  struct ZZ_p_Algebra {
190  typedef ZZ_p GFp;
192  typedef mat_ZZ_p MatGFp;
194  typedef vec_ZZ_p VecGFp;
196  typedef ZZ_pX GFpX;
198  typedef ZZ_pE GFpE;
200  typedef ZZ_pEX GFpEX;
202  typedef ZZ_auto BigInt;
208  typedef struct {
210  ZZ_pContext p;
212  ZZ_pEContext P;
213  } Context;
215  typedef ZZ_pXModulus GFpXModulus;
217  typedef ZZ_pXMultiplier GFpXMultiplier;
218 
220  static const Constants consts;
222  static char const * const name;
223  };
224 
230  struct GF2_Algebra {
232  typedef GF2 GFp;
234  typedef mat_GF2 MatGFp;
236  typedef vec_GF2 VecGFp;
238  typedef GF2X GFpX;
240  typedef GF2E GFpE;
242  typedef GF2EX GFpEX;
244  typedef int BigInt;
250  typedef struct {
252  GF2EContext P;
253  } Context;
255  typedef GF2XModulus GFpXModulus;
257  typedef GF2XTransMultiplier GFpXMultiplier;
258 
260  static const Constants consts;
262  static char const * const name;
263  };
264 
266 }
267 
268 #endif /*TYPES_H_*/