cacheable matrix inversion