cana.function_outputs.bit_lut module
Bit-packed dense Boolean look-up tables.
- class cana.function_outputs.bit_lut.BitLut(k=0, *, fill=0)[source]
Bases:
objectDense Boolean truth table packed 8 entries per byte.
Row
i(input state number, matchingstatenum_to_binstate()) lives in bit(i & 7)of bytei >> 3(LSB-first within each byte). Indexing and iteration yieldintvalues in{0, 1}.- Parameters:
k (int)
fill (int)
- classmethod from_sequence(seq)[source]
Build a
BitLutfrom any 0/1 sequence of length2**k.- Parameters:
seq (Sequence[object])
- Return type:
- classmethod from_bytes(data, k)[source]
Build from packed bytes with the same layout as
to_bytes().- Parameters:
data (bytes | bytearray)
k (int)
- Return type:
- property k: int
Number of inputs (
len(self) == 2**k, or 1 whenk == 0).
- eval(statenum)[source]
Return the output for input state number
statenum.- Parameters:
statenum (int)
- Return type:
int
- is_constant()[source]
Return
0or1if every row equals that value, elseNone.- Return type:
int | None
- negate_input(idx)[source]
Return a copy with input bit
idxnegated (MSB-first bit order).Row
iof the result equals rowi ^ (1 << (k - 1 - idx))ofself, matching the legacynegate_LUT_inputremapping.- Parameters:
idx (int)
- Return type:
- reorder(old_labels, new_labels)[source]
Return a copy with input-bit order remapped from
old_labelstonew_labels.Labels identify the
kinput variables in MSB-first bit order.new_labelsmust be a permutation ofold_labels. If the orders already match, returnsselfunchanged.- Parameters:
old_labels (Sequence[object])
new_labels (Sequence[object])
- Return type: