Added function for solving and caching matrix inverse.