Computes and caches the inverse of a matrix