completed code to cachematrix.R program