rewrite cachematrix.R