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); } }
public void InverseOnesMatrix() { var a = Matrix <int> .CreateOnesMatrix(5, 5); var matr = new InverseMatrix <int>(a); var inverse = matr.Calculate(); Assert.AreEqual(a, inverse); }
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()); }
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()); }
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]); }
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); }