Wrote cache matrix functions