Added implementation to compute and cache inverse of given matrix.