From 6bb2d0fb87030d45f47b9eac0fc485231ca2edae Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Wed, 9 May 2012 10:15:19 +0900 Subject: [PATCH] replace implementation functions to Sprout.Math.Functions --- sprout/complex.hpp | 75 +++++++++++-------- sprout/cstdlib/str_to_float.hpp | 1 - sprout/cstdlib/str_to_int.hpp | 7 +- sprout/darkroom/cameras/simple_camera.hpp | 10 ++- sprout/darkroom/coords/vector.hpp | 4 +- sprout/darkroom/objects/sphere.hpp | 9 ++- sprout/iterator/sinusoid_iterator.hpp | 6 +- sprout/math/abs.hpp | 42 +++++++++++ sprout/math/acosh.hpp | 1 + sprout/math/asinh.hpp | 5 +- sprout/math/cos.hpp | 17 +++-- sprout/math/fabs.hpp | 24 ------ sprout/math/fma.hpp | 55 ++++++++++++++ sprout/math/operations.hpp | 2 + sprout/numeric/dft/detail/dft_element_gen.hpp | 7 +- sprout/numeric/dft/fixed/sinusoid.hpp | 4 +- sprout/numeric/dft/fixed/spectrum.hpp | 10 +-- sprout/random/binomial_distribution.hpp | 20 +++-- sprout/random/geometric_distribution.hpp | 5 +- sprout/random/normal_distribution.hpp | 13 ++-- sprout/string/float_to_string.hpp | 1 - 21 files changed, 212 insertions(+), 106 deletions(-) create mode 100644 sprout/math/abs.hpp create mode 100644 sprout/math/fma.hpp diff --git a/sprout/complex.hpp b/sprout/complex.hpp index 41a92e40..7dbf25de 100644 --- a/sprout/complex.hpp +++ b/sprout/complex.hpp @@ -1,11 +1,20 @@ #ifndef SPROUT_COMPLEX_HPP #define SPROUT_COMPLEX_HPP -#include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace sprout { template @@ -281,12 +290,12 @@ namespace sprout { } template SPROUT_CONSTEXPR T abs(sprout::complex const& x) { - using std::sqrt; + using sprout::sqrt; return sqrt(sprout::norm(x)); } template SPROUT_CONSTEXPR T arg(sprout::complex const& x) { - using std::atan2; + using sprout::atan2; return atan2(x.imag(), x.real()); } template @@ -315,8 +324,8 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex polar(T const& rho, T const& theta = 0) { - using std::cos; - using std::sin; + using sprout::cos; + using sprout::sin; return sprout::complex(rho * cos(theta), rho * sin(theta)); } // 26.4.8, transcendentals: @@ -388,8 +397,8 @@ namespace sprout { T const& den ) { - using std::atan2; - using std::log; + 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)) @@ -440,8 +449,8 @@ namespace sprout { T const& den ) { - using std::atan2; - using std::log; + 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) @@ -468,10 +477,10 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex cos(sprout::complex const& x) { - using std::cos; - using std::sin; - using std::cosh; - using std::sinh; + 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())) @@ -479,10 +488,10 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex cosh(sprout::complex const& x) { - using std::cos; - using std::sin; - using std::cosh; - using std::sinh; + 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()) @@ -490,7 +499,7 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex exp(sprout::complex const& x) { - using std::exp; + using sprout::exp; return sprout::polar(exp(x.real()), x.imag()); } template @@ -499,19 +508,19 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex log10(sprout::complex const& x) { - using std::log; + using sprout::log; return sprout::log(x) / log(T(10)); } namespace detail { template SPROUT_CONSTEXPR sprout::complex pow_impl(sprout::complex const& t, T const& y) { - using std::exp; + using sprout::exp; return sprout::polar(exp(y * t.real()), y * t.imag()); } } // namespace detail template SPROUT_CONSTEXPR sprout::complex pow(sprout::complex const& x, T const& y) { - using std::pow; + using sprout::pow; return x == T() ? T() : x.imag() == T() && x.real() > T() ? pow(x.real(), y) : sprout::detail::pow_impl(sprout::log(x), y) @@ -525,17 +534,17 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex pow(T const& x, sprout::complex const& y) { - using std::log; + using sprout::log; return x > T() ? sprout::polar(sprout::pow(x, y.real()), y.imag() * log(x)) : sprout::pow(sprout::complex(x), y) ; } template SPROUT_CONSTEXPR sprout::complex sin(sprout::complex const& x) { - using std::cos; - using std::sin; - using std::cosh; - using std::sinh; + 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()) @@ -543,10 +552,10 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex sinh(sprout::complex const& x) { - using std::cos; - using std::sin; - using std::cosh; - using std::sinh; + 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()) @@ -559,7 +568,7 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::complex sqrt_impl_2_1(sprout::complex const& x, T const& t, T const& u) { - using std::abs; + using sprout::abs; return x.real() > T() ? sprout::complex(u, x.imag() / t) : sprout::complex(abs(x.imag()) / t, x.imag() < T() ? -u : u) ; @@ -571,8 +580,8 @@ namespace sprout { } // namespace detail template SPROUT_CONSTEXPR sprout::complex sqrt(sprout::complex const& x) { - using std::sqrt; - using std::abs; + 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())))) ; diff --git a/sprout/cstdlib/str_to_float.hpp b/sprout/cstdlib/str_to_float.hpp index 082f773b..31ae9880 100644 --- a/sprout/cstdlib/str_to_float.hpp +++ b/sprout/cstdlib/str_to_float.hpp @@ -3,7 +3,6 @@ #include #include -#include #include #include #include diff --git a/sprout/cstdlib/str_to_int.hpp b/sprout/cstdlib/str_to_int.hpp index e057f2e5..a352c03b 100644 --- a/sprout/cstdlib/str_to_int.hpp +++ b/sprout/cstdlib/str_to_int.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -83,9 +84,11 @@ namespace sprout { return !endptr ? sprout::detail::str_to_int(str, base) : std::is_signed::value ? sizeof(IntType) <= sizeof(long) ? static_cast(std::strtol(&*str, endptr, base)) - : static_cast(std::strtoll(&*str, endptr, base)) + : sizeof(IntType) <= sizeof(long long) ? static_cast(std::strtoll(&*str, endptr, base)) + : static_cast(std::strtoimax(&*str, endptr, base)) : sizeof(IntType) <= sizeof(unsigned long) ? static_cast(std::strtoul(&*str, endptr, base)) - : static_cast(std::strtoull(&*str, endptr, base)) + : sizeof(IntType) <= sizeof(unsigned long long) ? static_cast(std::strtoull(&*str, endptr, base)) + : static_cast(std::strtoumax(&*str, endptr, base)) ; } } // namespace detail diff --git a/sprout/darkroom/cameras/simple_camera.hpp b/sprout/darkroom/cameras/simple_camera.hpp index b9809720..6d02512a 100644 --- a/sprout/darkroom/cameras/simple_camera.hpp +++ b/sprout/darkroom/cameras/simple_camera.hpp @@ -1,9 +1,11 @@ #ifndef SPROUT_DARKROOM_CAMERAS_SIMPLE_CAMERA_HPP #define SPROUT_DARKROOM_CAMERAS_SIMPLE_CAMERA_HPP -#include #include #include +#include +#include +#include #include #include @@ -49,9 +51,9 @@ namespace sprout { unit_type const& v ) const { - using std::sqrt; - using std::sin; - using std::cos; + using sprout::sqrt; + using sprout::sin; + using sprout::cos; return transform_1( c, u * cos(rotate_) - v * sin(rotate_), diff --git a/sprout/darkroom/coords/vector.hpp b/sprout/darkroom/coords/vector.hpp index 218e03e7..54e7d6d8 100644 --- a/sprout/darkroom/coords/vector.hpp +++ b/sprout/darkroom/coords/vector.hpp @@ -1,11 +1,11 @@ #ifndef SPROUT_DARKROOM_COORDS_VECTOR_HPP #define SPROUT_DARKROOM_COORDS_VECTOR_HPP -#include #include #include #include #include +#include #include namespace sprout { @@ -63,7 +63,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::darkroom::access::unit::type length(Vector const& vec) { - using std::sqrt; + using sprout::sqrt; return sqrt(sprout::darkroom::coords::length_sq(vec)); } // diff --git a/sprout/darkroom/objects/sphere.hpp b/sprout/darkroom/objects/sphere.hpp index 6d9cc512..bfeec47a 100644 --- a/sprout/darkroom/objects/sphere.hpp +++ b/sprout/darkroom/objects/sphere.hpp @@ -2,12 +2,13 @@ #define SPROUT_DARKROOM_OBJECTS_SPHERE_HPP #include -#include #include #include #include #include #include +#include +#include #include #include #include @@ -142,8 +143,8 @@ namespace sprout { Vec const& normal ) const { - using std::atan2; - using std::sqrt; + using sprout::atan2; + using sprout::sqrt; return typename intersection::type( sprout::tuples::get(zwo), sprout::tuples::get(zwo), @@ -205,7 +206,7 @@ namespace sprout { unit_type const& det_sq ) const { - using std::sqrt; + using sprout::sqrt; return intersect_4( ray, zweitens( diff --git a/sprout/iterator/sinusoid_iterator.hpp b/sprout/iterator/sinusoid_iterator.hpp index e73a3bb7..ba8066ac 100644 --- a/sprout/iterator/sinusoid_iterator.hpp +++ b/sprout/iterator/sinusoid_iterator.hpp @@ -2,7 +2,6 @@ #define SPROUT_ITERATOR_SINUSOID_ITERATOR_HPP #include -#include #include #include #include @@ -11,6 +10,7 @@ #include #include #include +#include namespace sprout { // @@ -94,7 +94,7 @@ namespace sprout { return phase_; } SPROUT_CONSTEXPR reference operator*() const { - using std::sin; + using sprout::sin; return amplitude_ * sin(d_ * value_type(index_) + phase_); } SPROUT_CONSTEXPR pointer operator->() const { @@ -135,7 +135,7 @@ namespace sprout { return *this; } SPROUT_CONSTEXPR reference operator[](difference_type n) const { - using std::sin; + using sprout::sin; return amplitude_ * sin(d_ * value_type(index_ + n) + phase_); } SPROUT_CONSTEXPR sinusoid_iterator next() const { diff --git a/sprout/math/abs.hpp b/sprout/math/abs.hpp new file mode 100644 index 00000000..8bdc5c4f --- /dev/null +++ b/sprout/math/abs.hpp @@ -0,0 +1,42 @@ +#ifndef SPROUT_MATH_ABS_HPP +#define SPROUT_MATH_ABS_HPP + +#include +#include +#include +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION +# include +#endif + +namespace sprout { + namespace math { + namespace detail { + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR FloatType + abs(FloatType x) { + return x < 0 ? -x : x; + } + } // namespace detail + + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR FloatType + abs(FloatType x) { +# if SPROUT_USE_BUILTIN_CMATH_FUNCTION + using std::abs; +# else + using sprout::math::detail::abs; +# endif + return abs(x); + } + } // namespace math + + using sprout::math::abs; +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_ABS_HPP diff --git a/sprout/math/acosh.hpp b/sprout/math/acosh.hpp index d8a750a9..933ba193 100644 --- a/sprout/math/acosh.hpp +++ b/sprout/math/acosh.hpp @@ -21,6 +21,7 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType acosh(FloatType x) { return x < 1 ? std::numeric_limits::quiet_NaN() + : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() : sprout::math::detail::log(x + sprout::math::detail::sqrt(x * x - 1)) ; } diff --git a/sprout/math/asinh.hpp b/sprout/math/asinh.hpp index ef0fc6bd..228e7823 100644 --- a/sprout/math/asinh.hpp +++ b/sprout/math/asinh.hpp @@ -1,6 +1,7 @@ #ifndef SPROUT_MATH_ASINH_HPP #define SPROUT_MATH_ASINH_HPP +#include #include #include #include @@ -19,7 +20,9 @@ namespace sprout { > inline SPROUT_CONSTEXPR FloatType asinh(FloatType x) { - return sprout::math::detail::log(x + sprout::math::detail::sqrt(x * x + 1)) + return x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() + : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() + : sprout::math::detail::log(x + sprout::math::detail::sqrt(x * x + 1)) ; } diff --git a/sprout/math/cos.hpp b/sprout/math/cos.hpp index aaace216..32c0f7f0 100644 --- a/sprout/math/cos.hpp +++ b/sprout/math/cos.hpp @@ -2,6 +2,7 @@ #define SPROUT_MATH_COS_HPP #include +#include #include #include #include @@ -33,12 +34,16 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType cos(FloatType x) { typedef double type; - return static_cast(sprout::math::detail::cos_impl( - static_cast(x), - type(1), - 1, - static_cast(x) * static_cast(x) - )); + return x == std::numeric_limits::infinity() + || x == -std::numeric_limits::infinity() + ? std::numeric_limits::quiet_NaN() + : static_cast(sprout::math::detail::cos_impl( + static_cast(x), + type(1), + 1, + static_cast(x) * static_cast(x) + )) + ; } template< diff --git a/sprout/math/fabs.hpp b/sprout/math/fabs.hpp index 606ed855..068f5c12 100644 --- a/sprout/math/fabs.hpp +++ b/sprout/math/fabs.hpp @@ -11,15 +11,6 @@ namespace sprout { namespace math { namespace detail { - template< - typename FloatType, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR FloatType - abs(FloatType x) { - return x < 0 ? -x : x; - } - template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -39,20 +30,6 @@ namespace sprout { } } // namespace detail - template< - typename FloatType, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR FloatType - abs(FloatType x) { -# if SPROUT_USE_BUILTIN_CMATH_FUNCTION - using std::abs; -# else - using sprout::math::detail::abs; -# endif - return abs(x); - } - # if SPROUT_USE_BUILTIN_CMATH_FUNCTION using std::fabs; # else @@ -60,7 +37,6 @@ namespace sprout { # endif } // namespace math - using sprout::math::abs; using sprout::math::fabs; } // namespace sprout diff --git a/sprout/math/fma.hpp b/sprout/math/fma.hpp new file mode 100644 index 00000000..69af1946 --- /dev/null +++ b/sprout/math/fma.hpp @@ -0,0 +1,55 @@ +#ifndef SPROUT_MATH_FMA_HPP +#define SPROUT_MATH_FMA_HPP + +#include +#include +#include +#include +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION +# include +#endif + +namespace sprout { + namespace math { + namespace detail { + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR FloatType + fma(FloatType x, FloatType y, FloatType z) { + return x * y + z; + } + + template< + typename ArithmeticType1, + typename ArithmeticType2, + typename ArithmeticType3, + typename sprout::enabler_if< + std::is_arithmetic::value + && std::is_arithmetic::value + && std::is_arithmetic::value + >::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::math::float_promote< + ArithmeticType1, ArithmeticType2, ArithmeticType3 + >::type + fma(ArithmeticType1 x, ArithmeticType2 y, ArithmeticType3 z) { + typedef typename sprout::math::float_promote< + ArithmeticType1, ArithmeticType2, ArithmeticType3 + >::type type; + return sprout::math::detail::fma(static_cast(x), static_cast(y), static_cast(z)); + } + } // namespace detail + +# if SPROUT_USE_BUILTIN_CMATH_FUNCTION + using std::fma; +# else + using sprout::math::detail::fma; +# endif + } // namespace math + + using sprout::math::fma; +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_FMA_HPP diff --git a/sprout/math/operations.hpp b/sprout/math/operations.hpp index df845bd9..209eb73b 100644 --- a/sprout/math/operations.hpp +++ b/sprout/math/operations.hpp @@ -1,7 +1,9 @@ #ifndef SPROUT_MATH_OPERATIONS_HPP #define SPROUT_MATH_OPERATIONS_HPP +#include #include +#include #include #include #include diff --git a/sprout/numeric/dft/detail/dft_element_gen.hpp b/sprout/numeric/dft/detail/dft_element_gen.hpp index 193046e1..7957f3f6 100644 --- a/sprout/numeric/dft/detail/dft_element_gen.hpp +++ b/sprout/numeric/dft/detail/dft_element_gen.hpp @@ -1,11 +1,12 @@ #ifndef SPROUT_NUMERIC_DFT_DETAIL_DFT_ELEMENT_GEN_HPP #define SPROUT_NUMERIC_DFT_DETAIL_DFT_ELEMENT_GEN_HPP -#include #include #include #include #include +#include +#include namespace sprout { namespace detail { @@ -20,8 +21,8 @@ namespace sprout { ) { typedef typename std::iterator_traits::value_type value_type; - using std::cos; - using std::sin; + using sprout::cos; + using sprout::sin; return first != last ? value + sprout::detail::dft_element_gen( sprout::next(first), diff --git a/sprout/numeric/dft/fixed/sinusoid.hpp b/sprout/numeric/dft/fixed/sinusoid.hpp index 0339ef6d..a5585a82 100644 --- a/sprout/numeric/dft/fixed/sinusoid.hpp +++ b/sprout/numeric/dft/fixed/sinusoid.hpp @@ -1,7 +1,6 @@ #ifndef SPROUT_NUMERIC_DFT_FIXED_SINUSOID_HPP #define SPROUT_NUMERIC_DFT_FIXED_SINUSOID_HPP -#include #include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include namespace sprout { namespace fixed { @@ -26,7 +26,7 @@ namespace sprout { ) { typedef typename sprout::container_traits::value_type value_type; - using std::sin; + using sprout::sin; return sprout::remake( cont, size, diff --git a/sprout/numeric/dft/fixed/spectrum.hpp b/sprout/numeric/dft/fixed/spectrum.hpp index 89c8c798..7a2324f9 100644 --- a/sprout/numeric/dft/fixed/spectrum.hpp +++ b/sprout/numeric/dft/fixed/spectrum.hpp @@ -1,14 +1,14 @@ #ifndef SPROUT_NUMERIC_DFT_FIXED_SPECTRUM_HPP #define SPROUT_NUMERIC_DFT_FIXED_SPECTRUM_HPP -#include -#include #include #include #include #include #include #include +#include +#include #include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT namespace sprout { @@ -26,9 +26,9 @@ namespace sprout { typename sprout::container_traits::size_type input_size ) { - using std::sqrt; - using std::real; - using std::imag; + using sprout::sqrt; + using sprout::real; + using sprout::imag; return sprout::remake( result, size, diff --git a/sprout/random/binomial_distribution.hpp b/sprout/random/binomial_distribution.hpp index f4108447..1f5b81ad 100644 --- a/sprout/random/binomial_distribution.hpp +++ b/sprout/random/binomial_distribution.hpp @@ -7,6 +7,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -155,7 +159,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 std::sqrt; + using sprout::sqrt; return init_btrd_4(t, p, r, nr, npq, sqrt(npq)); } static SPROUT_CONSTEXPR btrd_type init_btrd_2(IntType t, RealType p, RealType r) { @@ -168,7 +172,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 std::pow; + using sprout::pow; return pow(1 - init_p(p), static_cast(init_t(t))); } static SPROUT_CONSTEXPR bool init_use_inversion(IntType t, RealType p) { @@ -230,7 +234,7 @@ 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 std::log; + 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) ? sprout::random::random_result(k, eng, *this) : generate(eng) @@ -238,7 +242,7 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::random::random_result generate_9(Engine const& eng, RealType v, IntType k, IntType nm) const { - using std::log; + 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); } template @@ -278,7 +282,7 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::random::random_result generate_6(Engine const& eng, RealType v, IntType k, RealType km) const { - using std::log; + 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)) @@ -286,7 +290,7 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::random::random_result generate_5(Engine const& eng, RealType v, RealType u, RealType us, IntType k) const { - using std::abs; + 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_)) @@ -299,7 +303,7 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::random::random_result generate_3(Engine const& eng, RealType v, RealType u) const { - using std::abs; + using sprout::abs; return generate_4(eng, v, u, 0.5 - abs(u)); } template @@ -320,7 +324,7 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::random_result generate_1_1(Engine const& eng, RealType u) const { using std::floor; - using std::abs; + using sprout::abs; return sprout::random::random_result( static_cast(floor((2 * btrd_.a / (RealType(0.5) - abs(u)) + btrd_.b) * u + btrd_.c)), eng, diff --git a/sprout/random/geometric_distribution.hpp b/sprout/random/geometric_distribution.hpp index 1a8d9c05..6efef849 100644 --- a/sprout/random/geometric_distribution.hpp +++ b/sprout/random/geometric_distribution.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -96,7 +97,7 @@ namespace sprout { private: public: static SPROUT_CONSTEXPR RealType init_log_1mp(RealType p) { - using std::log; + using sprout::log; return log(1 - p); } private: @@ -106,7 +107,7 @@ namespace sprout { private: template SPROUT_CONSTEXPR sprout::random::random_result generate_1(Random const& rnd) const { - using std::log; + using sprout::log; using std::floor; return sprout::random::random_result( static_cast(floor(log(RealType(1) - rnd.result()) / log_1mp_)), diff --git a/sprout/random/normal_distribution.hpp b/sprout/random/normal_distribution.hpp index 0b6bb94c..3e403d31 100644 --- a/sprout/random/normal_distribution.hpp +++ b/sprout/random/normal_distribution.hpp @@ -1,13 +1,16 @@ #ifndef SPROUT_RANDOM_NORMAL_DISTRIBUTION_HPP #define SPROUT_RANDOM_NORMAL_DISTRIBUTION_HPP -#include #include #include #include #include #include #include +#include +#include +#include +#include #include #include @@ -121,8 +124,8 @@ 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 std::sin; - using std::cos; + using sprout::sin; + using sprout::cos; return sprout::random::random_result( cached_rho * (valid @@ -144,8 +147,8 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::random::random_result generate_1_1(RealType r1, Random const& rnd) const { - using std::sqrt; - using std::log; + 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); } template diff --git a/sprout/string/float_to_string.hpp b/sprout/string/float_to_string.hpp index 9e7c33ad..8a1f9a6a 100644 --- a/sprout/string/float_to_string.hpp +++ b/sprout/string/float_to_string.hpp @@ -2,7 +2,6 @@ #define SPROUT_STRING_FLOAT_TO_STRING_HPP #include -#include #include #include #include