/*============================================================================= 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_COMPARISON_HPP #define SPROUT_VALARRAY_COMPARISON_HPP #include #include #include #include #include #include #include #include #include #include #include #include namespace sprout { // // operator== // template inline SPROUT_CONSTEXPR sprout::valarray operator==(sprout::valarray const& lhs, sprout::valarray const& rhs) { return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::equal_to<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator==(sprout::valarray const& lhs, T const& rhs) { return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::equal_to<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator==(T const& lhs, sprout::valarray const& rhs) { return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::equal_to<>(), lhs)); } // // operator!= // template inline SPROUT_CONSTEXPR sprout::valarray operator!=(sprout::valarray const& lhs, sprout::valarray const& rhs) { return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::not_equal_to<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator!=(sprout::valarray const& lhs, T const& rhs) { return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::not_equal_to<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator!=(T const& lhs, sprout::valarray const& rhs) { return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::not_equal_to<>(), lhs)); } // // operator< // template inline SPROUT_CONSTEXPR sprout::valarray operator<(sprout::valarray const& lhs, sprout::valarray const& rhs) { return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::less<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator<(sprout::valarray const& lhs, T const& rhs) { return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::less<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator<(T const& lhs, sprout::valarray const& rhs) { return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::less<>(), lhs)); } // // operator> // template inline SPROUT_CONSTEXPR sprout::valarray operator>(sprout::valarray const& lhs, sprout::valarray const& rhs) { return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::greater<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator>(sprout::valarray const& lhs, T const& rhs) { return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::greater<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator>(T const& lhs, sprout::valarray const& rhs) { return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::greater<>(), lhs)); } // // operator<= // template inline SPROUT_CONSTEXPR sprout::valarray operator<=(sprout::valarray const& lhs, sprout::valarray const& rhs) { return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::less_equal<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator<=(sprout::valarray const& lhs, T const& rhs) { return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::less_equal<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator<=(T const& lhs, sprout::valarray const& rhs) { return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::less_equal<>(), lhs)); } // // operator>= // template inline SPROUT_CONSTEXPR sprout::valarray operator>=(sprout::valarray const& lhs, sprout::valarray const& rhs) { return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::greater_equal<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator>=(sprout::valarray const& lhs, T const& rhs) { return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::greater_equal<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator>=(T const& lhs, sprout::valarray const& rhs) { return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::greater_equal<>(), lhs)); } } // namespace sprout #endif // #ifndef SPROUT_VALARRAY_COMPARISON_HPP