Trait rustnomial::SizedPolynomial[][src]

pub trait SizedPolynomial<N> {
    fn term_with_degree(&self, degree: usize) -> Term<N>;
fn terms_as_vec(&self) -> Vec<(N, usize)>;
fn degree(&self) -> Degree;
fn zero() -> Self
    where
        Self: Sized
;
fn set_to_zero(&mut self); fn is_zero(&self) -> bool { ... } }

Required methods

Returns the term with the given degree from self. If the term degree is larger than the actual degree, ZeroTerm will be returned. However, terms which are zero will also be returned as ZeroTerm, so this does not indicate that the final term has been reached.

Returns a Vec containing all of the terms of self, where each item is the coefficient and degree of each non-zero term, in order of descending degree.

Example

use rustnomial::{Polynomial, SizedPolynomial};
let polynomial = Polynomial::new(vec![1, 0, 2, 3]);
let terms = polynomial.terms_as_vec();
let mut iter = terms.into_iter();
assert_eq!(Some((1, 3)), iter.next());
assert_eq!(Some((2, 1)), iter.next());
assert_eq!(Some((3, 0)), iter.next());
assert_eq!(None, iter.next());

Returns the degree of self.

Returns the zero-instance of Self.

Sets the terms of self to zero.

Provided methods

Returns true if all terms of self are zero, and false if a non-zero term exists.

Example

use rustnomial::{SizedPolynomial, Polynomial};
let zero = Polynomial::new(vec![0, 0]);
assert!(zero.is_zero());
let non_zero = Polynomial::new(vec![0, 1]);
assert!(!non_zero.is_zero());

Implementors