Updated final version of cachedmatrix for Programmingassignment 2