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(); } }
private double CalcInterpolationError() //Maximum interp error among interpolation points { double error = 0; Point[] interpolationPoints = Lp.GetPointCollection(); Func <double, double> gx = Gx.CompileDynamicMethod(); for (int i = 0; i < interpolationPoints.Length; i++) { double gxValue = gx(interpolationPoints[i].X); if (gxValue != interpolationPoints[i].Y) { error = Math.Max(gxValue, error); } } return(error); }