My Project  debian-1:4.1.1-p2+ds-4
Functions
cf_irred.cc File Reference
#include "config.h"
#include "cf_assert.h"
#include "cf_defs.h"
#include "canonicalform.h"
#include "cf_algorithm.h"
#include "cf_random.h"
#include "NTLconvert.h"

Go to the source code of this file.

Functions

static bool is_irreducible (const CanonicalForm &f)
 
CanonicalForm find_irreducible (int deg, CFRandom &gen, const Variable &x)
 generate a random irreducible polynomial in x of degree deg More...
 
CanonicalForm randomIrredpoly (int i, const Variable &x)
 computes a random monic irreducible univariate polynomial in x over Fp of degree i via NTL More...
 

Function Documentation

◆ find_irreducible()

CanonicalForm find_irreducible ( int  deg,
CFRandom gen,
const Variable x 
)

generate a random irreducible polynomial in x of degree deg

Warning
this is done in the most naive way, i.e. a random is generated and then factorized

Definition at line 26 of file cf_irred.cc.

27 {
29  int i;
30  do {
31  result = power( x, deg );
32  for ( i = deg-1; i >= 0; i-- )
33  result += gen.generate() * power( x, i );
34  } while ( ! is_irreducible( result ) );
35  return result;
36 }

◆ is_irreducible()

static bool is_irreducible ( const CanonicalForm f)
static

Definition at line 19 of file cf_irred.cc.

20 {
21  CFFList F = factorize( f );
22  return F.length() == 1 && F.getFirst().exp() == 1;
23 }

◆ randomIrredpoly()

CanonicalForm randomIrredpoly ( int  i,
const Variable x 
)

computes a random monic irreducible univariate polynomial in x over Fp of degree i via NTL

Definition at line 42 of file cf_irred.cc.

43 {
44  int p= getCharacteristic();
45  if (fac_NTL_char != p)
46  {
47  fac_NTL_char= p;
48  zz_p::init (p);
49  }
50  zz_pX NTLirredpoly;
51  CanonicalForm CFirredpoly;
52  BuildIrred (NTLirredpoly, i);
53  CFirredpoly= convertNTLzzpX2CF (NTLirredpoly, x);
54  return CFirredpoly;
55 }
fac_NTL_char
long fac_NTL_char
Definition: NTLconvert.cc:41
f
FILE * f
Definition: checklibs.c:9
x
Variable x
Definition: cfModGcd.cc:4023
result
return result
Definition: facAbsBiFact.cc:76
power
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition: canonicalform.cc:1837
getCharacteristic
int getCharacteristic()
Definition: cf_char.cc:51
CanonicalForm
factory's main class
Definition: canonicalform.h:77
is_irreducible
static bool is_irreducible(const CanonicalForm &f)
Definition: cf_irred.cc:19
i
int i
Definition: cfEzgcd.cc:125
factorize
CFFList factorize(const CanonicalForm &f, bool issqrfree=false)
factorization over or
Definition: cf_factor.cc:390
List::getFirst
T getFirst() const
Definition: ftmpl_list.cc:279
CFRandom::generate
virtual CanonicalForm generate() const
Definition: cf_random.h:24
List::length
int length() const
Definition: ftmpl_list.cc:273
p
int p
Definition: cfModGcd.cc:4019
List
Definition: ftmpl_list.h:20
convertNTLzzpX2CF
CanonicalForm convertNTLzzpX2CF(const zz_pX &poly, const Variable &x)
Definition: NTLconvert.cc:248