Compute and cache inverse of a matrix, or retrieve inverse if already cached