migrated cacheMatrix.R from forked repo