Skip to content

Commit 5998fec

Browse files
committed
Submit promoted power as parameter rather than intermediate value
1 parent f4f18a5 commit 5998fec

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

include/boost/math/distributions/logistic.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ namespace boost { namespace math {
147147
return result;
148148
}
149149

150-
RealType power = (x - location) / scale;
151-
return logistic_sigmoid(power, Policy());
150+
using promoted_real_type = typename policies::evaluation<RealType, Policy>::type;
151+
promoted_real_type power = (static_cast<promoted_real_type>(x) - static_cast<promoted_real_type>(location)) / static_cast<promoted_real_type>(scale);
152+
return logistic_sigmoid<false>(power, Policy());
152153
}
153154

154155
template <class RealType, class Policy>
@@ -248,8 +249,10 @@ namespace boost { namespace math {
248249
{
249250
return result;
250251
}
251-
RealType power = (location - x) / scale;
252-
return logistic_sigmoid(power, Policy());
252+
253+
using promoted_real_type = typename policies::evaluation<RealType, Policy>::type;
254+
promoted_real_type power = (static_cast<promoted_real_type>(location) - static_cast<promoted_real_type>(x)) / static_cast<promoted_real_type>(scale);
255+
return logistic_sigmoid<false>(power, Policy());
253256
}
254257

255258
template <class RealType, class Policy>

0 commit comments

Comments
 (0)