modified cachematrix.R to calculate inverse of a matrix