#include <iostream>
#include <stdlib.h>
#include <givaro/givintsqrootmod.h>
#include <givaro/givtimer.h>
#include <givaro/givpoly1factor.h>
#include <givaro/modular-integer.h>
int main(
int argc,
char** argv)
{
Integer
a(argv[1]), n(argv[2]);
{
std::cerr <<
"a: " <<
a << std::endl;
std::cerr << "n: " << n << std::endl;
Integer r;
Timer chrono; chrono.start();
chrono.stop();
std::cout << r << std::endl;
std::cerr << chrono << std::endl;
std::cerr << "Check, (" << r << ")^2 mod " << n << " = " << ( (r*r)%n) << std::endl;
}
std::cout << "Using polynomial factorization : " << std::endl;
typedef Modular<Integer>
Field;
typedef Poly1FactorDom<Field,Dense>
Polys;
Pol.init(quad, Degree(2));
Timer chrono; chrono.start();
if (Pol.is_irreducible(quad)) {
std::cerr <<
a <<
" is not a quadratic residue mod " << n << std::endl;
chrono.stop();
std::cerr << chrono << std::endl;
return 0;
}
Pol.SplitFactor(
root, quad, Degree(1));
chrono.stop();
Pol.write(std::cout,
root) << std::endl;
std::cerr << chrono << std::endl;
std::cerr <<
"Check, (" <<
root[0] <<
")^2 mod " << n <<
" = " << ( (
root[0]*
root[0])%n) << std::endl;
}
return 0;
}
int main(int argc, char **argv)
Definition: benchmark-recint_exp.C:20
static int64_t seed()
Definition: givtimer.C:30
Rep & init(Rep &r) const
Definition: gfq.h:202
Rep & negin(Rep &r) const
Definition: gfq.inl:357
int isprime(const Rep &n, int r=_GIVARO_ISPRIMETESTS_) const
Definition: givintprime.h:71
Rep & sqrootmod(Rep &x, const Rep &a, const Rep &n) const
Definition: givintsqrootmod.inl:24
static void seeding()
Random numbers (no doc)
Definition: gmp++_int_rand.inl:54
Poly1Dom< Field, Dense > Polys
Definition: highorder.C:30
Namespace in which the whole Givaro library resides.
Definition: all_field.C:23
bool root(Integer &q, const Integer &, uint32_t n)
Definition: gmp++_int_misc.C:71
GFqDom< int64_t > Field
Definition: domain_to_operatorstyle.C:24
StaticElement< Field > Element
Definition: domain_to_operatorstyle.C:27
MG & a
Definition: rmadd.h:143
IntSqrtModDom ISM
Definition: test-brillhart.C:23