caching for inverse matrix multiplication