Added code to invert a matrix with cache.