/// <summary> /// 1D interpolation /// </summary> /// <param name="x">Vector of X values of the function to interpolate</param> /// <param name="y">Vector of Y values of the function to interpolate</param> /// <param name="xi">Vector of X values at which interpolated Y values are required</param> /// <param name="method">Interpolation method: InterpolationMethod.Linear, HermiteCubic or MonotoneHermiteCubicSpline</param> /// <returns>Numeric array with specified inner element type</returns> public static ILArray<double> interp1(ILArray<double> x, ILArray<double> y, ILArray<double> xi, InterpolationMethod method) { ILCurve<double> curve = new ILCurve<double>(x, y); switch (method) { case InterpolationMethod.Linear: return curve.GetValuesLinear(xi); case InterpolationMethod.CubicSpline: return curve.GetValuesCubicSpline(xi); case InterpolationMethod.MonotoneHermiteCubicSpline: return curve.GetValuesCubicSpline(xi); default: return curve.GetValuesLinear(xi); } }
/// <summary> /// 1D interpolation /// </summary> /// <param name="x">Vector of X values of the function to interpolate</param> /// <param name="y">Vector of Y values of the function to interpolate</param> /// <param name="xi">Vector of X values at which interpolated Y values are required</param> /// <param name="method">Interpolation method: InterpolationMethod.Linear, HermiteCubic or MonotoneHermiteCubicSpline</param> /// <returns>Numeric array with specified inner element type</returns> public static ILArray <double> interp1(ILArray <double> x, ILArray <double> y, ILArray <double> xi, InterpolationMethod method) { ILCurve <double> curve = new ILCurve <double>(x, y); switch (method) { case InterpolationMethod.Linear: return(curve.GetValuesLinear(xi)); case InterpolationMethod.CubicSpline: return(curve.GetValuesCubicSpline(xi)); case InterpolationMethod.MonotoneHermiteCubicSpline: return(curve.GetValuesCubicSpline(xi)); default: return(curve.GetValuesLinear(xi)); } }