-1

具体来说,我试图在 Z_p[x] 中以另一个多项式 P 为模构造一个多项式,这需要使用ZZ_pE. 从 NTL 库中,构造函数ZZ_pE

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

如您所见,您只能ZZ_pE从一个数字(ZZ_plong)或另一个构建 a ZZ_pE。因此,我能够构造的唯一多项式是 0 次。以下代码设置模 p = 100001 和 P = x^4 - 1,并构造ZZ_pEg = 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);

我的目标是做出g我选择的更高次多项式。我该怎么做呢?

一个后续问题是:初始化多项式(例如 in ZZX)的标准(最有效)方法是什么?如果我想构造 f = x^2 - 3x + 4,这是我目前的方法:

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]);

即,通过在 for 循环中分别添加多项式的每个项。似乎 NTL 库可以从ZZX([4 -3 1]). 有什么我想念的吗?

4

1 回答 1

0

因为ZZX官方的方法是自己设置每个系数。为此,有功能

void SetCoeff(ZZX& x, long i, const ZZ& a)

有关详细信息,请参阅http://www.shoup.net/ntl/doc/ZZX.cpp.html 。

我不确定这是否也适用于ZZ_pX.

于 2018-07-03T13:23:18.020 回答