コード例 #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("All vectors must have the same dimensionality.");
            }

            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
ファイル: LogLinear.cs プロジェクト: Xornent/simula
 /// <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);
 }