implement functions

implement functions to cache matrix inverse