functions to cache and retrieve inverse matrix