Implement a cacheable inverse of matrix