Interpolation
CSharpNumerics provides a unified interpolation API supporting linear and logarithmic scales:
- Linear
- LogβLog (log x, log y)
- LinβLog (lin x, log y)
- LogβLin (log x, lin y)
All methods are routed through one central function.
public enum InterpolationType
{
Linear,
Logarithmic, // logβlog
LogLin,
LinLog
}
double Interpolate<T>(
this IEnumerable<T> source,
Func<T, (double x, double y)> selector,
double index,
InterpolationType type);
Example:
var data = new List<Serie>
{
new Serie { Index = 1, Value = 10 },
new Serie { Index = 10, Value = 100 }
};
double y = data.Interpolate(
p => (p.Index, p.Value),
3.5,
InterpolationType.Linear
);