/*============================================================================= Copyright (c) 2011-2016 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_VALARRAY_EXPONENTIAL_HPP #define SPROUT_VALARRAY_EXPONENTIAL_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace sprout_math_detail { using sprout::math::exp; using sprout::math::exp10; using sprout::math::exp2; using sprout::math::expm1; using sprout::math::log; using sprout::math::log10; using sprout::math::log1p; using sprout::math::log2; template inline SPROUT_CONSTEXPR decltype(exp(std::declval())) call_exp(T&& x) SPROUT_NOEXCEPT_IF_EXPR(exp(std::declval())) { return exp(SPROUT_FORWARD(T, x)); } template inline SPROUT_CONSTEXPR decltype(exp10(std::declval())) call_exp10(T&& x) SPROUT_NOEXCEPT_IF_EXPR(exp10(std::declval())) { return exp10(SPROUT_FORWARD(T, x)); } template inline SPROUT_CONSTEXPR decltype(exp2(std::declval())) call_exp2(T&& x) SPROUT_NOEXCEPT_IF_EXPR(exp2(std::declval())) { return exp2(SPROUT_FORWARD(T, x)); } template inline SPROUT_CONSTEXPR decltype(expm1(std::declval())) call_expm1(T&& x) SPROUT_NOEXCEPT_IF_EXPR(expm1(std::declval())) { return expm1(SPROUT_FORWARD(T, x)); } template inline SPROUT_CONSTEXPR decltype(log(std::declval())) call_log(T&& x) SPROUT_NOEXCEPT_IF_EXPR(log(std::declval())) { return log(SPROUT_FORWARD(T, x)); } template inline SPROUT_CONSTEXPR decltype(log10(std::declval())) call_log10(T&& x) SPROUT_NOEXCEPT_IF_EXPR(log10(std::declval())) { return log10(SPROUT_FORWARD(T, x)); } template inline SPROUT_CONSTEXPR decltype(log1p(std::declval())) call_log1p(T&& x) SPROUT_NOEXCEPT_IF_EXPR(log1p(std::declval())) { return log1p(SPROUT_FORWARD(T, x)); } template inline SPROUT_CONSTEXPR decltype(log2(std::declval())) call_log2(T&& x) SPROUT_NOEXCEPT_IF_EXPR(log2(std::declval())) { return log2(SPROUT_FORWARD(T, x)); } } // namespace sprout namespace sprout { namespace detail { struct exp_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_exp(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_exp(std::declval())) { return sprout_math_detail::call_exp(SPROUT_FORWARD(T, x)); } }; struct exp10_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_exp10(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_exp10(std::declval())) { return sprout_math_detail::call_exp10(SPROUT_FORWARD(T, x)); } }; struct exp2_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_exp2(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_exp2(std::declval())) { return sprout_math_detail::call_exp2(SPROUT_FORWARD(T, x)); } }; struct expm1_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_expm1(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_expm1(std::declval())) { return sprout_math_detail::call_expm1(SPROUT_FORWARD(T, x)); } }; struct log_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_log(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_log(std::declval())) { return sprout_math_detail::call_log(SPROUT_FORWARD(T, x)); } }; struct log10_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_log10(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_log10(std::declval())) { return sprout_math_detail::call_log10(SPROUT_FORWARD(T, x)); } }; struct log1p_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_log1p(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_log1p(std::declval())) { return sprout_math_detail::call_log1p(SPROUT_FORWARD(T, x)); } }; struct log2_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_log2(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_log2(std::declval())) { return sprout_math_detail::call_log2(SPROUT_FORWARD(T, x)); } }; } // namespace detail // // exp // template inline SPROUT_CONSTEXPR sprout::valarray exp(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::exp_f()); } // // exp10 // template inline SPROUT_CONSTEXPR sprout::valarray exp10(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::exp10_f()); } // // exp2 // template inline SPROUT_CONSTEXPR sprout::valarray exp2(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::exp2_f()); } // // expm1 // template inline SPROUT_CONSTEXPR sprout::valarray expm1(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::expm1_f()); } // // log // template inline SPROUT_CONSTEXPR sprout::valarray log(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::log_f()); } // // log10 // template inline SPROUT_CONSTEXPR sprout::valarray log10(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::log10_f()); } // // log1p // template inline SPROUT_CONSTEXPR sprout::valarray log1p(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::log1p_f()); } // // log2 // template inline SPROUT_CONSTEXPR sprout::valarray log2(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::log2_f()); } } // namespace sprout #endif // #ifndef SPROUT_VALARRAY_EXPONENTIAL_HPP