Added comments and explanation.
Implemented the functions for caching and solving (inverse) matrices.