[][src]Struct sss_rs::geometry::polynomial::Polynomial

pub struct Polynomial { /* fields omitted */ }

A polynomial function that is made up of a Vec of @Term. It supports common operations done on polynomials including finding the 'y' value with a given 'x' value.

Methods

impl Polynomial[src]

pub fn new() -> Self[src]

Creates an empty polynomial with no terms

pub fn from_points(points: &Vec<Point>, degree: usize) -> Result<Self, Error>[src]

From a given list of points, attempts to use Lagrange interpolation to generate the polynomial that runs through those points. Will return an error if there's not enough pointes to satisfy the @degree requested. If the degree is not to be known, it can be set to @points.len() - 1

pub fn builder() -> PolynomialBuilder[src]

Returns a PolynomialBuilder struct that provides a builder design pattern.

pub fn get_degree(&self) -> i32[src]

Gets the degree of the polynomial

pub fn add_to_term(&mut self, term: Term)[src]

Adds a term to the polynomial

pub fn sub_to_term(&mut self, term: Term)[src]

Subs aterm from the polynomial

pub fn set_term(&mut self, term: Term)[src]

Sets the term with degree @term.get_degree() to @term

pub fn set_terms(&mut self, poly: Polynomial)[src]

Iterates through @poly's terms and sets each of @self's terms to those from @poly

pub fn get_term(&self, degree: i32) -> Term[src]

Returns a copy of the term with the given degree, or creates a new zero coefficient term and returns it. This term is not added into the polynomial

pub fn add_polynomial(self, rhs: Self) -> Self[src]

Adds together two polynomials, consuming both and returning the sum

pub fn sub_polynomial(self, rhs: Self) -> Self[src]

Subtracts one polynomial from the other, consuming both and returning the difference

pub fn mul_polynomial(self, rhs: Self) -> Self[src]

Multiplies together two polynomials, consuming both and returning the product

pub fn scale<T: Into<Fraction>>(self, scalar: T) -> Self[src]

Scales the polynomial with the given @scalar. Each term gets multiplied by @scalar with no impact on the terms' degree

pub fn negate(self) -> Self[src]

Negates the entire polynomial, meaning each term has its sign flipped

pub fn get_y_value(&self, x_val: Fraction) -> Fraction[src]

Get the corresponding 'y' value to the given 'x' value

Trait Implementations

impl From<Term> for Polynomial[src]

impl IntoIterator for Polynomial[src]

Creates an iterator that iterates through the terms of the polynomial

type Item = Term

The type of the elements being iterated over.

type IntoIter = IntoIter<Self::Item>

Which kind of iterator are we turning this into?

impl Clone for Polynomial[src]

impl Default for Polynomial[src]

impl Eq for Polynomial[src]

impl PartialEq<Polynomial> for Polynomial[src]

impl Display for Polynomial[src]

impl Debug for Polynomial[src]

impl Sub<Polynomial> for Polynomial[src]

type Output = Polynomial

The resulting type after applying the - operator.

impl<'_> Sub<&'_ Polynomial> for Polynomial[src]

type Output = Polynomial

The resulting type after applying the - operator.

impl<'_> Sub<Polynomial> for &'_ Polynomial[src]

type Output = Polynomial

The resulting type after applying the - operator.

impl<'_, '_> Sub<&'_ Polynomial> for &'_ Polynomial[src]

type Output = Polynomial

The resulting type after applying the - operator.

impl Sub<Polynomial> for Term[src]

type Output = Polynomial

The resulting type after applying the - operator.

impl<'_> Sub<&'_ Polynomial> for Term[src]

type Output = Polynomial

The resulting type after applying the - operator.

impl<'_> Sub<Polynomial> for &'_ Term[src]

type Output = Polynomial

The resulting type after applying the - operator.

impl<'_, '_> Sub<&'_ Polynomial> for &'_ Term[src]

type Output = Polynomial

The resulting type after applying the - operator.

impl Add<Polynomial> for Polynomial[src]

type Output = Polynomial

The resulting type after applying the + operator.

impl<'_> Add<&'_ Polynomial> for Polynomial[src]

type Output = Polynomial

The resulting type after applying the + operator.

impl<'_> Add<Polynomial> for &'_ Polynomial[src]

type Output = Polynomial

The resulting type after applying the + operator.

impl<'_, '_> Add<&'_ Polynomial> for &'_ Polynomial[src]

type Output = Polynomial

The resulting type after applying the + operator.

impl Add<Polynomial> for Term[src]

type Output = Polynomial

The resulting type after applying the + operator.

impl<'_> Add<&'_ Polynomial> for Term[src]

type Output = Polynomial

The resulting type after applying the + operator.

impl<'_> Add<Polynomial> for &'_ Term[src]

type Output = Polynomial

The resulting type after applying the + operator.

impl<'_, '_> Add<&'_ Polynomial> for &'_ Term[src]

type Output = Polynomial

The resulting type after applying the + operator.

impl Mul<Polynomial> for Polynomial[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl<'_> Mul<&'_ Polynomial> for Polynomial[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl<'_> Mul<Polynomial> for &'_ Polynomial[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl<'_, '_> Mul<&'_ Polynomial> for &'_ Polynomial[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl Mul<Polynomial> for Term[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl<'_> Mul<&'_ Polynomial> for Term[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl<'_> Mul<Polynomial> for &'_ Term[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl<'_, '_> Mul<&'_ Polynomial> for &'_ Term[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl Neg for Polynomial[src]

type Output = Self

The resulting type after applying the - operator.

impl<'_> Neg for &'_ Polynomial[src]

type Output = Polynomial

The resulting type after applying the - operator.

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]