Ejemplo n.º 1
0
        private void ShowMatrix(Matrix A)
        {
            int n = prirost;
            int m = prirost;

            if (isLastYPage())
            {
                n = A.N % prirost;
            }
            if (n == 0)
            {
                n = A.N;
            }
            if (isLastXPage())
            {
                m = A.N % prirost;
            }
            if (m == 0)
            {
                m = A.N;
            }
            // очистка
            this.dataGridViewOutput.Rows.Clear();  // удаление всех строк
            int count = this.dataGridViewOutput.Columns.Count;

            for (int i = 0; i < count; i++)     // цикл удаления всех столбцов
            {
                this.dataGridViewOutput.Columns.RemoveAt(0);
            }

            // создание новой
            DataGridViewTextBoxColumn[] column = new DataGridViewTextBoxColumn[m];
            for (int i = 0; i < m; i++)
            {
                column[i]            = new DataGridViewTextBoxColumn(); // выделяем память для объекта
                column[i].HeaderText = (i + 1 + left).ToString();
                column[i].Name       = (i + 1 + left).ToString();
            }
            // задание новой
            this.dataGridViewOutput.Columns.AddRange(column); // добавление столбцов
            for (int i = 0; i < n; i++)
            {
                object[] row = new object[m];
                for (int j = 0; j < m; j++)
                {
                    row[j] = ServiceFunctions.DeletZerosInEndString(String.Format("{0:F" + Epsilon.value.ToString() + "}", Operations.getElement(up + i, left + j, A)));
                }
                dataGridViewOutput.Rows.Add(row);// добавление строк
            }
            foreach (DataGridViewColumn col in dataGridViewOutput.Columns)
            {
                col.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
        }
Ejemplo n.º 2
0
        // Отображение матрицы С
        private void ShowMatrixC()
        {
            int n = Math.Min(20, C.N);
            int m = Math.Min(20, C.N);

            // очистка
            this.GridView_C.Rows.Clear();  // удаление всех строк
            int count = this.GridView_C.Columns.Count;

            for (int i = 0; i < count; i++)     // цикл удаления всех столбцов
            {
                this.GridView_C.Columns.RemoveAt(0);
            }
            if (C.Type != Category.none)
            {
                // создание новой
                DataGridViewTextBoxColumn[] column = new DataGridViewTextBoxColumn[m];
                for (int i = 0; i < m; i++)
                {
                    column[i]            = new DataGridViewTextBoxColumn(); // выделяем память для объекта
                    column[i].HeaderText = (i + 1).ToString();
                    column[i].Name       = (i + 1).ToString();
                }
                // задание новой
                this.GridView_C.Columns.AddRange(column); // добавление столбцов
                for (int i = 0; i < n && i < C.N; i++)
                {
                    object[] row = new object[m];
                    for (int j = 0; j < m; j++)
                    {
                        row[j] = ServiceFunctions.DeletZerosInEndString(String.Format("{0:F" + Epsilon.value.ToString() + "}", Operations.getElement(i, j, C)));
                    }
                    GridView_C.Rows.Add(row);// добавление строк
                }
                foreach (DataGridViewColumn col in GridView_C.Columns)
                {
                    col.SortMode = DataGridViewColumnSortMode.NotSortable;
                }
            }
        }
Ejemplo n.º 3
0
        private void ShowMatrixAdress(Matrix A)
        {
            int n = prirost;
            int m = prirost;

            if (isLastYPage())
            {
                n = A.N % prirost;
            }
            if (n == 0)
            {
                n = A.N;
            }
            if (isLastXPage())
            {
                m = A.N % prirost;
            }
            if (m == 0)
            {
                m = A.N;
            }
            // очистка
            this.dataGridViewOutput.Rows.Clear();  // удаление всех строк
            int count = this.dataGridViewOutput.Columns.Count;

            for (int i = 0; i < count; i++)     // цикл удаления всех столбцов
            {
                this.dataGridViewOutput.Columns.RemoveAt(0);
            }
            // создание новой
            DataGridViewTextBoxColumn[] column = new DataGridViewTextBoxColumn[m];
            for (int i = 0; i < m; i++)
            {
                column[i]            = new DataGridViewTextBoxColumn(); // выделяем память для объекта
                column[i].HeaderText = (i + 1 + left).ToString();
                column[i].Name       = (i + 1 + left).ToString();
            }
            // задание новой
            this.dataGridViewOutput.Columns.AddRange(column); // добавление столбцов
            unsafe {
                uint Adress;
                for (int i = 0; i < n && i < A.N; i++)
                {
                    object[] row = new object[m];
                    for (int j = 0; j < m; j++)
                    {
                        if (Operations.isV(i + up, j + left, A))
                        {
                            fixed(double *p = &A.v)
                            {
                                Adress = (uint)p;
                                row[j] = ServiceFunctions.DeletZerosInEndString(
                                    String.Format("{0:F" + Epsilon.value.ToString() + "}", A.V))
                                         + " | " + "0x" + Adress.ToString("X2");
                            }
                        }
                        else
                        {
                            fixed(double *p = &A.Packed_form[Operations.getIndexK(i + up, j + left, A)])
                            {
                                Adress = (uint)p;
                                row[j] = ServiceFunctions.DeletZerosInEndString(
                                    String.Format("{0:F" + Epsilon.value.ToString() + "}",
                                                  Operations.getElement(i + up, j + left, A))) + " | " + "0x" + Adress.ToString("X2");
                            }
                        }
                    }
                    dataGridViewOutput.Rows.Add(row);// добавление строк
                }
                foreach (DataGridViewColumn col in dataGridViewOutput.Columns)
                {
                    col.SortMode = DataGridViewColumnSortMode.NotSortable;
                }
            }
        }