Fixed the matrix inverse implementation and tested it successfully with an invertible matrix, comparing results with the numpy package.