Skip to main content

LinearInterpolationLib

Git Source - Generated with forge doc

Title: LinearInterpolationLib

Piecewise-linear interpolation with edge clamping over a sorted (x, y) curve.

Functions

interpolate

The caller must ensure knots is strictly increasing; unsorted input returns garbage without reverting.

Reverts if knots is empty or knots.length != values.length.

Rounds towards the left knot's value (down when the segment slopes upward, up when it slopes downward).

The error is < 1 and the result stays within the segment's two knot values.

function interpolate(uint256[] memory knots, uint256[] memory values, uint256 x) internal pure returns (uint256 y);

Errors

EmptyCurve

error EmptyCurve();

LengthMismatch

error LengthMismatch();