cachematrix.R modified for ProgrammingAssignment 2