24 #include <hip/hip_vector_types.h>
25 #include <hip/math_functions.h>
27 #include <type_traits>
31 template <
typename T,
unsigned int rank,
32 typename std::enable_if<(rank == 1),
bool>::type = 0>
33 __host__ __device__
static HIP_vector_type<T, rank>
pow(
34 HIP_vector_type<T, rank> vec,
double p) {
35 vec.x =
::pow(vec.x, p);
38 template <
typename T,
unsigned int rank,
39 typename std::enable_if<(rank == 2),
bool>::type = 0>
40 __host__ __device__
static HIP_vector_type<T, rank>
pow(
41 HIP_vector_type<T, rank> vec,
double p) {
42 vec.x =
::pow(vec.x, p);
43 vec.y =
::pow(vec.y, p);
46 template <
typename T,
unsigned int rank,
47 typename std::enable_if<(rank == 3),
bool>::type = 0>
48 __host__ __device__
static HIP_vector_type<T, rank>
pow(
49 HIP_vector_type<T, rank> vec,
double p) {
50 vec.x =
::pow(vec.x, p);
51 vec.y =
::pow(vec.y, p);
52 vec.z =
::pow(vec.z, p);
55 template <
typename T,
unsigned int rank,
56 typename std::enable_if<(rank == 4),
bool>::type = 0>
57 __host__ __device__
static HIP_vector_type<T, rank>
pow(
58 HIP_vector_type<T, rank> vec,
double p) {
59 vec.x =
::pow(vec.x, p);
60 vec.y =
::pow(vec.y, p);
61 vec.z =
::pow(vec.z, p);
62 vec.w =
::pow(vec.w, p);
66 template <
typename U,
typename T,
unsigned int rank,
67 typename std::enable_if<(rank == 1),
bool>::type = 0>
69 HIP_vector_type<T, rank> vec) {
70 HIP_vector_type<U, rank> out;
71 out.x =
static_cast<U
>(vec.x);
74 template <
typename U,
typename T,
unsigned int rank,
75 typename std::enable_if<(rank == 2),
bool>::type = 0>
77 HIP_vector_type<T, rank> vec) {
78 HIP_vector_type<U, rank> out;
79 out.x =
static_cast<U
>(vec.x);
80 out.y =
static_cast<U
>(vec.y);
83 template <
typename U,
typename T,
unsigned int rank,
84 typename std::enable_if<(rank == 3),
bool>::type = 0>
86 HIP_vector_type<T, rank> vec) {
87 HIP_vector_type<U, rank> out;
88 out.x =
static_cast<U
>(vec.x);
89 out.y =
static_cast<U
>(vec.y);
90 out.z =
static_cast<U
>(vec.z);
93 template <
typename U,
typename T,
unsigned int rank,
94 typename std::enable_if<(rank == 4),
bool>::type = 0>
96 HIP_vector_type<T, rank> vec) {
97 HIP_vector_type<U, rank> out;
98 out.x =
static_cast<U
>(vec.x);
99 out.y =
static_cast<U
>(vec.y);
100 out.z =
static_cast<U
>(vec.z);
101 out.w =
static_cast<U
>(vec.w);
105 template <
typename T,
unsigned int rank,
106 typename std::enable_if<(rank == 1),
bool>::type = 0>
107 __host__ __device__
static HIP_vector_type<T, 4>
fill(
108 HIP_vector_type<T, rank> vec) {
109 HIP_vector_type<T, 4> out{vec.x, 0, 0, 0};
112 template <
typename T,
unsigned int rank,
113 typename std::enable_if<(rank == 2),
bool>::type = 0>
114 __host__ __device__
static HIP_vector_type<T, 4>
fill(
115 HIP_vector_type<T, rank> vec) {
116 HIP_vector_type<T, 4> out{vec.x, vec.y, 0, 0};
119 template <
typename T,
unsigned int rank,
120 typename std::enable_if<(rank == 3),
bool>::type = 0>
121 __host__ __device__
static HIP_vector_type<T, 4>
fill(
122 HIP_vector_type<T, rank> vec) {
123 HIP_vector_type<T, 4> out{vec.x, vec.y, vec.z, 0};
126 template <
typename T,
unsigned int rank,
127 typename std::enable_if<(rank == 4),
bool>::type = 0>
128 __host__ __device__
static HIP_vector_type<T, 4>
fill(
129 HIP_vector_type<T, rank> vec) {
130 HIP_vector_type<T, 4> out{vec.x, vec.y, vec.z, vec.w};
134 template <
typename T,
unsigned int rank,
135 typename std::enable_if<(rank == 1),
bool>::type = 0>
136 __host__ __device__
static void trunc(HIP_vector_type<T, 4> vec,
137 HIP_vector_type<T, rank> *dst) {
138 HIP_vector_type<T, rank> out{vec.x };
141 template <
typename T,
unsigned int rank,
142 typename std::enable_if<(rank == 2),
bool>::type = 0>
143 __host__ __device__
static void trunc(HIP_vector_type<T, 4> vec,
144 HIP_vector_type<T, rank> *dst) {
145 HIP_vector_type<T, rank> out{vec.x, vec.y };
148 template <
typename T,
unsigned int rank,
149 typename std::enable_if<(rank == 3),
bool>::type = 0>
150 __host__ __device__
static void trunc(HIP_vector_type<T, 4> vec,
151 HIP_vector_type<T, rank> *dst) {
152 HIP_vector_type<T, rank> out{vec.x, vec.y, vec.z };
155 template <
typename T,
unsigned int rank,
156 typename std::enable_if<(rank == 4),
bool>::type = 0>
157 __host__ __device__
static void trunc(HIP_vector_type<T, 4> vec,
158 HIP_vector_type<T, rank> *dst) {
159 HIP_vector_type<T, rank> out{vec.x, vec.y, vec.z, vec.w};
Definition: math_vector.hpp:29
__host__ static __device__ HIP_vector_type< T, 4 > fill(HIP_vector_type< T, rank > vec)
Definition: math_vector.hpp:107
__host__ static __device__ HIP_vector_type< U, rank > convert_base(HIP_vector_type< T, rank > vec)
Definition: math_vector.hpp:68
__host__ static __device__ HIP_vector_type< T, rank > pow(HIP_vector_type< T, rank > vec, double p)
Definition: math_vector.hpp:33
__host__ static __device__ void trunc(HIP_vector_type< T, 4 > vec, HIP_vector_type< T, rank > *dst)
Definition: math_vector.hpp:136