update cachematrix.R to complete Coursera R Programming assignment 2