implementing caching matrix inverse functions