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