Code for cached inverse of matrix