Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion libcxx/include/__chrono/formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
# include <__format/write_escaped.h>
# include <__memory/addressof.h>
# include <__type_traits/is_specialization.h>
# include <cmath>
# include <ctime>
# include <limits>
# include <locale>
Expand Down
8 changes: 4 additions & 4 deletions libcxx/include/__format/formatter_floating_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
#include <__format/formatter_output.h>
#include <__format/parser_std_format_spec.h>
#include <__iterator/concepts.h>
#include <__math/traits.h>
#include <__memory/allocator.h>
#include <__system_error/errc.h>
#include <__type_traits/conditional.h>
#include <__utility/move.h>
#include <__utility/unreachable.h>
#include <cmath>

#if _LIBCPP_HAS_LOCALIZATION
# include <__locale>
Expand Down Expand Up @@ -636,10 +636,10 @@ _LIBCPP_HIDE_FROM_ABI auto __write_using_trailing_zeros(
template <floating_point _Tp, class _CharT, class _FormatContext>
_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
__format_floating_point(_Tp __value, _FormatContext& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) {
bool __negative = std::signbit(__value);
bool __negative = __math::signbit(__value);

if (!std::isfinite(__value)) [[unlikely]]
return __formatter::__format_floating_point_non_finite(__ctx.out(), __specs, __negative, std::isnan(__value));
if (!__math::isfinite(__value)) [[unlikely]]
return __formatter::__format_floating_point_non_finite(__ctx.out(), __specs, __negative, __math::isnan(__value));

// Depending on the std-format-spec string the sign and the value
// might not be outputted together:
Expand Down
7 changes: 4 additions & 3 deletions libcxx/include/__random/binomial_distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
#define _LIBCPP___RANDOM_BINOMIAL_DISTRIBUTION_H

#include <__config>
#include <__math/exponential_functions.h>
#include <__math/logarithms.h>
#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <iosfwd>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down Expand Up @@ -115,9 +116,9 @@ template <class _IntType>
binomial_distribution<_IntType>::param_type::param_type(result_type __t, double __p) : __t_(__t), __p_(__p) {
if (0 < __p_ && __p_ < 1) {
__r0_ = static_cast<result_type>((__t_ + 1) * __p_);
__pr_ = std::exp(
__pr_ = __math::exp(
std::__libcpp_lgamma(__t_ + 1.) - std::__libcpp_lgamma(__r0_ + 1.) - std::__libcpp_lgamma(__t_ - __r0_ + 1.) +
__r0_ * std::log(__p_) + (__t_ - __r0_) * std::log(1 - __p_));
__r0_ * __math::log(__p_) + (__t_ - __r0_) * __math::log(1 - __p_));
__odds_ratio_ = __p_ / (1 - __p_);
}
}
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__random/cauchy_distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#define _LIBCPP___RANDOM_CAUCHY_DISTRIBUTION_H

#include <__config>
#include <__math/trigonometric_functions.h>
#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>

Expand Down Expand Up @@ -100,7 +100,7 @@ inline _RealType cauchy_distribution<_RealType>::operator()(_URNG& __g, const pa
static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
uniform_real_distribution<result_type> __gen;
// purposefully let tan arg get as close to pi/2 as it wants, tan will return a finite
return __p.a() + __p.b() * std::tan(3.1415926535897932384626433832795 * __gen(__g));
return __p.a() + __p.b() * __math::tan(3.1415926535897932384626433832795 * __gen(__g));
}

template <class _CharT, class _Traits, class _RT>
Expand Down
7 changes: 5 additions & 2 deletions libcxx/include/__random/clamp_to_integral.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
#define _LIBCPP___RANDOM_CLAMP_TO_INTEGRAL_H

#include <__config>
#include <cmath>
#include <__math/rounding_functions.h>
#include <__type_traits/is_floating_point.h>
#include <__type_traits/is_integral.h>
#include <__type_traits/is_same.h>
#include <limits>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down Expand Up @@ -44,7 +47,7 @@ template <class _IntT, class _RealT>
_LIBCPP_HIDE_FROM_ABI _IntT __clamp_to_integral(_RealT __r) _NOEXCEPT {
using _Lim = numeric_limits<_IntT>;
const _IntT __max_val = __max_representable_int_for_float<_IntT, _RealT>();
if (__r >= ::nextafter(static_cast<_RealT>(__max_val), INFINITY)) {
if (__r >= __math::nextafter(static_cast<_RealT>(__max_val), numeric_limits<_RealT>::infinity())) {
return _Lim::max();
} else if (__r <= _Lim::lowest()) {
return _Lim::min();
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__random/exponential_distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#define _LIBCPP___RANDOM_EXPONENTIAL_DISTRIBUTION_H

#include <__config>
#include <__math/logarithms.h>
#include <__random/generate_canonical.h>
#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>

Expand Down Expand Up @@ -96,7 +96,7 @@ template <class _RealType>
template <class _URNG>
_RealType exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) {
static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
return -std::log(result_type(1) - std::generate_canonical<result_type, numeric_limits<result_type>::digits>(__g)) /
return -__math::log(result_type(1) - std::generate_canonical<result_type, numeric_limits<result_type>::digits>(__g)) /
__p.lambda();
}

Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__random/extreme_value_distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#define _LIBCPP___RANDOM_EXTREME_VALUE_DISTRIBUTION_H

#include <__config>
#include <__math/logarithms.h>
#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>

Expand Down Expand Up @@ -100,7 +100,7 @@ template <class _RealType>
template <class _URNG>
_RealType extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) {
static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
return __p.a() - __p.b() * std::log(-std::log(1 - uniform_real_distribution<result_type>()(__g)));
return __p.a() - __p.b() * __math::log(-__math::log(1 - uniform_real_distribution<result_type>()(__g)));
}

template <class _CharT, class _Traits, class _RT>
Expand Down
14 changes: 8 additions & 6 deletions libcxx/include/__random/gamma_distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
#define _LIBCPP___RANDOM_GAMMA_DISTRIBUTION_H

#include <__config>
#include <__math/exponential_functions.h>
#include <__math/logarithms.h>
#include <__math/roots.h>
#include <__random/exponential_distribution.h>
#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>

Expand Down Expand Up @@ -114,13 +116,13 @@ _RealType gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type
const result_type __v = __gen(__g);
const result_type __w = __u * (1 - __u);
if (__w != 0) {
const result_type __y = std::sqrt(__c / __w) * (__u - result_type(0.5));
const result_type __y = __math::sqrt(__c / __w) * (__u - result_type(0.5));
__x = __b + __y;
if (__x >= 0) {
const result_type __z = 64 * __w * __w * __w * __v * __v;
if (__z <= 1 - 2 * __y * __y / __x)
break;
if (std::log(__z) <= 2 * (__b * std::log(__x / __b) - __y))
if (__math::log(__z) <= 2 * (__b * __math::log(__x / __b) - __y))
break;
}
}
Expand All @@ -131,12 +133,12 @@ _RealType gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type
const result_type __u = __gen(__g);
const result_type __es = __egen(__g);
if (__u <= 1 - __a) {
__x = std::pow(__u, 1 / __a);
__x = __math::pow(__u, 1 / __a);
if (__x <= __es)
break;
} else {
const result_type __e = -std::log((1 - __u) / __a);
__x = std::pow(1 - __a + __a * __e, 1 / __a);
const result_type __e = -__math::log((1 - __u) / __a);
__x = __math::pow(1 - __a + __a * __e, 1 / __a);
if (__x <= __e + __es)
break;
}
Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/__random/lognormal_distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#define _LIBCPP___RANDOM_LOGNORMAL_DISTRIBUTION_H

#include <__config>
#include <__math/exponential_functions.h>
#include <__random/is_valid.h>
#include <__random/normal_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>

Expand Down Expand Up @@ -69,13 +69,13 @@ class _LIBCPP_TEMPLATE_VIS lognormal_distribution {
// generating functions
template <class _URNG>
_LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
return std::exp(__nd_(__g));
return __math::exp(__nd_(__g));
}

template <class _URNG>
_LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p) {
typename normal_distribution<result_type>::param_type __pn(__p.m(), __p.s());
return std::exp(__nd_(__g, __pn));
return __math::exp(__nd_(__g, __pn));
}

// property functions
Expand Down
5 changes: 3 additions & 2 deletions libcxx/include/__random/normal_distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
#define _LIBCPP___RANDOM_NORMAL_DISTRIBUTION_H

#include <__config>
#include <__math/logarithms.h>
#include <__math/roots.h>
#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>

Expand Down Expand Up @@ -123,7 +124,7 @@ _RealType normal_distribution<_RealType>::operator()(_URNG& __g, const param_typ
__v = __uni(__g);
__s = __u * __u + __v * __v;
} while (__s > 1 || __s == 0);
result_type __fp = std::sqrt(-2 * std::log(__s) / __s);
result_type __fp = __math::sqrt(-2 * __math::log(__s) / __s);
__v_ = __v * __fp;
__v_hot_ = true;
__up = __u * __fp;
Expand Down
5 changes: 3 additions & 2 deletions libcxx/include/__random/piecewise_linear_distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#include <__algorithm/upper_bound.h>
#include <__config>
#include <__cstddef/ptrdiff_t.h>
#include <__math/roots.h>
#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <__vector/comparison.h>
#include <__vector/vector.h>
#include <cmath>
#include <initializer_list>
#include <iosfwd>

Expand Down Expand Up @@ -256,7 +256,8 @@ _RealType piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const
return __u / __dk + __bk;
const result_type __bk1 = __p.__b_[__k + 1];
const result_type __deltab = __bk1 - __bk;
return (__bk * __dk1 - __bk1 * __dk + std::sqrt(__deltab * (__deltab * __dk * __dk + 2 * __deltad * __u))) / __deltad;
return (__bk * __dk1 - __bk1 * __dk + __math::sqrt(__deltab * (__deltab * __dk * __dk + 2 * __deltad * __u))) /
__deltad;
}

template <class _CharT, class _Traits, class _RT>
Expand Down
29 changes: 17 additions & 12 deletions libcxx/include/__random/poisson_distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@
#define _LIBCPP___RANDOM_POISSON_DISTRIBUTION_H

#include <__config>
#include <__math/exponential_functions.h>
#include <__math/logarithms.h>
#include <__math/roots.h>
#include <__math/rounding_functions.h>
#include <__math/traits.h>
#include <__random/clamp_to_integral.h>
#include <__random/exponential_distribution.h>
#include <__random/is_valid.h>
#include <__random/normal_distribution.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <cstdlib>
#include <iosfwd>
#include <limits>

Expand Down Expand Up @@ -107,21 +112,21 @@ poisson_distribution<_IntType>::param_type::param_type(double __mean)
// According to the standard `inf` is a valid input, but it causes the
// distribution to hang, so we replace it with the maximum representable
// mean.
: __mean_(isinf(__mean) ? numeric_limits<double>::max() : __mean) {
: __mean_(__math::isinf(__mean) ? numeric_limits<double>::max() : __mean) {
if (__mean_ < 10) {
__s_ = 0;
__d_ = 0;
__l_ = std::exp(-__mean_);
__l_ = __math::exp(-__mean_);
__omega_ = 0;
__c3_ = 0;
__c2_ = 0;
__c1_ = 0;
__c0_ = 0;
__c_ = 0;
} else {
__s_ = std::sqrt(__mean_);
__s_ = __math::sqrt(__mean_);
__d_ = 6 * __mean_ * __mean_;
__l_ = std::trunc(__mean_ - 1.1484);
__l_ = __math::trunc(__mean_ - 1.1484);
__omega_ = .3989423 / __s_;
double __b1 = .4166667E-1 / __mean_;
double __b2 = .3 * __b1 * __b1;
Expand All @@ -148,7 +153,7 @@ _IntType poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_t
double __g = __pr.__mean_ + __pr.__s_ * normal_distribution<double>()(__urng);
double __u;
if (__g > 0) {
__tx = std::trunc(__g);
__tx = __math::trunc(__g);
if (__tx >= __pr.__l_)
return std::__clamp_to_integral<result_type>(__tx);
__difmuk = __pr.__mean_ - __tx;
Expand All @@ -167,7 +172,7 @@ _IntType poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_t
__u += __u - 1;
__t = 1.8 + (__u < 0 ? -__e : __e);
} while (__t <= -.6744);
__tx = std::trunc(__pr.__mean_ + __pr.__s_ * __t);
__tx = __math::trunc(__pr.__mean_ + __pr.__s_ * __t);
__difmuk = __pr.__mean_ - __tx;
__using_exp_dist = true;
}
Expand All @@ -176,13 +181,13 @@ _IntType poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_t
if (__tx < 10 && __tx >= 0) {
const double __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
__px = -__pr.__mean_;
__py = std::pow(__pr.__mean_, (double)__tx) / __fac[static_cast<int>(__tx)];
__py = __math::pow(__pr.__mean_, (double)__tx) / __fac[static_cast<int>(__tx)];
} else {
double __del = .8333333E-1 / __tx;
__del -= 4.8 * __del * __del * __del;
double __v = __difmuk / __tx;
if (std::abs(__v) > 0.25)
__px = __tx * std::log(1 + __v) - __difmuk - __del;
__px = __tx * __math::log(1 + __v) - __difmuk - __del;
else
__px = __tx * __v * __v *
(((((((.1250060 * __v + -.1384794) * __v + .1421878) * __v + -.1661269) * __v + .2000118) * __v +
Expand All @@ -192,17 +197,17 @@ _IntType poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_t
__v +
-.5) -
__del;
__py = .3989423 / std::sqrt(__tx);
__py = .3989423 / __math::sqrt(__tx);
}
double __r = (0.5 - __difmuk) / __pr.__s_;
double __r2 = __r * __r;
double __fx = -0.5 * __r2;
double __fy = __pr.__omega_ * (((__pr.__c3_ * __r2 + __pr.__c2_) * __r2 + __pr.__c1_) * __r2 + __pr.__c0_);
if (__using_exp_dist) {
if (__pr.__c_ * std::abs(__u) <= __py * std::exp(__px + __e) - __fy * std::exp(__fx + __e))
if (__pr.__c_ * std::abs(__u) <= __py * __math::exp(__px + __e) - __fy * __math::exp(__fx + __e))
break;
} else {
if (__fy - __u * __fy <= __py * std::exp(__px - __fx))
if (__fy - __u * __fy <= __py * __math::exp(__px - __fx))
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__random/student_t_distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#define _LIBCPP___RANDOM_STUDENT_T_DISTRIBUTION_H

#include <__config>
#include <__math/roots.h>
#include <__random/gamma_distribution.h>
#include <__random/is_valid.h>
#include <__random/normal_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>

Expand Down Expand Up @@ -96,7 +96,7 @@ template <class _URNG>
_RealType student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) {
static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
gamma_distribution<result_type> __gd(__p.n() * .5, 2);
return __nd_(__g) * std::sqrt(__p.n() / __gd(__g));
return __nd_(__g) * __math::sqrt(__p.n() / __gd(__g));
}

template <class _CharT, class _Traits, class _RT>
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__random/weibull_distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#define _LIBCPP___RANDOM_WEIBULL_DISTRIBUTION_H

#include <__config>
#include <__math/exponential_functions.h>
#include <__random/exponential_distribution.h>
#include <__random/is_valid.h>
#include <cmath>
#include <iosfwd>
#include <limits>

Expand Down Expand Up @@ -75,7 +75,7 @@ class _LIBCPP_TEMPLATE_VIS weibull_distribution {
}
template <class _URNG>
_LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p) {
return __p.b() * std::pow(exponential_distribution<result_type>()(__g), 1 / __p.a());
return __p.b() * __math::pow(exponential_distribution<result_type>()(__g), 1 / __p.a());
}

// property functions
Expand Down
Loading