29 #ifndef VC_COMMON_VECTOR_H_
30 #define VC_COMMON_VECTOR_H_
34 #include "vectorabi.h"
35 #include "vectortraits.h"
36 #include "simdarrayfwd.h"
37 #include "loadstoreflags.h"
38 #include "writemaskedvector.h"
40 namespace Vc_VERSIONED_NAMESPACE
53 template <
typename T,
typename Abi,
54 typename = enable_if<std::is_floating_point<T>::value>>
90 template <
typename T,
typename Abi,
91 typename = enable_if<std::is_floating_point<T>::value>>
101 template <
typename T,
typename Abi>
121 template<
typename T,
typename Abi = VectorAbi::Best<T>>
class Vector
141 static constexpr
size_t size() {
return VectorTraits<T, Abi>::size(); }
153 using EntryType =
typename VectorTraits<T, Abi>::EntryType;
157 using VectorEntryType =
typename VectorTraits<T, Abi>::VectorEntryType;
161 using VectorType =
typename VectorTraits<T, Abi>::VectorType;
165 using vector_type = VectorType;
210 static inline Vector Random();
213 template <
typename G>
static inline Vector generate(G gen);
227 inline Vector() =
default;
234 explicit inline Vector(VectorSpecialInitializerZero);
241 explicit inline Vector(VectorSpecialInitializerOne);
248 explicit inline Vector(VectorSpecialInitializerIndexesFromZero);
256 template <
typename U>
258 enable_if<Traits::is_implicit_cast_allowed<U, T>::value> = nullarg);
270 template <
typename U>
273 enable_if<!Traits::is_implicit_cast_allowed<U, T>::value> = nullarg);
288 template <
typename U>
289 inline Vector(U a, enable_if<std::is_same<U, int>::value &&
290 !std::is_same<U, EntryType>::value> = nullarg);
296 #include "../common/loadinterface.h"
298 #include "../common/storeinterface.h"
304 inline void setZero();
322 inline void setZeroInverted(
MaskType mask);
327 inline void setQnan();
336 #define Vc_CURRENT_CLASS_NAME Vector
337 #include "../common/gatherinterface.h"
338 #include "../common/scatterinterface.h"
339 #undef Vc_CURRENT_CLASS_NAME
355 inline EntryType &operator[](
size_t index);
364 inline EntryType operator[](
size_t index)
const;
383 inline Vector operator~()
const;
386 inline Vector operator-()
const;
388 inline Vector operator+()
const;
401 inline Vector &operator++();
403 inline Vector operator++(
int);
404 inline Vector &operator--();
405 inline Vector operator--(
int);
408 #define Vc_OP(symbol) \
409 inline Vector &operator symbol##=(const Vector &x); \
410 inline Vc_PURE Vector operator symbol(const Vector &x) const;
436 Vc_ALL_ARITHMETICS(Vc_OP)
501 #define Vc_CMP_OP(symbol) inline Vc_PURE MaskType operator symbol(const Vector &x) const;
503 Vc_ALL_COMPARES(Vc_CMP_OP)
508 template <
typename V2>
inline V2 reinterpretCast()
const;
529 inline Common::WriteMaskedVector<Vector, MaskType> operator()(
MaskType mask);
556 inline Vector partialSum()
const;
636 inline Vector rotated(
int amount)
const;
638 inline Vector reversed()
const;
671 inline Vector sorted()
const;
704 template <
typename F>
void callWithValuesSorted(F &&f);
706 template <
typename F>
inline void call(F &&f)
const;
708 template <
typename F>
inline void call(F &&f,
MaskType mask)
const;
711 template <
typename F>
inline Vector apply(F &&f)
const;
713 template <
typename F>
inline Vector apply(F &&f,
MaskType mask)
const;
716 template <
typename IndexT>
inline void fill(
EntryType(&f)(IndexT));
742 inline VectorType &data();
744 inline const VectorType &data()
const;
751 inline Vc_DEPRECATED(
"use exponent(x) instead")
Vector exponent() const;
758 static constexpr
size_t Size = VectorTraits<T, Abi>::size();
767 template <typename V2> inline V2 staticCast() const;
779 inline Vc_DEPRECATED("use copysign(x, y) instead")
Vector
780 copySign(
Vector reference) const;
788 #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)
Data-parallel type with (somewhat) arbitrary number of components.
Abi abi
The ABI tag type of the current template instantiation.
Vector< T, Abi > exponent(Vector< T, Abi > x)
Extracts the exponent of each floating-point vector component.
Vector< T, Abi > copysign(Vector< T, Abi > magnitude, Vector< T, Abi > sign)
Copies the sign(s) of sign to the value(s) in magnitude and returns the resulting vector...
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.
Vector< T, Abi >::MaskType isnegative(Vector< T, Abi > x)
Returns for each vector component whether it stores a negative value.
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.