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

Method cofactor

linear_algebra/src/lib.py:394–403  ·  view source on GitHub ↗

returns the cofactor (signed minor) along (x, y)

(self, x: int, y: int)

Source from the content-addressed store, hash-verified

392 return Matrix(minor, self.__width - 1, self.__height - 1).determinant()
393
394 def cofactor(self, x: int, y: int) -> float:
395 """
396 returns the cofactor (signed minor) along (x, y)
397 """
398 if self.__height != self.__width:
399 raise Exception("Matrix is not square")
400 if 0 <= x < self.__height and 0 <= y < self.__width:
401 return (-1) ** (x + y) * self.minor(x, y)
402 else:
403 raise Exception("Indices out of bounds")
404
405 def determinant(self) -> float:
406 """

Callers 2

determinantMethod · 0.95
test_cofactorMethod · 0.95

Calls 1

minorMethod · 0.95

Tested by 1

test_cofactorMethod · 0.76