private GF256 ( int primitive ) : System | ||
primitive | int | irreducible polynomial whose coefficients are represented by /// the bits of an int, where the least-significant bit represents the constant /// coefficient /// |
return | System |
private GF256(int primitive)
{
expTable = new int[256];
logTable = new int[256];
int x = 1;
for (int i = 0; i < 256; i++)
{
expTable[i] = x;
x <<= 1; // x = x * 2; we're assuming the generator alpha is 2
if (x >= 0x100)
{
x ^= primitive;
}
}
for (int i = 0; i < 255; i++)
{
logTable[expTable[i]] = i;
}
// logTable[0] == 0 but this should never be used
zero = new GF256Poly(this, new[] {0});
one = new GF256Poly(this, new[] {1});
}