示例#1
0
 /// <summary>
 /// //////////////////////////////////////////////////////////////////////////////
 /// </summary>
 private void buttonMultiply_Click(object sender, EventArgs e)
 {
     try
     {
         if (ColA != RowB)
         {
             MyMessageBox.Show("Không thỏa điều kiện thực hiện phép nhân");
         }
         else
         {
             GlobalsMatrix.nhan();
             Add_MatrixRe(RowA, ColB);
             GlobalsMatrix.setRowMatrixRe(RowA);
             GlobalsMatrix.setColMatrixRe(ColB);
             RowR = GlobalsMatrix.RowRe;
             ColR = GlobalsMatrix.ColRe;
             if (RowR >= 5 && ColR >= 5)
             {
                 flowLayoutPanelR.FlowDirection = FlowDirection.LeftToRight;
             }
             else
             {
                 flowLayoutPanelR.FlowDirection = FlowDirection.TopDown;
             }
         }
     }
     catch (Exception ex)
     {
         MyMessageBox.Show(ex.Message);
     }
 }
示例#2
0
        /// <summary>
        /// //////////////////////////////////////////////////////////////////////////////
        /// </summary>

        private void buttonSubtract_Click(object sender, EventArgs e)
        {
            try
            {
                if (RowA != RowB || ColA != ColB)
                {
                    MyMessageBox.Show("Không thể trừ hai ma trận khác kích thước");
                }
                else
                {
                    GlobalsMatrix.tru();
                    Add_MatrixRe(RowA, ColA);
                    GlobalsMatrix.setRowMatrixRe(RowA);
                    GlobalsMatrix.setColMatrixRe(ColA);
                    RowR = GlobalsMatrix.RowRe;
                    ColR = GlobalsMatrix.ColRe;
                    if (RowR >= 5 && ColR >= 5)
                    {
                        flowLayoutPanelR.FlowDirection = FlowDirection.LeftToRight;
                    }
                    else
                    {
                        flowLayoutPanelR.FlowDirection = FlowDirection.TopDown;
                    }
                }
            }
            catch (Exception ex)
            {
                MyMessageBox.Show(ex.Message);
            }
        }
示例#3
0
 private void buttonTransposeB_Click(object sender, EventArgs e)
 {
     try
     {
         GlobalsMatrix.chuyenvi(GlobalsMatrix.RowB, GlobalsMatrix.ColB, GlobalsMatrix.B);
         GlobalsMatrix.setRowMatrixRe(RowB);
         GlobalsMatrix.setColMatrixRe(ColB);
         MyMessageBox.Show("Đã chuyển vị ma trận B");
     }
     catch (Exception ex)
     {
         MyMessageBox.Show(ex.Message);
     }
 }
示例#4
0
 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);
     }
 }
示例#5
0
 private void buttonClearResult_Click(object sender, EventArgs e)
 {
     try
     {
         MatrixName = "Re";
         Delete_Matrix();
         GlobalsMatrix.setRowMatrixRe(0);
         GlobalsMatrix.setColMatrixRe(0);
     }
     catch (Exception ex)
     {
         MyMessageBox.Show(ex.Message);
     }
 }
示例#6
0
 private void buttonSubtract_Click(object sender, EventArgs e)
 {
     try
     {
         if (RowA != RowB || ColA != ColB)
         {
             MyMessageBox.Show("Không thể trừ hai ma trận khác kích thước");
         }
         else
         {
             GlobalsMatrix.tru();
             GlobalsMatrix.setRowMatrixRe(RowA);
             GlobalsMatrix.setColMatrixRe(ColA);
             MyMessageBox.Show("Đã trừ hai ma trận");
         }
     }
     catch (Exception ex)
     {
         MyMessageBox.Show(ex.Message);
     }
 }
示例#7
0
 private void buttonMultiply_Click(object sender, EventArgs e)
 {
     try
     {
         if (ColA != RowB)
         {
             MyMessageBox.Show("Không thỏa điều kiện thực hiện phép nhân");
         }
         else
         {
             GlobalsMatrix.nhan();
             GlobalsMatrix.setRowMatrixRe(RowA);
             GlobalsMatrix.setColMatrixRe(ColB);
             MyMessageBox.Show("Đã nhân hai ma trận");
         }
     }
     catch (Exception ex)
     {
         MyMessageBox.Show(ex.Message);
     }
 }
