private void buttonInverseB_Click(object sender, EventArgs e) { try { if (GlobalsMatrix.RowB <= 30 && GlobalsMatrix.ColB <= 30) { if ((GlobalsMatrix.DetM(GlobalsMatrix.B, GlobalsMatrix.RowB) == 0) || (GlobalsMatrix.RowB != GlobalsMatrix.ColB)) { MyMessageBox.Show("Không thể thực hiện đảo ma trận B"); } else { MatrixName = "B"; InverseMatrix inversefrm = new InverseMatrix(MatrixName); inversefrm.Show(); MatrixName = "R"; Delete_Matrix(); Add_MatrixRe(ColB, RowB); GlobalsMatrix.setRowMatrixRe(ColB); GlobalsMatrix.setColMatrixRe(RowB); RowR = GlobalsMatrix.RowRe; ColR = GlobalsMatrix.ColRe; } } else { if ((GlobalsMatrix.DetM(GlobalsMatrix.B, GlobalsMatrix.RowB) == 0) || (GlobalsMatrix.RowB != GlobalsMatrix.ColB)) { MyMessageBox.Show("Không thể thực hiện đảo ma trận B"); } else { MatrixName = "B"; InverseMatrix inversefrm = new InverseMatrix(MatrixName); inversefrm.MergeMatrixBig(GlobalsMatrix.B, GlobalsMatrix.RowB); MatrixName = "R"; Delete_Matrix(); Add_MatrixRe(ColB, RowB); GlobalsMatrix.setRowMatrixRe(ColB); GlobalsMatrix.setColMatrixRe(RowB); RowR = GlobalsMatrix.RowRe; ColR = GlobalsMatrix.ColRe; } } } catch (Exception ex) { MyMessageBox.Show(ex.Message); } }
/// <summary> /// ////////////////////////////////////////////////////////////////////////////// /// </summary> private void buttonInverseA_Click(object sender, EventArgs e) { try { if (GlobalsMatrix.RowA <= 30 && GlobalsMatrix.ColA <= 30) { if ((GlobalsMatrix.DetM(GlobalsMatrix.A, GlobalsMatrix.RowA) != 0) && (GlobalsMatrix.RowA == GlobalsMatrix.ColA)) { MatrixName = "A"; InverseMatrix inversefrm = new InverseMatrix(); inversefrm.Show(); MatrixName = "R"; Delete_Matrix(); Add_MatrixRe(ColA, RowA); GlobalsMatrix.setRowMatrixRe(ColA); GlobalsMatrix.setColMatrixRe(RowA); RowR = GlobalsMatrix.RowRe; ColR = GlobalsMatrix.ColRe; if (RowR >= 5 && ColR >= 5) { flowLayoutPanelR.FlowDirection = FlowDirection.LeftToRight; } else { flowLayoutPanelR.FlowDirection = FlowDirection.TopDown; } } else { MyMessageBox.Show("Không thể thực hiện đảo ma trận A"); } } else { if ((GlobalsMatrix.DetM(GlobalsMatrix.A, GlobalsMatrix.RowA) != 0) && (GlobalsMatrix.RowA == GlobalsMatrix.ColA)) { MatrixName = "A"; InverseMatrix inversefrm = new InverseMatrix(); inversefrm.MergeMatrixBig(GlobalsMatrix.A, GlobalsMatrix.RowA); MatrixName = "R"; Delete_Matrix(); Add_MatrixRe(ColA, RowA); GlobalsMatrix.setRowMatrixRe(ColA); GlobalsMatrix.setColMatrixRe(RowA); RowR = GlobalsMatrix.RowRe; ColR = GlobalsMatrix.ColRe; if (RowR >= 5 && ColR >= 5) { flowLayoutPanelR.FlowDirection = FlowDirection.LeftToRight; } else { flowLayoutPanelR.FlowDirection = FlowDirection.TopDown; } } else { MyMessageBox.Show("Không thể thực hiện đảo ma trận A"); } } } catch (Exception ex) { MyMessageBox.Show(ex.Message); } }