Update function for caching inverse matrices