f_max.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Copyright (C) 2013-2014 Povilas Kanapickas <[email protected]>
  2. Distributed under the Boost Software License, Version 1.0.
  3. (See accompanying file LICENSE_1_0.txt or copy at
  4. http://www.boost.org/LICENSE_1_0.txt)
  5. */
  6. #ifndef LIBSIMDPP_SIMDPP_CORE_F_MAX_H
  7. #define LIBSIMDPP_SIMDPP_CORE_F_MAX_H
  8. #ifndef LIBSIMDPP_SIMD_H
  9. #error "This file must be included through simd.h"
  10. #endif
  11. #include <simdpp/types.h>
  12. #include <simdpp/detail/insn/f_max.h>
  13. #include <simdpp/core/detail/scalar_arg_impl.h>
  14. namespace simdpp {
  15. namespace SIMDPP_ARCH_NAMESPACE {
  16. /** Computes maxima of the values of two vectors. If at least one of the values
  17. is NaN, or both values are zeroes, it is unspecified which value will be
  18. returned.
  19. @code
  20. r0 = max(a0, b0)
  21. ...
  22. rN = max(aN, bN)
  23. @endcode
  24. @par 256-bit version:
  25. @icost{SSE2-SSE4.1, NEON, ALTIVEC, 2}
  26. */
  27. template<unsigned N, class E1, class E2> SIMDPP_INL
  28. float32<N,expr_empty> max(const float32<N,E1>& a, const float32<N,E2>& b)
  29. {
  30. return detail::insn::i_max(a.eval(), b.eval());
  31. }
  32. SIMDPP_SCALAR_ARG_IMPL_VEC(max, float32, float32)
  33. /** Computes maxima of the values of two vectors. If at least one of the values
  34. is NaN, or both values are zeroes, it is unspecified which value will be
  35. returned.
  36. @code
  37. r0 = max(a0, b0)
  38. ...
  39. rN = max(aN, bN)
  40. @endcode
  41. @par 128-bit version:
  42. @novec{NEON, ALTIVEC}
  43. @par 256-bit version:
  44. @icost{SSE2-SSE4.1, 2}
  45. @novec{NEON, ALTIVEC}
  46. */
  47. template<unsigned N, class E1, class E2> SIMDPP_INL
  48. float64<N,expr_empty> max(const float64<N,E1>& a, const float64<N,E2>& b)
  49. {
  50. return detail::insn::i_max(a.eval(), b.eval());
  51. }
  52. SIMDPP_SCALAR_ARG_IMPL_VEC(max, float64, float64)
  53. } // namespace SIMDPP_ARCH_NAMESPACE
  54. } // namespace simdpp
  55. #endif