cachematrix.R working and tested