SciML / DataInterpolations.jl

A library of data interpolation and smoothing functions
MIT License
203 stars 43 forks source link

Introduce idx_prev to use as iguess #273

Closed SouthEndMusic closed 1 week ago

SouthEndMusic commented 2 weeks ago

Fixes half of https://github.com/SciML/DataInterpolations.jl/issues/271

Checklist

SouthEndMusic commented 2 weeks ago

Quick benchmark:

using DataInterpolations
using BenchmarkTools

N = 1000
u = rand(N)
t = cumsum(rand(N))

itp = LinearInterpolation(u, t)

t_eval = range(first(t), last(t), length = 10000)

@btime itp.(t_eval)

# old: 276.000 μs (3 allocations: 78.25 KiB)
# new: 166.600 μs (3 allocations: 78.27 KiB)

So the better iguess gives a speedup because successive evaluations are close together. What kind of benchmarking would you like to see?

sathvikbhagavan commented 1 week ago

@ChrisRackauckas, can you approve CI?