final version of cachematrix.R