### Initializing Polynominals

Posted:

**Fri Oct 07, 2016 12:00 am**Are there any examples illustrating how to construct a particular polynomial in code? All of the examples I have seen either read from input or generate random polynomials.

I'm interested in particular in polynomials of type ZZ_pE and for example, I'd like to create polynomial 2x^2 + 3x + 1.

I start by initializing the modulus to a irreducible polynomial.

I then construct a polynomial of type ZZ_pX:

ZZ_pX ff;

SetCoeff(ff, 0, 1);

SetCoeff(ff, 1, 3);

SetCoeff(ff, 2, 2);

and then use it to initialize a polynomial of type ZZ_pE:

ZZ_pE f;

conv(f, ff);

This works, but seems very round-about. Is there any easier/more direct way of constructing such a polynomial?

Cheers, Wayne.

I'm interested in particular in polynomials of type ZZ_pE and for example, I'd like to create polynomial 2x^2 + 3x + 1.

I start by initializing the modulus to a irreducible polynomial.

I then construct a polynomial of type ZZ_pX:

ZZ_pX ff;

SetCoeff(ff, 0, 1);

SetCoeff(ff, 1, 3);

SetCoeff(ff, 2, 2);

and then use it to initialize a polynomial of type ZZ_pE:

ZZ_pE f;

conv(f, ff);

This works, but seems very round-about. Is there any easier/more direct way of constructing such a polynomial?

Cheers, Wayne.