我将如何使用 NTL 库在 Galois Field 中获得 int 表示。例如元素
GF2E xx=random_GF2E();
我正在尝试使用
printf("%d",xx._GF2E__rep.HexOutput);
但我得到 0
我将如何使用 NTL 库在 Galois Field 中获得 int 表示。例如元素
GF2E xx=random_GF2E();
我正在尝试使用
printf("%d",xx._GF2E__rep.HexOutput);
但我得到 0
GF2E 是一个扩展域,即GF2E 中的元素都存在于 中GF(2)[X]/(P)
,其中P
是一个不可约多项式。所以你不能得到一个整数表示。但是你可以得到一个向量的表示。
GF2X P;
SetCoeff(P, 0, 1);
SetCoeff(P, 1, 1);
SetCoeff(P, 2, 1);
// P is now x^2+x+1, this is irreducable since P(1)=1 and P(0)=1
GF2E::init(P);
GF2E xx = random_GF2E();
cout << xx << endl; // Prints something like "[0 1]"
注意:要使用此代码片段,您必须通过 using和在您的 include 之后将名称空间NTL
和程序导入到您的程序中。
另一种方法是添加到所有 NTL 函数和to和.
有关命名空间的更多信息,请参阅本教程。std
using namespace NTL;
using namespace std;
NTL::
std::
cout
endl