[][src]Struct splashsurf_lib::kernel::DiscreteSquaredDistanceCubicKernel

pub struct DiscreteSquaredDistanceCubicKernel<R: Real> { /* fields omitted */ }

Accelerator for efficient evaluation of a precomputed cubic kernel

This structure is used to pre-compute a discrete representation of the cubic kernel function. In some computations that require many evaluations of the kernel, it is more efficient to evaluate the kernel using a squared distance to avoid taking the square root. To produce an appropriate quantization of the kernel for this use case, the compact support radius of the kernel is divided into n segments with quadratically increasing width. To be more precise, on a quadratic scale, the compact support [0, h*h] is divided into n equally sized segments of width dr. For the actual pre-computation, the exact kernel k(r) is evaluated at the midpoint m_i of every segment given by m_i = sqrt(i * dr) for i ∈ [0, n]. This results in an array of kernel values K that can be evaluated at runtime using a squared radius s by just mapping this radius back to the corresponding segment index i followed by a lookup in the value array, i.e. k(sqrt(s)) ≈ K[s/dr] (while taking care of rounding and clamping to the allowed index range).

Implementations

impl<R: Real> DiscreteSquaredDistanceCubicKernel<R>[src]

pub fn new(n: usize, h: R) -> Self[src]

Precomputes the discrete cubic kernel with compact support radius h, the squared radius h * h is divided into n segments for the quantization

pub fn evaluate(&self, r_squared: R) -> R[src]

Evaluates the precomputed kernel function at the specified squared radius, i.e. returns an approximate cubic kernel value at the radius sqrt(r_squared)

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,