Caches and solves for inverse of matrix