completed the 2 functions for matrix inverse calculation with caching