implement cache matrix inverse