the cachematrix implementation