Cache and solve inverse of matrix