Exemplo n.º 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]);
            }
        }
Exemplo n.º 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();
        }
Exemplo n.º 3
0
        public void Update(string type)
        {
            SLAESource.GetSLAE(out matrix, type, out b, out x0);
            int n = matrix.Size;

            Location = Owner.Location;
            format   = type;

            DataGridView mat = new DataGridView();

            mat = MatrixVisualRepresentation.CoordinationalToGridView(MatrixExtensions.ConvertToCoordinationalMatrix(matrix), SLAESource.IsSymmetric);
            MatrixVisualRepresentation.CopyDataGridView(mat, ref A);

            width  = cellWidth * (n - 2);
            heigth = cellHeight * (n - 2);

            Size size = new Size(Width > 115 + width ? Width : 115 + width, 190 + heigth);

            MaximumSize = size;
            MinimumSize = size;
            Size        = size;
            A.ReadOnly  = true;
            MatrixVisualRepresentation.PaintPattern(ref A, Color.SteelBlue);
        }
Exemplo n.º 4
0
 private void A_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     patternChanged = true;
     MatrixVisualRepresentation.InverseElementPatternStatus(ref A, e.RowIndex, e.ColumnIndex);
     MatrixVisualRepresentation.PaintPattern(ref A, Color.SteelBlue);
 }