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 is undefined behavior and may revert.
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);
Parameters
| Name | Type | Description |
|---|---|---|
knots | uint256[] | |
values | uint256[] | |
x | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
y | uint256 |
Errors
EmptyCurve
error EmptyCurve();
LengthMismatch
error LengthMismatch();