Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            MethodGaussa gaussAuto = new MethodGaussa();

            gaussAuto = CopyToGauss();
            string str = "";

            str += "Рассширенная матрица системы: \n\n";
            str += gaussAuto.MatrToStr() + "\n";

            str += gaussAuto.AutoRezult();

            str += "С помощью элементарных преобразований получаем матрицу: \n\n";
            str += gaussAuto.MatrToStr() + "\n";
            str += "Ответ: ";

            if (!gaussAuto.IsResultExist())
            {
                str += " система несовместна (не имеет решений)\n";
            }
            else
            if (!gaussAuto.IsFindRez())
            {
                str += " система имеет бесконечно много решений\n";
            }
            else
            {
                str += gaussAuto.XtoStr();
            }


            lblAutoRezult.Text = str;
        }
Exemple #2
0
        public static void Serialize(MethodGaussa dataGridView, string file)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(MethodGaussa));
            string        xml;

            using (StringWriter stringWriter = new StringWriter())
            {
                xmlSerializer.Serialize(stringWriter, dataGridView);
                xml = stringWriter.ToString();
            }
            File.WriteAllText(file, xml, Encoding.Default);
        }
Exemple #3
0
        private void CopyFromGauss(MethodGaussa methodGaussa)
        {
            numericUpDown1.Value = methodGaussa.curKolPerem;

            for (int j = 0; j < kolUravn; j++)
            {
                for (int i = 1; i <= kolPerem; i++)
                {
                    dataGridView1["colA" + i, j].Value = Convert.ToString(methodGaussa.matrix[j][i - 1]);
                }
                dataGridView1["colB", j].Value = Convert.ToString(methodGaussa.matrix[j][kolPerem]);
            }
        }
Exemple #4
0
        private MethodGaussa CopyToGauss()
        {
            MethodGaussa methodGaussa = new MethodGaussa(kolUravn, kolPerem + 1);

            for (int j = 0; j < kolUravn; j++)
            {
                for (int i = 1; i <= kolPerem; i++)
                {
                    methodGaussa.matrix[j][i - 1] = Convert.ToDouble(dataGridView1["colA" + i, j].Value);
                }
                methodGaussa.matrix[j][kolPerem] = Convert.ToDouble(dataGridView1["colB", j].Value);
            }
            return(methodGaussa);
        }
Exemple #5
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (lblMatr.Text.Trim() == "")
            {
                gauss         = CopyToGauss();
                lblMatr.Text  = "Рассширенная матрица системы: \n\n";
                lblMatr.Text += gauss.MatrToStr() + "\n";

                numRow1.Maximum = numericUpDown1.Value;
                numRow2.Maximum = numericUpDown1.Value;
            }
            else
            if (MessageBox.Show("Очистить решение и скопировать исходную матрицу?", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                gauss         = CopyToGauss();
                lblMatr.Text  = "Рассширенная матрица системы: \n\n";
                lblMatr.Text += gauss.MatrToStr() + "\n";

                numRow1.Maximum = numericUpDown1.Value;
                numRow2.Maximum = numericUpDown1.Value;
            }
        }