Implemented cachematrix.