submitted version of cachematrix.R