Struct peroxide::structure::polynomial::Polynomial
source · [−]Expand description
Polynomial Structure
Fields
coef: Vec<f64>
Implementations
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);
}
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
Returns the “default value” for a type. Read more
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
}
type Output = Polynomial
type Output = Polynomial
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Polynomial
type Output = Polynomial
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Polynomial
type Output = Polynomial
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Polynomial
type Output = Polynomial
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = Polynomial
type Output = Polynomial
The resulting type after applying the *
operator.
Performs the *
operation. Read more
Auto Trait Implementations
impl RefUnwindSafe for Polynomial
impl Send for Polynomial
impl Sync for Polynomial
impl Unpin for Polynomial
impl UnwindSafe for Polynomial
Blanket Implementations
Mutably borrows from an owned value. Read more