36 #ifndef NEKTAR_LIB_LIBUTILITES_SIMDLIB_SCALAR_H
37 #define NEKTAR_LIB_LIBUTILITES_SIMDLIB_SCALAR_H
43 #include <type_traits>
52 template <
typename scalarType>
struct scalar
63 typename std::enable_if<std::is_arithmetic<T>::value>::type>
79 template <>
struct scalar<std::int64_t>
83 template <>
struct scalar<std::uint64_t>
87 template <>
struct scalar<std::int32_t>
91 template <>
struct scalar<std::uint32_t>
101 template <>
struct scalar<size_t>
110 template <
typename T,
typename>
struct scalarT
112 static constexpr
unsigned int width = 1;
159 template <
typename U,
typename =
typename std::enable_if<
160 std::is_integral<U>::value>::type>
166 template <
typename U,
typename =
typename std::enable_if<
167 std::is_integral<U>::value>::type>
214 template <
typename T>
220 typename T,
typename U,
221 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
224 return lhs + rhs.
_data;
227 typename T,
typename U,
228 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
231 return lhs.
_data + rhs;
234 template <
typename T>
240 typename T,
typename U,
241 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
244 return lhs - rhs.
_data;
247 typename T,
typename U,
248 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
251 return lhs.
_data - rhs;
254 template <
typename T>
260 typename T,
typename U,
261 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
264 return lhs * rhs.
_data;
267 typename T,
typename U,
268 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
271 return lhs.
_data * rhs;
274 template <
typename T>
280 typename T,
typename U,
281 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
284 return lhs / rhs.
_data;
287 typename T,
typename U,
288 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
291 return lhs.
_data / rhs;
308 template <
typename T>
312 for (
size_t i = 0; i < dataLen; ++i)
318 template <
typename T>
323 for (
size_t i = 0; i < dataLen; ++i)
325 out[i] = in[i]._data;
350 inline void store(std::uint32_t *
p)
const
352 *
p =
static_cast<std::uint32_t
>(
_data);
356 inline void load(
const std::uint32_t *
p)
358 _data =
static_cast<std::uint32_t
>(*p);
378 return lhs.
_data && rhs;
scalarT< T > log(scalarT< T > in)
scalarT< T > operator+(scalarT< T > lhs, scalarT< T > rhs)
void deinterleave_store(const std::vector< scalarT< T >, allocator< scalarT< T >>> &in, size_t dataLen, T *out)
scalarT< T > operator-(scalarT< T > lhs, scalarT< T > rhs)
scalarT< T > abs(scalarT< T > in)
boost::alignment::aligned_allocator< T, T::alignment > allocator
scalarMask operator>(scalarT< double > lhs, scalarT< double > rhs)
void load_interleave(const T *in, size_t dataLen, std::vector< scalarT< T >, allocator< scalarT< T >>> &out)
bool operator&&(scalarMask lhs, bool rhs)
scalarT< T > sqrt(scalarT< T > in)
scalarT< T > operator/(scalarT< T > lhs, scalarT< T > rhs)
scalarT< T > operator*(scalarT< T > lhs, scalarT< T > rhs)
static constexpr scalarType false_v
void load(const std::uint32_t *p)
void store(std::uint32_t *p) const
static constexpr scalarType true_v
void store(scalarType *p) const
scalarT(const scalarT &rhs)=default
void gather(const scalarType *p, const scalarT< U > &indices)
static constexpr unsigned int alignment
void broadcast(const scalarType rhs)
scalarType & operator[](size_t)
scalarType operator[](size_t) const
void operator/=(scalarT< T > rhs)
scalarType[width] scalarArray
void load(const scalarType *p, flag)
void operator+=(scalarT< T > rhs)
scalarT & operator=(const scalarT &)=default
scalarT(const vectorType &rhs)
static constexpr unsigned int width
void fma(const scalarT< T > &a, const scalarT< T > &b)
void operator-=(scalarT< T > rhs)
void load(const scalarType *p)
void operator*=(scalarT< T > rhs)
void store(scalarType *p, flag) const
void scatter(scalarType *p, const scalarT< U > &indices) const