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