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_SUB_H
9#define LIBSIMDPP_SIMDPP_CORE_F_SUB_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_sub.h>
17#include <simdpp/core/detail/scalar_arg_impl.h>
18#include <simdpp/core/detail/get_expr_uint.h>
19
20
21namespace simdpp {
22namespace SIMDPP_ARCH_NAMESPACE {
23
24/** Substracts the values of two vectors
25
26 @code
27 r0 = a0 - b0
28 ...
29 rN = aN - bN
30 @endcode
31
32 @par 256-bit version:
33 @icost{SSE2-SSE4.1, NEON, ALTIVEC, 2}
34*/
35template<unsigned N, class E1, class E2> SIMDPP_INL
36float32<N, expr_fsub<float32<N,E1>,
37 float32<N,E2>>> sub(const float32<N,E1>& a,
38 const float32<N,E2>& b)
39{
40 return { { a, b } };
41}
42
43SIMDPP_SCALAR_ARG_IMPL_EXPR(sub, expr_fsub, float32, float32)
44
45/** Subtracts the values of two vectors
46
47 @code
48 r0 = a0 - b0
49 ...
50 rN = aN - bN
51 @endcode
52
53 @par 128-bit version:
54 @novec{NEON, ALTIVEC}
55
56 @par 256-bit version:
57 @novec{NEON, ALTIVEC}
58 @icost{SSE2-SSE4.1, 2}
59*/
60template<unsigned N, class E1, class E2> SIMDPP_INL
61float64<N, expr_fsub<float64<N,E1>,
62 float64<N,E2>>> sub(const float64<N,E1>& a,
63 const float64<N,E2>& b)
64{
65 return { { a, b } };
66}
67
68SIMDPP_SCALAR_ARG_IMPL_EXPR(sub, expr_fsub, float64, float64)
69
70} // namespace SIMDPP_ARCH_NAMESPACE
71} // namespace simdpp
72
73#endif
74
75