galois.typing.ArrayLike

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

Union

  • IterableLike: A recursive iterable of iterables of elements.

    In [1]: GF = galois.GF(3**5)
    
    In [2]: GF([[17, 4], [148, 205]])
    Out[2]: 
    GF([[ 17,   4],
        [148, 205]], order=3^5)
    
    # Mix and match integers and strings
    In [3]: GF([["x^2 + 2x + 2", 4], ["x^4 + 2x^3 + x^2 + x + 1", 205]])
    Out[3]: 
    GF([[ 17,   4],
        [148, 205]], order=3^5)
    
    In [4]: GF = galois.GF(3**5, display="poly")
    
    In [5]: GF([[17, 4], [148, 205]])
    Out[5]: 
    GF([[             α^2 + 2α + 2,                     α + 1],
        [ α^4 + 2α^3 + α^2 + α + 1, 2α^4 + α^3 + α^2 + 2α + 1]], order=3^5)
    
    # Mix and match integers and strings
    In [6]: GF([["x^2 + 2x + 2", 4], ["x^4 + 2x^3 + x^2 + x + 1", 205]])
    Out[6]: 
    GF([[             α^2 + 2α + 2,                     α + 1],
        [ α^4 + 2α^3 + α^2 + α + 1, 2α^4 + α^3 + α^2 + 2α + 1]], order=3^5)
    
    In [7]: GF = galois.GF(3**5, display="power")
    
    In [8]: GF([[17, 4], [148, 205]])
    Out[8]: 
    GF([[α^222,  α^69],
        [ α^54,  α^24]], order=3^5)
    
    # Mix and match integers and strings
    In [9]: GF([["x^2 + 2x + 2", 4], ["x^4 + 2x^3 + x^2 + x + 1", 205]])
    Out[9]: 
    GF([[α^222,  α^69],
        [ α^54,  α^24]], order=3^5)
    
  • ndarray: A NumPy array of integers, representing finite field elements in their integer representation.

    In [10]: x = np.array([[17, 4], [148, 205]]); x
    Out[10]: 
    array([[ 17,   4],
           [148, 205]])
    
    In [11]: GF(x)
    Out[11]: 
    GF([[ 17,   4],
        [148, 205]], order=3^5)
    
    In [12]: x = np.array([[17, 4], [148, 205]]); x
    Out[12]: 
    array([[ 17,   4],
           [148, 205]])
    
    In [13]: GF(x)
    Out[13]: 
    GF([[             α^2 + 2α + 2,                     α + 1],
        [ α^4 + 2α^3 + α^2 + α + 1, 2α^4 + α^3 + α^2 + 2α + 1]], order=3^5)
    
    In [14]: x = np.array([[17, 4], [148, 205]]); x
    Out[14]: 
    array([[ 17,   4],
           [148, 205]])
    
    In [15]: GF(x)
    Out[15]: 
    GF([[α^222,  α^69],
        [ α^54,  α^24]], order=3^5)
    
  • Array: A previously-created Array object. No coercion is necessary.

Alias

alias of Union[Sequence[Union[int, str, Array]], Sequence[IterableLike], ndarray, Array]