matrix caching