1/* Copyright (C) 2013-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_CORE_TO_FLOAT64_H
9#define LIBSIMDPP_SIMDPP_CORE_TO_FLOAT64_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/capabilities.h>
17#include <simdpp/detail/insn/conv_any_to_float64.h>
18#include <simdpp/detail/not_implemented.h>
19
20namespace simdpp {
21namespace SIMDPP_ARCH_NAMESPACE {
22
23/** Converts elements within a vector to 64-bit floating-point values.
24
25 SSE specific:
26
27 If only inexact conversion can be performed, the current rounding mode is
28 used.
29
30 NEON specific:
31
32 If only inexact conversion can be performed, round to nearest mode is used.
33
34 @code
35 r0 = (double) a0
36 ...
37 rN = (double) aN
38 @endcode
39*/
40template<unsigned N, class E> SIMDPP_INL
41float64<N,expr_empty> to_float64(const int8<N,E>& a)
42{
43 return detail::insn::i_to_float64(a.eval());
44}
45template<unsigned N, class E> SIMDPP_INL
46float64<N,expr_empty> to_float64(const uint8<N,E>& a)
47{
48 return detail::insn::i_to_float64(a.eval());
49}
50template<unsigned N, class E> SIMDPP_INL
51float64<N,expr_empty> to_float64(const int16<N,E>& a)
52{
53 return detail::insn::i_to_float64(a.eval());
54}
55template<unsigned N, class E> SIMDPP_INL
56float64<N,expr_empty> to_float64(const uint16<N,E>& a)
57{
58 return detail::insn::i_to_float64(a.eval());
59}
60template<unsigned N, class E> SIMDPP_INL
61float64<N,expr_empty> to_float64(const int32<N,E>& a)
62{
63 return detail::insn::i_to_float64(a.eval());
64}
65template<unsigned N, class E> SIMDPP_INL
66float64<N,expr_empty> to_float64(const uint32<N,E>& a)
67{
68 return detail::insn::i_to_float64(a.eval());
69}
70template<unsigned N, class E> SIMDPP_INL
71float64<N,expr_empty> to_float64(const int64<N,E>& a)
72{
73#if SIMDPP_HAS_INT64_TO_FLOAT64_CONVERSION
74 return detail::insn::i_to_float64(a.eval());
75#else
76 return SIMDPP_NOT_IMPLEMENTED_TEMPLATE1(E, a);
77#endif
78}
79template<unsigned N, class E> SIMDPP_INL
80float64<N,expr_empty> to_float64(const uint64<N,E>& a)
81{
82#if SIMDPP_HAS_UINT64_TO_FLOAT64_CONVERSION
83 return detail::insn::i_to_float64(a.eval());
84#else
85 return SIMDPP_NOT_IMPLEMENTED_TEMPLATE1(E, a);
86#endif
87}
88template<unsigned N, class E> SIMDPP_INL
89float64<N,expr_empty> to_float64(const float32<N,E>& a)
90{
91 return detail::insn::i_to_float64(a.eval());
92}
93template<unsigned N, class E> SIMDPP_INL
94float64<N,expr_empty> to_float64(const float64<N,E>& a)
95{
96 return a;
97}
98
99} // namespace SIMDPP_ARCH_NAMESPACE
100} // namespace simdpp
101
102#endif
103
104