-
classmethod galois.FieldArray.repr_table(element: ElementLike | None =
None
, sort: 'power' | 'poly' | 'vector' | 'int' ='power'
) str Generates a finite field element representation table comparing the power, polynomial, vector, and integer representations.
- Parameters:¶
- element: ElementLike | None =
None
¶ An element to use as the exponent base in the power representation. The default is
None
which corresponds toprimitive_element
.- sort: 'power' | 'poly' | 'vector' | 'int' =
'power'
¶ The sorting method for the table. The default is
"power"
. Sorting by"power"
will order the rows of the table by ascending powers ofelement
. Sorting by any of the others will order the rows in lexicographical polynomial/vector order, which is equivalent to ascending order of the integer representation.
- element: ElementLike | None =
- Returns:¶
A string representation of the table comparing the power, polynomial, vector, and integer representations of each field element.
Examples¶
Create a
FieldArray
subclass for \(\mathrm{GF}(3^3)\).In [1]: GF = galois.GF(3**3) In [2]: print(GF.properties) Galois Field: name: GF(3^3) characteristic: 3 degree: 3 order: 27 irreducible_poly: x^3 + 2x + 1 is_primitive_poly: True primitive_element: x
Generate a representation table for \(\mathrm{GF}(3^3)\). Since \(x^3 + 2x + 1\) is a primitive polynomial, \(x\) is a primitive element of the field. Notice, \(\textrm{ord}(x) = 26\).
In [3]: print(GF.repr_table()) Power Polynomial Vector Integer ------- --------------- ----------- --------- 0 0 [0, 0, 0] 0 x^0 1 [0, 0, 1] 1 x^1 x [0, 1, 0] 3 x^2 x^2 [1, 0, 0] 9 x^3 x + 2 [0, 1, 2] 5 x^4 x^2 + 2x [1, 2, 0] 15 x^5 2x^2 + x + 2 [2, 1, 2] 23 x^6 x^2 + x + 1 [1, 1, 1] 13 x^7 x^2 + 2x + 2 [1, 2, 2] 17 x^8 2x^2 + 2 [2, 0, 2] 20 x^9 x + 1 [0, 1, 1] 4 x^10 x^2 + x [1, 1, 0] 12 x^11 x^2 + x + 2 [1, 1, 2] 14 x^12 x^2 + 2 [1, 0, 2] 11 x^13 2 [0, 0, 2] 2 x^14 2x [0, 2, 0] 6 x^15 2x^2 [2, 0, 0] 18 x^16 2x + 1 [0, 2, 1] 7 x^17 2x^2 + x [2, 1, 0] 21 x^18 x^2 + 2x + 1 [1, 2, 1] 16 x^19 2x^2 + 2x + 2 [2, 2, 2] 26 x^20 2x^2 + x + 1 [2, 1, 1] 22 x^21 x^2 + 1 [1, 0, 1] 10 x^22 2x + 2 [0, 2, 2] 8 x^23 2x^2 + 2x [2, 2, 0] 24 x^24 2x^2 + 2x + 1 [2, 2, 1] 25 x^25 2x^2 + 1 [2, 0, 1] 19 In [4]: GF("x").multiplicative_order() Out[4]: 26
Generate a representation table for \(\mathrm{GF}(3^3)\) using a different primitive element \(2x^2 + 2x + 2\). Notice, \(\textrm{ord}(2x^2 + 2x + 2) = 26\).
In [5]: print(GF.repr_table("2x^2 + 2x + 2")) Power Polynomial Vector Integer -------------------- --------------- ----------- --------- 0 0 [0, 0, 0] 0 (2x^2 + 2x + 2)^0 1 [0, 0, 1] 1 (2x^2 + 2x + 2)^1 2x^2 + 2x + 2 [2, 2, 2] 26 (2x^2 + 2x + 2)^2 x^2 + 2 [1, 0, 2] 11 (2x^2 + 2x + 2)^3 2x^2 + x + 2 [2, 1, 2] 23 (2x^2 + 2x + 2)^4 2x^2 + 2x + 1 [2, 2, 1] 25 (2x^2 + 2x + 2)^5 2x^2 + x [2, 1, 0] 21 (2x^2 + 2x + 2)^6 x^2 + x [1, 1, 0] 12 (2x^2 + 2x + 2)^7 x + 2 [0, 1, 2] 5 (2x^2 + 2x + 2)^8 2x + 2 [0, 2, 2] 8 (2x^2 + 2x + 2)^9 2x^2 [2, 0, 0] 18 (2x^2 + 2x + 2)^10 2x^2 + 2 [2, 0, 2] 20 (2x^2 + 2x + 2)^11 x [0, 1, 0] 3 (2x^2 + 2x + 2)^12 2x^2 + x + 1 [2, 1, 1] 22 (2x^2 + 2x + 2)^13 2 [0, 0, 2] 2 (2x^2 + 2x + 2)^14 x^2 + x + 1 [1, 1, 1] 13 (2x^2 + 2x + 2)^15 2x^2 + 1 [2, 0, 1] 19 (2x^2 + 2x + 2)^16 x^2 + 2x + 1 [1, 2, 1] 16 (2x^2 + 2x + 2)^17 x^2 + x + 2 [1, 1, 2] 14 (2x^2 + 2x + 2)^18 x^2 + 2x [1, 2, 0] 15 (2x^2 + 2x + 2)^19 2x^2 + 2x [2, 2, 0] 24 (2x^2 + 2x + 2)^20 2x + 1 [0, 2, 1] 7 (2x^2 + 2x + 2)^21 x + 1 [0, 1, 1] 4 (2x^2 + 2x + 2)^22 x^2 [1, 0, 0] 9 (2x^2 + 2x + 2)^23 x^2 + 1 [1, 0, 1] 10 (2x^2 + 2x + 2)^24 2x [0, 2, 0] 6 (2x^2 + 2x + 2)^25 x^2 + 2x + 2 [1, 2, 2] 17 In [6]: GF("2x^2 + 2x + 2").multiplicative_order() Out[6]: 26
Generate a representation table for \(\mathrm{GF}(3^3)\) using a non-primitive element \(x^2\). Notice, \(\textrm{ord}(x^2) = 13 \ne 26\).
In [7]: print(GF.repr_table("x^2")) Power Polynomial Vector Integer ---------- --------------- ----------- --------- 0 0 [0, 0, 0] 0 (x^2)^0 1 [0, 0, 1] 1 (x^2)^1 x^2 [1, 0, 0] 9 (x^2)^2 x^2 + 2x [1, 2, 0] 15 (x^2)^3 x^2 + x + 1 [1, 1, 1] 13 (x^2)^4 2x^2 + 2 [2, 0, 2] 20 (x^2)^5 x^2 + x [1, 1, 0] 12 (x^2)^6 x^2 + 2 [1, 0, 2] 11 (x^2)^7 2x [0, 2, 0] 6 (x^2)^8 2x + 1 [0, 2, 1] 7 (x^2)^9 x^2 + 2x + 1 [1, 2, 1] 16 (x^2)^10 2x^2 + x + 1 [2, 1, 1] 22 (x^2)^11 2x + 2 [0, 2, 2] 8 (x^2)^12 2x^2 + 2x + 1 [2, 2, 1] 25 (x^2)^13 1 [0, 0, 1] 1 (x^2)^14 x^2 [1, 0, 0] 9 (x^2)^15 x^2 + 2x [1, 2, 0] 15 (x^2)^16 x^2 + x + 1 [1, 1, 1] 13 (x^2)^17 2x^2 + 2 [2, 0, 2] 20 (x^2)^18 x^2 + x [1, 1, 0] 12 (x^2)^19 x^2 + 2 [1, 0, 2] 11 (x^2)^20 2x [0, 2, 0] 6 (x^2)^21 2x + 1 [0, 2, 1] 7 (x^2)^22 x^2 + 2x + 1 [1, 2, 1] 16 (x^2)^23 2x^2 + x + 1 [2, 1, 1] 22 (x^2)^24 2x + 2 [0, 2, 2] 8 (x^2)^25 2x^2 + 2x + 1 [2, 2, 1] 25 In [8]: GF("x^2").multiplicative_order() Out[8]: 13