コード例 #1
0
        /// <summary>
        /// Create a linear spline interpolation from an unsorted set of (x,y) value pairs.
        /// WARNING: Works in-place and can thus causes the data array to be reordered and modified.
        /// </summary>
        public static TransformedInterpolation InterpolateInplace(
            Func <double, double> transform,
            Func <double, double> transformInverse,
            double[] x,
            double[] y)
        {
            if (x.Length != y.Length)
            {
                throw new ArgumentException(Resources.ArgumentVectorsSameLength);
            }

            Sorting.Sort(x, y);
            CommonParallel.For(0, y.Length, 4096, (a, b) =>
            {
                for (int i = a; i < b; i++)
                {
                    y[i] = transformInverse(y[i]);
                }
            });

            return(new TransformedInterpolation(LinearSpline.InterpolateSorted(x, y), transform));
        }
コード例 #2
0
 /// <param name="x">Sample points (N), sorted ascending</param>
 /// <param name="logy">Natural logarithm of the sample values (N) at the corresponding points</param>
 public LogLinear(double[] x, double[] logy)
 {
     _spline = LinearSpline.InterpolateSorted(x, logy);
 }