1 #ifndef REGISTER_TRAITS_H
2 #define REGISTER_TRAITS_H
16 template<
typename>
struct mapper { };
17 template<>
struct mapper<double> {
typedef double type; };
21 template<>
struct mapper<double2> {
typedef double2
type; };
22 template<>
struct mapper<float2> {
typedef float2
type; };
23 template<>
struct mapper<short2> {
typedef float2
type; };
25 template<>
struct mapper<double4> {
typedef double4
type; };
26 template<>
struct mapper<float4> {
typedef float4
type; };
27 template<>
struct mapper<short4> {
typedef float4
type; };
30 template<
typename T >
struct isHalf{
static const bool value =
false; };
31 template<>
struct isHalf<short>{
static const bool value =
true; };
33 template<
typename T1,
typename T2> __host__ __device__
inline void copy (T1 &a,
const T2 &b) { a = b; }
34 template<> __host__ __device__
inline void copy(
float &a,
const short &b) { a = (float)b/
MAX_SHORT; }
35 template<> __host__ __device__
inline void copy(
short &a,
const float &b) { a = (short)(b*
MAX_SHORT); }
40 template <
bool isHalf>
43 __device__ __host__
static T
Atan2(
const T &a,
const T &b) {
return atan2(a,b); }
45 __device__ __host__
static T
Sin(
const T &a ) {
return sin(a); }
47 __device__ __host__
static T
Cos(
const T &a ) {
return cos(a); }
50 __device__ __host__
static void SinCos(
const T& a, T *
s, T *c) { *s =
sin(a); *c =
cos(a); }
59 __device__ __host__
static T
Atan2(
const T &a,
const T &b) {
return atan2(a,b)/M_PI; }
61 __device__ __host__
static T
Sin(
const T &a ) {
return sin(a*M_PI); }
63 __device__ __host__
static T
Cos(
const T &a ) {
return cos(a*M_PI); }
__device__ static __host__ T Sin(const T &a)
__device__ static __host__ T Atan2(const T &a, const T &b)
__host__ __device__ void copy(T1 &a, const T2 &b)
__device__ static __host__ T Atan2(const T &a, const T &b)
__host__ __device__ ValueType sin(ValueType x)
__host__ __device__ ValueType atan2(ValueType x, ValueType y)
__device__ static __host__ T Cos(const T &a)
__device__ static __host__ void SinCos(const T &a, T *s, T *c)
__host__ __device__ ValueType cos(ValueType x)
__device__ static __host__ T Cos(const T &a)
__device__ static __host__ T Sin(const T &a)