Interpolation.Inverse Linear Method
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.0.0
Overload List
| Inverse | Performs inverse linear interpolation to find the x-coordinate for a given y-value. |
| Inverse | Performs inverse linear interpolation to find the x-coordinate for a given y-value. |
InverseLinear(Double[], Double[], Double)
public static double InverseLinear(
double[] xValues,
double[] yValues,
double y
)Parameters
- xValues Double[]
- The x-coordinates of the data points. Must be strictly increasing.
- yValues Double[]
- The y-coordinates of the data points. Must be strictly monotone (increasing or decreasing).
- y Double
- The y-coordinate for which to find the corresponding x-coordinate.
Return Value
DoubleThe x-coordinate corresponding to the y-value y.
Remarks
This method performs the inverse operation of linear interpolation: given a y-value, it finds the corresponding x-value. This method requires yValues to be strictly monotone (either all increasing or all decreasing) to ensure a unique solution. The monotonicity direction is detected automatically.
For non-monotone data where multiple solutions may exist, use InverseLinearBefore(Double[], Double[], Double, Double), InverseLinearAfter(Double[], Double[], Double, Double), or InverseLinearNear(Double[], Double[], Double, Double) to select among multiple solutions.
This method uses binary search for optimal performance and makes no allocations.
Exceptions
| Argument | xValues or yValues is null. |
| Dimension | The lengths of xValues and yValues do not match. |
| Argument | xValues does not have at least 2 elements, the values in xValues are not strictly increasing, or yValues is not strictly monotone (increasing or decreasing). |
| Argument | y is outside the range [min(yValues), max(yValues)]. |
InverseLinear(ReadOnlySpan<Double>, ReadOnlySpan<Double>, Double, OutOfRangeMode)
public static double InverseLinear(
ReadOnlySpan<double> xValues,
ReadOnlySpan<double> yValues,
double y,
OutOfRangeMode outOfRange = OutOfRangeMode.Clamp
)Parameters
- xValues ReadOnlySpan<Double>
- The x-coordinates of the data points. Must be strictly increasing.
- yValues ReadOnlySpan<Double>
- The y-coordinates of the data points. Must be strictly monotone (increasing or decreasing).
- y Double
- The y-coordinate for which to find the corresponding x-coordinate.
- outOfRange OutOfRangeMode (Optional)
Return Value
DoubleThe x-coordinate corresponding to the y-value y.
Remarks
This method performs the inverse operation of linear interpolation: given a y-value, it finds the corresponding x-value. This method requires yValues to be strictly monotone (either all increasing or all decreasing) to ensure a unique solution. The monotonicity direction is detected automatically.
For non-monotone data where multiple solutions may exist, use InverseLinearBefore(ReadOnlySpan<Double>, ReadOnlySpan<Double>, Double, Double), InverseLinearAfter(ReadOnlySpan<Double>, ReadOnlySpan<Double>, Double, Double), or InverseLinearNear(ReadOnlySpan<Double>, ReadOnlySpan<Double>, Double, Double) to select among multiple solutions.
This method uses binary search for optimal performance and makes no allocations.
Exceptions
| Argument | xValues or yValues is null. |
| Dimension | The lengths of xValues and yValues do not match. |
| Argument | xValues does not have at least 2 elements, the values in xValues are not strictly increasing, or yValues is not strictly monotone (increasing or decreasing). |
| Argument | y is outside the range [min(yValues), max(yValues)]. |