Implemented functions for cached matrix inverse