Specifically, I am trying to construct an polynomial in Z_p[x] modulo another polynomial P, which requires the usage of ZZ_pE
. From the NTL library, the constructors for ZZ_pE
are
ZZ_pE(); // initial value 0
ZZ_pE(const ZZ_pE& a); // copy constructor
explicit ZZ_pE(const ZZ_p& a); // promotion
explicit ZZ_pE(long a); // promotion
ZZ_pE& operator=(const ZZ_pE& a); // assignment
ZZ_pE& operator=(const ZZ_p& a); // assignment
ZZ_pE& operator=(long a); // assignment
As you can see, you can only construct a ZZ_pE
from a number (ZZ_p
or long
) or from another ZZ_pE
. Therefore the only polynomials that I have been able to construct are of degree 0. The following code sets moduli p = 100001 and P = x^4 - 1, and constructs a ZZ_pE
g = 5.
// Declare polynomial and coefficient moduli
ZZ_p::init(ZZ(100001));
ZZ_pX cyclo = ZZ_pX(INIT_MONO, 4) - 1;
ZZ_pE::init(cyclo);
// Construct g
ZZ_pE g = ZZ_pE(5);
My goal is to make g
a higher degree polynomial of my choosing. How do I do this?
A follow up question is: what is the standard (most efficient) way of initializing a polynomial (for example, in ZZX
)? If I wanted to construct f = x^2 - 3x + 4, this is my current method:
ZZ list[3] ={ZZ(4), ZZ(-3), ZZ(1)};
ZZX f;
for(int i=0; i<4; i++)
f += ZZX(INIT_MONO, i, list[i]);
i.e., by adding each term of the polynomial separately in a for loop. It seems that the NTL library could benefit from a constructor like ZZX([4 -3 1])
. Is there something I'm missing?