Wrote cachematrix functions.