Caching inverse of matrix - programming assignment 2