f_div.h 1.6 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_DIV_H
  7. #define LIBSIMDPP_SIMDPP_CORE_F_DIV_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_div.h>
  13. #include <simdpp/core/detail/scalar_arg_impl.h>
  14. namespace simdpp {
  15. namespace SIMDPP_ARCH_NAMESPACE {
  16. /** Divides the values of two vectors.
  17. @code
  18. r0 = a0 / b0
  19. ...
  20. rN = aN / bN
  21. @endcode
  22. @icost{NEON, 6}
  23. @icost{ALTIVEC, 10}
  24. @par 256-bit version:
  25. @icost{SSE2-SSE4.1, 2}
  26. @icost{NEON, 12}
  27. @icost{ALTIVEC, 19}
  28. */
  29. template<unsigned N, class E1, class E2> SIMDPP_INL
  30. float32<N,expr_empty> div(const float32<N,E1>& a, const float32<N,E2>& b)
  31. {
  32. return detail::insn::i_div(a.eval(), b.eval());
  33. }
  34. SIMDPP_SCALAR_ARG_IMPL_VEC(div, float32, float32)
  35. /** Divides the values of two vectors
  36. @code
  37. r0 = a0 / b0
  38. ...
  39. rN = 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> div(const float64<N,E1>& a, const float64<N,E2>& b)
  49. {
  50. return detail::insn::i_div(a.eval(), b.eval());
  51. }
  52. SIMDPP_SCALAR_ARG_IMPL_VEC(div, float64, float64)
  53. } // namespace SIMDPP_ARCH_NAMESPACE
  54. } // namespace simdpp
  55. #endif