Implement cached matrix inverse for assignment 2