completed function in cachematrix.r