Implement matrix caching functions