[][src]Struct peroxide::structure::polynomial::Polynomial

pub struct Polynomial {
    pub coef: Vec<f64>,
}

Polynomial Structure

Fields

coef: Vec<f64>

Implementations

impl Polynomial[src]

pub fn new(coef: Vec<f64>) -> Self[src]

Create Polynomial

pub fn eval<T>(&self, x: T) -> f64 where
    T: Into<f64> + Copy
[src]

Evaluate polynomial with value according to Horner's method

Examples

#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;

fn main() {
    let a = poly(c!(1,3,2));
    assert_eq!(a.eval(1), 6_f64);

    let b = poly(c!(1, 1, -2, -2));
    let x = 2_f64.sqrt();
    let horner_evaluation = b.eval(x);
    let naive_evaluation = x.powf(3.0) + x.powf(2.0) - 2.0*x - 2.0;
    assert_eq!(horner_evaluation, 0_f64);
    assert_ne!(naive_evaluation, horner_evaluation);
}

pub fn eval_vec(&self, v: Vec<f64>) -> Vec<f64>[src]

Trait Implementations

impl Add<Polynomial> for Polynomial[src]

type Output = Self

The resulting type after applying the + operator.

impl<T> Add<T> for Polynomial where
    T: Into<f64> + Copy
[src]

type Output = Self

The resulting type after applying the + operator.

impl Calculus for Polynomial[src]

impl Clone for Polynomial[src]

impl Debug for Polynomial[src]

impl Display for Polynomial[src]

Polynomial Print

Examples

#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;

fn main() {
    let a = poly(c!(1,3,2));
    a.print(); //x^2 + 3x + 2
}

impl Div<Polynomial> for Polynomial[src]

type Output = (Self, Self)

The resulting type after applying the / operator.

impl<T> Div<T> for Polynomial where
    T: Into<f64> + Copy
[src]

type Output = Self

The resulting type after applying the / operator.

impl Mul<Polynomial> for Polynomial[src]

type Output = Self

The resulting type after applying the * operator.

impl Mul<Polynomial> for usize[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl Mul<Polynomial> for i32[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl Mul<Polynomial> for i64[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl Mul<Polynomial> for f32[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl Mul<Polynomial> for f64[src]

type Output = Polynomial

The resulting type after applying the * operator.

impl<T> Mul<T> for Polynomial where
    T: Into<f64> + Copy
[src]

type Output = Self

The resulting type after applying the * operator.

impl Neg for Polynomial[src]

type Output = Self

The resulting type after applying the - operator.

impl PowOps for Polynomial[src]

impl Printable for Polynomial[src]

impl Sub<Polynomial> for Polynomial[src]

type Output = Self

The resulting type after applying the - operator.

impl<T> Sub<T> for Polynomial where
    T: Into<f64> + Copy
[src]

type Output = Self

The resulting type after applying the - operator.

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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 = Infallible

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<V, T> VZip<V> for T where
    V: MultiLane<T>,