diff --git a/FreePIE.Core/Common/CurveMath.cs b/FreePIE.Core/Common/CurveMath.cs index 172fb0fd..a8953506 100644 --- a/FreePIE.Core/Common/CurveMath.cs +++ b/FreePIE.Core/Common/CurveMath.cs @@ -80,6 +80,7 @@ public static double SolveCubicSpline(IList knownSamples, double z) if (np > 1) { + if (knownSamples[0].X == z) return knownSamples[0].Y; double[] a = new double[np]; @@ -182,13 +183,13 @@ public static double SolveCubicSpline(IList knownSamples, double z) private static void SolveTridiag(double[] sub, double[] diag, double[] sup, ref double[] b, int n) { - /* solve linear system with tridiagonal n by n matrix a - using Gaussian elimination *without* pivoting - where a(i,i-1) = sub[i] for 2<=i<=n - a(i,i) = diag[i] for 1<=i<=n - a(i,i+1) = sup[i] for 1<=i<=n-1 - (the values sub[1], sup[n] are ignored) - right hand side vector b[1:n] is overwritten with solution + /* solve linear system with tridiagonal n by n matrix a + using Gaussian elimination *without* pivoting + where a(i,i-1) = sub[i] for 2<=i<=n + a(i,i) = diag[i] for 1<=i<=n + a(i,i+1) = sup[i] for 1<=i<=n-1 + (the values sub[1], sup[n] are ignored) + right hand side vector b[1:n] is overwritten with solution NOTE: 1...n is used in all arrays, 0 is unused */ int i; /* factorization and forward substitution */