Implemented functions to solve inverse matrix with cache