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;
156 template <
typename U,
typename =
typename std::enable_if<
157 std::is_integral<U>::value>::type>
163 template <
typename U,
typename =
typename std::enable_if<
164 std::is_integral<U>::value>::type>
211 template <
typename T>
217 typename T,
typename U,
218 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
221 return lhs + rhs.
_data;
224 typename T,
typename U,
225 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
228 return lhs.
_data + rhs;
231 template <
typename T>
237 typename T,
typename U,
238 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
241 return lhs - rhs.
_data;
244 typename T,
typename U,
245 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
248 return lhs.
_data - rhs;
251 template <
typename T>
257 typename T,
typename U,
258 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
261 return lhs * rhs.
_data;
264 typename T,
typename U,
265 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
268 return lhs.
_data * rhs;
271 template <
typename T>
277 typename T,
typename U,
278 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
281 return lhs / rhs.
_data;
284 typename T,
typename U,
285 typename =
typename std::enable_if<std::is_arithmetic<U>::value>::type>
288 return lhs.
_data / rhs;
305 template <
typename T>
309 for (
size_t i = 0; i < dataLen; ++i)
315 template <
typename T>
320 for (
size_t i = 0; i < dataLen; ++i)
322 out[i] = in[i]._data;
347 inline void store(std::uint32_t *
p)
const
349 *
p =
static_cast<std::uint32_t
>(
_data);
353 inline void load(
const std::uint32_t *
p)
355 _data =
static_cast<std::uint32_t
>(*p);
375 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(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