From 12a5a27809887c5f6e374884d0cdad8edc150a09 Mon Sep 17 00:00:00 2001 From: CWX Date: Fri, 17 Jan 2025 23:02:20 +0000 Subject: [PATCH] change to lists --- Core/Utils/MathUtil.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/Utils/MathUtil.cs b/Core/Utils/MathUtil.cs index a0bfac7c..4fa68ff5 100644 --- a/Core/Utils/MathUtil.cs +++ b/Core/Utils/MathUtil.cs @@ -91,14 +91,14 @@ public class MathUtil /// Support points in x (of same length as y) /// Support points in y (of same length as x) /// Interpolated value at xp, or null if xp is out of bounds - public static double? Interp1(double xp, double[] x, double[] y) + public double? Interp1(double xp, List x, List y) { if (xp > x[^1]) // ^1 is the last index in C# return y[^1]; if (xp < x[0]) return y[0]; - for (var i = 0; i < x.Length - 1; i++) + for (var i = 0; i < x.Count - 1; i++) if (xp >= x[i] && xp <= x[i + 1]) return y[i] + (xp - x[i]) * (y[i + 1] - y[i]) / (x[i + 1] - x[i]);