pub struct Lut { /* private fields */ }
Expand description
Arbitrary-size truth table
Implementations§
source§impl Lut
impl Lut
sourcepub fn num_blocks(&self) -> usize
pub fn num_blocks(&self) -> usize
Query the number of 64-bit blocks in the Lut
sourcepub fn nth_var(num_vars: usize, var: usize) -> Lut
pub fn nth_var(num_vars: usize, var: usize) -> Lut
Create a Lut returning the value of one of its variables
sourcepub fn parity(num_vars: usize) -> Lut
pub fn parity(num_vars: usize) -> Lut
Create a Lut returning true if the number of true variables is even
sourcepub fn majority(num_vars: usize) -> Lut
pub fn majority(num_vars: usize) -> Lut
Create a Lut returning true if the majority of the variables are true
sourcepub fn threshold(num_vars: usize, k: usize) -> Lut
pub fn threshold(num_vars: usize, k: usize) -> Lut
Create a Lut returning true if at least k variables are true
sourcepub fn equals(num_vars: usize, k: usize) -> Lut
pub fn equals(num_vars: usize, k: usize) -> Lut
Create a Lut returning true if exactly k variables are true
sourcepub fn symmetric(num_vars: usize, count_values: usize) -> Lut
pub fn symmetric(num_vars: usize, count_values: usize) -> Lut
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 swap(&self, ind1: usize, ind2: usize) -> Lut
pub fn swap(&self, ind1: usize, ind2: usize) -> Lut
Swap two variables: f(…, xi, …, xj, …) –> f(…, xj, …, xi, …)
sourcepub fn swap_adjacent(&mut self, ind: usize) -> Lut
pub fn swap_adjacent(&mut self, ind: usize) -> Lut
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(num_vars: usize, blocks: &[u64]) -> Self
pub fn from_blocks(num_vars: usize, blocks: &[u64]) -> Self
Create a Lut from its internal representation as 64-bit blocks
sourcepub fn p_canonization(&self) -> (Self, Vec<u8>)
pub fn p_canonization(&self) -> (Self, Vec<u8>)
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, Vec<u8>, u32)
pub fn npn_canonization(&self) -> (Self, Vec<u8>, 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(num_vars: usize) -> LutIterator
pub fn all_functions(num_vars: usize) -> LutIterator
Collection of all Luts of a given 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
Equivalent functions (up to output complementation) are represented by the same BDD node. The natural variable order (0 to num_vars) is used: smaller BDDs may be possible with another ordering.
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)
Trait Implementations§
source§impl BitAndAssign<&Lut> for Lut
impl BitAndAssign<&Lut> for Lut
source§fn bitand_assign(&mut self, rhs: &Lut)
fn bitand_assign(&mut self, rhs: &Lut)
&=
operation. Read moresource§impl BitAndAssign for Lut
impl BitAndAssign for Lut
source§fn bitand_assign(&mut self, rhs: Lut)
fn bitand_assign(&mut self, rhs: Lut)
&=
operation. Read moresource§impl BitOrAssign<&Lut> for Lut
impl BitOrAssign<&Lut> for Lut
source§fn bitor_assign(&mut self, rhs: &Lut)
fn bitor_assign(&mut self, rhs: &Lut)
|=
operation. Read moresource§impl BitOrAssign for Lut
impl BitOrAssign for Lut
source§fn bitor_assign(&mut self, rhs: Lut)
fn bitor_assign(&mut self, rhs: Lut)
|=
operation. Read moresource§impl BitXorAssign<&Lut> for Lut
impl BitXorAssign<&Lut> for Lut
source§fn bitxor_assign(&mut self, rhs: &Lut)
fn bitxor_assign(&mut self, rhs: &Lut)
^=
operation. Read moresource§impl BitXorAssign for Lut
impl BitXorAssign for Lut
source§fn bitxor_assign(&mut self, rhs: Lut)
fn bitxor_assign(&mut self, rhs: Lut)
^=
operation. Read moresource§impl Ord for Lut
impl Ord for Lut
source§impl PartialOrd for Lut
impl PartialOrd for Lut
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