Skip to content

Commit

Permalink
NVRTC fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Sep 4, 2024
1 parent 255b3f0 commit 6157217
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions include/boost/math/distributions/normal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@

#include <boost/math/tools/config.hpp>
#include <boost/math/tools/tuple.hpp>
#include <boost/math/tools/numeric_limits.hpp>
#include <boost/math/distributions/fwd.hpp>
#include <boost/math/special_functions/erf.hpp> // for erf/erfc.
#include <boost/math/distributions/complement.hpp>
#include <boost/math/distributions/detail/common_error_handling.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/math/policies/policy.hpp>

namespace boost{ namespace math{

Expand Down Expand Up @@ -93,30 +94,30 @@ normal_distribution(RealType)->normal_distribution<typename boost::math::tools::
#endif

template <class RealType, class Policy>
BOOST_MATH_GPU_ENABLED inline std::pair<RealType, RealType> range(const normal_distribution<RealType, Policy>& /*dist*/)
BOOST_MATH_GPU_ENABLED inline boost::math::pair<RealType, RealType> range(const normal_distribution<RealType, Policy>& /*dist*/)
{ // Range of permissible values for random variable x.
if (std::numeric_limits<RealType>::has_infinity)
BOOST_MATH_IF_CONSTEXPR (boost::math::numeric_limits<RealType>::has_infinity)
{
return std::pair<RealType, RealType>(-std::numeric_limits<RealType>::infinity(), std::numeric_limits<RealType>::infinity()); // - to + infinity.
return boost::math::pair<RealType, RealType>(-boost::math::numeric_limits<RealType>::infinity(), boost::math::numeric_limits<RealType>::infinity()); // - to + infinity.
}
else
{ // Can only use max_value.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max value.
return boost::math::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max value.
}
}

template <class RealType, class Policy>
BOOST_MATH_GPU_ENABLED inline std::pair<RealType, RealType> support(const normal_distribution<RealType, Policy>& /*dist*/)
BOOST_MATH_GPU_ENABLED inline boost::math::pair<RealType, RealType> support(const normal_distribution<RealType, Policy>& /*dist*/)
{ // This is range values for random variable x where cdf rises from 0 to 1, and outside it, the pdf is zero.
if (std::numeric_limits<RealType>::has_infinity)
BOOST_MATH_IF_CONSTEXPR (boost::math::numeric_limits<RealType>::has_infinity)
{
return std::pair<RealType, RealType>(-std::numeric_limits<RealType>::infinity(), std::numeric_limits<RealType>::infinity()); // - to + infinity.
return boost::math::pair<RealType, RealType>(-boost::math::numeric_limits<RealType>::infinity(), boost::math::numeric_limits<RealType>::infinity()); // - to + infinity.
}
else
{ // Can only use max_value.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max value.
return boost::math::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max value.
}
}

Expand Down Expand Up @@ -172,7 +173,7 @@ BOOST_MATH_GPU_ENABLED inline RealType logpdf(const normal_distribution<RealType

constexpr auto function = "boost::math::logpdf(const normal_distribution<%1%>&, %1%)";

RealType result = -std::numeric_limits<RealType>::infinity();
RealType result = -boost::math::numeric_limits<RealType>::infinity();
if(false == detail::check_scale(function, sd, &result, Policy()))
{
return result;
Expand Down Expand Up @@ -348,7 +349,7 @@ BOOST_MATH_GPU_ENABLED inline RealType kurtosis_excess(const normal_distribution
template <class RealType, class Policy>
BOOST_MATH_GPU_ENABLED inline RealType entropy(const normal_distribution<RealType, Policy> & dist)
{
using std::log;
BOOST_MATH_STD_USING
RealType arg = constants::two_pi<RealType>()*constants::e<RealType>()*dist.standard_deviation()*dist.standard_deviation();
return log(arg)/2;
}
Expand Down

0 comments on commit 6157217

Please sign in to comment.