pub struct StaticLut<const N: usize, const T: usize> { /* private fields */ }
Expand description
Fixed-size truth table
Implementations§
source§impl<const N: usize, const T: usize> StaticLut<N, T>
impl<const N: usize, const T: usize> StaticLut<N, T>
sourcepub fn num_blocks(&self) -> usize
pub 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 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 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 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 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 swap_adjacent(&mut self, ind: usize) -> Self
pub fn swap_adjacent(&mut 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; N])
pub fn p_canonization(&self) -> (Self, [u8; N])
Find the smallest equivalent Lut up to permutation. Return the canonical representation and the input permutation to obtain it.
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 npn_canonization(&self) -> (Self, [u8; N], u32)
pub fn npn_canonization(&self) -> (Self, [u8; N], 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 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<N, T>
pub fn all_functions() -> StaticLutIterator<N, T>
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 in 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 in printed: 0101
instead of Lut2(0101)
sourcepub fn from_hex_string(s: &str) -> Result<Self, ()>
pub fn from_hex_string(s: &str) -> Result<Self, ()>
Build a Lut from an hexadecimal string
Trait Implementations§
source§impl<const N: usize, const T: usize> BitAndAssign<&StaticLut<N, T>> for StaticLut<N, T>
impl<const N: usize, const T: usize> BitAndAssign<&StaticLut<N, T>> for StaticLut<N, T>
source§fn bitand_assign(&mut self, rhs: &Self)
fn bitand_assign(&mut self, rhs: &Self)
&=
operation. Read moresource§impl<const N: usize, const T: usize> BitAndAssign for StaticLut<N, T>
impl<const N: usize, const T: usize> BitAndAssign for StaticLut<N, T>
source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read moresource§impl<const N: usize, const T: usize> BitOrAssign<&StaticLut<N, T>> for StaticLut<N, T>
impl<const N: usize, const T: usize> BitOrAssign<&StaticLut<N, T>> for StaticLut<N, T>
source§fn bitor_assign(&mut self, rhs: &Self)
fn bitor_assign(&mut self, rhs: &Self)
|=
operation. Read moresource§impl<const N: usize, const T: usize> BitOrAssign for StaticLut<N, T>
impl<const N: usize, const T: usize> BitOrAssign for StaticLut<N, T>
source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read moresource§impl<const N: usize, const T: usize> BitXorAssign<&StaticLut<N, T>> for StaticLut<N, T>
impl<const N: usize, const T: usize> BitXorAssign<&StaticLut<N, T>> for StaticLut<N, T>
source§fn bitxor_assign(&mut self, rhs: &Self)
fn bitxor_assign(&mut self, rhs: &Self)
^=
operation. Read moresource§impl<const N: usize, const T: usize> BitXorAssign for StaticLut<N, T>
impl<const N: usize, const T: usize> BitXorAssign for StaticLut<N, T>
source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^=
operation. Read moresource§impl<const N: usize, const T: usize> Ord for StaticLut<N, T>
impl<const N: usize, const T: usize> Ord for StaticLut<N, T>
source§impl<const N: usize, const T: usize> PartialEq for StaticLut<N, T>
impl<const N: usize, const T: usize> PartialEq for StaticLut<N, T>
source§impl<const N: usize, const T: usize> PartialOrd for StaticLut<N, T>
impl<const N: usize, const T: usize> PartialOrd for StaticLut<N, T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more