komm.int_to_bits
Converts an integer array to its bit representation. Each integer is converted to width bits, which are concatenated along the last dimension. This is the inverse of bits_to_int.
For integers wider than $63$ bits, see to_binary.
Parameters:
-
input(ArrayLike) –The input integer array. Must be an array of integers in $[0 : 2^{\mathtt{width}})$.
-
width(int) –The number of bits per integer. Must be in $[0 : 64)$.
-
bit_order(Literal['LSB-first', 'MSB-first']) –Bit order convention. Must be either
"LSB-first"(least significant bit in the first position) or"MSB-first"(most significant bit in the first position). The default value is"LSB-first".
Returns:
-
output(NDArray[integer]) –The bit representation of the input integer array. Has the same shape as the input, but with the last dimension expanded by a factor of
width.
Examples:
>>> komm.int_to_bits([16], width=6)
array([0, 0, 0, 0, 1, 0])
>>> komm.int_to_bits([2], width=6, bit_order="MSB-first")
array([0, 0, 0, 0, 1, 0])
>>> komm.int_to_bits([0, 2], width=3)
array([0, 0, 0, 0, 1, 0])
>>> komm.int_to_bits([[0, 3], [2, 2]], width=2)
array([[0, 0, 1, 1],
[0, 1, 0, 1]])