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_TRUNC_H
9#define LIBSIMDPP_SIMDPP_CORE_F_TRUNC_H
10
11#ifndef LIBSIMDPP_SIMD_H
12 #error "This file must be included through simd.h"
13#endif
14
15#include <cmath>
16#include <simdpp/detail/insn/f_trunc.h>
17
18namespace simdpp {
19namespace SIMDPP_ARCH_NAMESPACE {
20
21
22/** Rounds the values of a vector towards zero
23 @code
24 r0 = trunc(a0)
25 ...
26 rN = trunc(aN)
27 @endcode
28
29 @par 128-bit version:
30 @icost{SSE2, SSE3, SSSE3, 7-9}
31 @icost{NEON, 5-6}
32
33 @par 256-bit version:
34 @icost{SSE2, SSE3, SSSE3, 14-16}
35 @icost{NEON, 10-11}
36 @icost{SSE4.1, ALTIVEC, 2}
37*/
38template<unsigned N, class E> SIMDPP_INL
39float32<N,expr_empty> trunc(const float32<N,E>& a)
40{
41 return detail::insn::i_trunc(a.eval());
42}
43template<unsigned N, class E> SIMDPP_INL
44float64<N,expr_empty> trunc(const float64<N,E>& a)
45{
46 return detail::insn::i_trunc(a.eval());
47}
48
49} // namespace SIMDPP_ARCH_NAMESPACE
50} // namespace simdpp
51
52#endif
53
54