Esempio n. 1
0
        private void Button_Click_Read(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                String   s   = File.ReadAllText(openFileDialog.FileName).ToString().Replace("\r\n", "  ");
                string[] arr = s.Split("  ");
                string   result;
                string   textResult = string.Empty;
                if (arr.Length == arr[0].Split(",").Length - 1)
                {
                    Matrix matrix = new Matrix(arr.Length, arr.Length + 1);
                    matrix.ReadFromArray(arr);
                    SLAR slar = new SLAR(matrix);
                    var  arrR = new Vector(slar.GaussMethod(matrix)).vector;
                    for (int i = 0; i < arrR.Length; i++)
                    {
                        textResult += "x_" + (i + 1) + " = " + arrR[i] + "\n";
                    }
                    Test.Text      = textResult;
                    Inversion.Text = slar.Inversion().ToString();
                    var path = @"C:\Users\Volod\OneDrive\Рабочий стол\Answer.txt";
                    result = slar.Steps.ToString();
                    File.WriteAllText(path, string.Empty);
                    File.WriteAllText(path, result);
                }
                else
                {
                    MessageBox.Show("Wrong!");
                }
            }
        }
Esempio n. 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (Amount.Text == "Введіть дані" || Left.Text == "Введіть дані" || Right.Text == "Введіть дані")
            {
                MessageBox.Show("Input value!");
            }
            else
            {
                string textResult = string.Empty;
                Matrix matrix     = new Matrix(int.Parse(Amount.Text), int.Parse(Amount.Text) + 1);
                matrix.GenerateMatrix(int.Parse(Left.Text), int.Parse(Right.Text));
                SLAR slar = new SLAR(matrix);
                var  arrR = new Vector(slar.GaussMethod(matrix)).vector;
                for (int i = 0; i < arrR.Length; i++)
                {
                    textResult += "x_" + (i + 1) + " = " + arrR[i] + "\n";
                }

                Test.Text      = textResult;
                Inversion.Text = slar.Inversion().ToString();
            }
        }