galois.typing.ElementLike

A Union representing objects that can be coerced into a Galois field element.

Scalars are 0-D Array objects.

Union

  • int: A finite field element in its integer representation.

    In [1]: GF = galois.GF(3**5)
    
    In [2]: GF(17)
    Out[2]: GF(17, order=3^5)
    
    In [3]: GF = galois.GF(3**5, repr="poly")
    
    In [4]: GF(17)
    Out[4]: GF(α^2 + 2α + 2, order=3^5)
    
    In [5]: GF = galois.GF(3**5, repr="power")
    
    In [6]: GF(17)
    Out[6]: GF(α^222, order=3^5)
    
  • str: A finite field element in its polynomial representation. Many string conventions are accepted, including: with/without *, with/without spaces, ^ or **, any indeterminate variable, increasing/decreasing degrees, etc. Or any combination of the above.

    In [7]: GF("x^2 + 2x + 2")
    Out[7]: GF(17, order=3^5)
    
    # Add explicit * for multiplication
    In [8]: GF("x^2 + 2*x + 2")
    Out[8]: GF(17, order=3^5)
    
    # No spaces
    In [9]: GF("x^2+2x+2")
    Out[9]: GF(17, order=3^5)
    
    # ** instead of ^
    In [10]: GF("x**2 + 2x + 2")
    Out[10]: GF(17, order=3^5)
    
    # Different indeterminate
    In [11]: GF("α^2 + 2α + 2")
    Out[11]: GF(17, order=3^5)
    
    # Ascending degrees
    In [12]: GF("2 + 2x + x^2")
    Out[12]: GF(17, order=3^5)
    
    In [13]: GF("x^2 + 2x + 2")
    Out[13]: GF(α^2 + 2α + 2, order=3^5)
    
    # Add explicit * for multiplication
    In [14]: GF("x^2 + 2*x + 2")
    Out[14]: GF(α^2 + 2α + 2, order=3^5)
    
    # No spaces
    In [15]: GF("x^2+2x+2")
    Out[15]: GF(α^2 + 2α + 2, order=3^5)
    
    # ** instead of ^
    In [16]: GF("x**2 + 2x + 2")
    Out[16]: GF(α^2 + 2α + 2, order=3^5)
    
    # Different indeterminate
    In [17]: GF("α^2 + 2α + 2")
    Out[17]: GF(α^2 + 2α + 2, order=3^5)
    
    # Ascending degrees
    In [18]: GF("2 + 2x + x^2")
    Out[18]: GF(α^2 + 2α + 2, order=3^5)
    
    In [19]: GF("x^2 + 2x + 2")
    Out[19]: GF(α^222, order=3^5)
    
    # Add explicit * for multiplication
    In [20]: GF("x^2 + 2*x + 2")
    Out[20]: GF(α^222, order=3^5)
    
    # No spaces
    In [21]: GF("x^2+2x+2")
    Out[21]: GF(α^222, order=3^5)
    
    # ** instead of ^
    In [22]: GF("x**2 + 2x + 2")
    Out[22]: GF(α^222, order=3^5)
    
    # Different indeterminate
    In [23]: GF("α^2 + 2α + 2")
    Out[23]: GF(α^222, order=3^5)
    
    # Ascending degrees
    In [24]: GF("2 + 2x + x^2")
    Out[24]: GF(α^222, order=3^5)
    
  • Array: A previously-created scalar Array object. No coercion is necessary.

Alias

alias of Union[int, str, Array]