예제 #1
0
        public Point Task3(Form form, Point location, double[] x, double[] y, double delta)
        {
            double[] xs = Range.Make(x.First(), x.Last(), delta);

            double[] poly2 = Poly.Fit(x, y, 2);
            double[] ys2   = Poly.Val(poly2, xs);

            double[] poly3 = Poly.Fit(x, y, 3);
            double[] ys3   = Poly.Val(poly3, xs);

            Plot plot = new Plot();

            plot.PlotSignalXY(x, y);
            plot.PlotSignalXY(xs, ys2);
            plot.PlotSignalXY(xs, ys3);

            return(plot.AddToForm(form, location));
        }
예제 #2
0
        public Point Task1(Form form, Point location)
        {
            double a = 0.9;

            double[] f = new double[] { 4 * a, -4.4 * a, -1, 1 };

            double[] firstDerivative  = Poly.GetPolyDerivative(f);
            double[] secondDerivative = Poly.GetPolyDerivative(firstDerivative);

            double[] xs      = Range.Make(-5, 5, 0.1);
            double[] breakXs = Poly.PolySolvePrimitive(secondDerivative, 0);

            (double[] mins, double[] maxs) = FindExtremumsUniform(f, -4, 4, 0.01);

            Console.WriteLine("MINS: " + string.Join(" ", mins));
            Console.WriteLine("MAXS: " + string.Join(" ", maxs));

            Plot plot = new Plot();

            plot.PlotSignalXY(xs, Poly.Val(f, xs), Color.Red, 7, label: "Original signal");
            plot.PlotSignalXY(xs, Poly.Val(firstDerivative, xs), Color.Green, 5, label: "First Derivative");
            plot.PlotSignalXY(xs, Poly.Val(secondDerivative, xs), Color.Blue, 3, label: "Second Derivative");

            plot.PlotScatter(
                breakXs.Concat(breakXs).Concat(breakXs).ToArray(),
                Poly.Val(f, breakXs).Concat(Poly.Val(firstDerivative, breakXs)).Concat(Poly.Val(secondDerivative, breakXs)).ToArray(),
                Color.Yellow, label: "Unimodal break points", markerSize: 3, lineStyle: LineStyle.Dot
                );

            plot.PlotScatter(mins, Poly.Val(f, mins), Color.Cyan, markerSize: 7, label: "Min points", lineStyle: LineStyle.Dot);
            plot.PlotScatter(maxs, Poly.Val(f, maxs), Color.LightGreen, markerSize: 7, label: "Max points", lineStyle: LineStyle.Dot);

            plot.Legend();

            return(plot.AddToForm(form, location));
        }
예제 #3
0
        public Point Task2(Form form, Point location, IEnumerable <Interpolator.Point> knownPoints, double delta)
        {
            Plot plot = MakeInterpolationTaskPlot <PolyInterpolator>(knownPoints, delta);

            return(plot.AddToForm(form, location));
        }