Updated cacheMatrix.R according to the assignment requirements.