Added functionality to get the inverse of a matrix and cache the result