Struct volute::Lut

source ·
pub struct Lut { /* private fields */ }
Expand description

Arbitrary-size truth table

Implementations§

source§

impl Lut

source

pub fn num_vars(&self) -> usize

Query the number of variables of the Lut

source

pub fn num_bits(&self) -> usize

Query the number of bits in the Lut

source

pub fn num_blocks(&self) -> usize

Query the number of 64-bit blocks in the Lut

source

pub fn one(num_vars: usize) -> Lut

Create a constant true Lut

source

pub fn zero(num_vars: usize) -> Lut

Create a constant false Lut

source

pub fn nth_var(num_vars: usize, var: usize) -> Lut

Create a Lut returning the value of one of its variables

source

pub fn parity(num_vars: usize) -> Lut

Create a Lut returning true if the number of true variables is even

source

pub fn majority(num_vars: usize) -> Lut

Create a Lut returning true if the majority of the variables are true

source

pub fn threshold(num_vars: usize, k: usize) -> Lut

Create a Lut returning true if at least k variables are true

source

pub fn equals(num_vars: usize, k: usize) -> Lut

Create a Lut returning true if exactly k variables are true

source

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

source

pub fn random(num_vars: usize) -> Lut

Create a random Lut

source

pub fn value(&self, mask: usize) -> bool

Get the value of the Lut for these inputs (input bits packed in the mask)

source

pub fn get_bit(&self, mask: usize) -> bool

Get the value of the Lut for these inputs (input bits packed in the mask)

source

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)

source

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)

source

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)

source

pub fn not_inplace(&mut self)

Complement the Lut in place: f(x) –> !f(x)

source

pub fn and_inplace(&mut self, rhs: &Self)

And two Luts in place

source

pub fn or_inplace(&mut self, rhs: &Self)

Or two Luts in place

source

pub fn xor_inplace(&mut self, rhs: &Self)

Xor two Luts in place

source

pub fn flip_inplace(&mut self, ind: usize)

Flip a variable in place: f(x1, … xi, … xn) –> f(x1, … !xi, … xn)

source

pub fn swap_inplace(&mut self, ind1: usize, ind2: usize)

Swap two variables in place: f(…, xi, …, xj, …) –> f(…, xj, …, xi, …)

source

pub fn swap_adjacent_inplace(&mut self, ind: usize)

Swap two adjacent variables in place: f(…, xi, x+1, …) –> f(…, xi+1, xi, …)

source

pub fn not(&self) -> Lut

Complement the Lut: f(x) –> !f(x)

source

pub fn and(&self, rhs: &Lut) -> Lut

And two Luts

source

pub fn or(&self, rhs: &Lut) -> Lut

Or two Luts

source

pub fn xor(&self, rhs: &Lut) -> Lut

Xor two Luts

source

pub fn flip(&self, ind: usize) -> Lut

Flip a variable: f(x1, … xi, … xn) –> f(x1, … !xi, … xn)

source

pub fn swap(&self, ind1: usize, ind2: usize) -> Lut

Swap two variables: f(…, xi, …, xj, …) –> f(…, xj, …, xi, …)

source

pub fn swap_adjacent(&mut self, ind: usize) -> Lut

Swap two adjacent variables: f(…, xi, x+1, …) –> f(…, xi+1, xi, …)

source

pub fn cofactors(&self, ind: usize) -> (Self, Self)

Obtain the two cofactors with respect to a variable

source

pub fn from_cofactors(c0: &Self, c1: &Self, ind: usize) -> Self

Create a Lut from its two cofactors

source

pub fn blocks(&self) -> &[u64]

Return the internal representation as 64-bit blocks

source

pub fn from_blocks(num_vars: usize, blocks: &[u64]) -> Self

Create a Lut from its internal representation as 64-bit blocks

source

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.

source

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.

source

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.

source

pub fn top_decomposition(&self, ind: usize) -> DecompositionType

Top decomposition of the function with respect to this variable

source

pub fn is_pos_unate(&self, ind: usize) -> bool

Returns whether the function is positive unate

source

pub fn is_neg_unate(&self, ind: usize) -> bool

Returns whether the function is negative unate

source

pub fn all_functions(num_vars: usize) -> LutIterator

Collection of all Luts of a given size

source

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.

source

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)

source

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)

source

pub fn from_hex_string(num_vars: usize, s: &str) -> Result<Self, ()>

Build a Lut from an hexadecimal string

Trait Implementations§

source§

impl Binary for Lut

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl BitAnd<&Lut> for &Lut

§

type Output = Lut

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: &Lut) -> Self::Output

Performs the & operation. Read more
source§

