53 #include <NTL/vec_GF2.h>
54 #include <NTL/GF2EX.h>
55 #include <NTL/lzz_pEX.h>
67 vector<unsigned> gens;
91 PAlgebra(
unsigned mm,
unsigned pp = 2);
93 bool operator==(
const PAlgebra& other)
const;
94 bool operator!=(
const PAlgebra& other)
const {
return !(*
this==other);}
105 unsigned getM()
const {
return m; }
108 unsigned getP()
const {
return p; }
127 {
return (i<gens.size())? gens[i] : 0; }
131 {
return (i<ords.size())? abs(ords[i]) : 0; }
135 {
return (i<ords.size())? (ords[i]>0) :
false; }
141 {
return (i<nSlots)? T[i]: 0; }
145 {
return (t>0 && t<m)? Tidx[t]: -1; }
149 {
return (t>0 && t<m && Tidx[t]>-1); }
153 {
return (t>0 && t<m)? zmsIdx[t]: -1; }
157 {
return (t>0 && t<m && zmsIdx[t]>-1); }
166 bool onlySameOrd=
false)
const;
169 const int*
dLog(
unsigned t)
const {
171 if (i<0)
return NULL;
172 return &(dLogT[i*gens.size()]);
179 unsigned qGrpOrd(
bool onlySameOrd=
false)
const {
180 if (gens.size()<=0)
return 1;
182 for (
unsigned i=0; i<ords.size(); i++)
183 if (!onlySameOrd ||
SameOrd(i)) ord *= abs(ords[i]);
194 enum PA_tag { PA_GF2_tag, PA_zz_p_tag };
229 void restore()
const {}
237 void restore()
const {}
239 DummyContext(
long) {}
246 static const PA_tag tag = PA_GF2_tag;
248 typedef vec_GF2X vec_RX;
249 typedef GF2XModulus RXModulus;
250 typedef DummyBak RBak;
251 typedef DummyContext RContext;
253 typedef vec_GF2E vec_RE;
255 typedef GF2EBak REBak;
256 typedef vec_GF2EX vec_REX;
257 typedef GF2EContext REContext;
265 static const PA_tag tag = PA_zz_p_tag;
267 typedef vec_zz_pX vec_RX;
268 typedef zz_pXModulus RXModulus;
269 typedef zz_pBak RBak;
270 typedef zz_pContext RContext;
272 typedef vec_zz_pE vec_RE;
274 typedef zz_pEBak REBak;
275 typedef vec_zz_pEX vec_REX;
276 typedef zz_pEContext REContext;
290 virtual PA_tag
getTag()
const = 0;
299 virtual long getR()
const = 0;
321 #ifndef DOXYGEN_IGNORE
322 #define PA_INJECT(typ)\
323 static const PA_tag tag = typ::tag; \
324 typedef typename typ::RX RX; \
325 typedef typename typ::vec_RX vec_RX; \
326 typedef typename typ::RXModulus RXModulus; \
327 typedef typename typ::RBak RBak; \
328 typedef typename typ::RContext RContext; \
329 typedef typename typ::RE RE; \
330 typedef typename typ::vec_RE vec_RE; \
331 typedef typename typ::REX REX; \
332 typedef typename typ::REBak REBak; \
333 typedef typename typ::vec_REX vec_REX; \
334 typedef typename typ::REContext REContext; \
356 REContext contextForG;
360 const RX& getG()
const {
return G; }
361 long getDegG()
const {
return degG; }
373 RContext pPowRContext;
378 vector<ZZX> factorsOverZZ;
380 vector< vector< RX > > maskTable;
388 : zMStar(other.zMStar), r(other.r), pPowR(other.pPowR),
389 pPowRContext(other.pPowRContext)
392 PhimXMod = other.PhimXMod;
393 factors = other.factors;
394 maskTable = other.maskTable;
399 if (
this == &other)
return *
this;
401 assert(&zMStar == &other.zMStar);
404 pPowRContext = other.pPowRContext;
407 PhimXMod = other.PhimXMod;
408 factors = other.factors;
409 maskTable = other.maskTable;
418 virtual PA_tag
getTag()
const {
return tag; }
427 virtual long getR()
const {
return r; }
479 if (maskTable.size() == 0)
542 static void SetModulus(
long p) {
548 void mapToF1(RX& w,
const RX& G)
const { mapToFt(w,G,1); }
552 void mapToFt(RX& w,
const RX& G,
unsigned t,
const RX* rF1=NULL)
const;
566 cloned_ptr<PAlgebraModBase> rep;
577 : rep( buildPAlgebraMod(zMStar, r) )
596 return !(*
this == other);
603 PA_tag
getTag()
const {
return rep->getTag(); }
609 long getR()
const {
return rep->getR(); }
629 #endif // #ifdef _PAlgebra_H_