sdr.gray_code(length: int) NDArray[int_]

Generates a Gray code of length \(n = 2^m\).

Parameters:
length: int

The length \(n = 2^m\) of the Gray code.

Returns:

A Gray code of length \(n = 2^m\).

Examples

In [1]: sdr.gray_code(2)
Out[1]: array([0, 1])

In [2]: sdr.gray_code(4)
Out[2]: array([0, 1, 3, 2])

In [3]: sdr.gray_code(8)
Out[3]: array([0, 1, 3, 2, 6, 7, 5, 4])

In [4]: sdr.gray_code(16)
Out[4]: array([ 0,  1,  3,  2,  6,  7,  5,  4, 12, 13, 15, 14, 10, 11,  9,  8])