Implemented CacheMatrix for programming assignment 2.