Module interpolate

Module interpolate 

Source
Expand description

Interpolation module for NumRS2

Provides interpolation methods similar to scipy.interpolate:

§1D Interpolation

  • Linear interpolation: Fast piecewise linear interpolation
  • Cubic spline: Smooth C² continuous splines (natural, clamped, not-a-knot)
  • B-splines: Basis spline interpolation
  • Hermite interpolation: Piecewise cubic with derivative constraints
  • PCHIP: Piecewise Cubic Hermite Interpolating Polynomial (monotone)

§2D Interpolation

  • Bilinear: Fast rectangular grid interpolation
  • Bicubic: Smooth 2D cubic interpolation
  • Regular grid: N-dimensional grid interpolation

§Multivariate Interpolation

  • RBF: Radial basis function interpolation
  • Nearest neighbor: Closest point interpolation

§Examples

use numrs2::prelude::*;
use numrs2::interpolate::*;

// 1D linear interpolation
let x: Array<f64> = Array::from_vec(vec![0.0, 1.0, 2.0, 3.0]);
let y: Array<f64> = Array::from_vec(vec![0.0, 1.0, 4.0, 9.0]);
let interp = Interp1D::linear(&x, &y).unwrap();
let result: f64 = interp.evaluate(1.5).unwrap();
assert!((result - 2.5).abs() < 1e-10);

// Cubic spline interpolation
let spline = CubicSplineInterp::natural(&x, &y).unwrap();
let smooth: f64 = spline.evaluate(1.5).unwrap();

Structs§

BilinearInterp
Bilinear interpolation on a regular grid
CubicSplineInterp
Enhanced cubic spline interpolator with boundary conditions
Interp1D
1D interpolator for univariate functions

Enums§

Interp1DKind
1D interpolation methods
SplineBoundary
Boundary condition types for cubic splines