modified cachematrix.R for Assignment 2