Updating cachematrix.R with my solution to the problem.