functions for caching inverse matrix