As part of a complex task, I need to compute matrix cofactors. I did this in a straightforward way using this nice code for computing matrix minors. Here is my code:
from sympy import * A = Matrix([[1,2,0],[0,3,0],[0,7,1]]) A.adjugate().T
And the output (which is cofactor matrix) is:
Matrix([ [ 3, 0, 0], [-2, 1, -7], [ 0, 0, 3]])