adding function implementation for caching the result of matrix inverse