Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions matrix/inverse_of_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def inverse_of_matrix(matrix: list[list[float]]) -> list[list[float]]:

Doctests for 3x3
>>> inverse_of_matrix([[2, 5, 7], [2, 0, 1], [1, 2, 3]])
[[2.0, 5.0, -4.0], [1.0, 1.0, -1.0], [-5.0, -12.0, 10.0]]
[[2.0, 1.0, -5.0], [5.0, 1.0, -12.0], [-4.0, -1.0, 10.0]]
>>> inverse_of_matrix([[1, 2, 2], [1, 2, 2], [3, 2, -1]])
Traceback (most recent call last):
...
Expand Down Expand Up @@ -145,7 +145,7 @@ def inverse_of_matrix(matrix: list[list[float]]) -> list[list[float]]:
adjoint_matrix[i][j] = cofactor_matrix[j][i]

# Inverse of the matrix using the formula (1/determinant) * adjoint matrix
inverse_matrix = array(cofactor_matrix)
inverse_matrix = array(adjoint_matrix)
for i in range(3):
for j in range(3):
inverse_matrix[i][j] /= d(determinant)
Expand Down