29 #ifndef VC_COMMON_VECTOR_H_
30 #define VC_COMMON_VECTOR_H_
33 #include "vectorabi.h"
34 #include "vectortraits.h"
35 #include "simdarrayfwd.h"
36 #include "loadstoreflags.h"
37 #include "writemaskedvector.h"
39 namespace Vc_VERSIONED_NAMESPACE
55 template<
typename T,
typename Abi = VectorAbi::Best<T>>
class Vector
75 static constexpr
size_t size() {
return VectorTraits<T, Abi>::size(); }
81 static constexpr
size_t MemoryAlignment = VectorTraits<T, Abi>::memoryAlignment();
87 using EntryType =
typename VectorTraits<T, Abi>::EntryType;
91 using VectorEntryType =
typename VectorTraits<T, Abi>::VectorEntryType;
95 using VectorType =
typename VectorTraits<T, Abi>::VectorType;
99 using vector_type = VectorType;
144 static inline Vector Random();
147 template <
typename G>
static inline Vector generate(G gen);
161 inline Vector() =
default;
168 explicit inline Vector(VectorSpecialInitializerZero);
175 explicit inline Vector(VectorSpecialInitializerOne);
182 explicit inline Vector(VectorSpecialInitializerIndexesFromZero);
190 template <
typename U>
192 enable_if<Traits::is_implicit_cast_allowed<U, T>::value> = nullarg);
204 template <
typename U>
207 enable_if<!Traits::is_implicit_cast_allowed<U, T>::value> = nullarg);
222 template <
typename U>
223 inline Vector(U a, enable_if<std::is_same<U, int>::value &&
224 !std::is_same<U, EntryType>::value> = nullarg);
230 #include "../common/loadinterface.h"
232 #include "../common/storeinterface.h"
238 inline void setZero();
256 inline void setZeroInverted(
MaskType mask);
261 inline void setQnan();
270 #define Vc_CURRENT_CLASS_NAME Vector
271 #include "../common/gatherinterface.h"
272 #include "../common/scatterinterface.h"
273 #undef Vc_CURRENT_CLASS_NAME
289 inline EntryType &operator[](
size_t index);
298 inline EntryType operator[](
size_t index)
const;
317 inline Vector operator~()
const;
320 inline Vector operator-()
const;
322 inline Vector operator+()
const;
335 inline Vector &operator++();
337 inline Vector operator++(
int);
338 inline Vector &operator--();
339 inline Vector operator--(
int);
342 #define Vc_OP(symbol) \
343 inline Vector &operator symbol##=(const Vector &x); \
344 inline Vc_PURE Vector operator symbol(const Vector &x) const;
370 Vc_ALL_ARITHMETICS(Vc_OP)
435 #define Vc_CMP_OP(symbol) inline Vc_PURE MaskType operator symbol(const Vector &x) const;
437 Vc_ALL_COMPARES(Vc_CMP_OP)
445 template <
typename V2>
inline V2 reinterpretCast()
const;
466 inline Common::WriteMaskedVector<Vector, MaskType> operator()(
MaskType mask);
493 inline Vector partialSum()
const;
573 inline Vector rotated(
int amount)
const;
575 inline Vector reversed()
const;
608 inline Vector sorted()
const;
641 template <
typename F>
void callWithValuesSorted(F &&f);
643 template <
typename F>
inline void call(F &&f)
const;
645 template <
typename F>
inline void call(F &&f,
MaskType mask)
const;
648 template <
typename F>
inline Vector apply(F &&f)
const;
650 template <
typename F>
inline Vector apply(F &&f,
MaskType mask)
const;
653 template <
typename IndexT>
inline void fill(
EntryType(&f)(IndexT));
659 inline Vector exponent()
const;
682 inline VectorType &data();
684 inline const VectorType &data()
const;
692 static constexpr
size_t Size = VectorTraits<T, Abi>::size();
701 template <
typename V2>
inline V2 staticCast()
const;
721 #endif // VC_COMMON_VECTOR_H_
static constexpr size_t size()
Returns the number of scalar components ( ) in a vector of this type.
The main vector class for expressing data parallelism.
constexpr VectorSpecialInitializerIndexesFromZero IndexesFromZero
The special object Vc::IndexesFromZero can be used to construct Vector objects initialized to values ...
Vc::Vector< T > min(const Vc::Vector< T > &x, const Vc::Vector< T > &y)
Vc::Vector< T > max(const Vc::Vector< T > &x, const Vc::Vector< T > &y)
Abi abi
The ABI tag type of the current template instantiation.
IndexType index_type
The type of the vector used for indexes in gather and scatter operations.
EntryType value_type
The type of the entries in the vector.
void assign(Adapter< S, T, N > &a, size_t i, const S &x)
Assigns one scalar object x to a SIMD slot at offset i in the simdized object a.
The main SIMD mask class.
constexpr VectorSpecialInitializerZero Zero
The special object Vc::Zero can be used to construct Vector and Mask objects initialized to zero/fals...
Adapter< S, T, N > shifted(const Adapter< S, T, N > &a, int shift)
Returns a new vectorized object where each entry is shifted by shift.
constexpr VectorSpecialInitializerOne One
The special object Vc::One can be used to construct Vector and Mask objects initialized to one/true...
constexpr std::size_t MemoryAlignment
Specifies the most conservative memory alignment necessary for aligned loads and stores of Vector typ...
typename VectorTraits< T, Abi >::EntryType EntryType
The type of the entries in the vector.
Vc::SimdArray< int, size()> IndexType
The type of the vector used for indexes in gather and scatter operations.