Implement cached matrix inversion functions.