Added caching functions

Added two functions which calculate and  caching the inverse value of a
matrix.