Exemple #1
0
        static public double[] interpolate(double[] arr, int len)
        {
            int    cnt = arr.Length;
            mapper map = new mapper(0, cnt - 1, 1, len);

            double[] X = new double[cnt], Y = new double[cnt], ans = new double[len];
            for (int i = 0; i < cnt; i++)
            {
                X[i] = map.map(i);
                Y[i] = arr[i];
            }
            var t = FindRegression.Find(X, Y);

            Console.Error.WriteLine("LENGTH:" + t.Length);
            var f = t[0];

            Console.Error.WriteLine("FUNCTION:" + f.Function);
            for (int i = 0; i < len; i++)
            {
                ans[i] = f.GetY(i + 1);
            }
            return(ans);
        }
Exemple #2
0
 static Regression[] StrToFun(string str)
 => FindRegression.Find(str.Select((a, i) => (double)i).ToArray(),
                        str.Select(x => (double)x).ToArray());