Completed both function to cache the matrix inversion.