mathnet-numerics icon indicating copy to clipboard operation
mathnet-numerics copied to clipboard

Added segment index caching for more efficient interpolation of large…

Open AdsRSherman opened this issue 9 years ago • 5 comments

I added a cache to linear, cubic, and quadratic spline interpolators to prevent unnecessary binary searches.

Very simply, it won't redo a binary search if the last returned index is valid for the current query.

AdsRSherman avatar Aug 25 '16 21:08 AdsRSherman

Thanks for proposing this change! It does indeed likely improve performance on typical use cases.

Unfortunately it does seem like this could break in multi-threaded use cases though, i.e. when the resulting interpolation is used concurrently from multiple threads.

cdrnet avatar Aug 30 '16 08:08 cdrnet

Gotcha. I can change the caches to ThreadLocal caches if that would help.

Also, I have n-degree lagrange and hermite polynomial interpolators that implement IInterpolation if you're interested. The algorithms were borrowed from JPL's SPICE toolkit.

AdsRSherman avatar Sep 29 '16 17:09 AdsRSherman

@cdrnet Added thread-local caches. In my testing this substantially improves performance, especially when abscissa are sparse and queries are dense.

AdsRSherman avatar Jul 21 '17 15:07 AdsRSherman

In other news, I'm not rightfully sure why those checks would have failed.

AdsRSherman avatar Jul 24 '17 12:07 AdsRSherman

@cdrnet

I have 3 other polynomial interpolations implemented: lagrange, hermite, and chebychev.

Is there interest in my adding those to the pr?

AdsRSherman avatar Aug 16 '17 20:08 AdsRSherman