Fix lgamma_r linking errors on Windows. It appears the normal lgamma function is thread safe anyway
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302330 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -3997,7 +3997,18 @@ public:
|
||||
{return !(__x == __y);}
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_MSVCRT
|
||||
extern "C" double lgamma_r(double, int *);
|
||||
#endif
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY double __libcpp_lgamma(double __d) {
|
||||
#if defined(_LIBCPP_MSVCRT)
|
||||
return lgamma(__d);
|
||||
#else
|
||||
int __sign;
|
||||
return lgamma_r(__d, &__sign);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class _IntType>
|
||||
binomial_distribution<_IntType>::param_type::param_type(const result_type __t, const double __p)
|
||||
@@ -4005,11 +4016,10 @@ binomial_distribution<_IntType>::param_type::param_type(const result_type __t, c
|
||||
{
|
||||
if (0 < __p_ && __p_ < 1)
|
||||
{
|
||||
int __sign;
|
||||
__r0_ = static_cast<result_type>((__t_ + 1) * __p_);
|
||||
__pr_ = _VSTD::exp(lgamma_r(__t_ + 1., &__sign) -
|
||||
lgamma_r(__r0_ + 1., &__sign) -
|
||||
lgamma_r(__t_ - __r0_ + 1., &__sign) + __r0_ * _VSTD::log(__p_) +
|
||||
__pr_ = _VSTD::exp(__libcpp_lgamma(__t_ + 1.) -
|
||||
__libcpp_lgamma(__r0_ + 1.) -
|
||||
__libcpp_lgamma(__t_ - __r0_ + 1.) + __r0_ * _VSTD::log(__p_) +
|
||||
(__t_ - __r0_) * _VSTD::log(1 - __p_));
|
||||
__odds_ratio_ = __p_ / (1 - __p_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user