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_NEG_H
9#define LIBSIMDPP_SIMDPP_CORE_I_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/i_neg.h>
17
18namespace simdpp {
19namespace SIMDPP_ARCH_NAMESPACE {
20
21/** Negates signed 8-bit values.
22
23 @code
24 r0 = -a0
25 ...
26 rN = -aN
27 @endcode
28
29 @par 256-bit version:
30 @icost{SSE2-AVX, NEON, ALTIVEC, 2}
31*/
32template<unsigned N, class E> SIMDPP_INL
33int8<N, expr_ineg<int8<N,E>>> neg(const int8<N,E>& a)
34{
35 return { { a } };
36}
37
38/** Negates signed 16-bit values.
39
40 @code
41 r0 = -a0
42 ...
43 rN = -aN
44 @endcode
45
46 @par 256-bit version:
47 @icost{SSE2-AVX, NEON, ALTIVEC, 2}
48*/
49template<unsigned N, class E> SIMDPP_INL
50int16<N, expr_ineg<int16<N,E>>> neg(const int16<N,E>& a)
51{
52 return { { a } };
53}
54
55/** Negates signed 32-bit values.
56
57 @code
58 r0 = -a0
59 ...
60 rN = -aN
61 @endcode
62
63 @par 256-bit version:
64 @icost{SSE2-AVX, NEON, ALTIVEC, 2}
65*/
66template<unsigned N, class E> SIMDPP_INL
67int32<N, expr_ineg<int32<N,E>>> neg(const int32<N,E>& a)
68{
69 return { { a } };
70}
71
72/** Negates signed 64-bit values.
73
74 @code
75 r0 = -a0
76 ...
77 rN = -aN
78 @endcode
79
80 @par 128-bit version:
81 @icost{ALTIVEC, 4-5}
82
83 @par 256-bit version:
84 @icost{SSE2-AVX, NEON, 2}
85 @icost{ALTIVEC, 8-9}
86*/
87template<unsigned N, class E> SIMDPP_INL
88int64<N, expr_ineg<int64<N,E>>> neg(const int64<N,E>& a)
89{
90 return { { a } };
91}
92
93} // namespace SIMDPP_ARCH_NAMESPACE
94} // namespace simdpp
95
96#endif
97
98