Computing the determinant of a matrix is performed by following a given row and computing the value of the adjugates. For example, suppose we have a matrix of the form:
that would mean that:
For larger matrices, supposing that represents a sub-matrix of , its determinant has to be computed. This is performed recursively by traversing a matrix row and then calling
wasDeterminant on any sub-matrix.
For a larger matrix, such as:
the element must be multiplied with the value of the sub-determinant while minding the alternation of the signs. In this case:
The adjugate step consists in finding the cofactor (determinants) of every element in the matrix and replacing the original value with the cofactor of the sub-matrix. For example, for a matrix :
One would take each element, ignore the row and column it appears in and compute the determinant of the sub-matrix . For example, in this particular case, the element will be replaced with the value of the determinant:
The signs alternate on rows and columns, for example, the cofactor of the second element will have a negative sign:
The same applies to the cofactor of element , that will have a negative sign as well:
By going through every element of the matrix and replacing each element with value of the determinants of the sub-matrix (also called the co-factor), we obtain a new matrix that has to finally be transposed in order to finally obtain the adjugate of the matrix.
For a multiplication between a scalar and a matrix so that :
we multiply the scalar with every element in in order to obtain the resulting matrix .
In order to multiply two matrixes, the number of columns of the first matrix has to be equal to the number of rows of the second matrix .
in this case, we have and with . For every element in we multiply elements from the rows of with elements from the column of and add them up to obtain the elements in .