functions for cache and inverse matrix