示例#8
0
 private void buttonInverseA_Click(object sender, EventArgs e)
 {
     try
     {
         if ((GlobalsMatrix.DetM(GlobalsMatrix.A, GlobalsMatrix.RowA) != 0) && (GlobalsMatrix.RowA == GlobalsMatrix.ColA))
         {
             MatrixName = "A";
             InverseMatrix inversefrm = new InverseMatrix();
             inversefrm.MergeMatrixBig(GlobalsMatrix.A, GlobalsMatrix.RowA);
             GlobalsMatrix.setRowMatrixRe(ColA);
             GlobalsMatrix.setColMatrixRe(RowA);
             MyMessageBox.Show("Đã đảo ma trận A");
         }
         else
         {
             MyMessageBox.Show("Không thể thực hiện đảo ma trận A");
         }
     }
     catch (Exception ex)
     {
         MyMessageBox.Show(ex.Message);
     }
 }
示例#9
0
 /// <summary>
 /// //////////////////////////////////////////////////////////////////////////////
 /// </summary>
 private void buttonTransposeB_Click(object sender, EventArgs e)
 {
     try
     {
         GlobalsMatrix.chuyenvi(GlobalsMatrix.RowB, GlobalsMatrix.ColB, GlobalsMatrix.B);
         Add_MatrixRe(ColB, RowB);
         GlobalsMatrix.setRowMatrixRe(ColB);
         GlobalsMatrix.setColMatrixRe(RowB);
         RowR = GlobalsMatrix.RowRe;
         ColR = GlobalsMatrix.ColRe;
         if (RowR >= 5 && ColR >= 5)
         {
             flowLayoutPanelR.FlowDirection = FlowDirection.LeftToRight;
         }
         else
         {
             flowLayoutPanelR.FlowDirection = FlowDirection.TopDown;
         }
     }
     catch (Exception ex)
     {
         MyMessageBox.Show(ex.Message);
     }
 }
示例#10
0
 /// <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);
     }
 }
示例#11
0
 /// <summary>
 /// //////////////////////////////////////////////////////////////////////////////
 /// </summary>
 private void Delete_Matrix()
 {
     try
     {
         if (MatrixName == "A")
         {
             Col = GlobalsMatrix.ColA;
             Row = GlobalsMatrix.RowA;
             for (int i = 0; i < Row; i++)
             {
                 foreach (FlowLayoutPanel pan in flowLayoutPanelA.Controls.OfType <FlowLayoutPanel>())
                 {
                     if ((MatrixName + i) == pan.Name)
                     {
                         foreach (Button btn in pan.Controls.OfType <Button>())
                         {
                             for (int j = 0; j < Col; j++)
                             {
                                 if ((MatrixName + i + "_" + j) == btn.Name)
                                 {
                                     pan.Controls.Remove(btn);
                                 }
                             }
                         }
                         flowLayoutPanelA.Controls.Remove(pan);
                     }
                 }
             }
             GlobalsMatrix.setColMatrixA(0);
             GlobalsMatrix.setRowMatrixA(0);
         }
         else
         if (MatrixName == "B")
         {
             Col = GlobalsMatrix.ColB;
             Row = GlobalsMatrix.RowB;
             for (int i = 0; i < Row; i++)
             {
                 foreach (FlowLayoutPanel pan in flowLayoutPanelB.Controls.OfType <FlowLayoutPanel>())
                 {
                     if ((MatrixName + i) == pan.Name)
                     {
                         foreach (Button btn in pan.Controls.OfType <Button>())
                         {
                             for (int j = 0; j < Col; j++)
                             {
                                 if ((MatrixName + i + "_" + j) == btn.Name)
                                 {
                                     pan.Controls.Remove(btn);
                                 }
                             }
                         }
                         flowLayoutPanelB.Controls.Remove(pan);
                     }
                 }
             }
             GlobalsMatrix.setColMatrixB(0);
             GlobalsMatrix.setRowMatrixB(0);
         }
         else
         if (MatrixName == "Re")
         {
             Col = GlobalsMatrix.ColRe;
             Row = GlobalsMatrix.RowRe;
             for (int i = 0; i < Row; i++)
             {
                 foreach (FlowLayoutPanel pan in flowLayoutPanelR.Controls.OfType <FlowLayoutPanel>())
                 {
                     if ((MatrixName + i) == pan.Name)
                     {
                         foreach (Button btn in pan.Controls.OfType <Button>())
                         {
                             for (int j = 0; j < Col; j++)
                             {
                                 if ((MatrixName + i + "_" + j) == btn.Name)
                                 {
                                     pan.Controls.Remove(btn);
                                 }
                             }
                         }
                         flowLayoutPanelR.Controls.Remove(pan);
                     }
                 }
             }
             GlobalsMatrix.setColMatrixRe(0);
             GlobalsMatrix.setRowMatrixRe(0);
         }
     }
     catch (Exception ex)
     {
         MyMessageBox.Show(ex.Message);
     }
 }