have implemented the cachematrix functions