my take on cachematrix.R