programmed cachematrix.r