Implement cache matrix functions