MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / minor

Method minor

linear_algebra/src/lib.py:383–392  ·  view source on GitHub ↗

returns the minor along (x, y)

(self, x: int, y: int)

Source from the content-addressed store, hash-verified

381 raise Exception("change_component: indices out of bounds")
382
383 def minor(self, x: int, y: int) -> float:
384 """
385 returns the minor along (x, y)
386 """
387 if self.__height != self.__width:
388 raise Exception("Matrix is not square")
389 minor = self.__matrix[:x] + self.__matrix[x + 1 :]
390 for i in range(len(minor)):
391 minor[i] = minor[i][:y] + minor[i][y + 1 :]
392 return Matrix(minor, self.__width - 1, self.__height - 1).determinant()
393
394 def cofactor(self, x: int, y: int) -> float:
395 """

Callers 2

cofactorMethod · 0.95
test_minorMethod · 0.95

Calls 2

MatrixClass · 0.70
determinantMethod · 0.45

Tested by 1

test_minorMethod · 0.76