| 1 | /* Copyright (C) 2017 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_DETAIL_INSN_CONV_FLOAT_TO_INT16_H |
| 9 | #define LIBSIMDPP_SIMDPP_DETAIL_INSN_CONV_FLOAT_TO_INT16_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/insn/conv_float_to_int32.h> |
| 17 | #include <simdpp/detail/insn/conv_shrink_to_int16.h> |
| 18 | |
| 19 | namespace simdpp { |
| 20 | namespace SIMDPP_ARCH_NAMESPACE { |
| 21 | namespace detail { |
| 22 | namespace insn { |
| 23 | |
| 24 | |
| 25 | template<unsigned N> SIMDPP_INL |
| 26 | uint16<N> i_to_uint16(const float32<N>& a) |
| 27 | { |
| 28 | return i_to_uint16( (uint32<N>) i_to_int32(a)); |
| 29 | } |
| 30 | |
| 31 | template<unsigned N> SIMDPP_INL |
| 32 | uint16<N> i_to_uint16(const float64<N>& a) |
| 33 | { |
| 34 | return i_to_uint16( (uint32<N>) i_to_int32(a)); |
| 35 | } |
| 36 | |
| 37 | template<unsigned N> SIMDPP_INL |
| 38 | int16<N> i_to_int16(const float32<N>& a) |
| 39 | { |
| 40 | return (int16<N>) i_to_uint16((uint32<N>) i_to_int32(a)); |
| 41 | } |
| 42 | |
| 43 | template<unsigned N> SIMDPP_INL |
| 44 | int16<N> i_to_int16(const float64<N>& a) |
| 45 | { |
| 46 | return (int16<N>) i_to_uint16((uint32<N>) i_to_int32(a)); |
| 47 | } |
| 48 | |
| 49 | |
| 50 | } // namespace insn |
| 51 | } // namespace detail |
| 52 | } // namespace SIMDPP_ARCH_NAMESPACE |
| 53 | } // namespace simdpp |
| 54 | |
| 55 | #endif |
| 56 | |
| 57 | |
| 58 |