logo
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. Space Complexity: O(m * 10^n), where m = max_x - min_x and n = frac_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. Time Complexity for lookup: O(1) if min_x <= x < max_x and O(func(x)) otherwise.

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

Performs the conversion.

Performs the conversion.

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

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.