enhanced cachematrix.R