ProgrammingAssignment2 - cache matrix functions