Use boost::math::isnan instead of x != x trick for detecting NaNs