My Project
Loading...
Searching...
No Matches
Functions
facIrredTest.h File Reference

This file provides a probabilistic irreducibility test for polynomials over Z/p. More...

#include "canonicalform.h"

Go to the source code of this file.

Functions

double numZeros (const CanonicalForm &F, int k)
 evaluate F at k random points in Z/p^n and count the number of zeros that occur More...
 
int FACTORY_PUBLIC probIrredTest (const CanonicalForm &F, double error)
 given some error probIrredTest detects irreducibility or reducibility of F with confidence level 1-error More...
 

Detailed Description

This file provides a probabilistic irreducibility test for polynomials over Z/p.

ABSTRACT: irreducibility test based on "Quick and Dirty Irreducibility Test" by v. Bothmer and Schreyer

Author
Martin Lee

Definition in file facIrredTest.h.

Function Documentation

◆ numZeros()

double numZeros ( const CanonicalForm F,
int  k 
)

evaluate F at k random points in Z/p^n and count the number of zeros that occur

Returns
numZeros returns #zeros/trials
Parameters
[in]Fsome poly over Z/p with n variables
[in]knumber of trials

Definition at line 24 of file facIrredTest.cc.

25{
26 int result= 0;
27
28 FFRandom FFgen;
30 for (int i= 0; i < k; i++)
31 {
32 buf= F;
33 for (int j= F.level(); j > 0; j++)
34 buf= buf (FFgen.generate(), j);
35 if (buf.isZero())
36 result++;
37 }
38
39 return (double) result/k;
40}
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
factory's main class
Definition: canonicalform.h:86
int level() const
level() returns the level of CO.
generate random elements in F_p
Definition: cf_random.h:44
CanonicalForm generate() const
Definition: cf_random.cc:68
return result
Definition: facAbsBiFact.cc:75
int j
Definition: facHensel.cc:110
int status int void * buf
Definition: si_signals.h:59

◆ probIrredTest()

int FACTORY_PUBLIC probIrredTest ( const CanonicalForm F,
double  error 
)

given some error probIrredTest detects irreducibility or reducibility of F with confidence level 1-error

Returns
probIrredTest returns 1 for irreducibility, -1 for reducibility or 0 if the test is not applicable
Parameters
[in]Fsome poly over Z/p
[in]error0 < error < 1

Definition at line 63 of file facIrredTest.cc.

64{
65 CFMap N;
67 int n= G.level();
68 int p= getCharacteristic();
69
70 double sqrtTrials= inverseERF (1-2.0*error)*sqrt (2.0);
71
72 double s= sqrtTrials;
73
74 double pn= pow ((double) p, (double) n);
75 double p1= (double) 1/p;
76 p1= p1*(1.0-p1);
77 p1= p1/(double) pn;
78 p1= sqrt (p1);
79 p1 *= s;
80 p1 += (double) 1/p;
81
82 double p2= (double) (2*p-1)/(p*p);
83 p2= p2*(1-p2);
84 p2= p2/(double) pn;
85 p2= sqrt (p2);
86 p2 *= s;
87 p2= (double) (2*p - 1)/(p*p)-p2;
88
89 //no testing possible
90 if (p2 < p1)
91 return 0;
92
93 double den= sqrt (p1*(1-p1))+sqrt (p2*(1-p2));
94 double num= p2-p1;
95
96 sqrtTrials *= den/num;
97
98 int trials= (int) floor (pow (sqrtTrials, 2.0));
99
100 double experimentalNumZeros= numZeros (G, trials);
101
102 double pmiddle= sqrt (p1*p2);
103
104 num= den;
105 den= sqrt (p1*(1.0-p2))+sqrt (p2*(1.0-p1));
106 pmiddle *= (den/num);
107
108 if (experimentalNumZeros < pmiddle)
109 return 1;
110 else
111 return -1;
112}
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:411
CanonicalForm num(const CanonicalForm &f)
CanonicalForm den(const CanonicalForm &f)
int FACTORY_PUBLIC getCharacteristic()
Definition: cf_char.cc:70
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
int p
Definition: cfModGcd.cc:4078
CanonicalForm compress(const CanonicalForm &f, CFMap &m)
CanonicalForm compress ( const CanonicalForm & f, CFMap & m )
Definition: cf_map.cc:210
class CFMap
Definition: cf_map.h:85
const CanonicalForm int s
Definition: facAbsFact.cc:51
double numZeros(const CanonicalForm &F, int k)
evaluate F at k random points in Z/p^n and count the number of zeros that occur
Definition: facIrredTest.cc:24
double inverseERF(double d)
Definition: facIrredTest.cc:42
STATIC_VAR TreeM * G
Definition: janet.cc:31
gmp_float sqrt(const gmp_float &a)
Definition: mpr_complex.cc:327
#define error(a)
Definition: mpr_numeric.cc:966