[][src]Trait rustnomial::FreeSizePolynomial

pub trait FreeSizePolynomial<N> {
    pub fn from_terms(terms: &[(N, usize)]) -> Self
    where
        Self: Sized
;
pub fn add_term(&mut self, coeff: N, degree: usize); }

Required methods

pub fn from_terms(terms: &[(N, usize)]) -> Self where
    Self: Sized
[src]

Creates an instance of Self with the provided terms

pub fn add_term(&mut self, coeff: N, degree: usize)[src]

Adds the term with given coefficient and degree to self.

Loading content...

Implementors

impl<N> FreeSizePolynomial<N> for Polynomial<N> where
    N: Zero + Copy + AddAssign
[src]

pub fn from_terms(terms: &[(N, usize)]) -> Self[src]

Returns a Polynomial with the corresponding terms, in order of ax^n + bx^(n-1) + ... + cx + d

Arguments

  • terms - A slice of (coefficient, degree) pairs.

Example

use rustnomial::{FreeSizePolynomial, Polynomial};
// Corresponds to 1.0x^2 + 4.0x + 4.0
let polynomial = Polynomial::from_terms(&[(1.0, 2), (4.0, 1), (4.0, 0)]);
assert_eq!(Polynomial::new(vec![1., 4., 4.]), polynomial);

impl<N> FreeSizePolynomial<N> for SparsePolynomial<N> where
    N: Zero + Copy + AddAssign
[src]

pub fn from_terms(terms: &[(N, usize)]) -> Self[src]

Returns a SparsePolynomial with the corresponding terms.

Arguments

  • terms - A slice of (coefficient, degree) pairs.

Example

use rustnomial::{SparsePolynomial, FreeSizePolynomial};
// Corresponds to 1.0x^2 + 4.0x + 4.0
let polynomial = SparsePolynomial::from_terms(&[(1.0, 2), (4.0, 1), (4.0, 1)]);
Loading content...