public void GetDeterminant() { matrix = new Matrix(1, 0, 0, 0, 0, 1, 2, 1, 0, 2, 1, 3, 0, 2, 1, 1); Assert.AreEqual(6, matrix.GetDeterminant()); }
public void TestDeterminant4() { var m = Matrix.GetIdentity(4); Assert.AreEqual(1, m.GetDeterminant()); m.SetRow(0, 1, 0, 0, 0); m.SetRow(1, 0, 1, 0, 0); m.SetRow(2, 0, 0, 1, 0); m.SetRow(3, 0, 0, 5, 0); Assert.AreEqual(0, m.GetDeterminant()); m = new Matrix(new float[,] { {1, 2, 3, 4}, {8, 7, 6, 5}, {10, 9, 11, 12}, {14, 15, 13, 16} }); Assert.AreEqual(-108, m.GetDeterminant()); }
public void TestDeterminant3() { var m = Matrix.GetIdentity(3); Assert.AreEqual(1, m.GetDeterminant()); m.SetRow(0, 1, 0, 0); m.SetRow(1, 0, 1, 0); m.SetRow(2, 0, 5, 0); Assert.AreEqual(0, m.GetDeterminant()); m = new Matrix(new float[,] { {1, 2, 3}, {6, 5, 4}, {8, 7, 9} }); Assert.AreEqual(1*5*9 + 2*4*8 + 3*7*6 - 8*5*3 - 7*4*1 - 9*2*6, m.GetDeterminant()); }
public void TestDeterminant2() { var m = Matrix.GetIdentity(2); Assert.AreEqual(1, m.GetDeterminant()); m.SetRow(0, 1, 0); m.SetRow(1, 5, 0); Assert.AreEqual(0, m.GetDeterminant()); m = new Matrix(new float[,] { {1, 2}, {4, 3} }); Assert.AreEqual(1*3 - 2*4, m.GetDeterminant()); }
public void TestDeterminant1() { var m = Matrix.GetIdentity(1); Assert.AreEqual(1, m.GetDeterminant()); m.SetRow(0, 0); Assert.AreEqual(0, m.GetDeterminant()); m = new Matrix(new float[,] { {2} }); Assert.AreEqual(2, m.GetDeterminant()); }
public void TestDeterminant() { try { var m = new Matrix(3, 2); m.GetDeterminant(); Assert.Fail("Expected an exception"); } catch (ArgumentException) {} try { var m = Matrix.GetIdentity(5); m.GetDeterminant(); Assert.Fail("Expected an exception"); } catch (NotImplementedException) {} }