Modified cachematrix.R for assignment2