Module bio::data_structures::interpolation_table[][src]

Fast lookup table for arbitrary floating point functions.

Examples

Easy:

use bio::data_structures::interpolation_table::*;

let table = InterpolationTable::new(0.0, 10.0, 5, |x| x.powf(2.0));
assert_eq!(table.get(3.0), 9.0);
assert_eq!(table.get(5.0), 25.0);

More complicated:

extern crate approx;
fn main() {
    use bio::data_structures::interpolation_table::*;
    use approx::assert_relative_eq;

    let table = InterpolationTable::new(0.0, 10.0, 5, |x| x.ln_1p());
    for &x in &[0.02, 0.04, 0.45678686, 0.23875, 1.45345e-6] {
        assert_relative_eq!(table.get(x), x.ln_1p(), epsilon = 0.00001);
    }
}

Structs

InterpolationTable

Fast lookup table for arbitrary floating point functions. This can be used to e.g., provide fast lookups of distribution values. Input values are sampled with a given precision and results are stored in a vector. During lookup, infimum and supremum of a given value are calculated and the result is interpolated.

Functions

interpolate