36#ifndef NEKTAR_LIB_LIBUTILITES_SIMDLIB_SCALAR_H
37#define NEKTAR_LIB_LIBUTILITES_SIMDLIB_SCALAR_H
52template <
typename scalarType>
struct scalar
63 typename std::enable_if<std::is_arithmetic<T>::value>::type>
101template <>
struct scalar<size_t>
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>
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;
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;
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;
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;
310 const T *in,
const size_t dataLen,
313 for (
size_t i = 0; i < dataLen; ++i)
323 for (
size_t i = 0; i < dataLen; ++i)
332 const size_t dataLen, T *out)
334 for (
size_t i = 0; i < dataLen; ++i)
336 out[i] = in[i]._data;
343 const size_t dataLen, T *out)
345 for (
size_t i = 0; i < dataLen; ++i)
347 out[i] = in[i]._data;
372 inline void store(std::uint32_t *
p)
const
374 *
p =
static_cast<std::uint32_t
>(
_data);
378 inline void load(
const std::uint32_t *
p)
380 _data =
static_cast<std::uint32_t
>(*p);
400 return lhs.
_data && rhs;
void load_interleave(const T *in, const size_t dataLen, std::vector< scalarT< T >, allocator< scalarT< T > > > &out)
scalarT< T > abs(scalarT< T > in)
void deinterleave_unalign_store(const std::vector< scalarT< T >, allocator< scalarT< T > > > &in, const size_t dataLen, T *out)
scalarT< T > operator-(scalarT< T > lhs, scalarT< T > rhs)
scalarT< T > operator/(scalarT< T > lhs, scalarT< T > rhs)
boost::alignment::aligned_allocator< T, T::alignment > allocator
scalarT< T > log(scalarT< T > in)
scalarT< T > operator*(scalarT< T > lhs, scalarT< T > rhs)
scalarMask operator>(scalarT< double > lhs, scalarT< double > rhs)
bool operator&&(scalarMask lhs, bool rhs)
void load_unalign_interleave(const T *in, const size_t dataLen, std::vector< scalarT< T >, allocator< scalarT< T > > > &out)
void deinterleave_store(const std::vector< scalarT< T >, allocator< scalarT< T > > > &in, const size_t dataLen, T *out)
scalarT< T > sqrt(scalarT< T > in)
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) const
void operator/=(scalarT< T > rhs)
scalarType[width] scalarArray
void load(const scalarType *p, flag)
void operator+=(scalarT< T > rhs)
scalarType & operator[](size_t)
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
scalarT & operator=(const scalarT &)=default
void scatter(scalarType *p, const scalarT< U > &indices) const