Has anyone ever come across the calculation of the cofactor matrix of a square matrix. Any idea how that can be done?
Here is an example of a 3x3 matrix (I need to do the same for a nxn).
As you can see the element i,j of the cofactor matrix C, is the determinant of a submatrix of A, that does not contain the row i and column j.
I did look in the library and there is not a method to do this directly.
Mi idea is to do my own method that does the following:
For every i,j
- Copy the matrix A into a another matrix lets say M
- Remove row i from matrix M with the method using a new matrix R= M.RemoveRow(i)
- Remove column j from matrix M with the method using a new matrix Q= M.RemoveColumn(j)
- Calculate the determinant of Q Q.determinat()
- Store the determinant of Q in C[i,j] with the proper sign
Any other idea that maybe faster??
Any help will be greatly appreciated.