def test_adj_computation(self): self.assertEqual(Matrix.adj(Matrix(list_51)), Matrix([[1]]).transpose()) self.assertEqual(Matrix.adj(Matrix(list_52)), Matrix([[3, -2], [-1, 4]]).transpose()) self.assertEqual( Matrix.adj(Matrix(list_53)), Matrix([[30, 6, -36], [2, 0, -4], [11, 3, -13]]).transpose()) self.assertEqual( Matrix.adj(Matrix(list_54)), Matrix([[15, -98, 4, 104], [-156, 331, -116, -226], [54, -111, 33, 21], [42, -107, 67, 68]]).transpose())
from matrix import Matrix # 1x1 matrix whose determinant is (-4) ------------------------------- list_51 = [[-4]] mat_51 = Matrix(list_51) print(mat_51) print(Matrix.adj(mat_51)) # 2x2 matrix whose determinant is (10) ------------------------------- list_52 = [[4, 1], [2, 3]] mat_52 = Matrix(list_52) print(mat_52) print(Matrix.adj(mat_52)) # 3x3 matrix whose determinant is (-6) ------------------------------- list_53 = [[-2, 3, -1], [5, -1, 4], [4, -8, 2]] mat_53 = Matrix(list_53) print(mat_53) print(Matrix.adj(mat_53)) # 4x4 matrix whose determinant is (-279) ----------------------------- list_54 = [[7, 4, 2, 0], [6, 3, -1, 2], [4, 6, 2, 5], [8, 2, -7, 1]] mat_54 = Matrix(list_54) print(mat_54) print(Matrix.adj(mat_54))