Inverse matrix with caching done