Caches the inverse of a matrix and finds its mean