final cachematrix.R for peer review