pub struct Cube { /* private fields */ }
Expand description
Representation of the And of variables (a cube in Sum-of-Products representations)
Each variable is represented by a pair of bits, representing respectively the positive and negative literal. If none is set, the variable is unused. If both are set, the cube is 0.
It only supports And operations. Anything else must be implemented by more complex representations that use it, such as sum-of-products.
Implementations§
source§impl Cube
impl Cube
sourcepub fn is_constant(&self) -> bool
pub fn is_constant(&self) -> bool
Check whether the cube is a constant
sourcepub fn is_zero(&self) -> bool
pub fn is_zero(&self) -> bool
Check whether the cube is a constant zero
This can happen after And operations, so we check if any variable has the two bits set.
sourcepub fn nth_var_inv(var: usize) -> Cube
pub fn nth_var_inv(var: usize) -> Cube
Return the cube representing the nth variable, inverted
sourcepub fn minterm(num_vars: usize, mask: usize) -> Cube
pub fn minterm(num_vars: usize, mask: usize) -> Cube
Obtain the minterm for a value of the variables
sourcepub fn value(&self, mask: usize) -> bool
pub fn value(&self, mask: usize) -> bool
Get the value of the Cube for these inputs (input bits packed in the mask)
sourcepub fn from_vars(pos_vars: &[usize], neg_vars: &[usize]) -> Cube
pub fn from_vars(pos_vars: &[usize], neg_vars: &[usize]) -> Cube
Build a cube from the literals in it
sourcepub fn num_gates(&self) -> usize
pub fn num_gates(&self) -> usize
Return the number of And2 gates necessary to implement the cube
sourcepub fn pos_vars(&self) -> impl Iterator<Item = usize> + '_
pub fn pos_vars(&self) -> impl Iterator<Item = usize> + '_
Returns the variables that are positive in the cube
sourcepub fn neg_vars(&self) -> impl Iterator<Item = usize> + '_
pub fn neg_vars(&self) -> impl Iterator<Item = usize> + '_
Returns the variables that are negative in the cube
sourcepub fn intersects(&self, o: Cube) -> bool
pub fn intersects(&self, o: Cube) -> bool
Returns whether the cube intersects another
sourcepub fn implies_lut(&self, lut: &Lut) -> bool
pub fn implies_lut(&self, lut: &Lut) -> bool
Return whether the cube implies the given Lut
Trait Implementations§
source§impl Ord for Cube
impl Ord for Cube
source§impl PartialEq for Cube
impl PartialEq for Cube
source§impl PartialOrd for Cube
impl PartialOrd for Cube
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