pub struct StaticLut<const NUM_VARS: usize, const NUM_WORDS: usize> { /* private fields */ }Expand description
Fixed-size truth table representing a N-input boolean function with 2^N bits; more compact than Lut when the size is known
Implementations§
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> StaticLut<NUM_VARS, NUM_WORDS>
Sourcepub const fn num_blocks(&self) -> usize
pub const fn num_blocks(&self) -> usize
Query the number of 64-bit blocks in the Lut
Sourcepub fn majority() -> Self
pub fn majority() -> Self
Create a Lut returning true if the majority of the variables are true
Sourcepub fn threshold(k: usize) -> Self
pub fn threshold(k: usize) -> Self
Create a Lut returning true if at least k variables are true
Sourcepub fn symmetric(count_values: usize) -> Self
pub fn symmetric(count_values: usize) -> Self
Create a Lut representing a symmetric function. Bit at position k gives the value when k variables are true
Sourcepub fn value(&self, mask: usize) -> bool
pub fn value(&self, mask: usize) -> bool
Get the value of the Lut for these inputs (input bits packed in the mask)
Sourcepub fn get_bit(&self, mask: usize) -> bool
pub fn get_bit(&self, mask: usize) -> bool
Get the value of the Lut for these inputs (input bits packed in the mask)
Sourcepub fn set_value(&mut self, mask: usize, value: bool)
pub fn set_value(&mut self, mask: usize, value: bool)
Set the value of the Lut for these inputs (input bits packed in the mask)
Sourcepub fn set_bit(&mut self, mask: usize)
pub fn set_bit(&mut self, mask: usize)
Set the value of the Lut for these inputs to true (input bits packed in the mask)
Sourcepub fn unset_bit(&mut self, mask: usize)
pub fn unset_bit(&mut self, mask: usize)
Set the value of the Lut for these inputs to false (input bits packed in the mask)
Sourcepub fn count_ones(&self) -> usize
pub fn count_ones(&self) -> usize
Count the number of one bits in the Lut
Sourcepub fn count_zeros(&self) -> usize
pub fn count_zeros(&self) -> usize
Count the number of zero bits in the Lut
Sourcepub fn not_inplace(&mut self)
pub fn not_inplace(&mut self)
Complement the Lut in place: f(x) –> !f(x)
Sourcepub fn and_inplace(&mut self, rhs: &Self)
pub fn and_inplace(&mut self, rhs: &Self)
And two Luts in place
Sourcepub fn or_inplace(&mut self, rhs: &Self)
pub fn or_inplace(&mut self, rhs: &Self)
Or two Luts in place
Sourcepub fn xor_inplace(&mut self, rhs: &Self)
pub fn xor_inplace(&mut self, rhs: &Self)
Xor two Luts in place
Sourcepub fn flip_inplace(&mut self, ind: usize)
pub fn flip_inplace(&mut self, ind: usize)
Flip a variable in place: f(x1, … xi, … xn) –> f(x1, … !xi, … xn)
Sourcepub fn flip_n_inplace(&mut self, mask: u32)
pub fn flip_n_inplace(&mut self, mask: u32)
Flip multiple variables in a mask, as generated by canonization methods
Bit i determines if variable i should be flipped, bit num_var if the output should be flipped
Sourcepub fn swap_inplace(&mut self, ind1: usize, ind2: usize)
pub fn swap_inplace(&mut self, ind1: usize, ind2: usize)
Swap two variables in place: f(…, xi, …, xj, …) –> f(…, xj, …, xi, …)
Sourcepub fn permute_inplace(&mut self, perm: &[u8])
pub fn permute_inplace(&mut self, perm: &[u8])
Permute the variables: f(x1, …, xi, …, xn) –> f(xp[1], …, xp[i], …, xp[n])
Sourcepub fn swap_adjacent_inplace(&mut self, ind: usize)
pub fn swap_adjacent_inplace(&mut self, ind: usize)
Swap two adjacent variables in place: f(…, xi, x+1, …) –> f(…, xi+1, xi, …)
Sourcepub fn flip(&self, ind: usize) -> Self
pub fn flip(&self, ind: usize) -> Self
Flip a variable: f(x1, … xi, … xn) –> f(x1, … !xi, … xn)
Sourcepub fn flip_n(&self, mask: u32) -> Self
pub fn flip_n(&self, mask: u32) -> Self
Flip multiple variables in a mask, as generated by canonization methods
Bit i determines if variable i should be flipped, bit num_var if the output should be flipped
Sourcepub fn swap(&self, ind1: usize, ind2: usize) -> Self
pub fn swap(&self, ind1: usize, ind2: usize) -> Self
Swap two variables: f(…, xi, …, xj, …) –> f(…, xj, …, xi, …)
Sourcepub fn permute(&self, perm: &[u8]) -> Self
pub fn permute(&self, perm: &[u8]) -> Self
Permute the variables: f(x1, …, xi, …, xn) –> f(xp[1], …, xp[i], …, xp[n])
Sourcepub fn swap_adjacent(&self, ind: usize) -> Self
pub fn swap_adjacent(&self, ind: usize) -> Self
Swap two adjacent variables: f(…, xi, x+1, …) –> f(…, xi+1, xi, …)
Sourcepub fn cofactors(&self, ind: usize) -> (Self, Self)
pub fn cofactors(&self, ind: usize) -> (Self, Self)
Obtain the two cofactors with respect to a variable
Sourcepub fn from_cofactors(c0: &Self, c1: &Self, ind: usize) -> Self
pub fn from_cofactors(c0: &Self, c1: &Self, ind: usize) -> Self
Create a Lut from its two cofactors
Sourcepub fn from_blocks(blocks: &[u64]) -> Self
pub fn from_blocks(blocks: &[u64]) -> Self
Create a Lut from its internal representation as 64-bit blocks
Sourcepub fn p_canonization(&self) -> (Self, [u8; NUM_VARS])
pub fn p_canonization(&self) -> (Self, [u8; NUM_VARS])
Find the smallest equivalent Lut up to permutation. Return the canonical representation and the input permutation to obtain it.
Sourcepub fn is_p_canonical(&self) -> bool
pub fn is_p_canonical(&self) -> bool
Returns whether the Lut is already p-canonical
Sourcepub fn n_canonization(&self) -> (Self, u32)
pub fn n_canonization(&self) -> (Self, u32)
Find the smallest equivalent Lut up to input flips and output flip. Return the canonical representation and the flips to obtain it.
Sourcepub fn is_n_canonical(&self) -> bool
pub fn is_n_canonical(&self) -> bool
Returns whether the Lut is already n-canonical
Sourcepub fn npn_canonization(&self) -> (Self, [u8; NUM_VARS], u32)
pub fn npn_canonization(&self) -> (Self, [u8; NUM_VARS], u32)
Find the smallest equivalent Lut up to permutation, input flips and output flip. Return the canonical representation and the permutation and flips to obtain it.
Sourcepub fn is_npn_canonical(&self) -> bool
pub fn is_npn_canonical(&self) -> bool
Returns whether the Lut is already npn-canonical
Sourcepub fn top_decomposition(&self, ind: usize) -> DecompositionType
pub fn top_decomposition(&self, ind: usize) -> DecompositionType
Top decomposition of the function with respect to this variable
Sourcepub fn is_pos_unate(&self, ind: usize) -> bool
pub fn is_pos_unate(&self, ind: usize) -> bool
Returns whether the function is positive unate
Sourcepub fn is_neg_unate(&self, ind: usize) -> bool
pub fn is_neg_unate(&self, ind: usize) -> bool
Returns whether the function is negative unate
Sourcepub fn all_functions() -> StaticLutIterator<NUM_VARS, NUM_WORDS>
pub fn all_functions() -> StaticLutIterator<NUM_VARS, NUM_WORDS>
Collection of all Luts of this size
Sourcepub fn bdd_complexity(luts: &[Self]) -> usize
pub fn bdd_complexity(luts: &[Self]) -> usize
Compute the number of nodes in the BDD representing these functions
This function uses the natural variable order (0 to num_vars) to build the BDD. This may not be the smallest possible BDD.
Sourcepub fn to_hex_string(&self) -> String
pub fn to_hex_string(&self) -> String
Return the hexadecimal string representing the function
Contrary to display, nothing else is printed: a45b instead of Lut4(a45b)
Sourcepub fn to_bin_string(&self) -> String
pub fn to_bin_string(&self) -> String
Return the binary string representing the function
Contrary to display, nothing else is printed: 0101 instead of Lut2(0101)
Sourcepub fn from_hex_string(s: &str) -> Result<Self, ParseLutError>
pub fn from_hex_string(s: &str) -> Result<Self, ParseLutError>
Build a Lut from an hexadecimal string
Sourcepub fn from_bin_string(s: &str) -> Result<Self, ParseLutError>
pub fn from_bin_string(s: &str) -> Result<Self, ParseLutError>
Build a Lut from a binary string
Trait Implementations§
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> Binary for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> Binary for StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitAnd<&StaticLut<NUM_VARS, NUM_WORDS>> for &StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitAnd<&StaticLut<NUM_VARS, NUM_WORDS>> for &StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitAnd<&StaticLut<NUM_VARS, NUM_WORDS>> for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitAnd<&StaticLut<NUM_VARS, NUM_WORDS>> for StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitAnd<StaticLut<NUM_VARS, NUM_WORDS>> for &StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitAnd<StaticLut<NUM_VARS, NUM_WORDS>> for &StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitAnd for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitAnd for StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitAndAssign<&StaticLut<NUM_VARS, NUM_WORDS>> for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitAndAssign<&StaticLut<NUM_VARS, NUM_WORDS>> for StaticLut<NUM_VARS, NUM_WORDS>
Source§fn bitand_assign(&mut self, rhs: &Self)
fn bitand_assign(&mut self, rhs: &Self)
&= operation. Read moreSource§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitAndAssign for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitAndAssign for StaticLut<NUM_VARS, NUM_WORDS>
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitOr<&StaticLut<NUM_VARS, NUM_WORDS>> for &StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitOr<&StaticLut<NUM_VARS, NUM_WORDS>> for &StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitOr<&StaticLut<NUM_VARS, NUM_WORDS>> for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitOr<&StaticLut<NUM_VARS, NUM_WORDS>> for StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitOr<StaticLut<NUM_VARS, NUM_WORDS>> for &StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitOr<StaticLut<NUM_VARS, NUM_WORDS>> for &StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitOrAssign<&StaticLut<NUM_VARS, NUM_WORDS>> for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitOrAssign<&StaticLut<NUM_VARS, NUM_WORDS>> for StaticLut<NUM_VARS, NUM_WORDS>
Source§fn bitor_assign(&mut self, rhs: &Self)
fn bitor_assign(&mut self, rhs: &Self)
|= operation. Read moreSource§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitOrAssign for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitOrAssign for StaticLut<NUM_VARS, NUM_WORDS>
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitXor<&StaticLut<NUM_VARS, NUM_WORDS>> for &StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitXor<&StaticLut<NUM_VARS, NUM_WORDS>> for &StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitXor<&StaticLut<NUM_VARS, NUM_WORDS>> for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitXor<&StaticLut<NUM_VARS, NUM_WORDS>> for StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitXor<StaticLut<NUM_VARS, NUM_WORDS>> for &StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitXor<StaticLut<NUM_VARS, NUM_WORDS>> for &StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitXor for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitXor for StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitXorAssign<&StaticLut<NUM_VARS, NUM_WORDS>> for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitXorAssign<&StaticLut<NUM_VARS, NUM_WORDS>> for StaticLut<NUM_VARS, NUM_WORDS>
Source§fn bitxor_assign(&mut self, rhs: &Self)
fn bitxor_assign(&mut self, rhs: &Self)
^= operation. Read moreSource§impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitXorAssign for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> BitXorAssign for StaticLut<NUM_VARS, NUM_WORDS>
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§impl<const NUM_VARS: usize, const NUM_WORDS: usize> Default for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> Default for StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> Display for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> Display for StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> From<StaticLut<NUM_VARS, NUM_WORDS>> for Lut
impl<const NUM_VARS: usize, const NUM_WORDS: usize> From<StaticLut<NUM_VARS, NUM_WORDS>> for Lut
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> LowerHex for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> LowerHex for StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> Ord for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> Ord for StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> PartialEq for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> PartialEq for StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> PartialOrd for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> PartialOrd for StaticLut<NUM_VARS, NUM_WORDS>
Source§impl<const NUM_VARS: usize, const NUM_WORDS: usize> TryFrom<Lut> for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> TryFrom<Lut> for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> Copy for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> Eq for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> StructuralPartialEq for StaticLut<NUM_VARS, NUM_WORDS>
Auto Trait Implementations§
impl<const NUM_VARS: usize, const NUM_WORDS: usize> Freeze for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> RefUnwindSafe for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> Send for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> Sync for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> Unpin for StaticLut<NUM_VARS, NUM_WORDS>
impl<const NUM_VARS: usize, const NUM_WORDS: usize> UnwindSafe for StaticLut<NUM_VARS, NUM_WORDS>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more