completed cachematrix functions