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
19namespace simdpp {
20namespace SIMDPP_ARCH_NAMESPACE {
21namespace detail {
22namespace insn {
23
24
25template<unsigned N> SIMDPP_INL
26uint16<N> i_to_uint16(const float32<N>& a)
27{
28 return i_to_uint16( (uint32<N>) i_to_int32(a));
29}
30
31template<unsigned N> SIMDPP_INL
32uint16<N> i_to_uint16(const float64<N>& a)
33{
34 return i_to_uint16( (uint32<N>) i_to_int32(a));
35}
36
37template<unsigned N> SIMDPP_INL
38int16<N> i_to_int16(const float32<N>& a)
39{
40 return (int16<N>) i_to_uint16((uint32<N>) i_to_int32(a));
41}
42
43template<unsigned N> SIMDPP_INL
44int16<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