mokka.utils.bitops

Operations for bit manipulation.

Module to implement bit operations in NumPy.

mokka.utils.bitops.numpy.bits2idx(bits)

Convert bits in LSB-first to their integer representation.

Parameters:

bits – Vectors of bits with the last dimension representing the size of words

Returns:

Vector of integers

mokka.utils.bitops.numpy.generate_all_input_bits(m)

Generate all \(2^m\) possible bitstrings.

Parameters:

m – Length of the bitstring

Returns:

Array with all possible bitstrings in LSB

mokka.utils.bitops.numpy.gray(m)

Generate a sequence of bit strings with binary-reflected Gray coding.

Parameters:

m – length of the bitstrings

Returns:

Tuple of \(2^m\) Gray-encoded bitstrings

mokka.utils.bitops.numpy.idx2bits(idxs, num_bits_per_symbol)

Convert integer representations of bit vectors to bits in LSB-first.

Parameters:
  • idxs – Vector of indices

  • num_bits_per_symbol – size of the bit vectors

Returns:

vector of bit vectors

Operations for bit manipulation in PyTorch.

mokka.utils.bitops.torch.bits2idx(bits)

Convert bits to their integer representation.

Parameters:

bits – Vectors of bits with the last dimension representing the size of words

Returns:

Vector of integers

mokka.utils.bitops.torch.bits_to_onehot(bits)

Convert bits to one hot vectors.

Parameters:

bits – Vectors of bits with the last dimension representing the size of words

Returns:

Vectors of one-hot vectors

mokka.utils.bitops.torch.idx2bits(idxs, num_bits_per_symbol)

Convert integer representations of bit vectors back to bits.

Parameters:
  • idxs – Vector of indices

  • num_bits_per_symbol – size of the bit vectors

Returns:

vector of bit vectors