Write cachematrix functions