implements cachematrix.R