ENH: implement cache matrix functions