Skip to main content

cubic_spline_kernel_batch

Function cubic_spline_kernel_batch 

Source
pub fn cubic_spline_kernel_batch(r: &[f64], h: f64) -> Vec<f64>
Expand description

Evaluate the cubic spline kernel (M4 kernel) for a batch of distances.

The cubic spline kernel is widely used in Smoothed Particle Hydrodynamics (SPH). It is defined in 3D as:

W(r, h) = σ * { (2-q)^3 - 4*(1-q)^3   if 0 ≤ q < 1
              { (2-q)^3                  if 1 ≤ q < 2
              { 0                        if q ≥ 2

where q = r/h and σ = 1/(4π h³) is the 3D normalization constant.

§Arguments

  • r - batch of distances
  • h - smoothing length (must be positive)

§Returns

Vector of kernel values. Returns empty vec if h is not positive.