# \[ANN\] FastInterpolations.jl — Fast & zero-allocation ND interpolation

**URL:** <https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911>\
**Category:** Package Announcements\
**Tags:** package, interpolations, high-performance\
**Created:** [February 28, 2026, 7:05am UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911 "2026-02-28T07:05:47Z")\
**Posts on this page:** 16\
**Page:** 2

<div class="post-metadata">

**Author:** ![mgyoo86](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@mgyoo86](https://discourse.julialang.org/u/mgyoo86)\
**Post date:** [March 28, 2026, 3:58am UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/22 "2026-03-28T03:58:30Z")

</div>

@hersle  
Thanks for your interest!

The current `cubic_interp` API is a global formulation that guarantees `C2` continuity, so it does not currently provide the kind of local `C1` Hermite-style interface you described.

I do think this kind of local C1 scheme would be a useful feature, so I’ll add it to the higher-priority items on my development roadmap.

Since the relevant Hermite-style infrastructure is already in place internally, I expect it should be quite feasible to implement. My current thinking is that this would more likely become a separate API, rather than an extension of `cubic_interp`, to keep it clearly distinct from the existing `C2` formulation. That said, nothing is fixed yet, and I still want to think through the most ergonomic interface.

I’ll try to work on it soon after finishing the issues I’m already working on.

If you want, it would also be great to open an issue on the GitHub page to discuss the details further and keep track of updates.

Thanks!

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [March 28, 2026, 2:31pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/23 "2026-03-28T14:31:12Z")

</div>

Maybe you will find this package [CubicHermiteSpline.jl](https://github.com/liuyxpp/CubicHermiteSpline.jl) interesting. [It is developed as a side project for research in my group]

---

<div class="post-metadata">

**Author:** ![mgyoo86](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@mgyoo86](https://discourse.julialang.org/u/mgyoo86)\
**Post date:** [April 9, 2026, 4:14am UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/24 "2026-04-09T04:14:55Z")

</div>

@hersle  
A new version of `FastInterpolations.jl` ([**v0.4.8**](https://github.com/ProjectTorreyPines/FastInterpolations.jl/releases/tag/v0.4.8)) has just been released, and it finally supports a **C¹-continuous local cubic Hermite family**!

Note that `cubic_interp` in this package is the _global_ cubic spline, so for the local cubic Hermite (with a pre-defined slope `dydx` as you asked) you use a separate entry point `hermite_interp`.

In addition to the user-provided slope case, there are also `pchip_interp`, `cardinal_interp`, and `akima_interp`, which compute the slopes automatically by their own rules (monotone-preserving, Catmull-Rom with tension, Akima, respectively):

```julia
using FastInterpolations

# One-shot API
hermite_interp(x, y, dydx, 1.0) # user-supplied slopes (dydx)

# Interpolant API
itp = hermite_interp(x, y, dydx) # build a reusable interpolant
itp(1.0) # evaluate at x = 1.0

# auto-slope variants (no dydx needed)
pchip_interp(x, y, 1.0) # monotone-preserving
cardinal_interp(x, y, 1.0) # Catmull-Rom with tension
akima_interp(x, y, 1.0) # Akima

```

They all work in both 1D and ND (except `hermite_interp` for ND, which will come in a later release). Not every advanced feature is fully covered yet, but most of the common usage already works, and I will keep improving it in the upcoming releases.

For more details, please see [Local Cubic Hermite docs](https://projecttorreypines.github.io/FastInterpolations.jl/stable/interpolation/local_hermite/).

---

<div class="post-metadata">

**Author:** ![hersle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hersle/32/211689_2.png) [@hersle](https://discourse.julialang.org/u/hersle)\
**Post date:** [April 9, 2026, 7:41pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/25 "2026-04-09T19:41:42Z")

</div>

> [@mgyoo86](#):
>
> A new version of `FastInterpolations.jl` ([**v0.4.8**](https://github.com/ProjectTorreyPines/FastInterpolations.jl/releases/tag/v0.4.8)) has just been released, and it finally supports a **C¹-continuous local cubic Hermite family**!

Thanks a lot! I am testing it now and it seems to work well.

---

<div class="post-metadata">

**Author:** ![Deduction42](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/deduction42/32/9206_2.png) [@Deduction42](https://discourse.julialang.org/u/Deduction42)\
**Post date:** [May 31, 2026, 5:44pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/26 "2026-05-31T17:44:14Z")

</div>

I just stumbled across this package when going through some of my statistics toolchains. It looks amazing! I tend to use cubic interpolations for storing kernel density estimates and for non-parametric convolutions. One way to express a cubic spline is to store cubic polynomials in a vector and map them to intervals. Is there any way to extract the cubic polynomial coefficients from one of your interpolation objects? I use this form for a lot of operations (not just integrals and derivatives but also convolutions).

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 1, 2026, 1:35pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/27 "2026-06-01T13:35:05Z")

</div>

One question (probably mentioned in the documentation, but I just skimmed through it):

- Does FastInterpolations.jl support cases of missing data? This is super important in many cases involving experimental data, e.g., thermodynamics, etc.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 1, 2026, 1:37pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/28 "2026-06-01T13:37:25Z")

</div>

> [@BLI](#):
>
> Does [FastInterpolations.jl](https://juliaregistries.github.io/General/packages/redirect_to_repo/FastInterpolations) support cases of missing data? This is super important in many cases involving experimental data, e.g., thermodynamics, etc.

What would you want it to do for missing data? Return `missing` if interpolation is requested in that part of the array? Would using `NaN` be acceptable instead?

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 1, 2026, 2:19pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/29 "2026-06-01T14:19:41Z")

</div>

I am not quite sure what the response should be, but there are many thermodynamics books with property tables where data are clearly missing, e.g., relations between temperature, pressure, enthalpy, density, entropy, etc., and where it would be useful to be able to “interpolate” somehow to get numeric values.

So my questions are perhaps:

1. If there are missing data in the case of multiple independent variables, will the interpolation code actually work?
2. If the code builds an interpolant even with missing data in the data set, what should be the response if I ask for a numerical value in a region where the data were missing? Perhaps some sort of “extrapolation”?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 1, 2026, 2:23pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/30 "2026-06-01T14:23:24Z")

</div>

> [@BLI](#):
>
> If there are missing data in the case of multiple independent variables, will the interpolation code actually work?

I don’t think it currently supports `missing`, but ~~I’m guessing that it should “work” (in the sense of returning `NaN` for the missing regions) if you represent missing data by `NaN` values.~~

Just tried it: `missing` is not supported, and if you have a single `NaN` value then it returns `NaN` everywhere. Seems like this could be improved?

> [@BLI](#):
>
> If the code builds an interpolant even with missing data in the data set, what should be the response if I ask for a numerical value in a region where the data were missing? Perhaps some sort of “extrapolation”?

Going in this direction leads more towards unstructured-grid interpolation (e.g. you could have missing data in an irregular region in the interior of the domain), which is a _very_ different problem and requires entirely different algorithms. There are other packages for this.

And, of course, extrapolation (if the missing data is on the _edge_ of the domain) is even more specialized, and generally requires you to have a model or some other priors.

_Caveat:_ I don’t speak for the authors of FastInterpolations.jl

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 1, 2026, 2:35pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/31 "2026-06-01T14:35:05Z")

</div>

Perhaps I’m describing the case that, e.g., enthalpy and entropy are not available for the same set of p,T variables… Perhaps the solution is to build several interpolation surfaces. I should find a good example, but am out of my office for the time. I’ll think it over.

---

<div class="post-metadata">

**Author:** ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)\
**Post date:** [June 1, 2026, 2:49pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/32 "2026-06-01T14:49:22Z")

</div>

If you want to fill in the missing data, [Impute](https://github.com/invenia/Impute.jl)gives a model for doing this. This might be one of the packages alluded to above.

---

<div class="post-metadata">

**Author:** ![mark.garnett](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mark.garnett](https://discourse.julialang.org/u/mark.garnett)\
**Post date:** [June 1, 2026, 3:52pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/33 "2026-06-01T15:52:14Z")

</div>

I am also using interpolated thermodynamic data generated from Coolprop and REFPROP.

I also haven’t found a great solution to dealing with areas of the lookup table having a NaN value with any of the interpolation libraries. I am currently using DataInterpolationsND, and it also returns NaN when any value is in the table is NaN. This really shouldn’t be the case especially for linear interpolation, where you are looking up 2^N (N is table dim) table values around your query point- if they are all valid numbers then it should not return NaN.

My workaround is to simply fill the values in the table with the “nearest” valid value. Then, after the fact check that my solution is in a valid region. REFPROP returns NaN for properties if fluid in the solid phase. So if something should be a liquid, make sure press and temperature are not telling me it’s a solid.

I have looked into using Clayperon.jl but this level of fluid modeling is far too involved for what I want to do-- I am not a chemist or physicist. Even figuring out what model to use to get the same results as REFPROP seem quite involved.

---

<div class="post-metadata">

**Author:** ![mgyoo86](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@mgyoo86](https://discourse.julialang.org/u/mgyoo86)\
**Post date:** [June 1, 2026, 5:22pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/34 "2026-06-01T17:22:09Z")

</div>

Hello, welcome to this stop on your journey through the package 😄

There is a dedicated API of `coeffs` for retrieving the coefficients of polynomials at a specific position.

```julia
x = 0:3
y = @. 3*x^3 + 2*x^2 + x # polynomial (x + 2x^2 + 3x^3)

# First, create an interpolant object
itp = cubic_interp(x, y)

# Return a coeffecient object found at x=1.5,
# so the polynomial between x=1 and x=2 nodes.
xq = 1.5
cff = coeffs(itp, 1.5)

# A tuple of polynomial coefficients in ascending order
cff.p # ≈(0.0, 1.0, 2.0, 3.0), meaning the polynomial `0 + x + 2x^2 + 3x^3`

# Evaluation of polynomial at specific position
xq = 1.5
cff(xq) # returns 16.125 = 0 + (1.5) + 2*(1.5)^2 + 3*(1.5)^3
evalpoly(xq, cff) # same result

# If you want to find all coeffs across the domain, 
# there is no dedicated API for this purpose yet, 
# but you can use the list comprehension.
julia> [coeffs(itp, xx) for xx in x[1:end-1]]
3-element Vector{CellPoly{4, Float64, Float64}}:
CellPoly{deg=3, Float64}(x ∈ [0.0, 1.0])
CellPoly{deg=3, Float64}(x ∈ [1.0, 2.0])
CellPoly{deg=3, Float64}(x ∈ [2.0, 3.0])

```

See more details:

> **[FastInterpolations.coeffs - Types · FastInterpolations.jl](https://projecttorreypines.github.io/FastInterpolations.jl/stable/api/types/#FastInterpolations.coeffs)**
>
> Extract the local polynomial coefficients of itp at query point x. Returns a CellPoly with ascending-power coefficients for evalpoly. | Documentation for FastInterpolations.jl.

* * *

Currently, this API only supports 1D interpolation and a specific query point.

It can be generalized to provide a more ergonomic API, and possibly to support ND interpolation.

For a clearer design, it would be very helpful if you could open an issue on GitHub and provide a minimal example of your use case and expected behavior.

---

<div class="post-metadata">

**Author:** ![mgyoo86](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@mgyoo86](https://discourse.julialang.org/u/mgyoo86)\
**Post date:** [June 1, 2026, 6:03pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/35 "2026-06-01T18:03:18Z")

</div>

@BLI @stevengj @Jake @mark.garnett

Thanks all for the valuable discussion. Let me clarify how FastInterpolations currently handles `NaN` and `missing`.

## 1. `NaN` is supported naturally

- **Global-solve methods (quadratic, cubic):** since the solve couples nodes together, a single `NaN` spreads across the domain (the entire domain for cubic) and yields `NaN`. This is the reasonable consequence of a global solve.

- **Local methods (constant, linear, and local cubic Hermite (pchip/cardinal/akima)):** evaluate correctly wherever possible, returning `NaN` only where the local stencil includes the `NaN`.

See an example with visualizations:

> <https://github.com/ProjectTorreyPines/FastInterpolations.jl/issues/68>
>
> Thank you for sharing this package! 
> 
> I noticed that if the input array contains… a NaN somewhere, the interpolant returns NaN everywhere, including at points far from the invalid entries.
> 
> Is this intended behavior? If so, would it make sense to support a NaN-tolerant or masked interpolation mode?

## 2. `missing` is not supported yet

A dataset containing `missing` has an element type like `Union{Missing,Float64}`, which currently breaks internal type constraints (the kernels assume a single concrete value type). I’ll look into whether we can propagate `missing` the same way we propagate `NaN`.

For now, you can replace `missing` with `NaN` before the interpolation:

```julia
x = 1:5
y = [1.0, missing, 3.0, 4.0, missing]

# Replace missing with NaN values
y[ismissing.(y)] .= NaN # This y is Vector{Union{{Missing, Float64}}}

# or allocate a new clean y (more type-stable)
y_new = coalesce.(y, NaN) # This y_new is Vector{Float64}

# Examples
itp = linear_interp(x, y)
itp(1.5) # returns NaN
itp(3.5) # returns 3.5
itp(4.5) # returns NaN

```

## 3. Recommendation for missing data

How to best fill missing data is fairly problem-specific, so for now I’d suggest pre-filling the gaps as your case requires (with a dedicated package or your own logic), or simply leaving them and using a local method (constant/linear/cardinal/pchip/akima) to interpolate.

For simple cases, automatically filling the gaps with an internal local interpolation (e.g. a `linear_interp` pass) might be feasible inside FastInterpolations; I’ll think about it a bit more!

---

<div class="post-metadata">

**Author:** ![Deduction42](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/deduction42/32/9206_2.png) [@Deduction42](https://discourse.julialang.org/u/Deduction42)\
**Post date:** [June 1, 2026, 6:12pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/36 "2026-06-01T18:12:18Z")

</div>

Perfect! 1-d retrieval of the original polynomials is all I need, I generally don’t use this functionality for higher dimensional distributions (polynomial convolutions aren’t well defined for multivariate distributions). This package makes me want to pick up multivariate kernel density regression again!

---

<div class="post-metadata">

**Author:** ![mgyoo86](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@mgyoo86](https://discourse.julialang.org/u/mgyoo86)\
**Post date:** [July 15, 2026, 8:08pm UTC](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911/37 "2026-07-15T20:08:54Z")

</div>

Hi all,  
a quick update on the recent releases (now **v0.4.16** ): a fair bit of performance work, plus one new feature I wanted to share — **`GriddedQuery`** , for much faster resampling onto a regular grid.

### `GriddedQuery` API

If you evaluate an interpolant on a regular output grid —image resize, resampling onto a denser grid, sampling on a lattice — you no longer need a nested comprehension or a manual loop. Pass one query axis per dimension, and it resolves each axis once instead of re-searching at every output point.

```julia
using FastInterpolations

data = rand(20, 30)
itp = linear_interp(axes(data), data)

xq = range(1, 20, 200)
yq = range(1, 30, 300)

# 🐌 Old way 1: one scalar call per output point.
out = [itp(xi, yi) for xi in xq, yi in yq]

# 🐌 Old way 2: pre-build the full batch, then one batch call.
query_aos = [(xi, yi) for xi in xq, yi in yq] # a matrix of points (aos)
query_soa = ([xi for xi in xq, yi in yq], [yi for xi in xq, yi in yq]) # or two coord matrices (soa)
out = itp(query_aos) # == itp(query_soa)

# ✅ New way: GriddedQuery — keeps the axes, nothing to materialize.
# 🚀 MUCH FASTER !!
gq = GriddedQuery(xq, yq)
out = itp(gq) # same values, size (200, 300)

# One-shot API is also available
out = linear_interp(axes(data), data, GriddedQuery(1:0.1:20, 1:0.1:30))

```

On the example above that’s about **20× faster than the scalar loop** and **~10× faster than a pre-built batch** , with no extra allocation.  
It works for every method (linear, cubic, pchip, …), and `GriddedQuery` is a lazy `AbstractArray`, so slicing / broadcast / `collect` just work.

### Also: batch queries keep their shape

A batch query now returns the same shape as the query instead of a flat vector:

```julia
itp = linear_interp(0:10, (0:10) .^ 2)

Q = rand(10, 5) # a 10×5 matrix of query points
itp(Q) # returns 10×5 matrix 

Q = rand(3, 5, 3) # a 3×5x3 matrix of query points
itp(Q) # returns 3×5x3 matrix 

```

See more details in Docs: [Performance Tips](https://projecttorreypines.github.io/FastInterpolations.jl/stable/guides/performance_tips/) and [ND overview](https://projecttorreypines.github.io/FastInterpolations.jl/stable/nd/overview/).

Any questions and feedback welcome!

[Previous page](https://discourse.julialang.org/t/ann-fastinterpolations-jl-fast-zero-allocation-nd-interpolation/135911.md?page=1)
