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_NEG_H |
9 | #define LIBSIMDPP_SIMDPP_CORE_F_NEG_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_neg.h> |
17 | |
18 | namespace simdpp { |
19 | namespace SIMDPP_ARCH_NAMESPACE { |
20 | |
21 | /** Negates the values of a float32x4 vector |
22 | |
23 | @code |
24 | r0 = -a0 |
25 | ... |
26 | rN = -aN |
27 | @endcode |
28 | |
29 | @par 128-bit version: |
30 | @icost{SSE2-AVX2, ALTIVEC, 1-2} |
31 | |
32 | @par 256-bit version: |
33 | @icost{SSE2-SSE4.1, ALTIVEC, 2-3} |
34 | @icost{AVX-AVX2, NEON, 2} |
35 | */ |
36 | template<unsigned N, class E> SIMDPP_INL |
37 | float32<N, expr_fneg<float32<N,E>>> neg(const float32<N,E>& a) |
38 | { |
39 | return { { a } }; |
40 | } |
41 | |
42 | /** Negates the values of a vector |
43 | |
44 | @code |
45 | r0 = -a0 |
46 | ... |
47 | rN = -aN |
48 | @endcode |
49 | |
50 | @par 128-bit version: |
51 | @icost{SSE2-AVX2, 1-2} |
52 | @novec{NEON, ALTIVEC} |
53 | |
54 | @par 256-bit version: |
55 | @icost{SSE2-SSE4.1, 2-3} |
56 | @icost{AVX-AVX2, 1-2} |
57 | @novec{NEON, ALTIVEC} |
58 | */ |
59 | template<unsigned N, class E> SIMDPP_INL |
60 | float64<N, expr_fneg<float64<N,E>>> neg(const float64<N,E>& a) |
61 | { |
62 | return { { a } }; |
63 | } |
64 | |
65 | |
66 | } // namespace SIMDPP_ARCH_NAMESPACE |
67 | } // namespace simdpp |
68 | |
69 | #endif |
70 | |
71 | |