impl BitAnd<&Lut> for Lut

§

type Output = Lut

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: &Lut) -> Self::Output

Performs the & operation. Read more
source§

impl BitAnd<Lut> for &Lut

§

type Output = Lut

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Lut) -> Self::Output

Performs the & operation. Read more
source§

impl BitAnd for Lut

§

type Output = Lut

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Lut) -> Self::Output

Performs the & operation. Read more
source§

impl BitAndAssign<&Lut> for Lut

source§

fn bitand_assign(&mut self, rhs: &Lut)

Performs the &= operation. Read more
source§

impl BitAndAssign for Lut

source§

fn bitand_assign(&mut self, rhs: Lut)

Performs the &= operation. Read more
source§

impl BitOr<&Lut> for &Lut

§

type Output = Lut

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: &Lut) -> Self::Output

Performs the | operation. Read more
source§

impl BitOr<&Lut> for Lut

§

type Output = Lut

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: &Lut) -> Self::Output

Performs the | operation. Read more
source§

impl BitOr<Lut> for &Lut

§

type Output = Lut

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Lut) -> Self::Output

Performs the | operation. Read more
source§

impl BitOr for Lut

§

type Output = Lut

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Lut) -> Self::Output

Performs the | operation. Read more
source§

impl BitOrAssign<&Lut> for Lut

source§

fn bitor_assign(&mut self, rhs: &Lut)

Performs the |= operation. Read more
source§

impl BitOrAssign for Lut

source§

fn bitor_assign(&mut self, rhs: Lut)

Performs the |= operation. Read more
source§

impl BitXor<&Lut> for &Lut

§

type Output = Lut

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: &Lut) -> Self::Output

Performs the ^ operation. Read more
source§

impl BitXor<&Lut> for Lut

§

type Output = Lut

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: &Lut) -> Self::Output

Performs the ^ operation. Read more
source§

impl BitXor<Lut> for &Lut

§

type Output = Lut

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Lut) -> Self::Output

Performs the ^ operation. Read more
source§

impl BitXor for Lut

§

type Output = Lut

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Lut) -> Self::Output

Performs the ^ operation. Read more
source§

impl BitXorAssign<&Lut> for Lut

source§

fn bitxor_assign(&mut self, rhs: &Lut)

Performs the ^= operation. Read more
source§

impl BitXorAssign for Lut

source§

fn bitxor_assign(&mut self, rhs: Lut)

Performs the ^= operation. Read more
source§

impl Clone for Lut

source§

fn clone(&self) -> Lut

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Lut

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Lut

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for Lut

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&Esop> for Lut

source§

fn from(value: &Esop) -> Self

Converts to this type from the input type.
source§

impl From<&Lut> for Esop

source§

fn from(value: &Lut) -> Self

Obtain the canonical Esop representation, with only positive cubes

source§

impl From<&Lut> for Sop

source§

fn from(value: &Lut) -> Self

Converts to this type from the input type.
source§

impl From<&Soes> for Lut

source§

fn from(value: &Soes) -> Self

Converts to this type from the input type.
source§

impl From<&Sop> for Lut

source§

fn from(value: &Sop) -> Self

Converts to this type from the input type.
source§

impl From<Esop> for Lut

source§

fn from(value: Esop) -> Self

Converts to this type from the input type.
source§

impl From<Lut> for Esop

source§

fn from(value: Lut) -> Self

Converts to this type from the input type.
source§

impl From<Lut> for Sop

source§

fn from(value: Lut) -> Self

Converts to this type from the input type.
source§

impl From<Soes> for Lut

source§

fn from(value: Soes) -> Self

Converts to this type from the input type.
source§

impl From<Sop> for Lut

source§

fn from(value: Sop) -> Self

Converts to this type from the input type.
source§

impl<const N: usize, const T: usize> From<StaticLut<N, T>> for Lut

source§

fn from(lut: StaticLut<N, T>) -> Lut

Converts to this type from the input type.
source§

impl Hash for Lut

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl LowerHex for Lut

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl Not for &Lut

§

type Output = Lut

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
source§

impl Not for Lut

§

type Output = Lut

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
source§

impl Ord for Lut

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Lut

source§

fn eq(&self, other: &Lut) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Lut

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<const N: usize, const T: usize> TryFrom<Lut> for StaticLut<N, T>

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(lut: Lut) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for Lut

source§

impl StructuralEq for Lut

source§

impl StructuralPartialEq for Lut

Auto Trait Implementations§

§

impl RefUnwindSafe for Lut

§

impl Send for Lut

§

impl Sync for Lut

§

impl Unpin for Lut

§

impl UnwindSafe for Lut

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V