cachematrix.R final version