galois.GLFSR.step(steps: int = `1`)

Produces the next `steps` output symbols.

Parameters:
steps: int = `1`

The direction and number of output symbols to produce. The default is 1. If negative, the Galois LFSR will step backwards.

Returns:

An array of output symbols of type `field` with size `abs(steps)`.

Examples

Step the Galois LFSR one output at a time.

``````In [1]: c = galois.primitive_poly(7, 4)

In [2]: lfsr = galois.GLFSR(c.reverse(), state=[1, 2, 3, 4]); lfsr
Out[2]: <Galois LFSR: f(x) = 5x^4 + 3x^3 + x^2 + 1 over GF(7)>

In [3]: lfsr.state, lfsr.step()
Out[3]: (GF([1, 2, 3, 4], order=7), GF(4, order=7))

In [4]: lfsr.state, lfsr.step()
Out[4]: (GF([1, 3, 5, 3], order=7), GF(3, order=7))

In [5]: lfsr.state, lfsr.step()
Out[5]: (GF([6, 6, 0, 5], order=7), GF(5, order=7))

In [6]: lfsr.state, lfsr.step()
Out[6]: (GF([3, 5, 1, 0], order=7), GF(0, order=7))

In [7]: lfsr.state, lfsr.step()
Out[7]: (GF([0, 3, 5, 1], order=7), GF(1, order=7))

# Ending state
In [8]: lfsr.state
Out[8]: GF([2, 4, 2, 5], order=7)
``````

Step the Galois LFSR 5 steps in one call. This is more efficient than iterating one output at a time.

``````In [9]: c = galois.primitive_poly(7, 4)

In [10]: lfsr = galois.GLFSR(c.reverse(), state=[1, 2, 3, 4]); lfsr
Out[10]: <Galois LFSR: f(x) = 5x^4 + 3x^3 + x^2 + 1 over GF(7)>

In [11]: lfsr.state
Out[11]: GF([1, 2, 3, 4], order=7)

In [12]: lfsr.step(5)
Out[12]: GF([4, 3, 5, 0, 1], order=7)

# Ending state
In [13]: lfsr.state
Out[13]: GF([2, 4, 2, 5], order=7)
``````

Step the Galois LFSR 5 steps backward. Notice the output sequence is the reverse of the original sequence. Also notice the ending state is the same as the initial state.

``````In [14]: lfsr.step(-5)
Out[14]: GF([1, 0, 5, 3, 4], order=7)

In [15]: lfsr.state
Out[15]: GF([1, 2, 3, 4], order=7)
``````