the completed version of cachematrix.R