Inverts and Caches a matrix