pub struct CubicSpline { /* private fields */ }
Expand description

Cubic Spline (Natural)

Description

Implement traits of Natural cubic splines, by Arne Morten Kvarving.

Type

(&[f64], &[f64]) -> Cubic Spline

Examples

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

fn main() {
    let x = c!(0.9, 1.3, 1.9, 2.1);
    let y = c!(1.3, 1.5, 1.85, 2.1);

    let s = CubicSpline::from_nodes(&x, &y);

    let new_x = c!(1, 1.5, 2.0);

    // Generate Cubic polynomial
    for t in new_x.iter() {
        s.polynomial_at(*t).print();
    }
    // -0.2347x^3 + 0.6338x^2 - 0.0329x + 0.9873
    // 0.9096x^3 - 3.8292x^2 + 5.7691x - 1.5268
    // -2.2594x^3 + 14.2342x^2 - 28.5513x + 20.2094

    // Evaluation
    for t in new_x.iter() {
        s.eval(*t).print();
    }
}

Implementations

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

fn main() {
    let x = c!(0.9, 1.3, 1.9, 2.1);
    let y = c!(1.3, 1.5, 1.85, 2.1);

    let s = CubicSpline::from_nodes(&x, &y);

    for i in 0 .. 4 {
        println!("{}", s.eval(i as f64 / 2.0));
    }
}

Extends the spline with the given nodes.

Description

The method ensures that the transition between each polynomial is smooth and that the spline interpolation of the new nodes is calculated around x = 0 in order to avoid that successive spline extensions with large x values become inaccurate.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Converts to this type from the input type.

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Converts this type into the (usually inferred) input type.

Converts this type into the (usually inferred) input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.