Struct Polynomial

Source
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>

Source

pub fn from_nodes_in_context<'a, I>( ctx: &ContextHandle, face: Face, node_id: NodeID, poly_ids: I, ) -> Self
where I: IntoIterator + 'a, I::Item: IntoIterator<Item = &'a NodeID>,

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>

Source

pub fn new() -> Self

Creates an empty polynomial, θ.

Source

pub fn new_docked(dock: Face) -> Self

Creates an empty polynomial, θ, docked at a given Face.

Source

pub fn clear(&mut self)

Resets this polynomial into θ.

Source

pub fn atomic_multiply(&mut self, atomic: T)

Multiplies this polynomial (all its monomials) by a single-element monomial.

Source

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.

Source

pub fn is_empty(&self) -> bool

Source

pub fn is_atomic(&self) -> bool

Source

pub fn is_monomial(&self) -> bool

Source

pub fn num_monomials(&self) -> usize

Source

pub fn get_monomials(&self) -> Monomials<'_, T>

Creates a Monomials iterator.

Source

pub fn get_atomics(&self) -> Iter<'_, T>

Source

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>

Source§

fn clone(&self) -> Polynomial<T>

Returns a duplicate 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 Contextual for Polynomial<LinkID>

Source§

fn format(&self, ctx: &ContextHandle) -> Result<String, AcesError>

Source§

fn with(&self, ctx: &ContextHandle) -> InContext<'_, Self>

Source§

fn with_mut(&mut self, ctx: &ContextHandle) -> InContextMut<'_, Self>

Source§

impl<T: Debug + Atomic + Debug> Debug for Polynomial<T>

Source§

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

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

impl<T: Atomic + Debug> PartialEq for Polynomial<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Atomic + Debug> PartialOrd for Polynomial<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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Atomic + Debug> Eq for Polynomial<T>

Auto Trait Implementations§

§

impl<T> Freeze for Polynomial<T>

§

impl<T> RefUnwindSafe for Polynomial<T>
where T: RefUnwindSafe,

§

impl<T> Send for Polynomial<T>
where T: Send,

§

impl<T> Sync for Polynomial<T>
where T: Sync,

§

impl<T> Unpin for Polynomial<T>
where T: Unpin,

§

impl<T> UnwindSafe for Polynomial<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<Reference, Outer, OuterFieldType, Inner> HasPart<Nested<Outer, Inner>> for Reference
where Reference: HasPart<Outer> + ?Sized, Outer: Part<PartType = Field<OuterFieldType>>, Inner: Part, OuterFieldType: HasPart<Inner, RawTarget = OuterFieldType> + PartialRefTarget + ?Sized,

Source§

unsafe fn part_ptr( ptr: *const <Reference as PartialRefTarget>::RawTarget, ) -> <<Inner as Part>::PartType as PartType>::Ptr

Given a constant pointer to a target, produce a constant pointer to a part of it. Read more
Source§

unsafe fn part_ptr_mut( ptr: *mut <Reference as PartialRefTarget>::RawTarget, ) -> <<Inner as Part>::PartType as PartType>::PtrMut

Given a mutable pointer to a target, produce a mutable pointer to a part of it. Read more
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,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.
Source§

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

Source§

fn vzip(self) -> V