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_I_SUBS_H |
9 | #define LIBSIMDPP_SIMDPP_CORE_I_SUBS_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/i_sub_sat.h> |
17 | #include <simdpp/core/detail/scalar_arg_impl.h> |
18 | |
19 | namespace simdpp { |
20 | namespace SIMDPP_ARCH_NAMESPACE { |
21 | |
22 | /** Subtracts and saturaters signed 8-bit integer values. |
23 | |
24 | @code |
25 | r0 = saturated(a0 - b0) |
26 | ... |
27 | rN = saturated(aN - bN) |
28 | @endcode |
29 | |
30 | @par 256-bit version: |
31 | @icost{SSE2-AVX, NEON, ALTIVEC, 2} |
32 | */ |
33 | template<unsigned N, class E1, class E2> SIMDPP_INL |
34 | int8<N, expr_isub_sat<int8<N,E1>, |
35 | int8<N,E2>>> sub_sat(const int8<N,E1>& a, |
36 | const int8<N,E2>& b) |
37 | { |
38 | return { { a, b } }; |
39 | } |
40 | |
41 | SIMDPP_SCALAR_ARG_IMPL_EXPR(sub_sat, expr_isub_sat, int8, int8) |
42 | |
43 | /** Subtracts and saturaters signed 16-bit integer values. |
44 | |
45 | @code |
46 | r0 = saturated(a0 - b0) |
47 | ... |
48 | rN = saturated(aN - bN) |
49 | @endcode |
50 | |
51 | @par 256-bit version: |
52 | @icost{SSE2-AVX, NEON, ALTIVEC, 2} |
53 | */ |
54 | template<unsigned N, class E1, class E2> SIMDPP_INL |
55 | int16<N, expr_isub_sat<int16<N,E1>, |
56 | int16<N,E2>>> sub_sat(const int16<N,E1>& a, |
57 | const int16<N,E2>& b) |
58 | { |
59 | return { { a, b } }; |
60 | } |
61 | |
62 | SIMDPP_SCALAR_ARG_IMPL_EXPR(sub_sat, expr_isub_sat, int16, int16) |
63 | |
64 | /** Subtracts and saturaters unsigned 8-bit integer values. |
65 | |
66 | @code |
67 | r0 = saturated(a0 - b0) |
68 | ... |
69 | rN = saturated(aN - bN) |
70 | @endcode |
71 | |
72 | @par 256-bit version: |
73 | @icost{SSE2-AVX, NEON, ALTIVEC, 2} |
74 | */ |
75 | template<unsigned N, class E1, class E2> SIMDPP_INL |
76 | uint8<N, expr_isub_sat<uint8<N,E1>, |
77 | uint8<N,E2>>> sub_sat(const uint8<N,E1>& a, |
78 | const uint8<N,E2>& b) |
79 | { |
80 | return { { a, b } }; |
81 | } |
82 | |
83 | SIMDPP_SCALAR_ARG_IMPL_EXPR(sub_sat, expr_isub_sat, uint8, uint8) |
84 | |
85 | /** Subtracts and saturaters unsigned 16-bit integer values. |
86 | |
87 | @code |
88 | r0 = saturated(a0 - b0) |
89 | ... |
90 | rN = saturated(aN - bN) |
91 | @endcode |
92 | |
93 | @par 256-bit version: |
94 | @icost{SSE2-AVX, NEON, ALTIVEC, 2} |
95 | */ |
96 | template<unsigned N, class E1, class E2> SIMDPP_INL |
97 | uint16<N, expr_isub_sat<uint16<N,E1>, |
98 | uint16<N,E2>>> sub_sat(const uint16<N,E1>& a, |
99 | const uint16<N,E2>& b) |
100 | { |
101 | return { { a, b } }; |
102 | } |
103 | |
104 | SIMDPP_SCALAR_ARG_IMPL_EXPR(sub_sat, expr_isub_sat, uint16, uint16) |
105 | |
106 | } // namespace SIMDPP_ARCH_NAMESPACE |
107 | } // namespace simdpp |
108 | |
109 | #endif |
110 | |
111 | |