#include <iostream>
#include <givaro/givintnumtheo.h>
#include <givaro/givtimer.h>
#include <cmath>
int main(
int argc,
char** argv)
{
#ifdef __GMP_PLUSPLUS__
#endif
double error;
bool comp ;
if ( (comp=(!
IP.
isprime(
a))) ) std::cerr <<
a <<
" is not prime, primitive root will have no sense and may loop forever ..." << std::endl;
double epsilon = argc > 2 ? atof(argv[2]) : 0.0000001;
Timer tim; tim.clear();
tim.start();
#define GIVARO_POLLARD
IP.probable_prim_root(pr, error,
a, epsilon );
tim.stop();
if (comp) std::cerr <<
IP.
gcd(g,
a,pr) <<
" is a factor of " <<
a << std::endl;
if (error > 0) {
std::cout << ", correct with probability at least : 1-" << error << std::endl;
std::cerr << tim << std::endl;
std::cerr << "Now checking primitivity, this may take some time (complete factorization of n-1) ...";
#define GIVARO_LENSTRA
Timer verif; verif.clear(); verif.start();
if (
IP.isorder(
a-1, pr,
a) ) {
verif.stop();
std::cerr << "... Pimitivity checked" << std::endl;
std::cerr << verif << std::endl;
}
else {
verif.stop();
std::cerr << "... WARNING : FAILURE" << std::endl;
std::cerr << verif << std::endl;
}
} else {
std::cout << ", deterministically correct" << std::endl;
std::cerr << tim << std::endl;
}
return 0;
}
IntFactorDom IP
Definition: ProbLucas.C:43
int main(int argc, char **argv)
Definition: benchmark-recint_exp.C:20
static int64_t seed()
Definition: givtimer.C:30
int isprime(const Rep &n, int r=_GIVARO_ISPRIMETESTS_) const
Definition: givintprime.h:71
Rep & gcd(Rep &g, Rep &u, Rep &v, const Rep &a, const Rep &b) const
Definition: givinteger.h:153
Rep Element
Definition: givinteger.h:38
std::ostream & write(std::ostream &o) const
Definition: givinteger.h:400
Namespace in which the whole Givaro library resides.
Definition: all_field.C:23
ZRing< Integer > IntegerDom
Definition: givinteger.h:413
MG & a
Definition: rmadd.h:143