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

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

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]

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

Linear transformation of a polynomial by a given x according to Horner’s method

Examples

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

fn main() {
    let a = poly(c!(1,3,2));
    let translated = a.translate_x(2);

    assert_eq!(translated.eval(3), 6_f64);
}

Trait Implementations

impl Add<Polynomial> for Polynomial[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, other: Self) -> Self[src]

Performs the + operation. Read more

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

type Output = Self

The resulting type after applying the + operator.

fn add(self, other: T) -> Self[src]

Performs the + operation. Read more

impl Calculus for Polynomial[src]

fn diff(&self) -> Self[src]

fn integral(&self) -> Self[src]

impl Clone for Polynomial[src]

fn clone(&self) -> Polynomial[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Polynomial[src]

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

Formats the value using the given formatter. Read more

impl Default for Polynomial[src]

fn default() -> Polynomial[src]

Returns the “default value” for a type. Read more

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
}

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

Formats the value using the given formatter. Read more

impl Div<Polynomial> for Polynomial[src]

type Output = (Self, Self)

The resulting type after applying the / operator.

fn div(self, other: Self) -> Self::Output[src]

Performs the / operation. Read more

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

type Output = Self

The resulting type after applying the / operator.

fn div(self, other: T) -> Self[src]

Performs the / operation. Read more

impl Mul<Polynomial> for Polynomial[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, other: Self) -> Self[src]

Performs the * operation. Read more

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

type Output = Self

The resulting type after applying the * operator.

fn mul(self, other: T) -> Self[src]

Performs the * operation. Read more

impl Neg for Polynomial[src]

type Output = Self

The resulting type after applying the - operator.

fn neg(self) -> Self::Output[src]

Performs the unary - operation. Read more

impl PowOps for Polynomial[src]

fn powi(&self, n: i32) -> Self[src]

fn powf(&self, _f: f64) -> Self[src]

fn pow(&self, _f: Self) -> Self[src]

fn sqrt(&self) -> Self[src]

impl Printable for Polynomial[src]

fn print(&self)[src]

impl Sub<Polynomial> for Polynomial[src]

type Output = Self

The resulting type after applying the - operator.

fn sub(self, other: Self) -> Self[src]

Performs the - operation. Read more

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

type Output = Self

The resulting type after applying the - operator.

fn sub(self, other: T) -> Self[src]

Performs the - operation. Read more

impl Environment for Polynomial[src]

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

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

pub fn vzip(self) -> V