Cachematrix implementation