Added R code for cachematrix