mr2.utils.interp
- mr2.utils.interp(x: Tensor, xp: Tensor, fp: Tensor, *, left: Tensor | float | None = None, right: Tensor | float | None = None) Tensor[source]
One-dimensional linear interpolation for monotonically increasing sample points.
Implements numpy.interp
Evaluates the function at the given coordinates x based on the known points (xp, fp). Out-of-bounds values default to fp[0] and fp[-1], matching the default behavior of numpy.interp. Custom left/right fill values can be provided.
- Parameters:
x (
Tensor) – The x-coordinates at which to evaluate the interpolated values.xp (
Tensor) – 1d tensor of x coordinates of data points. The tensor will be sorted internally if needed.fp (
Tensor) – 1d tensor of y coordinates matching the length of xp.left (
Tensor|float|None, default:None) – Fill value for x < xp[0]. If None, uses fp[0].right (
Tensor|float|None, default:None) – Fill value for x > xp[-1]. If None, uses fp[-1].
- Returns:
The interpolated values matching the shape of x.