public void TestLogLinearInterpolation() { double[] t = { 0.0, 1.0, 2.0, 3.0, 5.0 }; double[] y = { 1.0, .98, .95, .93, .88 }; double[] exp = SetUp(); Random r = new Random(Environment.TickCount); var interpolation = new LogLinearInterpolation(); interpolation.Initialize(_times, exp); for (int i = 0; i < 10; ++i) { double time = i + r.Next(-10000, 10000) / 10000; double interpRate = interpolation.ValueAt(time, true); Debug.WriteLine($"interpolatedRate : {interpRate} Time: {time}"); } interpolation.Initialize(t, y); double[] a = { 2.4, 10.9 }; double[] b = { 0.941948898488354, 0.724019983080858 }; double c = 1e-15; for (var i = 0; i < a.Length; i++) { var val = interpolation.ValueAt(a[i], true); Assert.AreEqual(b[i], val, c); } }
public void TestLogLinearInterpolation() { double[] exp = SetUp(); Random r = new Random(Environment.TickCount); IInterpolation interpolation = new LogLinearInterpolation(); // IList list = new ArrayList(exp.ToGeneralVector().StorageArray); interpolation.Initialize(_times, exp); for (int i = 0; i < 10; ++i) { double time = (i + r.Next(-10000, 10000) / 10000); double interpRate = interpolation.ValueAt(time, true); Debug.WriteLine($"interpolatedRate : {interpRate} Time: {time}"); } }