39 Array<Array<int> > GF::alphapow;
40 Array<Array<int> > GF::logalpha;
41 ivec GF::q =
"1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536";
46 m =
static_cast<char>(
round_i(::
log2(static_cast<double>(qvalue))));
47 it_assert((1 << m) == qvalue,
"GF::setsize : q is not a power of 2");
48 it_assert((m > 0) && (m <= 16),
"GF::setsize : q must be positive and "
49 "less than or equal to 2^16");
55 const int reducetable[] = {3, 3, 3, 5, 3, 9, 29, 17, 9, 5, 83, 27, 43, 3, 4107};
57 if (alphapow.
size() < (m + 1)) {
62 if (alphapow(m).
size() == 0) {
73 reduce = reducetable[m-2];
75 for (n = 1; n < (1 << m) - 1; n++) {
76 temp = alphapow(m)(n - 1);
79 alphapow(m)(n) = (temp & ~(1 << m)) ^ reduce;
81 alphapow(m)(n) = temp;
87 for (n = 0;n < (1 << m) - 1;n++)
88 logalpha(m)(alphapow(m)(n)) = n;
96 static const std::string prefix(
"alpha^");
100 std::string::const_iterator pr_it = prefix.begin(); pr_it++;
101 for(; pr_it < prefix.end(); ++pr_it) {
104 is.setstate(std::ios_base::failbit);
118 is.setstate(std::ios_base::failbit);
127 if (ingf.value == -1)
130 os <<
"alpha^" << ingf.value;
138 for (
int i = 0; i < ingfx.degree + 1; i++) {
139 if (ingfx.coeffs(i) !=
GF(ingfx.q, -1)) {
140 if (terms != 0) os <<
" + ";
142 if (ingfx.coeffs(i) ==
GF(ingfx.q, 0)) {
146 os << ingfx.coeffs(i) <<
"*x^" << i;
150 if (terms == 0) os <<
"0";
163 int degreedif = tempdegree - gdegree;
164 if (degreedif < 0)
return GFX(q, 0);
165 GFX m(q, degreedif), divisor(q);
168 m[degreedif] = temp[tempdegree] / g[gdegree];
171 divisor[degreedif] = m[degreedif];
174 degreedif = tempdegree - gdegree;
190 if (degreedif < 0)
return temp;
191 GFX m(q, degreedif), divisor(q);
194 m[degreedif] = temp[tempdegree] / b[bdegree];
197 divisor[degreedif] = m[degreedif];