MTToolBox  0.2.10
period.hpp
Go to the documentation of this file.
1 #ifndef MTTOOLBOX_PERIOD_HPP
2 #define MTTOOLBOX_PERIOD_HPP
3 
26 #include <stdint.h>
27 #include <NTL/GF2X.h>
28 #include <NTL/vector.h>
30 #include <MTToolBox/util.hpp>
31 
32 namespace MTToolBox {
55  template<typename U> void
56  minpoly(NTL::GF2X& poly, AbstractGenerator<U>& generator, int pos = 0,
57  int stateSize = 0)
58  {
59  using namespace std;
60  using namespace NTL;
61 
62  Vec<GF2> v;
63  int size;
64  if (stateSize <= 0) {
65  size = generator.bitSize();
66  } else {
67  size = stateSize;
68  }
69  v.SetLength(2 * size);
70  for (int i = 0; i < 2 * size; i++) {
71 // v[i] = (generator.generate() >> pos) & 1;
72  v[i] = getBitOfPos(generator.generate(), pos);
73  }
74  MinPolySeq(poly, v, size);
75  }
76 
96  bool isMexp(uint32_t degree);
97 
113  bool isIrreducible(const NTL::GF2X& poly);
114 
139  bool isPrime(const NTL::GF2X& poly);
140 
170  bool isPrime(const NTL::GF2X& poly, int degree,
171  const NTL::Vec<NTL::ZZ>& prime_factors);
172 
202  bool isPrime(const NTL::GF2X& poly,
203  int degree, const char * prime_factors[]);
204 
227  bool hasFactorOfDegree(NTL::GF2X& poly, long degree);
228 }
229 #endif // MTTOOLBOX_PERIOD_HPP
bool hasFactorOfDegree(NTL::GF2X &poly, long degree)
Check if primitive polynomial of given degree appears in factorization of poly.
pseudo random number generator.
Definition: AbstractGenerator.hpp:48
void minpoly(NTL::GF2X &poly, AbstractGenerator< U > &generator, int pos=0, int stateSize=0)
Calculate minimal polynomial of output sequence.
Definition: period.hpp:56
virtual int bitSize() const =0
Return bit size of internal state, i.e dimension of GF(2)-vector space.
Abstract class of GF(2)-linear pseudo random number generators.
bool isIrreducible(const NTL::GF2X &poly)
Check if polynomial is irreducible.
unsigned int getBitOfPos(U bits, int pos)
set zero
Definition: util.hpp:609
Utility functions.
bool isMexp(uint32_t degree)
Returns if 2degree-1 is prime number.
virtual U generate()=0
transit current internal state to next state and output a pseudo random number.
bool isPrime(const NTL::GF2X &poly)
Check if polynomial is primitive.
name space for MTToolBox