Skip to content

v0.4.20

Latest

Choose a tag to compare

@github-actions github-actions released this 14 Oct 17:37
· 4 commits to master since this release

What's New

ND jacobian for vector-valued data, a new LinearGallopSearch policy, polyharmonic splines (PHS) as the first Experimental feature, faster quadratic builds and cubic evaluation, and several fixes.

ND Jacobian (#217, #218)

jacobian, jacobian! and value_jacobian return J[i, j] = ∂Fᵢ/∂xⱼ for every ND family. SVector{M} data gives an M×N matrix; scalar data gives a 1×N row. With Zygote, they are differentiable with respect to both the data and the query point, for scalar, complex and SVector data.

using FastInterpolations, StaticArrays

xs = range(0.0, 2.0, 21); ys = range(0.0, 1.0, 11)
itp = cubic_interp((xs, ys), [SA[x * y, sin(x) + y] for x in xs, y in ys])

J    = jacobian(itp, (0.5, 1.0))         # 2×2 SMatrix
F, J = value_jacobian(itp, (0.5, 1.0))   # value + Jacobian in one call

LinearGallopSearch (#208)

A new opt-in search policy for sorted queries that jump past the linear window. Instead of a binary search over the whole grid, it gallops out from the previous position (1, 2, 4, … cells) and bisects. With average gaps of roughly 10–100 cells it is up to ~3× faster than LinearBinarySearch. AutoSearch never selects it; for random or very sparse queries, keep the default.

x  = cumsum(rand(1_000_000))        # long non-uniform grid
y  = sin.(x)
xq = range(x[1], x[end], 100_000)   # sorted queries, ~10 cells apart

itp = linear_interp(x, y)
itp(xq; search = LinearGallopSearch())                    # per call
itp = linear_interp(x, y; search = LinearGallopSearch())  # stored in the interpolant

See Search policies.

Polyharmonic splines — experimental (#136, #209, #222)

PHS interpolation on uniform grids in any dimension, 1D included (pass the grid as (x,)). An optional log transform (log_reference) suits data with sharp peaks, such as electron densities.

PHS lives in the new FastInterpolations.Experimental submodule. Features there are not covered by SemVer and may change in any release. For now PHS is mainly for values; known derivative issues are listed in the docs. Inputs it cannot handle yet, such as non-uniform axes or Clamp/Wrap extrapolation, raise an ArgumentError.

using FastInterpolations
using FastInterpolations.Experimental   # phs_interp, phs_interp!, PHSInterpolantND

x = range(0.0, 1.0, 21); y = range(0.0, 2.0, 41)
itp = phs_interp((x, y), [sin(2a) * cos(b) for a in x, b in y])
itp((0.33, 0.71))

Performance

  • Quadratic builds (#219, #221): 20–45 % faster; first ND build compiles ~5× faster.
  • Cubic evaluation (#211): up to 30 % faster.

Fixes

  • Cubic PeriodicBC on non-uniform grids (#220): wrong spline system, now fixed.
  • Cubic node values (#211): exact (itp(x[i]) == y[i]) at interior nodes of Vector grids.
  • ND hessian with ForwardDiff Dual queries (#216, #213): no longer throws.
  • Symbolics ≥ 7.43 (#210): 1D symbolic derivatives work again.

Note

  • Cubic values may differ from v0.4.19 by a few ULPs (#211), and periodic cubic results on non-uniform grids change (#220).

What's Changed

  • feat: polyharmonic spline (PHS) N-dimensional interpolation by @twilsonco in #136
  • fix(symbolics): 1D symbolic derivatives on Symbolics ≥ 7.43 by @mgyoo86 in #210
  • perf(search): gallop on LinearBinarySearch window overflow by @Beforerr in #208
  • fix(cubic): exact node values from the cubic value kernel by @mgyoo86 in #211
  • test(search): compare cubic values across search policies with a ULP budget by @mgyoo86 in #212
  • fix(nd): ND hessian output eltype follows a Dual query (ForwardDiff) by @mgyoo86 in #216
  • feat(nd): jacobian, jacobian!, value_jacobian for vector-valued ND interpolants by @mgyoo86 in #217
  • feat(ext): reverse-mode AD for ND jacobian and vector-valued data by @mgyoo86 in #218
  • fix(cubic): wrong super-diagonal in PeriodicBC system on non-uniform grids by @StuartBenjamin in #220
  • perf(quadratic): build spline coefficients in one sweep, without a secant buffer by @mgyoo86 in #219
  • perf(quadratic): ND builds solve each line in place through a view by @mgyoo86 in #221
  • refactor(phs): one log_reference keyword for the log transform by @mgyoo86 in #209
  • fix(phs): ship PHS as experimental and reject inputs it cannot evaluate by @mgyoo86 in #222

New Contributors

Full Changelog: v0.4.19...v0.4.20