galois.typing.ElementLike

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)
    
  • 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 [3]: GF("x^2 + 2x + 2")
    Out[3]: GF(17, order=3^5)
    
    # Add explicit * for multiplication
    In [4]: GF("x^2 + 2*x + 2")
    Out[4]: GF(17, order=3^5)
    
    # No spaces
    In [5]: GF("x^2+2x+2")
    Out[5]: GF(17, order=3^5)
    
    # ** instead of ^
    In [6]: GF("x**2 + 2x + 2")
    Out[6]: GF(17, order=3^5)
    
    # Different indeterminate
    In [7]: GF("α^2 + 2α + 2")
    Out[7]: GF(17, order=3^5)
    
    # Ascending degrees
    In [8]: GF("2 + 2x + x^2")
    Out[8]: GF(17, order=3^5)
    
  • Array: A previously-created scalar Array object. No coercion is necessary.

Alias

alias of Union[int, str, Array]


Last update: May 17, 2022