f_sub.h 1.7 KB

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