Writed 2 functions to calculate inverted matrix with cache