completed cachematrix functions.