Calculates the reciprocal of a matrix.