diff --git a/sprout/complex.hpp b/sprout/complex.hpp index 7dbf25de..e8781b20 100644 --- a/sprout/complex.hpp +++ b/sprout/complex.hpp @@ -290,13 +290,11 @@ namespace sprout { } template SPROUT_CONSTEXPR T abs(sprout::complex const& x) { - using sprout::sqrt; - return sqrt(sprout::norm(x)); + return sprout::sqrt(sprout::norm(x)); } template SPROUT_CONSTEXPR T arg(sprout::complex const& x) { - using sprout::atan2; - return atan2(x.imag(), x.real()); + return sprout::atan2(x.imag(), x.real()); } template SPROUT_CONSTEXPR T norm(sprout::complex const& x) { @@ -324,9 +322,7 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex polar(T const& rho, T const& theta = 0) { - using sprout::cos; - using sprout::sin; - return sprout::complex(rho * cos(theta), rho * sin(theta)); + return sprout::complex(rho * sprout::cos(theta), rho * sprout::sin(theta)); } // 26.4.8, transcendentals: template @@ -397,11 +393,9 @@ namespace sprout { T const& den ) { - using sprout::atan2; - using sprout::log; return sprout::complex( - T(0.5) * atan2(T(2) * x.real(), z), - T(0.25) * log((r2 + num * num) / (r2 + den * den)) + T(0.5) * sprout::atan2(T(2) * x.real(), z), + T(0.25) * sprout::log((r2 + num * num) / (r2 + den * den)) ); } template @@ -449,11 +443,9 @@ namespace sprout { T const& den ) { - using sprout::atan2; - using sprout::log; return sprout::complex( - T(0.25) * (log(i2 + num * num) - log(i2 + den * den)), - T(0.5) * atan2(T(2) * x.imag(), z) + T(0.25) * (sprout::log(i2 + num * num) - sprout::log(i2 + den * den)), + T(0.5) * sprout::atan2(T(2) * x.imag(), z) ); } template @@ -477,30 +469,21 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex cos(sprout::complex const& x) { - using sprout::cos; - using sprout::sin; - using sprout::cosh; - using sprout::sinh; return sprout::complex( - cos(x.real()) * cosh(x.imag()), - -(sin(x.real()) * sinh(x.imag())) + sprout::cos(x.real()) * sprout::cosh(x.imag()), + -(sprout::sin(x.real()) * sprout::sinh(x.imag())) ); } template SPROUT_CONSTEXPR sprout::complex cosh(sprout::complex const& x) { - using sprout::cos; - using sprout::sin; - using sprout::cosh; - using sprout::sinh; return sprout::complex( - cosh(x.real()) * cos(x.imag()), - sinh(x.real()) * sin(x.imag()) + sprout::cosh(x.real()) * sprout::cos(x.imag()), + sprout::sinh(x.real()) * sprout::sin(x.imag()) ); } template SPROUT_CONSTEXPR sprout::complex exp(sprout::complex const& x) { - using sprout::exp; - return sprout::polar(exp(x.real()), x.imag()); + return sprout::polar(sprout::exp(x.real()), x.imag()); } template SPROUT_CONSTEXPR sprout::complex log(sprout::complex const& x) { @@ -508,21 +491,18 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex log10(sprout::complex const& x) { - using sprout::log; - return sprout::log(x) / log(T(10)); + return sprout::log(x) / sprout::log(T(10)); } namespace detail { template SPROUT_CONSTEXPR sprout::complex pow_impl(sprout::complex const& t, T const& y) { - using sprout::exp; - return sprout::polar(exp(y * t.real()), y * t.imag()); + return sprout::polar(sprout::exp(y * t.real()), y * t.imag()); } } // namespace detail template SPROUT_CONSTEXPR sprout::complex pow(sprout::complex const& x, T const& y) { - using sprout::pow; return x == T() ? T() - : x.imag() == T() && x.real() > T() ? pow(x.real(), y) + : x.imag() == T() && x.real() > T() ? sprout::pow(x.real(), y) : sprout::detail::pow_impl(sprout::log(x), y) ; } @@ -534,31 +514,22 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex pow(T const& x, sprout::complex const& y) { - using sprout::log; - return x > T() ? sprout::polar(sprout::pow(x, y.real()), y.imag() * log(x)) + return x > T() ? sprout::polar(sprout::pow(x, y.real()), y.imag() * sprout::log(x)) : sprout::pow(sprout::complex(x), y) ; } template SPROUT_CONSTEXPR sprout::complex sin(sprout::complex const& x) { - using sprout::cos; - using sprout::sin; - using sprout::cosh; - using sprout::sinh; return sprout::complex( - sin(x.real()) * cosh(x.imag()), - cos(x.real()) * sinh(x.imag()) + sprout::sin(x.real()) * sprout::cosh(x.imag()), + sprout::cos(x.real()) * sprout::sinh(x.imag()) ); } template SPROUT_CONSTEXPR sprout::complex sinh(sprout::complex const& x) { - using sprout::cos; - using sprout::sin; - using sprout::cosh; - using sprout::sinh; return sprout::complex( - sinh(x.real()) * cos(x.imag()), - cosh(x.real()) * sin(x.imag()) + sprout::sinh(x.real()) * sprout::cos(x.imag()), + sprout::cosh(x.real()) * sprout::sin(x.imag()) ); } namespace detail { @@ -568,9 +539,8 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex sqrt_impl_2_1(sprout::complex const& x, T const& t, T const& u) { - using sprout::abs; return x.real() > T() ? sprout::complex(u, x.imag() / t) - : sprout::complex(abs(x.imag()) / t, x.imag() < T() ? -u : u) + : sprout::complex(sprout::abs(x.imag()) / t, x.imag() < T() ? -u : u) ; } template @@ -580,10 +550,8 @@ namespace sprout { } // namespace detail template SPROUT_CONSTEXPR sprout::complex sqrt(sprout::complex const& x) { - using sprout::sqrt; - using sprout::abs; - return x.real() == T() ? sprout::detail::sqrt_impl_1(x, sqrt(abs(x.imag()) / 2)) - : sprout::detail::sqrt_impl_2(x, sqrt(2 * (sprout::abs(x) + abs(x.real())))) + return x.real() == T() ? sprout::detail::sqrt_impl_1(x, sprout::sqrt(abs(x.imag()) / 2)) + : sprout::detail::sqrt_impl_2(x, sprout::sqrt(2 * (sprout::abs(x) + sprout::abs(x.real())))) ; } template diff --git a/sprout/darkroom/cameras/simple_camera.hpp b/sprout/darkroom/cameras/simple_camera.hpp index 6d02512a..a556a1cf 100644 --- a/sprout/darkroom/cameras/simple_camera.hpp +++ b/sprout/darkroom/cameras/simple_camera.hpp @@ -51,14 +51,11 @@ namespace sprout { unit_type const& v ) const { - using sprout::sqrt; - using sprout::sin; - using sprout::cos; return transform_1( c, - u * cos(rotate_) - v * sin(rotate_), - u * sin(rotate_) + v * cos(rotate_), - sqrt( + u * sprout::cos(rotate_) - v * sprout::sin(rotate_), + u * sprout::sin(rotate_) + v * sprout::cos(rotate_), + sprout::sqrt( sprout::darkroom::coords::x(c) * sprout::darkroom::coords::x(c) + sprout::darkroom::coords::z(c) * sprout::darkroom::coords::z(c) ) diff --git a/sprout/darkroom/coords/vector.hpp b/sprout/darkroom/coords/vector.hpp index 54e7d6d8..c23a9741 100644 --- a/sprout/darkroom/coords/vector.hpp +++ b/sprout/darkroom/coords/vector.hpp @@ -63,8 +63,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::darkroom::access::unit::type length(Vector const& vec) { - using sprout::sqrt; - return sqrt(sprout::darkroom::coords::length_sq(vec)); + return sprout::sqrt(sprout::darkroom::coords::length_sq(vec)); } // // add diff --git a/sprout/darkroom/materials/texture_map.hpp b/sprout/darkroom/materials/texture_map.hpp index d756b4c7..b3770b6b 100644 --- a/sprout/darkroom/materials/texture_map.hpp +++ b/sprout/darkroom/materials/texture_map.hpp @@ -121,8 +121,10 @@ namespace sprout { } template SPROUT_CONSTEXPR result_type calc_bilinear(Unit const& x, Unit const& y) const { - using sprout::floor; - return calc_bilinear_1(x, floor(x - 0.5), floor(x + 0.5), y, floor(y - 0.5), floor(y + 0.5)); + return calc_bilinear_1( + x, sprout::floor(x - 0.5), sprout::floor(x + 0.5), + y, sprout::floor(y - 0.5), sprout::floor(y + 0.5) + ); } template SPROUT_CONSTEXPR result_type calc(Unit const& x, Unit const& y) const { diff --git a/sprout/darkroom/objects/sphere.hpp b/sprout/darkroom/objects/sphere.hpp index a38ab6c0..8f9d148c 100644 --- a/sprout/darkroom/objects/sphere.hpp +++ b/sprout/darkroom/objects/sphere.hpp @@ -143,8 +143,6 @@ namespace sprout { Vec const& normal ) const { - using sprout::atan2; - using sprout::sqrt; return typename intersection::type( sprout::tuples::get(zwo), sprout::tuples::get(zwo), @@ -152,15 +150,15 @@ namespace sprout { sprout::tuples::get(drei), sprout::darkroom::materials::calc_material( // ! Spherical mat_, - atan2( + sprout::atan2( sprout::darkroom::coords::z(normal), sprout::darkroom::coords::x(normal) ) / sprout::math::pi() , - atan2( + sprout::atan2( sprout::darkroom::coords::y(normal), - sqrt( + sprout::sqrt( sprout::darkroom::coords::x(normal) * sprout::darkroom::coords::x(normal) + sprout::darkroom::coords::z(normal) * sprout::darkroom::coords::z(normal) ) @@ -206,14 +204,13 @@ namespace sprout { unit_type const& det_sq ) const { - using sprout::sqrt; return intersect_4( ray, zweitens( ray, det_sq > 0, b, - sqrt(det_sq) + sprout::sqrt(det_sq) ) ); } diff --git a/sprout/detail/math/float.hpp b/sprout/detail/math/float.hpp index 0096f58e..8fcd9e3d 100644 --- a/sprout/detail/math/float.hpp +++ b/sprout/detail/math/float.hpp @@ -91,8 +91,7 @@ namespace sprout { template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR int float_digit_of_impl(FloatType val) { - using sprout::floor; - return static_cast((val - floor(val)) * 10); + return static_cast((val - sprout::floor(val)) * 10); } template inline SPROUT_CONSTEXPR int @@ -106,8 +105,7 @@ namespace sprout { template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR FloatType float_round_impl(FloatType val, FloatType p10) { - using sprout::round; - return round(val * p10) / p10; + return sprout::round(val * p10) / p10; } template inline SPROUT_CONSTEXPR FloatType diff --git a/sprout/math/ceil.hpp b/sprout/math/ceil.hpp index f2fe790c..d0468b7d 100644 --- a/sprout/math/ceil.hpp +++ b/sprout/math/ceil.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include namespace sprout { @@ -16,7 +17,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR FloatType ceil_impl(FloatType x, FloatType x0) { - return x - x0 < std::numeric_limits::epsilon() ? x0 + return sprout::math::equal_to(x, x0) ? x0 : x0 + 1 ; } diff --git a/sprout/math/compare.hpp b/sprout/math/compare.hpp new file mode 100644 index 00000000..18dc119e --- /dev/null +++ b/sprout/math/compare.hpp @@ -0,0 +1,38 @@ +#ifndef SPROUT_MATH_COMPARE_HPP +#define SPROUT_MATH_COMPARE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { + template + inline SPROUT_CONSTEXPR int + compare_impl(T x, T y) { + return sprout::math::equal_to(x, y) ? 0 + : x < y ? -1 + : 1 + ; + } + } // namespace detail + // + // compare + // + template< + typename T1, + typename T2, + typename sprout::enabler_if::value && std::is_arithmetic::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR int + compare(T1 x, T2 y) { + typedef typename sprout::math::float_promote::type promoted; + return sprout::math::detail::compare_impl(x, y); + } + } // namespace math +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_COMPARE_HPP diff --git a/sprout/math/comparison.hpp b/sprout/math/comparison.hpp new file mode 100644 index 00000000..d73a4c7e --- /dev/null +++ b/sprout/math/comparison.hpp @@ -0,0 +1,13 @@ +#ifndef SPROUT_MATH_COMPARISON_HPP +#define SPROUT_MATH_COMPARISON_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_MATH_COMPARISON_HPP diff --git a/sprout/math/equal_to.hpp b/sprout/math/equal_to.hpp new file mode 100644 index 00000000..86564ce4 --- /dev/null +++ b/sprout/math/equal_to.hpp @@ -0,0 +1,58 @@ +#ifndef SPROUT_MATH_EQUAL_TO_HPP +#define SPROUT_MATH_EQUAL_TO_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { + template + inline SPROUT_CONSTEXPR T + max3(T x, T y, T z) { + return sprout::max(sprout::max(x, y), z); + } + + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + equal_to(FloatType x, FloatType y) { + return x == y + || sprout::abs(x - y) + <= std::numeric_limits::epsilon() * sprout::math::detail::max3(std::abs(x), std::abs(y), FloatType(1.0)) + ; + } + + template< + typename IntType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + equal_to(IntType x, IntType y) { + return x == y; + } + } // namespace detail + // + // equal_to + // + template< + typename T1, + typename T2, + typename sprout::enabler_if::value && std::is_arithmetic::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + equal_to(T1 x, T2 y) { + typedef typename sprout::math::float_promote::type promoted; + return sprout::math::detail::equal_to(x, y); + } + } // namespace math +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_EQUAL_TO_HPP diff --git a/sprout/math/floor.hpp b/sprout/math/floor.hpp index 6f8e24e1..3d298fa6 100644 --- a/sprout/math/floor.hpp +++ b/sprout/math/floor.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include namespace sprout { @@ -16,7 +17,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR FloatType floor_impl(FloatType x, FloatType x0) { - return x0 - x < std::numeric_limits::epsilon() ? x0 + return sprout::math::equal_to(x, x0) ? x0 : x0 - 1 ; } diff --git a/sprout/math/functions.hpp b/sprout/math/functions.hpp index 37ab90d0..6d1cb184 100644 --- a/sprout/math/functions.hpp +++ b/sprout/math/functions.hpp @@ -12,5 +12,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_MATH_FUNCTIONS_HPP diff --git a/sprout/math/greater.hpp b/sprout/math/greater.hpp new file mode 100644 index 00000000..a49774c2 --- /dev/null +++ b/sprout/math/greater.hpp @@ -0,0 +1,47 @@ +#ifndef SPROUT_MATH_GREATER_HPP +#define SPROUT_MATH_GREATER_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + greater(FloatType x, FloatType y) { + return sprout::math::not_equal_to(x, y) && x > y; + } + + template< + typename IntType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + greater(IntType x, IntType y) { + return x > y; + } + } // namespace detail + // + // greater + // + template< + typename T1, + typename T2, + typename sprout::enabler_if::value && std::is_arithmetic::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + greater(T1 x, T2 y) { + typedef typename sprout::math::float_promote::type promoted; + return sprout::math::detail::greater(x, y); + } + } // namespace math +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_GREATER_HPP diff --git a/sprout/math/greater_equal.hpp b/sprout/math/greater_equal.hpp new file mode 100644 index 00000000..8c83996f --- /dev/null +++ b/sprout/math/greater_equal.hpp @@ -0,0 +1,47 @@ +#ifndef SPROUT_MATH_GREATER_EQUAL_HPP +#define SPROUT_MATH_GREATER_EQUAL_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + greater_equal(FloatType x, FloatType y) { + return sprout::math::equal_to(x, y) || x > y; + } + + template< + typename IntType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + greater_equal(IntType x, IntType y) { + return x >= y; + } + } // namespace detail + // + // greater_equal + // + template< + typename T1, + typename T2, + typename sprout::enabler_if::value && std::is_arithmetic::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + greater_equal(T1 x, T2 y) { + typedef typename sprout::math::float_promote::type promoted; + return sprout::math::detail::greater_equal(x, y); + } + } // namespace math +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_GREATER_EQUAL_HPP diff --git a/sprout/math/less.hpp b/sprout/math/less.hpp new file mode 100644 index 00000000..f4108331 --- /dev/null +++ b/sprout/math/less.hpp @@ -0,0 +1,47 @@ +#ifndef SPROUT_MATH_LESS_HPP +#define SPROUT_MATH_LESS_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + less(FloatType x, FloatType y) { + return sprout::math::not_equal_to(x, y) && x < y; + } + + template< + typename IntType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + less(IntType x, IntType y) { + return x < y; + } + } // namespace detail + // + // less + // + template< + typename T1, + typename T2, + typename sprout::enabler_if::value && std::is_arithmetic::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + less(T1 x, T2 y) { + typedef typename sprout::math::float_promote::type promoted; + return sprout::math::detail::less(x, y); + } + } // namespace math +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_LESS_HPP diff --git a/sprout/math/less_equal.hpp b/sprout/math/less_equal.hpp new file mode 100644 index 00000000..e7418fd9 --- /dev/null +++ b/sprout/math/less_equal.hpp @@ -0,0 +1,47 @@ +#ifndef SPROUT_MATH_LESS_EQUAL_HPP +#define SPROUT_MATH_LESS_EQUAL_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + less_equal(FloatType x, FloatType y) { + return sprout::math::equal_to(x, y) || x < y; + } + + template< + typename IntType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + less_equal(IntType x, IntType y) { + return x <= y; + } + } // namespace detail + // + // less_equal + // + template< + typename T1, + typename T2, + typename sprout::enabler_if::value && std::is_arithmetic::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + less_equal(T1 x, T2 y) { + typedef typename sprout::math::float_promote::type promoted; + return sprout::math::detail::less_equal(x, y); + } + } // namespace math +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_LESS_EQUAL_HPP diff --git a/sprout/math/not_equal_to.hpp b/sprout/math/not_equal_to.hpp new file mode 100644 index 00000000..60037abb --- /dev/null +++ b/sprout/math/not_equal_to.hpp @@ -0,0 +1,26 @@ +#ifndef SPROUT_MATH_NOT_EQUAL_TO_HPP +#define SPROUT_MATH_NOT_EQUAL_TO_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace math { + // + // not_equal_to + // + template< + typename T1, + typename T2, + typename sprout::enabler_if::value && std::is_arithmetic::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR bool + not_equal_to(T1 x, T2 y) { + return !sprout::math::equal_to(x, y); + } + } // namespace math +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_NOT_EQUAL_TO_HPP diff --git a/sprout/random/binomial_distribution.hpp b/sprout/random/binomial_distribution.hpp index 6c7a2ae6..20de76d7 100644 --- a/sprout/random/binomial_distribution.hpp +++ b/sprout/random/binomial_distribution.hpp @@ -168,8 +168,7 @@ namespace sprout { return init_btrd_5(t, p, r, nr, npq, sqrt_npq, RealType(1.15) + RealType(2.53) * sqrt_npq); } static SPROUT_CONSTEXPR btrd_type init_btrd_3(IntType t, RealType p, RealType r, RealType nr, RealType npq) { - using sprout::sqrt; - return init_btrd_4(t, p, r, nr, npq, sqrt(npq)); + return init_btrd_4(t, p, r, nr, npq, sprout::sqrt(npq)); } static SPROUT_CONSTEXPR btrd_type init_btrd_2(IntType t, RealType p, RealType r) { return init_btrd_3(t, p, r, (t + 1) * r, t * p * (1 - p)); @@ -181,8 +180,7 @@ namespace sprout { return init_btrd_1(init_t(t), init_p(p)); } static SPROUT_CONSTEXPR RealType init_q_n(IntType t, RealType p) { - using sprout::pow; - return pow(1 - init_p(p), static_cast(init_t(t))); + return sprout::pow(1 - init_p(p), static_cast(init_t(t))); } static SPROUT_CONSTEXPR bool init_use_inversion(IntType t, RealType p) { return init_m(t, p) < 11; @@ -243,16 +241,14 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::random::random_result generate_10(Engine const& eng, RealType v, IntType k, IntType nm, RealType h, IntType nk) const { - using sprout::log; - return v <= h + (t_ + 1) * log(static_cast(nm) / nk) + (k + RealType(0.5)) * log(nk * btrd_.r / (k + 1))- fc(k)- fc(t_ - k) + return v <= h + (t_ + 1) * sprout::log(static_cast(nm) / nk) + (k + RealType(0.5)) * sprout::log(nk * btrd_.r / (k + 1)) - fc(k) - fc(t_ - k) ? sprout::random::random_result(k, eng, *this) : generate(eng) ; } template SPROUT_CONSTEXPR sprout::random::random_result generate_9(Engine const& eng, RealType v, IntType k, IntType nm) const { - using sprout::log; - return generate_10(eng, v, k, nm, (m_ + RealType(0.5)) * log((m_ + 1) / (btrd_.r * nm)) + fc(m_) + fc(t_ - m_), t_ - k + 1); + return generate_10(eng, v, k, nm, (m_ + RealType(0.5)) * sprout::log((m_ + 1) / (btrd_.r * nm)) + fc(m_) + fc(t_ - m_), t_ - k + 1); } template SPROUT_CONSTEXPR sprout::random::random_result generate_8(Engine const& eng, RealType v, IntType k, RealType rho, RealType t) const { @@ -291,29 +287,25 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::random::random_result generate_6(Engine const& eng, RealType v, IntType k, RealType km) const { - using sprout::log; return km <= 15 ? generate_7(eng, v, k) - : generate_8(eng, log(v), k, (km / btrd_.npq) * (((km / RealType(3.0) + RealType(0.625)) * km + RealType(1.0) / 6) / btrd_.npq + RealType(0.5)), -km * km / (2 * btrd_.npq)) + : generate_8(eng, sprout::log(v), k, (km / btrd_.npq) * (((km / RealType(3.0) + RealType(0.625)) * km + RealType(1.0) / 6) / btrd_.npq + RealType(0.5)), -km * km / (2 * btrd_.npq)) ; } template SPROUT_CONSTEXPR sprout::random::random_result generate_5(Engine const& eng, RealType v, RealType u, RealType us, IntType k) const { - using sprout::abs; return k < 0 || k > t_ ? generate(eng) - : generate_6(eng, v * btrd_.alpha / (btrd_.a / (us * us) + btrd_.b), k, abs(k - m_)) + : generate_6(eng, v * btrd_.alpha / (btrd_.a / (us * us) + btrd_.b), k, sprout::abs(k - m_)) ; } template SPROUT_CONSTEXPR sprout::random::random_result generate_4(Engine const& eng, RealType v, RealType u, RealType us) const { - using sprout::floor; - return generate_5(eng, v, u, us, static_cast(floor((2 * btrd_.a / us + btrd_.b) * u + btrd_.c))); + return generate_5(eng, v, u, us, static_cast(sprout::floor((2 * btrd_.a / us + btrd_.b) * u + btrd_.c))); } template SPROUT_CONSTEXPR sprout::random::random_result generate_3(Engine const& eng, RealType v, RealType u) const { - using sprout::abs; - return generate_4(eng, v, u, 0.5 - abs(u)); + return generate_4(eng, v, u, 0.5 - sprout::abs(u)); } template SPROUT_CONSTEXPR sprout::random::random_result generate_2(Random const& rnd, RealType v) const { @@ -332,10 +324,8 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::random::random_result generate_1_1(Engine const& eng, RealType u) const { - using sprout::floor; - using sprout::abs; return sprout::random::random_result( - static_cast(floor((2 * btrd_.a / (RealType(0.5) - abs(u)) + btrd_.b) * u + btrd_.c)), + static_cast(sprout::floor((2 * btrd_.a / (RealType(0.5) - sprout::abs(u)) + btrd_.b) * u + btrd_.c)), eng, *this ); diff --git a/sprout/random/geometric_distribution.hpp b/sprout/random/geometric_distribution.hpp index abcfd189..bfc235ea 100644 --- a/sprout/random/geometric_distribution.hpp +++ b/sprout/random/geometric_distribution.hpp @@ -87,8 +87,7 @@ namespace sprout { private: public: static SPROUT_CONSTEXPR RealType init_log_1mp(RealType p) { - using sprout::log; - return log(1 - p); + return sprout::log(1 - p); } private: public: @@ -97,10 +96,8 @@ namespace sprout { private: template SPROUT_CONSTEXPR sprout::random::random_result generate_1(Random const& rnd) const { - using sprout::log; - using sprout::floor; return sprout::random::random_result( - static_cast(floor(log(RealType(1) - rnd.result()) / log_1mp_)), + static_cast(sprout::floor(sprout::log(RealType(1) - rnd.result()) / log_1mp_)), rnd.engine(), *this ); diff --git a/sprout/random/normal_distribution.hpp b/sprout/random/normal_distribution.hpp index 7f3ac36e..84fd1dd5 100644 --- a/sprout/random/normal_distribution.hpp +++ b/sprout/random/normal_distribution.hpp @@ -124,13 +124,11 @@ namespace sprout { {} template SPROUT_CONSTEXPR sprout::random::random_result generate_2(Engine const& eng, RealType r1, RealType r2, RealType cached_rho, bool valid) const { - using sprout::sin; - using sprout::cos; return sprout::random::random_result( cached_rho * (valid - ? cos(result_type(2) * sprout::math::pi() * r1) - : sin(result_type(2) * sprout::math::pi() * r1) + ? sprout::cos(result_type(2) * sprout::math::pi() * r1) + : sprout::sin(result_type(2) * sprout::math::pi() * r1) ) * sigma_ + mean_, eng, @@ -147,9 +145,7 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::random::random_result generate_1_1(RealType r1, Random const& rnd) const { - using sprout::sqrt; - using sprout::log; - return generate_2(rnd.engine(), r1, rnd.result(), sqrt(-result_type(2) * log(result_type(1) - rnd.result())), true); + return generate_2(rnd.engine(), r1, rnd.result(), sprout::sqrt(-result_type(2) * sprout::log(result_type(1) - rnd.result())), true); } template SPROUT_CONSTEXPR sprout::random::random_result generate_1(Random const& rnd) const {