示例#1
0
        void fillInfo()
        {
            textBoxSplineGrid.Text = (spline.webCount - 1).ToString();
            textBoxMainGrid.Text   = ((spline.webCount - 1) * 100).ToString();

            SplineGraph sg  = spline.lsgLast[0];
            SplineGraph sg1 = spline.lsgLast[0];
            SplineGraph sg2 = spline.lsgLast[0];

            foreach (var s in spline.lsgLast)
            {
                if (s.error.maxErrorF > sg.error.maxErrorF)
                {
                    sg = s;
                }
                if (s.error.maxErrorF1 > sg1.error.maxErrorF1)
                {
                    sg1 = s;
                }
                if (s.error.maxErrorF2 > sg2.error.maxErrorF2)
                {
                    sg2 = s;
                }
            }

            textBoxMaxErrorFunc.Text  = sg.error.maxErrorF.ToString();
            textBoxMaxErrorFuncX.Text = sg.error.xmef.ToString();
            textBoxMaxError1d.Text    = sg1.error.maxErrorF1.ToString();
            textBoxMaxError1dX.Text   = sg1.error.xmef1.ToString();
            textBoxMaxError2d.Text    = sg2.error.maxErrorF2.ToString();
            textBoxMaxError2dX.Text   = sg2.error.xmef2.ToString();
        }
示例#2
0
        List <SplineGraph> GetSpline(Func <double, double> func, BackgroundWorker worker)
        {
            List <SplineGraph> lsg    = new List <SplineGraph>();
            List <double>      delta  = new List <double>();
            List <double>      lambda = new List <double>();

            if (webCount > 2)
            {
                delta.Add(-0.25);
                var test1 = func(webX[2]) - 2 * func(webX[1]) + func(webX[0]);
                var test2 = test1 * 3;
                var test3 = test2 / (4 * webStep * webStep);
                lambda.Add((3 * (func(webX[2]) - 2 * func(webX[1]) + func(webX[0]))) / (4 * webStep * webStep));
            }

            for (var i = 1; i < webCount - 2; i++)
            {
                worker.ReportProgress((int)((double)i / (webCount - 2) * 15));
                delta.Add(-1 / (4 + delta[i - 1]));
                var test1 = func(webX[i + 2]) - 2 * func(webX[i + 1]) + func(webX[i]);
                var test2 = test1 * 3 / (webStep * webStep);
                var test3 = test2 - lambda[i - 1];
                var test4 = test3 / (4 + delta[i - 1]);
                lambda.Add((3 * (func(webX[i + 2]) - 2 * func(webX[i + 1]) + func(webX[i])) / (webStep * webStep) - lambda[i - 1]) / (4 + delta[i - 1]));
            }

            if (webCount > 2)
            {
                delta.Reverse();
                lambda.Reverse();
            }
            webX.Reverse();

            lsg.Add(new SplineGraph()
            {
                interval = new Interval()
                {
                    left = webX[1], right = webX[0]
                }, param = new Params()
                {
                    a = func(webX[0]), c = 0
                }
            });
            for (var i = 0; i < webCount - 2; i++)
            {
                worker.ReportProgress(15 + (int)((double)i / (webCount - 2) * 15));
                var sg = new SplineGraph()
                {
                    interval = new Interval(), param = new Params()
                };
                sg.interval.left  = webX[i + 2];
                sg.interval.right = webX[i + 1];
                sg.param.c        = delta[i] * lsg[i].param.c + lambda[i];
                lsg.Add(sg);
            }

            webX.Reverse();
            lsg.Reverse();

            for (var i = 0; i < webCount - 1; i++)
            {
                worker.ReportProgress(30 + (int)((double)i / (webCount - 1) * 20));
                lsg[i].param.a = func(lsg[i].interval.right);
                lsg[i].param.b = i == 0 ? (func(lsg[i].interval.right) - func(lsg[i].interval.left)) / webStep + webStep * (2 * lsg[i].param.c) / 3
                    : (func(lsg[i].interval.right) - func(lsg[i].interval.left)) / webStep + webStep * (2 * lsg[i].param.c + lsg[i - 1].param.c) / 3;
                lsg[i].param.d = i == 0 ? lsg[i].param.c / (3 * webStep) : (lsg[i].param.c - lsg[i - 1].param.c) / (3 * webStep);
            }

            return(lsg);
        }