pub struct AnfPolynomial { /* private fields */ }Expand description
Polynomial representation of Boolean function in Algebraic Normal Form (ANF).
The ANF representation is a XOR sum of monomials, where each monomial is a AND product of variables.
Implementations§
Source§impl AnfPolynomial
impl AnfPolynomial
Sourcepub fn get_polynomial_small(&self) -> Option<u64>
pub fn get_polynomial_small(&self) -> Option<u64>
Get the polynomial in ANF representation in unsigned 64-bit integer format. The unsigned representation of ANF is explained in README.md.
Returns None if the polynomial is too big to fit in a 64-bit integer (ie more than 6 variables).
Sourcepub fn get_polynomial_big(&self) -> BigUint
pub fn get_polynomial_big(&self) -> BigUint
Get the polynomial in ANF representation in big unsigned integer format. The unsigned representation of ANF is explained in README.md.
Sourcepub fn get_degree(&self) -> usize
pub fn get_degree(&self) -> usize
Get the degree of the polynomial.
The degree of the polynomial is the maximum number of variables in a monomial.
Sourcepub fn to_string(&self) -> String
pub fn to_string(&self) -> String
Returns the string representation of the polynomial.
The monomials are ordered by the number of variables in the monomial in descending order, and then by the lexicographic order of the variables.
Example: “x0*x1 + x0 + x1 + x2”, the ‘+’ operator is the XOR operator, and the ‘*’ operator is the AND operator.
Sourcepub fn from_str(
anf_polynomial: &str,
num_variables: usize,
) -> Result<Self, BooleanFunctionError>
pub fn from_str( anf_polynomial: &str, num_variables: usize, ) -> Result<Self, BooleanFunctionError>
Computes the ANF polynomial from string representation
Representation must be in the form “x0*x2*x3 + x2*x3 + x1 + 1”.
X’s index starts at 0, meaning the maximum index is variable count - 1.
§Parameters:
anf_polynomial: The string representation of the ANF formnum_variables: Variable count of the polynomial
§Returns:
The ANF polynomial, or an error if the input string doesn’t respect the format and unsafe_disable_safety_checks feature is not activated.
Sourcepub fn get_boolean_function_type(&self) -> BooleanFunctionType
pub fn get_boolean_function_type(&self) -> BooleanFunctionType
Sourcepub fn to_boolean_function(&self) -> BooleanFunction
pub fn to_boolean_function(&self) -> BooleanFunction
Convert ANF polynomial to the corresponding Boolean Function, using fast ANF transform algorithm
§Returns
A Boolean function corresponding to the polynomial
Trait Implementations§
Source§impl Add for AnfPolynomial
ADD operator for Boolean functions ANF polynomial.
impl Add for AnfPolynomial
ADD operator for Boolean functions ANF polynomial.
It is equivalent to crate::AnfPolynomial::bitxor operator.
§Panics
If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.
Source§impl AddAssign for AnfPolynomial
In-place ADD operator for Boolean functions ANF polynomial.
impl AddAssign for AnfPolynomial
In-place ADD operator for Boolean functions ANF polynomial.
It is equivalent to crate::AnfPolynomial::bitxor_assign operator.
§Panics
If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl BitAnd for AnfPolynomial
AND operator for Boolean functions ANF polynomial
impl BitAnd for AnfPolynomial
AND operator for Boolean functions ANF polynomial
§Panics
If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.
Source§impl BitAndAssign for AnfPolynomial
In-place AND operator for Boolean functions ANF polynomial
impl BitAndAssign for AnfPolynomial
In-place AND operator for Boolean functions ANF polynomial
§Panics
If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitXor for AnfPolynomial
XOR operator for Boolean functions ANF polynomial
impl BitXor for AnfPolynomial
XOR operator for Boolean functions ANF polynomial
§Panics
If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.
Source§impl BitXorAssign for AnfPolynomial
In-place XOR operator for Boolean functions ANF polynomial
impl BitXorAssign for AnfPolynomial
In-place XOR operator for Boolean functions ANF polynomial
§Panics
If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§impl Clone for AnfPolynomial
impl Clone for AnfPolynomial
Source§fn clone(&self) -> AnfPolynomial
fn clone(&self) -> AnfPolynomial
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AnfPolynomial
impl Debug for AnfPolynomial
Source§impl Display for AnfPolynomial
Display implementation for AnfPolynomial.
impl Display for AnfPolynomial
Display implementation for AnfPolynomial.
Internally uses the AnfPolynomial::to_string method.
Source§impl Into<BooleanFunction> for AnfPolynomial
impl Into<BooleanFunction> for AnfPolynomial
Source§fn into(self) -> BooleanFunction
fn into(self) -> BooleanFunction
Source§impl Into<String> for AnfPolynomial
impl Into<String> for AnfPolynomial
Source§impl Mul for AnfPolynomial
MUL operator for Boolean functions ANF polynomial.
impl Mul for AnfPolynomial
MUL operator for Boolean functions ANF polynomial.
It is equivalent to crate::AnfPolynomial::bitand operator.
§Panics
If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.
Source§impl MulAssign for AnfPolynomial
In-place MUL operator for Boolean functions ANF polynomial.
impl MulAssign for AnfPolynomial
In-place MUL operator for Boolean functions ANF polynomial.
It is equivalent to crate::AnfPolynomial::bitand_assign operator.
§Panics
If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moreSource§impl PartialEq for AnfPolynomial
impl PartialEq for AnfPolynomial
impl Eq for AnfPolynomial
impl StructuralPartialEq for AnfPolynomial
Auto Trait Implementations§
impl Freeze for AnfPolynomial
impl RefUnwindSafe for AnfPolynomial
impl Send for AnfPolynomial
impl Sync for AnfPolynomial
impl Unpin for AnfPolynomial
impl UnsafeUnpin for AnfPolynomial
impl UnwindSafe for AnfPolynomial
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more