Esempio n. 1
0
        private void LoadTableFromXML()
        {
            OpenFileDialog openDlg = new OpenFileDialog();

            openDlg.Filter = "XML | *.xml";

            if (openDlg.ShowDialog() == true)
            {
                try
                {
                    Lp = LagrangePolynom.ReadFromXML(openDlg.FileName);
                }
                catch (InvalidOperationException)
                {
                    MessageBox.Show("Invalid XML file!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                Gx            = new ExprTree.Expression(Lp.ToString(), "x");
                this.FileName = openDlg.FileName;

                //show the values in the point grid
                pointsDt.Clear();
                foreach (Point p in Lp.GetPointCollection())
                {
                    DataRow newRow = pointsDt.NewRow();
                    newRow["X"] = p.X;
                    newRow["Y"] = p.Y;
                    pointsDt.Rows.Add(newRow);
                }
                pointGrid.DataContext = pointsDt;
                pointGrid.UpdateLayout();
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("x^2-4:\n");
            Expression x2   = new Expression("x^2", "x");
            Expression four = new Expression("4");

            PrintRoots(x2 - four);

            //x^2-x-2 => x1=-1; x2=2
            Console.WriteLine("x^2-x-2:\n");
            Expression x   = new Expression("x", "x");
            Expression two = new Expression("2");

            PrintRoots(x2 - x - two);


            //Using L'argrange's polynom
            Console.WriteLine("x^2:\n");
            Expression lagrange = new Expression(LagrangePolynom.ReadFromXML("testPol_1.xml").ToString(), "x");

            PrintRoots(lagrange); //x^2 => root: 0

            Console.WriteLine("Sin:\n");
            Expression sin = new Expression(LagrangePolynom.ReadFromXML("sin.xml").ToString(), "x");

            PrintRoots(sin);

            Console.WriteLine("Chebyshev tan:\n");
            Expression ch_Tan = new Expression(LagrangePolynom.ReadFromXML("chebyshevTan.xml").ToString(), "x");

            PrintRoots(ch_Tan);

            Console.WriteLine("Tan:\n");
            Expression tan = new Expression(LagrangePolynom.ReadFromXML("tan.xml").ToString(), "x");

            PrintRoots(tan);

            Console.WriteLine("x^8:\n");
            Expression x8 = new Expression(LagrangePolynom.ReadFromXML("x8.xml").ToString(), "x");

            PrintRoots(x8);
        }