28 #ifndef VC_COMMON_CONST_H_
29 #define VC_COMMON_CONST_H_
31 #include <type_traits>
32 #include <Vc/global.h>
34 namespace Vc_VERSIONED_NAMESPACE
39 template <
int exponent> constexpr
double exponentToFloat(std::integral_constant<bool, true>);
40 template <
int exponent> constexpr
double exponentToFloat(std::integral_constant<bool, false>);
41 template <> constexpr
double exponentToFloat<0>(std::integral_constant<bool, true>)
45 template <> constexpr
double exponentToFloat<0>(std::integral_constant<bool, false>)
49 template <> constexpr
double exponentToFloat<-32>(std::integral_constant<bool, true>)
51 return 1. / (65536. * 65536.);
53 template <> constexpr
double exponentToFloat<32>(std::integral_constant<bool, false>)
55 return 65536. * 65536.;
57 template <> constexpr
double exponentToFloat<-64>(std::integral_constant<bool, true>)
59 return 1. / (65536. * 65536. * 65536. * 65536.);
61 template <> constexpr
double exponentToFloat<64>(std::integral_constant<bool, false>)
63 return 65536. * 65536. * 65536. * 65536.;
65 template <
int exponent>
66 constexpr
double exponentToFloat(std::integral_constant<bool, false> negative)
68 return exponentToFloat<
exponent - 1>(negative) * 2.0;
70 template <
int exponent>
71 constexpr
double exponentToFloat(std::integral_constant<bool, true> negative)
73 return exponentToFloat<exponent + 1>(negative) * 0.5;
75 template <
int sign,
unsigned long long mantissa,
int exponent> constexpr
double doubleConstant()
77 return (static_cast<double>((mantissa & 0x000fffffffffffffull) | 0x0010000000000000ull) /
78 0x0010000000000000ull) *
79 exponentToFloat<exponent>(std::integral_constant<bool, (exponent < 0)>()) * sign;
81 template <
int sign,
unsigned int mantissa,
int exponent> constexpr
float floatConstant()
83 return (static_cast<float>((mantissa & 0x007fffffu) | 0x00800000u) / 0x00800000u) *
85 exponentToFloat<exponent>(std::integral_constant<bool, (exponent < 0)>())) *
92 #endif // VC_COMMON_CONST_H_
SimdArray< T, N, V, M > exponent(const SimdArray< T, N, V, M > &x)
Applies the std:: exponent function component-wise and concurrently.