implementing methods in cachematrix.R