1 | /* Copyright (C) 2013-2014 Povilas Kanapickas <povilas@radix.lt> |
2 | |
3 | Distributed under the Boost Software License, Version 1.0. |
4 | (See accompanying file LICENSE_1_0.txt or copy at |
5 | http://www.boost.org/LICENSE_1_0.txt) |
6 | */ |
7 | |
8 | #ifndef LIBSIMDPP_SIMDPP_CORE_F_ADD_H |
9 | #define LIBSIMDPP_SIMDPP_CORE_F_ADD_H |
10 | |
11 | #ifndef LIBSIMDPP_SIMD_H |
12 | #error "This file must be included through simd.h" |
13 | #endif |
14 | |
15 | #include <simdpp/types.h> |
16 | #include <simdpp/detail/expr/f_add.h> |
17 | #include <simdpp/core/detail/scalar_arg_impl.h> |
18 | |
19 | namespace simdpp { |
20 | namespace SIMDPP_ARCH_NAMESPACE { |
21 | |
22 | |
23 | /** Adds the values of two vectors |
24 | |
25 | @code |
26 | r0 = a0 + b0 |
27 | ... |
28 | rN = aN + bN |
29 | @endcode |
30 | |
31 | @par 256-bit version: |
32 | @icost{SSE2-SSE4.1, NEON, ALTIVEC, 2} |
33 | */ |
34 | template<unsigned N, class E1, class E2> SIMDPP_INL |
35 | float32<N, expr_fadd<float32<N,E1>, |
36 | float32<N,E2>>> add(const float32<N,E1>& a, const float32<N,E2>& b) |
37 | { |
38 | return { { a, b } }; |
39 | } |
40 | |
41 | SIMDPP_SCALAR_ARG_IMPL_EXPR(add, expr_fadd, float32, float32) |
42 | |
43 | /** Adds the values of two vectors |
44 | |
45 | @code |
46 | r0 = a0 + b0 |
47 | ... |
48 | rN = aN + bN |
49 | @endcode |
50 | |
51 | @par 128-bit version: |
52 | @novec{NEON, ALTIVEC} |
53 | |
54 | @par 256-bit version: |
55 | @novec{NEON, ALTIVEC} |
56 | @icost{SSE2-SSE4.1, 2} |
57 | */ |
58 | template<unsigned N, class E1, class E2> SIMDPP_INL |
59 | float64<N, expr_fadd<float64<N,E1>, |
60 | float64<N,E2>>> add(const float64<N,E1>& a, const float64<N,E2>& b) |
61 | { |
62 | return { { a, b } }; |
63 | } |
64 | |
65 | SIMDPP_SCALAR_ARG_IMPL_EXPR(add, expr_fadd, float64, float64) |
66 | |
67 | } // namespace SIMDPP_ARCH_NAMESPACE |
68 | } // namespace simdpp |
69 | |
70 | #endif |
71 | |
72 | |