public static object acq_interpolator_create( [ExcelArgument(Description = "Array of nodes")] double[] x, [ExcelArgument(Description = "Array of values")] double[] y, [ExcelArgument(Description = "linear, quadratic, cubic, hermite, akima, steffen etc")] object method, [ExcelArgument(Description = "Out of range value: false (num error), true (closest)")] object bounds) { if (ExcelDnaUtil.IsInFunctionWizard()) { return(ExcelError.ExcelErrorRef); } else { return(ACQ.Excel.Handles.GlobalCache.CreateHandle(m_tag, new object[] { x, y, method, bounds, "acq_interpolator_create" }, (objectType, parameters) => { ACQ.Math.Interpolation.InterpolationInterface interpolator = construct_interpolator(x, y, method, bounds); if (interpolator == null) { return ExcelError.ExcelErrorNull; } else { return interpolator; } })); } }
private static ACQ.Math.Interpolation.InterpolationInterface construct_interpolator(double[] x, double[] y, object method, object bounds) { ACQ.Math.Interpolation.InterpolationInterface interpolator = null; try { string interpolation_method = ExcelHelper.Check(method, m_defaultInterpolator); bool interpolation_bounds = ExcelHelper.CheckValue(bounds, true); interpolator = ACQ.Math.Interpolation.InterpolationFactory.GetInterpolator(interpolation_method, x, y); interpolator.Bounds = interpolation_bounds; } catch (Exception ex) { lock (m_sync) { LogDisplay.WriteLine("Error: " + ex.ToString()); } } return(interpolator); }
public static object acq_interpolation(double xi, double[] x, double[] y, object method, object bounds) { if (ExcelDnaUtil.IsInFunctionWizard()) { return(ExcelError.ExcelErrorRef); } else { ACQ.Math.Interpolation.InterpolationInterface interpolator = construct_interpolator(x, y, method, bounds); if (interpolator != null) { return(ExcelHelper.CheckNan(interpolator.Eval(xi))); } else { return(ExcelError.ExcelErrorNA); } } }