Wrote function to solve and cache matrix inverse