implement cache inverse matrix