cachematrix.R working solution