Implemented cache matrix.