Struct twenty_first::shared_math::circuit::Circuit
source · pub struct Circuit<T: Clone + Debug + Add<Output = T> + Mul<Output = T> + Sub<Output = T> + Zero + One + Hash + Eq> {
pub id: usize,
pub visited_counter: usize,
pub expression: CircuitExpression<T>,
}
Expand description
A wrapper around a CircuitExpression
that manages additional bookkeeping information.
Fields§
§id: usize
§visited_counter: usize
§expression: CircuitExpression<T>
Implementations§
source§impl<T: Clone + Debug + WrappingAdd<Output = T> + WrappingMul<Output = T> + WrappingSub<Output = T> + Zero + One + Hash + Eq> Circuit<T>
impl<T: Clone + Debug + WrappingAdd<Output = T> + WrappingMul<Output = T> + WrappingSub<Output = T> + Zero + One + Hash + Eq> Circuit<T>
sourcepub fn traverse_multiple(ccs: &mut [Circuit<T>])
pub fn traverse_multiple(ccs: &mut [Circuit<T>])
Count how many times each reachable node is reached when traversing from
the starting points that are given as input. The result is stored in the
visited_counter
field in each node.
sourcepub fn assert_has_unique_ids(constraints: &mut [Circuit<T>])
pub fn assert_has_unique_ids(constraints: &mut [Circuit<T>])
Verify that a multicircuit has unique IDs. Panics otherwise.
sourcepub fn get_all_visited_counters(&self) -> Vec<usize>
pub fn get_all_visited_counters(&self) -> Vec<usize>
Return all visited counters in the subtree
sourcepub fn print_without_parentheses(&self) -> bool
pub fn print_without_parentheses(&self) -> bool
Return true if the contained multivariate polynomial consists of only a single term. This means that it can be pretty-printed without parentheses.
sourcepub fn is_zero(&self) -> bool
pub fn is_zero(&self) -> bool
Return true if this node represents a constant value of zero, does not catch composite expressions that will always evaluate to zero.
sourcepub fn is_one(&self) -> bool
pub fn is_one(&self) -> bool
Return true if this node represents a constant value of one, does not catch composite expressions that will always evaluate to one.
sourcepub fn assert_all_evaluate_different(circuits: &[Self], input: Vec<T>)
pub fn assert_all_evaluate_different(circuits: &[Self], input: Vec<T>)
Panics if two nodes evaluate to the same value