Added function for creating a cache matrix.