Modified sample functions to return / cache matrix inverse