Final version of cachematrix.R for R Programming MOOC Assignment 2