Functions to compute matrix inverse and caching the result.