11 #include <type_traits>
18 template <
typename T> __host__ __device__
inline float i2f(T a)
21 return static_cast<float>(a);
29 return f - 12582912.0f;
34 __device__ __host__
inline int f2i(
float f)
38 return reinterpret_cast<int &
>(f);
40 return static_cast<int>(f);
45 __device__ __host__
inline int d2i(
double d)
48 d += 6755399441055744.0;
49 return reinterpret_cast<int &
>(d);
51 return static_cast<int>(d);
62 template <
typename T1,
typename T2>
63 __host__ __device__
inline typename std::enable_if<!isFixed<T1>::value && !
isFixed<T2>::value,
void>::type
69 template <
typename T1,
typename T2>
70 __host__ __device__
inline typename std::enable_if<!isFixed<T1>::value &&
isFixed<T2>::value,
void>::type
76 template <
typename T1,
typename T2>
77 __host__ __device__
inline typename std::enable_if<isFixed<T1>::value && !
isFixed<T2>::value,
void>::type
87 template <
typename T1,
typename T2>
88 __host__ __device__
inline typename std::enable_if<!isFixed<T1>::value,
void>::type
copy_scaled(T1 &a,
const T2 &b)
93 template <
typename T1,
typename T2>
94 __host__ __device__
inline typename std::enable_if<isFixed<T1>::value,
void>::type
copy_scaled(T1 &a,
const T2 &b)
104 template <
typename T1,
typename T2,
typename T3>
105 __host__ __device__
inline typename std::enable_if<!isFixed<T2>::value,
void>::type
copy_and_scale(T1 &a,
const T2 &b,
111 template <
typename T1,
typename T2,
typename T3>
112 __host__ __device__
inline typename std::enable_if<isFixed<T2>::value,
void>::type
copy_and_scale(T1 &a,
const T2 &b,
__host__ __device__ float i2f(T a)
__device__ __host__ int f2i(float f)
__device__ __host__ int d2i(double d)
__host__ __device__ std::enable_if<!isFixed< T1 >::value, void >::type copy_scaled(T1 &a, const T2 &b)
Specialized variants of the copy function that assumes the scaling factor has already been done.
__host__ __device__ std::enable_if<!isFixed< T1 >::value &&!isFixed< T2 >::value, void >::type copy(T1 &a, const T2 &b)
Copy function which is trival between floating point types. When converting to an integer type,...
__host__ __device__ std::enable_if<!isFixed< T2 >::value, void >::type copy_and_scale(T1 &a, const T2 &b, const T3 &c)
Specialized variants of the copy function that include an additional scale factor....
Provides precision abstractions and defines the register precision given the storage precision using ...