Final version of matrix inversion solver with cache functionality