private void CountButton_Click(object sender, RoutedEventArgs e) { UIElementCollection coefGridChildren = CoefGrid.Children; double[,] arr = new double[2, 3]; /// Пропускается первый дочерний элемент int offset = 1; for (int c = offset; c < coefGridChildren.Count; c++) { for (int i = 0; i < 2; i++) { StackPanel stackPanel = (StackPanel)(coefGridChildren[c] as Grid).Children[i]; TextBox current = stackPanel.Children[0] as TextBox; if (current.Text == string.Empty) { arr[i, c - offset] = 0; } else { arr[i, c - offset] = double.Parse(current.Text); } } } Matrix2 matrix2 = new Matrix2(arr); double[] results = matrix2.CountByKramerMethod(); SetCoefs(matrix2.VarCoefs, matrix2.FreeCoefs); SetResults(results); }
private void Polynomial1Button_Click(object sender, RoutedEventArgs e) { GrafPoint[] grafPoints = coordinateSystem.GrafPoints.ToArray(); if (grafPoints.Length >= 2) { Polynomial polynomial1 = new Polynomial(grafPoints); Matrix2 matrix2 = (Matrix2)polynomial1.Matrix; double[] results = matrix2.CountByKramerMethod(); if (matrix2.mainDet != 0) { LES2.SetResults(results); LES2.SetCoefs(matrix2.VarCoefs, matrix2.FreeCoefs); coordinateSystem.Draw(results[0], results[1]); } else { MessageBox.Show("Один или оба коэффициента b равны нулю!\nИзмените значения x чтобы построить полином.", "Введены некорректные данные"); } } }