2
0

f_add.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_ADD_H
  7. #define LIBSIMDPP_SIMDPP_CORE_F_ADD_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/expr/f_add.h>
  13. #include <simdpp/core/detail/scalar_arg_impl.h>
  14. namespace simdpp {
  15. namespace SIMDPP_ARCH_NAMESPACE {
  16. /** Adds the values of two vectors
  17. @code
  18. r0 = a0 + b0
  19. ...
  20. rN = aN + bN
  21. @endcode
  22. @par 256-bit version:
  23. @icost{SSE2-SSE4.1, NEON, ALTIVEC, 2}
  24. */
  25. template<unsigned N, class E1, class E2> SIMDPP_INL
  26. float32<N, expr_fadd<float32<N,E1>,
  27. float32<N,E2>>> add(const float32<N,E1>& a, const float32<N,E2>& b)
  28. {
  29. return { { a, b } };
  30. }
  31. SIMDPP_SCALAR_ARG_IMPL_EXPR(add, expr_fadd, float32, float32)
  32. /** Adds the values of two vectors
  33. @code
  34. r0 = a0 + b0
  35. ...
  36. rN = aN + bN
  37. @endcode
  38. @par 128-bit version:
  39. @novec{NEON, ALTIVEC}
  40. @par 256-bit version:
  41. @novec{NEON, ALTIVEC}
  42. @icost{SSE2-SSE4.1, 2}
  43. */
  44. template<unsigned N, class E1, class E2> SIMDPP_INL
  45. float64<N, expr_fadd<float64<N,E1>,
  46. float64<N,E2>>> add(const float64<N,E1>& a, const float64<N,E2>& b)
  47. {
  48. return { { a, b } };
  49. }
  50. SIMDPP_SCALAR_ARG_IMPL_EXPR(add, expr_fadd, float64, float64)
  51. } // namespace SIMDPP_ARCH_NAMESPACE
  52. } // namespace simdpp
  53. #endif