Writing cachematrix functions.