Implementation of cached matrix program

Compare the input data with cached data. If they are the same, it will
return the cached result.