Matrix Minors

The minor of a matrix element \((i, j)\) is the determinant of a smaller matrix, which is obtained by removing row i and column j from the original matrix. The process of removing rows and columns is often called cutting a matrix. If you find the minor of every element in a matrix, the result is called the matrix of minors, sometimes just minor matrix.

For example, given the following matrix:

$$ M = \begin{bmatrix} A & D & G \\ B & E & H \\ C & F & I \end{bmatrix} $$

The minor of element \(2, 1\) (using zero based indices here) could be found like this:

$$ minor(2, 1) = \begin{bmatrix} A & \square & G \\ B & \square & H \\ \square & F & \square \end{bmatrix} = | \begin{bmatrix} A & G \\ B & H \\ \end{bmatrix} | = AH - GB $$

For higher order matrices, the process is recursive. To find the minor of an element in a 4x4 matrix, you would have to remove one row and one column, then find the determinant of the resulting 3x3 matrix. Finding the determinant of a 3x3 matrix will be covered in section 7d, 3x3 Determinant.The process for larger matrices is recursive. Finding the determinant of a 3x3 matrix involves finding the minor of some of it's elements, which in turn requires you to find the determinant of smaller 2x2 matrices.

Before implementing the Minor function, create helper functions to cut lower order matrices from higher order matrices.

// 0 based index
mat3 Cut(mat4, int row, int col) { 
    mat3 result = mat3();
    int cur = 0;
    for (int c = 0; c < 4; ++ c) {
        for (int r = 0; r < 4; ++r) {
            if (r == row || c == col) {
            result.v[cur++] = m.v[c * 4 + r];
    return result;

// mat3 cut (produces mat2) is similar, the for loops and indexing m need to be adjusted

The code below is for a 3x3 matrix because only the 2x2 determinant function has been covered. Finding the minor of bigger matrices, like a 4x4 matrix is covered in section 7d, Laplace expansion. To support bigger matrices adjust the loops and the index with the appropriate size.

mat3 Minor(mat3 m) {
    mat3 result = mat3();
    for (int c = 0; c < 3; ++c) {
        for (int r = 0; r < 3; ++r) {
            int index = c * 3 + r; 
            result.v[index] = Determinant(Cut(m, r, c));

// Higher order matrices are very similar