#include <givaro/gfq.h>
#include <givaro/givpower.h>
#include <givaro/givtimer.h>
int main(int argc, char** argv)
{
int64_t p = (argc>1?atoi(argv[1]):5);
int64_t e = (argc>2?atoi(argv[2]):3);
std::cout << "Working in GF(" << p << '^' << e << ')' << std::endl;
std::cout << "Elements are polynomials in X modulo " << p << std::endl;
Poly1Dom< GFqDom<int64_t>, Dense > Pdom( PrimeField,
Indeter(
"X") );
Poly1Dom< GFqDom<int64_t>, Dense >
::Element G, H, J, mQ, irred, modP;
Pdom.init(G,
Degree((int64_t)GFq.
exponent()-1));
GFq.init(t,H);
GFq.init(tmp);
int64_t lowerpart;
GFq.
convert(lowerpart, tmp);
std::cout << ' ' << p << "-adic value of the lower part of the irreducible : " << lowerpart << std::endl;
int64_t ptoe =
power(p,e);
std::cout << ' ' << p << '^' << e << " is : " << ptoe << std::endl;
std::cout << " --> Computed irreducible: " << ptoe+lowerpart << std::endl;
std::cout <<
"Stored irreducible: " << GFq.
irreducible() << std::endl;
Poly1PadicDom< GFqDom<int64_t>, Dense > PAD(Pdom);
Poly1PadicDom< GFqDom<int64_t>, Dense >
::Element Polynomial;
PAD.radix(Polynomial, GFq.irreducible());
std::cout << "Irreducible polynomial coefficients: ";
for(Poly1PadicDom<
GFqDom<int64_t>, Dense >::Element::iterator it = Polynomial.begin(); it != Polynomial.end(); ++it)
PrimeField.
write(std::cout <<
' ', *it);
std::cout << std::endl;
PAD.write(std::cout << "The latter " << GFq.irreducible() << " represents: ", Polynomial)
<< " in " << p << "-adic"
<< std::endl;
return 0;
}