Fleshed out code for creating special matrix that caches inverse