modified cachematrix.R, solution completed