/*============================================================================= 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_BITWISE_HPP #define SPROUT_VALARRAY_BITWISE_HPP #include #include #include #include #include #include #include #include #include #include #include #include namespace sprout_math_detail { using sprout::math::acos; using sprout::math::asin; using sprout::math::atan; using sprout::math::atan2; using sprout::math::cos; using sprout::math::sin; using sprout::math::tan; template inline SPROUT_CONSTEXPR decltype(acos(std::declval())) call_acos(T&& x) SPROUT_NOEXCEPT_IF_EXPR(acos(std::declval())) { return acos(SPROUT_FORWARD(T, x)); } template inline SPROUT_CONSTEXPR decltype(asin(std::declval())) call_asin(T&& x) SPROUT_NOEXCEPT_IF_EXPR(asin(std::declval())) { return asin(SPROUT_FORWARD(T, x)); } template inline SPROUT_CONSTEXPR decltype(atan(std::declval())) call_atan(T&& x) SPROUT_NOEXCEPT_IF_EXPR(atan(std::declval())) { return atan(SPROUT_FORWARD(T, x)); } template inline SPROUT_CONSTEXPR decltype(atan2(std::declval(), std::declval())) call_atan2(T&& x, U&& y) SPROUT_NOEXCEPT_IF_EXPR(atan2(std::declval(), std::declval())) { return atan2(SPROUT_FORWARD(T, x), SPROUT_FORWARD(U, u)); } template inline SPROUT_CONSTEXPR decltype(cos(std::declval())) call_cos(T&& x) SPROUT_NOEXCEPT_IF_EXPR(cos(std::declval())) { return cos(SPROUT_FORWARD(T, x)); } template inline SPROUT_CONSTEXPR decltype(sin(std::declval())) call_sin(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sin(std::declval())) { return sin(SPROUT_FORWARD(T, x)); } template inline SPROUT_CONSTEXPR decltype(tan(std::declval())) call_tan(T&& x) SPROUT_NOEXCEPT_IF_EXPR(tan(std::declval())) { return tan(SPROUT_FORWARD(T, x)); } } // namespace sprout namespace sprout { namespace detail { struct acos_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_acos(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_acos(std::declval())) { return sprout_math_detail::call_acos(SPROUT_FORWARD(T, x)); } }; struct asin_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_asin(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_asin(std::declval())) { return sprout_math_detail::call_asin(SPROUT_FORWARD(T, x)); } }; struct atan_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_atan(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_atan(std::declval())) { return sprout_math_detail::call_atan(SPROUT_FORWARD(T, x)); } }; struct atan2_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_atan2(std::declval(), std::declval())) operator()(T&& x, U&& y) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_atan2(std::declval(), std::declval())) { return sprout_math_detail::call_atan2(SPROUT_FORWARD(T, x), SPROUT_FORWARD(U, y)); } }; struct cos_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_cos(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_cos(std::declval())) { return sprout_math_detail::call_cos(SPROUT_FORWARD(T, x)); } }; struct sin_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_sin(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_sin(std::declval())) { return sprout_math_detail::call_sin(SPROUT_FORWARD(T, x)); } }; struct tan_f : public sprout::transparent<> { public: template SPROUT_CONSTEXPR decltype(sprout_math_detail::call_tan(std::declval())) operator()(T&& x) SPROUT_NOEXCEPT_IF_EXPR(sprout_math_detail::call_tan(std::declval())) { return sprout_math_detail::call_tan(SPROUT_FORWARD(T, x)); } }; } // namespace detail // // acos // template inline SPROUT_CONSTEXPR sprout::valarray acos(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::acos_f()); } // // asin // template inline SPROUT_CONSTEXPR sprout::valarray asin(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::asin_f()); } // // atan // template inline SPROUT_CONSTEXPR sprout::valarray atan(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::atan_f()); } // // atan2 // template inline SPROUT_CONSTEXPR sprout::valarray atan2(sprout::valarray const& x, sprout::valarray const& y) { return sprout::fixed::transform(x.begin(), x.end(), y.end(), x, sprout::detail::atan2_f()); } template inline SPROUT_CONSTEXPR sprout::valarray atan2(sprout::valarray const& lhs, T const& y) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::bind2nd(sprout::detail::atan2_f()()), y)); } template inline SPROUT_CONSTEXPR sprout::valarray atan2(T const& x, sprout::valarray const& y) { return sprout::fixed::transform(y.begin(), y.end(), y, sprout::bind1st(sprout::detail::atan2_f()()), x)); } // // cos // template inline SPROUT_CONSTEXPR sprout::valarray cos(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::cos_f()); } // // sin // template inline SPROUT_CONSTEXPR sprout::valarray sin(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::sin_f()); } // // tan // template inline SPROUT_CONSTEXPR sprout::valarray tan(sprout::valarray const& x) { return sprout::fixed::transform(x.begin(), x.end(), x, sprout::detail::tan_f()); } } // namespace sprout #endif // #ifndef SPROUT_VALARRAY_BITWISE_HPP