Caching solution for the matrix inversion problem