Advanced Usage

Once you're comfortable with basic interpolation, these features help optimize for specific use cases.

Grid Selection: Range vs Vector

The most impactful optimization is choosing the right grid type:

Grid TypeLookupWhen to Use
Range (0.0:0.1:10.0)O(1) alwaysUniform spacing
Vector ([0.0, 0.2, 0.5, ...])O(log n)Non-uniform spacing
# ✅ Uniform grid: use Range (O(1) lookup)
x = 0.0:0.01:10.0

# ✅ Non-uniform grid: must use Vector
x = [0.0, 0.1, 0.3, 0.6, 1.0, 1.5, 2.5, 5.0, 10.0]

# ❌ Avoid: collect() on uniform grid (degrades O(1) → O(log n))
x = collect(0.0:0.01:10.0)

For Vector grids, see Search & Hints section help optimize lookup performance.


Features

FeatureUse CaseDescription
Search & HintsSequential or streaming queriesO(1) amortized lookup with hints
Series InterpolantMultiple y-series on shared x-grid10-120× faster than separate interpolants
Memory & AllocationTight loops, real-time systemsZero-allocation patterns
Optimization (Optim.jl)Minimization over interpolated surfacesAnalytical gradient!/hessian! for Optim.jl

Quick Decision Guide

Which feature do I need?

These features can be combined. For example, a Series Interpolant can use LinearBinary search policy with external hints for maximum performance in ODE integrator callbacks.