Struct volute::StaticLut

source ·
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>

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() -> Self

Create a constant true Lut

source

pub fn zero() -> Self

Create a constant false Lut

source

pub fn nth_var(var: usize) -> Self

Create a Lut returning the value of one of its variables

source

pub fn parity() -> Self

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

source

pub fn majority() -> Self

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

source

pub fn threshold(k: usize) -> Self

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

source

pub fn equals(k: usize) -> Self

Create a Lut returning true if exactly k variables are true

source

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

source

pub fn random() -> Self

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) -> StaticLut<N, T>

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

source

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

And two Luts

source

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

Or two Luts

source

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

Xor two Luts

source

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

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

source

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

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

source

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

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(blocks: &[u64]) -> Self

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

source

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.

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, [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.

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() -> StaticLutIterator<N, T>

Collection of all Luts of this size

source

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.

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(s: &str) -> Result<Self, ()>

Build a Lut from an hexadecimal string

Trait Implementations§

source§

impl<const N: usize, const T: usize> Binary for StaticLut<N, T>

source§

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

Formats the value using the given formatter.
source§

impl<const N: usize, const T: usize> BitAnd<&StaticLut<N, T>> for &StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: &StaticLut<N, T>) -> Self::Output

Performs the & operation. Read more
source§

impl<const N: usize, const T: usize> BitAnd<&StaticLut<N, T>> for StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: &StaticLut<N, T>) -> Self::Output

Performs the & operation. Read more
source§

impl<const N: usize, const T: usize> BitAnd<StaticLut<N, T>> for &StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: StaticLut<N, T>) -> Self::Output

Performs the & operation. Read more
source§

impl<const N: usize, const T: usize> BitAnd for StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the & operator.
source§

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

Performs the & operation. Read more
source§

impl<const N: usize, const T: usize> BitAndAssign<&StaticLut<N, T>> for StaticLut<N, T>

source§

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

Performs the &= operation. Read more
source§

impl<const N: usize, const T: usize> BitAndAssign for StaticLut<N, T>

source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
source§

impl<const N: usize, const T: usize> BitOr<&StaticLut<N, T>> for &StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: &StaticLut<N, T>) -> Self::Output

Performs the | operation. Read more
source§

impl<const N: usize, const T: usize> BitOr<&StaticLut<N, T>> for StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: &StaticLut<N, T>) -> Self::Output

Performs the | operation. Read more
source§

impl<const N: usize, const T: usize> BitOr<StaticLut<N, T>> for &StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: StaticLut<N, T>) -> Self::Output

Performs the | operation. Read more
source§

impl<const N: usize, const T: usize> BitOr for StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the | operator.
source§

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

Performs the | operation. Read more
source§

impl<const N: usize, const T: usize> BitOrAssign<&StaticLut<N, T>> for StaticLut<N, T>

source§

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

Performs the |= operation. Read more
source§

impl<const N: usize, const T: usize> BitOrAssign for StaticLut<N, T>

source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
source§

impl<const N: usize, const T: usize> BitXor<&StaticLut<N, T>> for &StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: &StaticLut<N, T>) -> Self::Output

Performs the ^ operation. Read more
source§

impl<const N: usize, const T: usize> BitXor<&StaticLut<N, T>> for StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: &StaticLut<N, T>) -> Self::Output

Performs the ^ operation. Read more
source§

impl<const N: usize, const T: usize> BitXor<StaticLut<N, T>> for &StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: StaticLut<N, T>) -> Self::Output

Performs the ^ operation. Read more
source§

impl<const N: usize, const T: usize> BitXor for StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the ^ operator.
source§

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

Performs the ^ operation. Read more
source§

impl<const N: usize, const T: usize> BitXorAssign<&StaticLut<N, T>> for StaticLut<N, T>

source§

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

Performs the ^= operation. Read more
source§

impl<const N: usize, const T: usize> BitXorAssign for StaticLut<N, T>

source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
source§

impl<const N: usize, const T: usize> Clone for StaticLut<N, T>

source§

fn clone(&self) -> StaticLut<N, T>

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<const N: usize, const T: usize> Debug for StaticLut<N, T>

source§

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

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

impl<const N: usize, const T: usize> Default for StaticLut<N, T>

source§

fn default() -> Self

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

impl<const N: usize, const T: usize> Display for StaticLut<N, T>

source§

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

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

impl From<StaticLut<3, 1>> for u8

source§

fn from(lut: Lut3) -> u8

Converts to this type from the input type.
source§

impl From<StaticLut<4, 1>> for u16

source§

fn from(lut: Lut4) -> u16

Converts to this type from the input type.
source§

impl From<StaticLut<5, 1>> for u32

source§

fn from(lut: Lut5) -> u32

Converts to this type from the input type.
source§

impl From<StaticLut<6, 1>> for u64

source§

fn from(lut: Lut6) -> u64

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<const N: usize, const T: usize> Hash for StaticLut<N, T>

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<const N: usize, const T: usize> LowerHex for StaticLut<N, T>

source§

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

Formats the value using the given formatter.
source§

impl<const N: usize, const T: usize> Not for &StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
source§

impl<const N: usize, const T: usize> Not for StaticLut<N, T>

§

type Output = StaticLut<N, T>

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
source§

impl<const N: usize, const T: usize> Ord for StaticLut<N, T>

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<const N: usize, const T: usize> PartialEq for StaticLut<N, T>

source§

fn eq(&self, other: &StaticLut<N, T>) -> 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<const N: usize, const T: usize> PartialOrd for StaticLut<N, T>

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<const N: usize, const T: usize> Copy for StaticLut<N, T>

source§

impl<const N: usize, const T: usize> Eq for StaticLut<N, T>

source§

impl<const N: usize, const T: usize> StructuralEq for StaticLut<N, T>

source§

impl<const N: usize, const T: usize> StructuralPartialEq for StaticLut<N, T>

Auto Trait Implementations§

§

impl<const N: usize, const T: usize> RefUnwindSafe for StaticLut<N, T>

§

impl<const N: usize, const T: usize> Send for StaticLut<N, T>

§

impl<const N: usize, const T: usize> Sync for StaticLut<N, T>

§

impl<const N: usize, const T: usize> Unpin for StaticLut<N, T>

§

impl<const N: usize, const T: usize> UnwindSafe for StaticLut<N, T>

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