pub struct Polynomial<T: Atomic + Debug> { /* private fields */ }Expand description
A formal polynomial.
Internally a Polynomial is represented as a vector of N
Atomic identifiers and a boolean matrix with N columns and
M rows. Vector of Atomic identifiers is sorted in strictly
increasing order. It represents the set of nodes occuring in the
polynomial and N is the number of such nodes.
M is the number of monomials in the canonical representation of the polynomial. The order in which monomials are listed is arbitrary. An element in row i and column j of the matrix determines if a node in j-th position in the vector of identifiers occurs in i-th monomial.
Polynomials may be compared and added using traits from
std::cmp and std::ops standard modules, with the obvious
exception of std::cmp::Ord. Note however that, in general,
preventing Context or Port mismatch between polynomials is
the responsibility of the caller of an operation. Implementation
detects some, but not all, cases of mismatch and panics if it does
so.
Implementations§
Source§impl Polynomial<LinkID>
impl Polynomial<LinkID>
Sourcepub fn from_nodes_in_context<'a, I>(
ctx: &ContextHandle,
face: Face,
node_id: NodeID,
poly_ids: I,
) -> Self
pub fn from_nodes_in_context<'a, I>( ctx: &ContextHandle, face: Face, node_id: NodeID, poly_ids: I, ) -> Self
Creates a polynomial from a sequence of sequences of
NodeIDs and in a Context given by a ContextHandle.
Source§impl<T: Atomic + Debug> Polynomial<T>
impl<T: Atomic + Debug> Polynomial<T>
Sourcepub fn new_docked(dock: Face) -> Self
pub fn new_docked(dock: Face) -> Self
Creates an empty polynomial, θ, docked at a given
Face.
Sourcepub fn atomic_multiply(&mut self, atomic: T)
pub fn atomic_multiply(&mut self, atomic: T)
Multiplies this polynomial (all its monomials) by a single-element monomial.
Sourcepub fn add_atomics_sorted<I>(&mut self, atomics: I) -> Result<bool, AcesError>where
I: IntoIterator<Item = T>,
pub fn add_atomics_sorted<I>(&mut self, atomics: I) -> Result<bool, AcesError>where
I: IntoIterator<Item = T>,
Adds a sequence of Atomic identifiers to this polynomial
as another monomial.
On success, returns true if this polynomial changed or
false if it didn’t, due to idempotency of addition.
Returns error if atomics aren’t given in strictly increasing
order, or in case of port mismatch, or if context mismatch was
detected.
pub fn is_empty(&self) -> bool
pub fn is_atomic(&self) -> bool
pub fn is_monomial(&self) -> bool
pub fn num_monomials(&self) -> usize
Sourcepub fn get_monomials(&self) -> Monomials<'_, T> ⓘ
pub fn get_monomials(&self) -> Monomials<'_, T> ⓘ
Creates a Monomials iterator.
pub fn get_atomics(&self) -> Iter<'_, T>
Sourcepub fn as_sat_clauses(&self, port_lit: Literal) -> Vec<Clause>
pub fn as_sat_clauses(&self, port_lit: Literal) -> Vec<Clause>
Constructs the firing rule of this polynomial, the logical
constraint imposed on firing components, if the polynomial is
attached to the node and face represented by port_lit. The
rule is transformed into a CNF formula, a conjunction of
disjunctions of sat::Literals (a sequence of clauses).
Returns a sequence of clauses in the form of vector of vectors
of sat::Literals.
Trait Implementations§
Source§impl<T: Clone + Atomic + Debug> Clone for Polynomial<T>
impl<T: Clone + Atomic + Debug> Clone for Polynomial<T>
Source§fn clone(&self) -> Polynomial<T>
fn clone(&self) -> Polynomial<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more