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_FMSUB_H
9#define LIBSIMDPP_SIMDPP_CORE_F_FMSUB_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_fmsub.h>
17
18namespace simdpp {
19namespace SIMDPP_ARCH_NAMESPACE {
20
21/** Performs a fused multiply-sutract operation
22
23 @code
24 r0 = a0 * b0 - c0
25 ...
26 rN = aN * bN - cN
27 @endcode
28
29 Implemented only on architectures with either @c X86_FMA3 or @c X86_FMA4
30 support.
31*/
32template<unsigned N, class E1, class E2, class E3> SIMDPP_INL
33float32<N, expr_fmsub<float32<N,E1>,
34 float32<N,E2>,
35 float32<N,E3>>> fmsub(const float32<N,E1>& a,
36 const float32<N,E2>& b,
37 const float32<N,E3>& c)
38{
39 return { { a, b, c } };
40}
41
42template<unsigned N, class E1, class E2, class E3> SIMDPP_INL
43float64<N, expr_fmsub<float64<N,E1>,
44 float64<N,E2>,
45 float64<N,E3>>> fmsub(const float64<N,E1>& a,
46 const float64<N,E2>& b,
47 const float64<N,E3>& c)
48{
49 return { { a, b, c } };
50}
51
52} // namespace SIMDPP_ARCH_NAMESPACE
53} // namespace simdpp
54
55#endif
56
57