13 #define FN_SPECIFIERS inline __host__ __device__
15 #define FN_SPECIFIERS inline
23 template <
class T,
int N>
29 template <
class... TInit>
33 for (
int i = 0; i < N; ++i)
operator[](i) = ptr[i];
43 for (
int i = 0; i < N; ++i) a[i] = T2(
operator[](i));
49 for (
int i = 0; i < N; ++i)
result +=
operator[](i) * a[i];
55 for (
int i = 0; i < N; ++i) r[i] = std::abs(
operator[](i));
66 for (
int i = 0; i < N; ++i)
67 if (
operator[](i))
return true;
77 for (
int i = 0; i < N; ++i) r[i] = floorf(a[i]);
84 for (
int i = 0; i < N; ++i) r[i] =
std::floor(a[i]);
91 for (
int i = 0; i < N; ++i) r[i] = ceilf(a[i]);
98 for (
int i = 0; i < N; ++i) r[i] =
std::ceil(a[i]);
102 template <
class T,
int N>
105 for (
int i = 0; i < N; ++i) r[i] = -a[i];
109 template <
class T,
int N>
112 for (
int i = 0; i < N; ++i) r[i] = !a[i];
116 #define DEFINE_OPERATOR(op, opas) \
117 template <class T, int N> \
118 FN_SPECIFIERS MiniVec<T, N> operator op(const MiniVec<T, N>& a, \
119 const MiniVec<T, N>& b) { \
121 for (int i = 0; i < N; ++i) c[i] = a[i] op b[i]; \
125 template <class T, int N> \
126 FN_SPECIFIERS void operator opas(MiniVec<T, N>& a, \
127 const MiniVec<T, N>& b) { \
128 for (int i = 0; i < N; ++i) a[i] opas b[i]; \
131 template <class T, int N> \
132 FN_SPECIFIERS MiniVec<T, N> operator op(const MiniVec<T, N>& a, T b) { \
134 for (int i = 0; i < N; ++i) c[i] = a[i] op b; \
138 template <class T, int N> \
139 FN_SPECIFIERS MiniVec<T, N> operator op(T a, const MiniVec<T, N>& b) { \
141 for (int i = 0; i < N; ++i) c[i] = a op b[i]; \
145 template <class T, int N> \
146 FN_SPECIFIERS void operator opas(MiniVec<T, N>& a, T b) { \
147 for (int i = 0; i < N; ++i) a[i] opas b; \
154 #undef DEFINE_OPERATOR
156 #define DEFINE_OPERATOR(op) \
157 template <class T, int N> \
158 FN_SPECIFIERS MiniVec<bool, N> operator op(const MiniVec<T, N>& a, \
159 const MiniVec<T, N>& b) { \
160 MiniVec<bool, N> c; \
161 for (int i = 0; i < N; ++i) c[i] = a[i] op b[i]; \
165 template <class T, int N> \
166 FN_SPECIFIERS MiniVec<bool, N> operator op(const MiniVec<T, N>& a, T b) { \
168 for (int i = 0; i < N; ++i) c[i] = a[i] op b; \
172 template <class T, int N> \
173 FN_SPECIFIERS MiniVec<T, N> operator op(T a, const MiniVec<T, N>& b) { \
174 MiniVec<bool, N> c; \
175 for (int i = 0; i < N; ++i) c[i] = a op b[i]; \
187 #undef DEFINE_OPERATOR
#define DEFINE_OPERATOR(op, opas)
Definition: MiniVec.h:156
#define FN_SPECIFIERS
Definition: MiniVec.h:15
core::Tensor result
Definition: VtkUtils.cpp:75
FN_SPECIFIERS MiniVec< T, N > operator!(const MiniVec< T, N > &a)
Definition: MiniVec.h:110
FN_SPECIFIERS MiniVec< float, N > ceil(const MiniVec< float, N > &a)
Definition: MiniVec.h:89
FN_SPECIFIERS MiniVec< double, N > floor(const MiniVec< double, N > &a)
Definition: MiniVec.h:82
FN_SPECIFIERS MiniVec< double, N > ceil(const MiniVec< double, N > &a)
Definition: MiniVec.h:96
FN_SPECIFIERS MiniVec< float, N > floor(const MiniVec< float, N > &a)
Definition: MiniVec.h:75
FN_SPECIFIERS MiniVec< T, N > operator-(const MiniVec< T, N > &a)
Definition: MiniVec.h:103
Definition: PinholeCameraIntrinsic.cpp:16
FN_SPECIFIERS MiniVec(const T *const ptr)
Definition: MiniVec.h:32
FN_SPECIFIERS bool all() const
Definition: MiniVec.h:59
T arr[N]
Definition: MiniVec.h:71
FN_SPECIFIERS MiniVec()
Definition: MiniVec.h:27
T Scalar_t
Definition: MiniVec.h:25
FN_SPECIFIERS T dot(const MiniVec< T, N > &a) const
Definition: MiniVec.h:47
FN_SPECIFIERS MiniVec< T2, N > cast() const
Definition: MiniVec.h:41
FN_SPECIFIERS bool any() const
Definition: MiniVec.h:65
FN_SPECIFIERS MiniVec< T, N > abs() const
Definition: MiniVec.h:53
FN_SPECIFIERS MiniVec(TInit... as)
Definition: MiniVec.h:30
FN_SPECIFIERS T & operator[](size_t i)
Definition: MiniVec.h:38
FN_SPECIFIERS const T operator[](size_t i) const
Definition: MiniVec.h:36