Computing the inverse of matrix and cache it.