示例#1
0
 private void Button8_Click(Object sender, EventArgs e)
 {
     try
     {
         if (comboBox11.Text == Resources.res14)
         {
             var matrix       = new InverseMatrix <int>(Matrix <int> .GetLeftMatrix());
             var resultMatrix = matrix.Calculate();
             var form         = new Matrix <int>(resultMatrix.CountOfRows, resultMatrix.CountOfColumns, resultMatrix.Get2DArray());
             form.ShowDialog();
         }
         else
         {
             var matrix       = new InverseMatrix <double>(Matrix <double> .GetLeftMatrix());
             var resultMatrix = matrix.Calculate();
             var form         = new Matrix <double>(resultMatrix.CountOfRows, resultMatrix.CountOfColumns, resultMatrix.Get2DArray());
             form.ShowDialog();
         }
     }
     catch (NullReferenceException)
     {
         MessageBox.Show(Resources.res12, Resources.res03);
     }
     catch (MatrixLib.MatrixException exception)
     {
         MessageBox.Show(exception.Message, Resources.res03);
     }
 }
示例#2
0
        public void InverseOnesMatrix()
        {
            var a = Matrix <int> .CreateOnesMatrix(5, 5);

            var matr = new InverseMatrix <int>(a);

            var inverse = matr.Calculate();

            Assert.AreEqual(a, inverse);
        }
示例#3
0
        public void IsCorrectNotException()
        {
            var matrOfArray = new int[, ] {
                { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }
            };
            var a  = new Matrix <int>(3, 3, matrOfArray);
            var im = new InverseMatrix <int>(a);

            Assert.ThrowsException <MatrixException>(() => im.Calculate());
        }
示例#4
0
        public void InverseExceptionDouble()
        {
            var matrOfArray = new double[, ] {
                { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }
            };
            var a  = new Matrix <double>(3, 3, matrOfArray);
            var im = new InverseMatrix <double>(a);

            Assert.ThrowsException <MatrixException>(() => im.Calculate());
        }
示例#5
0
        public void InverseUsersMatrixNumb()
        {
            var matrOfArray = new int[, ] {
                { 0, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }
            };
            var a = new Matrix <int>(3, 3, matrOfArray);

            var matr = new InverseMatrix <int>(a);

            var inverse = matr.Calculate();

            Assert.AreEqual(-1, inverse[0, 0]);
        }
示例#6
0
        public void InverseUsersMatrix0()
        {
            var matrOfArray = new int[, ] {
                { 2, 6, 5 }, { 5, 3, -2 }, { 7, 4, -3 }
            };
            var resultMatr = new int[, ] {
                { 1, -38, 27 }, { -1, 41, -29 }, { 1, -34, 24 }
            };
            var a = new Matrix <int>(3, 3, matrOfArray);

            var matr    = new InverseMatrix <int>(a);
            var ad      = new Matrix <int>(3, 3, resultMatr);
            var inverse = matr.Calculate();

            Assert.AreEqual(ad, inverse);
        }