Added code for matrix inverse caching function