Final draft of the cachematrix R script