32 #define FN_SPECIFIERS inline __host__ __device__ 34 #define FN_SPECIFIERS inline 42 template <
class T,
int N>
48 template <
class... TInit>
52 for (
int i = 0; i < N; ++i)
operator[](i) = ptr[i];
62 for (
int i = 0; i < N; ++i) a[i] = T2(
operator[](i));
68 for (
int i = 0; i < N; ++i) result +=
operator[](i) * a[i];
74 for (
int i = 0; i < N; ++i) r[i] = std::abs(
operator[](i));
80 for (
int i = 0; i < N && result; ++i) result = result &&
operator[](i);
85 for (
int i = 0; i < N; ++i)
86 if (
operator[](i))
return true;
96 for (
int i = 0; i < N; ++i) r[i] = floorf(a[i]);
103 for (
int i = 0; i < N; ++i) r[i] =
std::floor(a[i]);
110 for (
int i = 0; i < N; ++i) r[i] = ceilf(a[i]);
117 for (
int i = 0; i < N; ++i) r[i] =
std::ceil(a[i]);
121 template <
class T,
int N>
124 for (
int i = 0; i < N; ++i) r[i] = -a[i];
128 template <
class T,
int N>
131 for (
int i = 0; i < N; ++i) r[i] = !a[i];
135 #define DEFINE_OPERATOR(op, opas) \ 136 template <class T, int N> \ 137 FN_SPECIFIERS MiniVec<T, N> operator op(const MiniVec<T, N>& a, \ 138 const MiniVec<T, N>& b) { \ 140 for (int i = 0; i < N; ++i) c[i] = a[i] op b[i]; \ 144 template <class T, int N> \ 145 FN_SPECIFIERS void operator opas(MiniVec<T, N>& a, \ 146 const MiniVec<T, N>& b) { \ 147 for (int i = 0; i < N; ++i) a[i] opas b[i]; \ 150 template <class T, int N> \ 151 FN_SPECIFIERS MiniVec<T, N> operator op(const MiniVec<T, N>& a, T b) { \ 153 for (int i = 0; i < N; ++i) c[i] = a[i] op b; \ 157 template <class T, int N> \ 158 FN_SPECIFIERS MiniVec<T, N> operator op(T a, const MiniVec<T, N>& b) { \ 160 for (int i = 0; i < N; ++i) c[i] = a op b[i]; \ 164 template <class T, int N> \ 165 FN_SPECIFIERS void operator opas(MiniVec<T, N>& a, T b) { \ 166 for (int i = 0; i < N; ++i) a[i] opas b; \ 173 #undef DEFINE_OPERATOR 175 #define DEFINE_OPERATOR(op) \ 176 template <class T, int N> \ 177 FN_SPECIFIERS MiniVec<bool, N> operator op(const MiniVec<T, N>& a, \ 178 const MiniVec<T, N>& b) { \ 179 MiniVec<bool, N> c; \ 180 for (int i = 0; i < N; ++i) c[i] = a[i] op b[i]; \ 184 template <class T, int N> \ 185 FN_SPECIFIERS MiniVec<bool, N> operator op(const MiniVec<T, N>& a, T b) { \ 187 for (int i = 0; i < N; ++i) c[i] = a[i] op b; \ 191 template <class T, int N> \ 192 FN_SPECIFIERS MiniVec<T, N> operator op(T a, const MiniVec<T, N>& b) { \ 193 MiniVec<bool, N> c; \ 194 for (int i = 0; i < N; ++i) c[i] = a op b[i]; \ 206 #undef DEFINE_OPERATOR T Scalar_t
Definition: MiniVec.h:44
FN_SPECIFIERS MiniVec(TInit... as)
Definition: MiniVec.h:49
FN_SPECIFIERS T & operator[](size_t i)
Definition: MiniVec.h:57
FN_SPECIFIERS const T operator[](size_t i) const
Definition: MiniVec.h:55
#define FN_SPECIFIERS
Definition: MiniVec.h:34
FN_SPECIFIERS MiniVec< T, N > operator!(const MiniVec< T, N > &a)
Definition: MiniVec.h:129
FN_SPECIFIERS MiniVec< double, N > floor(const MiniVec< double, N > &a)
Definition: MiniVec.h:101
FN_SPECIFIERS MiniVec< T, N > operator-(const MiniVec< T, N > &a)
Definition: MiniVec.h:122
FN_SPECIFIERS MiniVec< float, N > ceil(const MiniVec< float, N > &a)
Definition: MiniVec.h:108
FN_SPECIFIERS MiniVec< float, N > floor(const MiniVec< float, N > &a)
Definition: MiniVec.h:94
FN_SPECIFIERS MiniVec< T, N > abs() const
Definition: MiniVec.h:72
FN_SPECIFIERS bool all() const
Definition: MiniVec.h:78
FN_SPECIFIERS bool any() const
Definition: MiniVec.h:84
FN_SPECIFIERS T dot(const MiniVec< T, N > &a) const
Definition: MiniVec.h:66
Definition: PinholeCameraIntrinsic.cpp:35
#define DEFINE_OPERATOR(op, opas)
Definition: MiniVec.h:175
FN_SPECIFIERS MiniVec()
Definition: MiniVec.h:46
FN_SPECIFIERS MiniVec(const T *const ptr)
Definition: MiniVec.h:51
FN_SPECIFIERS MiniVec< double, N > ceil(const MiniVec< double, N > &a)
Definition: MiniVec.h:115
FN_SPECIFIERS MiniVec< T2, N > cast() const
Definition: MiniVec.h:60
T arr[N]
Definition: MiniVec.h:90