예제 #1
0
        public void GetSLAE(out IMatrix _A, string type, out IVector _b, out IVector _x0)
        {
            _b  = new Vector(n);
            _x0 = new Vector(n);

            for (int i = 0; i < n; i++)
            {
                _b[i]  = double.Parse(F.Rows[i].Cells[0].Value.ToString());
                _x0[i] = double.Parse(x0.Rows[0].Cells[i].Value.ToString());
            }

            IMatrix matrix = MatrixVisualRepresentation.GridViewToCoordinational(A, IsSymmetric);

            if (IsSymmetric)
            {
                _A = FormatFactory.Convert((SymmetricCoordinationalMatrix)matrix, FormatFactory.FormatsDictionary[type]);
            }
            else
            {
                _A = FormatFactory.Convert((CoordinationalMatrix)matrix, FormatFactory.FormatsDictionary[type]);
            }
        }
예제 #2
0
        private void forwardToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            bool symmetric = SLAESource.IsSymmetric;
            var  tmp       = new FormatFactory();

            if (symmetric)
            {
                matrix = FormatFactory.Convert((SymmetricCoordinationalMatrix)MatrixVisualRepresentation.PatternedGridViewToCoordinational(A, symmetric),
                                               FormatFactory.FormatsDictionary[format]);
            }
            else
            {
                matrix = FormatFactory.Convert((CoordinationalMatrix)MatrixVisualRepresentation.PatternedGridViewToCoordinational(A, symmetric),
                                               FormatFactory.FormatsDictionary[format]);
            }

            if (patternChanged)
            {
                CoordinationalMatrix user = (CoordinationalMatrix)MatrixVisualRepresentation.PatternedGridViewToCoordinational(A, symmetric);
                CoordinationalMatrix auto = matrix.ConvertToCoordinationalMatrix();

                foreach (var elem in auto)
                {
                    if (!user.Contains((elem.value, elem.row, elem.col)))
                    {
                        var res = MessageBox.Show("Заданный портрет не соответствует выбранному формату хранения. Портрет будет автоматически преобразован к корректному виду.", "Уведомление", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                        if (res == DialogResult.OK)
                        {
                            mainForm.SetSLAE(matrix, b, x0);
                            Close();
                        }
                        return;
                    }
                }
            }

            mainForm.SetSLAE(matrix, b, x0);
            Close();
        }