Skip to main content

bits_to_indices

Function bits_to_indices 

Source
pub fn bits_to_indices(bits: &[u8], n_bits: usize) -> Result<Vec<usize>>
Expand description

The indices of the blocks of n_bits bits of bits, each the bits_to_index of its block (the labels of the symbols of a bit stream, the symbols of a code over $\mathrm{GF}(2^{m})$).

§Errors

Error::Config for n_bits = 0, Error::Shape if the number of bits is not a multiple of n_bits.

§Examples

use comnum_math::bits::bits_to_indices;
assert_eq!(bits_to_indices(&[1, 0, 1, 1, 1, 0], 3)?, [5, 6]);
assert!(bits_to_indices(&[1, 0, 1], 2).is_err());