コード例 #1
0
ファイル: PolynomTests.cs プロジェクト: MianenCZ/Mianen
        public void PolynomAprox01()
        {
            Point2D <double>[] Points = new Point2D <double> [5];
            Points[0] = new Point2D <double>(0, 1);
            Points[1] = new Point2D <double>(1, 3);
            Points[2] = new Point2D <double>(-1, 1);
            Points[3] = new Point2D <double>(2, 7);
            Points[4] = new Point2D <double>(-2, 3);

            Polynom <double> p = Polynom <double> .Aproximate(Points, 2);
        }
コード例 #2
0
ファイル: PolynomTests.cs プロジェクト: MianenCZ/Mianen
        public void PolynomAprox02()
        {
            Point2D <double>[] Points = new Point2D <double> [38];
            Points[0]  = new Point2D <double>(160, 60);
            Points[1]  = new Point2D <double>(168, 60);
            Points[2]  = new Point2D <double>(168, 58);
            Points[3]  = new Point2D <double>(169, 96);
            Points[4]  = new Point2D <double>(170, 70);
            Points[5]  = new Point2D <double>(170, 62);
            Points[6]  = new Point2D <double>(172, 61);
            Points[7]  = new Point2D <double>(172, 79);
            Points[8]  = new Point2D <double>(175, 72);
            Points[9]  = new Point2D <double>(177, 62);
            Points[10] = new Point2D <double>(180, 86);
            Points[11] = new Point2D <double>(180, 60);
            Points[12] = new Point2D <double>(180, 75);
            Points[13] = new Point2D <double>(180, 70);
            Points[14] = new Point2D <double>(181, 76);
            Points[15] = new Point2D <double>(183, 65);
            Points[16] = new Point2D <double>(183, 77);
            Points[17] = new Point2D <double>(183, 87);
            Points[18] = new Point2D <double>(183, 76);
            Points[19] = new Point2D <double>(184, 65);
            Points[20] = new Point2D <double>(185, 90);
            Points[21] = new Point2D <double>(185, 65);
            Points[22] = new Point2D <double>(185, 80);
            Points[23] = new Point2D <double>(185, 72);
            Points[24] = new Point2D <double>(185, 85);
            Points[25] = new Point2D <double>(189, 85);
            Points[26] = new Point2D <double>(190, 75);
            Points[27] = new Point2D <double>(190, 70);
            Points[28] = new Point2D <double>(191, 70);
            Points[29] = new Point2D <double>(193, 71);
            Points[30] = new Point2D <double>(194, 87);
            Points[31] = new Point2D <double>(195, 95);
            Points[32] = new Point2D <double>(178, 73);
            Points[33] = new Point2D <double>(187, 85);
            Points[34] = new Point2D <double>(195, 88);
            Points[35] = new Point2D <double>(167, 63);
            Points[36] = new Point2D <double>(195, 79);
            Points[37] = new Point2D <double>(177, 80);


            for (int i = 0; i < Points.Length; i++)
            {
                Console.WriteLine($"Bod[{{{Points[i].X},{Points[i].Y}}}]");
            }


            Polynom <double> p = Polynom <double> .Aproximate(Points, 2);

            Console.WriteLine(p.DefVector);
            Assert.IsTrue(true, p.DefVector.ToString());
        }
コード例 #3
0
ファイル: Loader.cs プロジェクト: MianenCZ/HW2_LSM
        public Loader(string Path)
        {
            this.FileName = Path;
            StreamReader streamReader = new StreamReader((Stream) new FileStream(Path, FileMode.Open, FileAccess.Read));

            this.Data = new Series[2];
            Data[0]   = new Series
            {
                Name        = "Measurements",
                ChartType   = SeriesChartType.Point,
                BorderWidth = 2,
                Color       = Color.Blue
            };
            Data[1] = new Series
            {
                Name        = "Trend",
                ChartType   = SeriesChartType.Spline,
                BorderWidth = 1,
                Color       = Color.Green
            };
            List <Point2D <double> > point2DList = new List <Point2D <double> >();
            string line;

            while ((line = streamReader.ReadLine()) != null)
            {
                string[] array = line.Split(new char[1] {
                    ';'
                }, StringSplitOptions.RemoveEmptyEntries);
                array = array.Select(q => q.Trim()).ToArray <string>();
                double num1 = double.Parse(array[0], (IFormatProvider)CultureInfo.InvariantCulture);
                double num2 = double.Parse(array[1], (IFormatProvider)CultureInfo.InvariantCulture);
                this.Data[0].Points.Add(new DataPoint(num1, num2));
                point2DList.Add(new Point2D <double>(num1, num2));
            }
            Polynom <double> polynom = Polynom <double> .Aproximate(point2DList.ToArray(), 2);

            for (double xValue = 50.0; xValue <= 250; ++xValue)
            {
                double yValue = polynom.DefVector[0, true] + xValue * polynom.DefVector[1, true] + xValue * xValue * polynom.DefVector[2, true];
                this.Data[1].Points.Add(new DataPoint(xValue, yValue));
            }
        }