Implemented CacheMatrix functions.