write code in cachematrx.R