Finished cachematrix.R for peer review