Update cachematrix.R

Comments and logic added