Completed functions to solve and cache matrix inverse.