completed code in cachematrix.R