hmf.core._kernels.interpolation

Interpolation kernels: local interpolants on uniform lattices, and frozen splines.

The local interpolants work in a coordinate u in [0, 1] between two adjacent nodes x0 and x0 + h of a uniform lattice, from the values (and derivatives) at a fixed set of nodes. Each result depends only on those nodes and on u, so interpolants on a lazily extended lattice do not change as the lattice grows, and all of them are elementwise (batch-size independent).

Tables (of a transfer function, a growth factor, a power spectrum) are interpolated by cubic splines, fitted once and kept as their coefficients:

  • FrozenSpline: a scipy.interpolate.CubicSpline’s breakpoints and piecewise-polynomial coefficients, evaluated by scipy.interpolate.PPoly.construct_fast(), so it gives exactly the spline’s values;

  • extrapolate_power_law(): a spline of ln y against ln x, continued beyond its ends as straight lines (power laws in y) with its slopes there.

Classes

FrozenSpline(x, c[, extrapolate])

A cubic spline, fitted once and kept as its piecewise-polynomial coefficients.

Functions

extrapolate_power_law(spline, ln_x)

A spline of ln y against ln x, continued as power laws beyond its ends.

hermite_cubic(u, h, y0, y1, d0, d1)

The cubic Hermite interpolant on [x0, x0 + h] at x0 + u h.

hermite_quintic(u, h, y0, y1, d0, d1, c0, c1)

The quintic Hermite interpolant on [x0, x0 + h] at x0 + u h.

invert_hermite(target, h, y0, y1, d0, d1[, ...])

Solve hermite(u) = target for u in [0, 1], for a decreasing interpolant.

lagrange4(u, f_m1, f_0, f_1, f_2)

The 4-point Lagrange interpolant through nodes at -1, 0, 1, 2, evaluated at u.