cachematrix.R final verision for programming assignment 2