pub struct InterpolationTable<F: Fn(f64) -> f64> { /* private fields */ }
Expand description

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.

Implementations

Create a new InterpolationTable.

Arguments
  • min_x - minimum sample value
  • max_x - maximum sample value
  • frac_digits - number of fraction digits to store in sample
  • func - Function to emulate.

If given value is outside of min_x and max_x, the lookup falls back to applying the function itself. The table size grows with the number of fraction digits.

Lookup given value in table, and interpolate the result between the sampled values if necessary. This provides an approximation that is better the more fraction digits are used to generate this table.

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 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.