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 TestInterpolatedCurve2() { IInterpolation interp = new LogLinearInterpolation(); DiscreteCurve curve = new DiscreteCurve(_pointCoords, _pointValues2); IInterpolatedSpace interpCurve = new InterpolatedCurve(curve, interp, true); foreach (double point in _testPointArray) { IPoint p = new Point1D(point); Console.WriteLine(interpCurve.Value(p)); } }
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}"); } }
public static string eqMathLogLinearInterpolation( [ExcelArgument(Description = "interpolation obj id")] string objId, [ExcelArgument(Description = "variable x ")] double[] x, [ExcelArgument(Description = "variable y ")] double[] y) { if (ExcelUtil.CallFromWizard()) { return(""); } string callerAddress = ""; callerAddress = ExcelUtil.getActiveCellAddress(); try { if (x.Length != y.Length) { return("size mismatch"); } QlArray xa = new QlArray((uint)x.Length); QlArray ya = new QlArray((uint)y.Length); for (uint i = 0; i < x.Length; i++) { xa.set(i, x[i]); ya.set(i, y[i]); } LogLinearInterpolation interp = new LogLinearInterpolation(xa, ya); // Store the futures and return its id string id = "Int@" + objId; OHRepository.Instance.storeObject(id, interp, callerAddress); id += "#" + (String)DateTime.Now.ToString(@"HH:mm:ss"); return(id); } catch (Exception e) { ExcelUtil.logError(callerAddress, System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString(), e.Message); return(e.Message); } }
public static object eqMathGet1DInterpolation( [ExcelArgument(Description = "interpolation obj id")] string objId, [ExcelArgument(Description = "variable x ")] double x, [ExcelArgument(Description = "Linear/LogLinear ")] string type) { if (ExcelUtil.CallFromWizard()) { return(""); } string callerAddress = ""; callerAddress = ExcelUtil.getActiveCellAddress(); try { if (type.ToUpper() == "LINEAR") { LinearInterpolation interp = OHRepository.Instance.getObject <LinearInterpolation>(objId); double ret = interp.call(x, true); return(ret); } else if (type.ToUpper() == "LOGLINEAR") { LogLinearInterpolation interp = OHRepository.Instance.getObject <LogLinearInterpolation>(objId); double ret = interp.call(x, true); return(ret); } else { return("Unknown interpolation type"); } } catch (Exception e) { ExcelUtil.logError(callerAddress, System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString(), e.Message); return(e.Message); } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LogLinearInterpolation obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LogLinearInterpolation obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }