有限体演算に関連する NTL 機能の一部を調べようとしていますが、奇妙なことが起こっています。フィールド $GF(2^8)$ に 2 つのランダム要素を生成し、それらを加算および減算しようとしています。しかし、取得した 2 つの「ランダム」要素は、テスト プログラムを実行するたびに等しいようです。アイデアはありますか?
私のテストコード:
void test3(long n) {
NTL::GF2X P;
NTL::BuildIrred(P, n);
// P is now x^2+x+1, this is irreducable since P(1)=1 and P(0)=1
NTL::GF2E::init(P);
NTL::GF2E xx = NTL::random_GF2E();
NTL::GF2E yy = NTL::random_GF2E();
std::cout << "xx: " << xx << std::endl; // Prints something like "[0 1]"
std::cout << "yy: " << yy << std::endl; // Prints something like "[0 1]"
xx += yy;
std::cout << "xx: " << xx << std::endl; // Prints something like "[0 1]"
xx -= yy;
std::cout << "xx: " << xx << std::endl; // Prints something like "[0 1]"
xx -= yy;
std::cout << "xx: " << xx << std::endl; // Prints something like "[0 1]"
}
数回実行したときのテスト プログラムの出力:
~\Release>test.exe
xx: [0 1 0 0 1 0 0 1]
yy: [0 1 0 0 1]
xx: [0 0 0 0 0 0 0 1]
xx: [0 1 0 0 1 0 0 1]
xx: [0 0 0 0 0 0 0 1]
~\Release>test.exe
xx: [0 1 0 0 1 0 0 1]
yy: [0 1 0 0 1]
xx: [0 0 0 0 0 0 0 1]
xx: [0 1 0 0 1 0 0 1]
xx: [0 0 0 0 0 0 0 1]
~\Release>test.exe
xx: [0 1 0 0 1 0 0 1]
yy: [0 1 0 0 1]
xx: [0 0 0 0 0 0 0 1]
xx: [0 1 0 0 1 0 0 1]
xx: [0 0 0 0 0 0 0 1]
~\Release>test.exe
xx: [0 1 0 0 1 0 0 1]
yy: [0 1 0 0 1]
xx: [0 0 0 0 0 0 0 1]
xx: [0 1 0 0 1 0 0 1]
xx: [0 0 0 0 0 0 0 1]