Skip to main content

LutF64

Struct LutF64 

Source
pub struct LutF64 { /* private fields */ }
Expand description

A pre-computed interpolating lookup table mapping [0, 1] → f64.

Built at assembly time. Immutable and thread-safe after construction.

Implementations§

Source§

impl LutF64

Source

pub fn from_fn(f: impl Fn(f64) -> f64, resolution: usize) -> Self

Build from an arbitrary function over [0, 1].

f(p) is evaluated at resolution + 1 evenly spaced points from 0.0 to 1.0. Non-finite results are replaced with the nearest finite neighbor.

Source

pub fn from_values(values: &[f64]) -> Self

Build from a pre-computed slice of values.

Source

pub fn sample(&self, u: f64) -> f64

Query the LUT with linear interpolation.

u should be in [0.0, 1.0]. Values outside are clamped.

Source

pub fn len(&self) -> usize

Number of precomputed points (resolution + 1).

Source

pub fn is_empty(&self) -> bool

Whether the LUT has no precomputed points.

Source

pub fn as_ptr(&self) -> *const f64

Raw pointer to the LUT data (for JIT constant baking).

Source

pub fn resolution(&self) -> usize

The resolution (number of intervals).

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.