cachematrix.R Final