1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/sprout/math/quaternion/detail/abs_max.hpp

39 lines
1.3 KiB
C++
Raw Normal View History

2016-02-26 16:21:46 +00:00
/*=============================================================================
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_MATH_QUATERNION_DETAIL_ABS_MAX_HPP
#define SPROUT_MATH_QUATERNION_DETAIL_ABS_MAX_HPP
#include <sprout/config.hpp>
#include <sprout/workaround/std/cstddef.hpp>
#include <sprout/array/array.hpp>
#include <sprout/math/abs.hpp>
#include <sprout/range/algorithm/max_element.hpp>
namespace sprout {
namespace math {
namespace detail {
template<typename T>
class abs_less {
public:
SPROUT_CONSTEXPR T
operator()(T const& lhs, T const& rhs) const {
return sprout::math::abs(lhs) < sprout::math::abs(rhs);
}
};
template<typename T, std::size_t N>
SPROUT_CONSTEXPR T
abs_max(sprout::array<T, N> const& c) {
return sprout::math::abs(*sprout::range::max_element(c, sprout::math::detail::abs_less<T>()));
}
} // namespace detail
} // namespace math
} // namespace sprout
#endif // #ifndef SPROUT_MATH_QUATERNION_DETAIL_ABS_MAX_HPP