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

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

Parameters:
n: int

The length of the Gray code.

Returns:

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

Examples

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

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

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

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