28 #ifndef VC_COMMON_VECTOR_H_ 29 #define VC_COMMON_VECTOR_H_ 32 #include "elementreference.h" 34 #include "vectorabi.h" 35 #include "vectortraits.h" 36 #include "simdarrayfwd.h" 37 #include "loadstoreflags.h" 38 #include "writemaskedvector.h" 41 namespace Vc_VERSIONED_NAMESPACE
54 template <
typename T,
typename Abi,
55 typename = enable_if<std::is_floating_point<T>::value &&
56 !detail::is_fixed_size_abi<Abi>::value>>
92 template <
typename T,
typename Abi,
93 typename = enable_if<std::is_floating_point<T>::value &&
94 !detail::is_fixed_size_abi<Abi>::value>>
104 template <
typename T,
typename Abi>
125 template<
typename T,
typename Abi = VectorAbi::Best<T>>
class Vector 142 static constexpr
size_t size() {
return VectorTraits<T, Abi>::size(); }
154 using EntryType =
typename VectorTraits<T, Abi>::EntryType;
158 using VectorEntryType =
typename VectorTraits<T, Abi>::VectorEntryType;
162 using VectorType =
typename VectorTraits<T, Abi>::VectorType;
166 using vector_type = VectorType;
181 using reference = Detail::ElementReference<Vector>;
213 static inline Vector Random();
216 template <
typename G>
static inline Vector generate(G gen);
230 inline Vector() =
default;
237 explicit inline Vector(VectorSpecialInitializerZero);
244 explicit inline Vector(VectorSpecialInitializerOne);
251 explicit inline Vector(VectorSpecialInitializerIndexesFromZero);
259 template <
typename U>
261 enable_if<Traits::is_implicit_cast_allowed<U, T>::value> = nullarg);
274 template <
typename U>
275 Vc_DEPRECATED(
"use simd_cast instead of explicit type casting to convert between " 276 "vector types") inline explicit
Vector(
278 enable_if<!Traits::is_implicit_cast_allowed<U, T>::value> = nullarg);
289 template <
typename U>
290 inline Vector(U a, enable_if<std::is_same<U, int>::value &&
291 !std::is_same<U, EntryType>::value> = nullarg);
297 #include "../common/loadinterface.h" 299 #include "../common/storeinterface.h" 305 inline void setZero();
323 inline void setZeroInverted(
MaskType mask);
328 inline void setQnan();
337 #define Vc_CURRENT_CLASS_NAME Vector 338 #include "../common/gatherinterface.h" 339 #include "../common/scatterinterface.h" 340 #undef Vc_CURRENT_CLASS_NAME 360 inline reference operator[](
size_t index) noexcept;
369 inline EntryType operator[](
size_t index)
const noexcept;
388 inline Vector operator~()
const;
406 inline Vector &operator++();
408 inline Vector operator++(
int);
409 inline Vector &operator--();
410 inline Vector operator--(
int);
413 #define Vc_OP(symbol) \ 414 inline Vc_PURE Vector operator symbol(const Vector &x) const; 440 Vc_ALL_ARITHMETICS(Vc_OP);
462 Vc_ALL_BINARY(Vc_OP);
483 Vc_ALL_SHIFTS(Vc_OP);
505 #define Vc_CMP_OP(symbol) inline Vc_PURE MaskType operator symbol(const Vector &x) const; 507 Vc_ALL_COMPARES(Vc_CMP_OP);
530 inline Common::WriteMaskedVector<Vector, MaskType> operator()(
MaskType mask);
557 inline Vector partialSum()
const;
637 inline Vector rotated(
int amount)
const;
639 inline Vector reversed()
const;
672 inline Vector sorted()
const;
705 template <
typename F>
void callWithValuesSorted(F &&f);
707 template <
typename F>
inline void call(F &&f)
const;
709 template <
typename F>
inline void call(F &&f,
MaskType mask)
const;
712 template <
typename F>
inline Vector apply(F &&f)
const;
714 template <
typename F>
inline Vector apply(F &&f,
MaskType mask)
const;
717 template <
typename IndexT>
inline void fill(
EntryType(&f)(IndexT));
743 inline VectorType &data();
745 inline const VectorType &data()
const;
758 Vc_DEPRECATED(
"use exponent(x) instead") inline
Vector exponent() const;
771 static constexpr
size_t Size = VectorTraits<T, Abi>::size();
780 template <typename V2> inline V2 staticCast() const;
789 template <typename V2>
791 reinterpretCast() const;
803 Vc_DEPRECATED("use copysign(x, y) instead") inline
Vector 804 copySign(
Vector reference) const;
807 Vc_FREE_STORE_OPERATORS_ALIGNED(alignof(
Vector));
831 template <typename V, typename T, typename Abi>
832 Vc_ALWAYS_INLINE Vc_CONST enable_if<
833 (V::size() == Vector<T, Abi>::size() &&
834 sizeof(typename V::VectorEntryType) ==
835 sizeof(typename Vector<T, Abi>::VectorEntryType) &&
836 sizeof(V) == sizeof(Vector<T, Abi>) && alignof(V) <= alignof(Vector<T, Abi>)),
840 return reinterpret_cast<const V &
>(x);
843 #define Vc_OP(symbol) \ 844 template <typename T, typename Abi> \ 845 inline Vector<T, Abi> &operator symbol##=(Vector<T, Abi> &, \ 846 const Vector<T, Abi> &x); 854 #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)
result_vector_type< L, R > operator-(L &&lhs, R &&rhs)
Applies - component-wise and concurrently.
Vc::Vector< T > max(const Vc::Vector< T > &x, const Vc::Vector< T > &y)
Vector< T, detail::not_fixed_size_abi< Abi > >::MaskType isnegative(Vector< T, Abi > x)
Returns for each vector component whether it stores a negative value.
Abi abi
The ABI tag type of the current template instantiation.
void assign(SimdizeDetail::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 > exponent(Vector< T, Abi > x)
Extracts the exponent of each floating-point vector component.
enable_if<(V::size()==Vector< T, Abi >::size() &&sizeof(typename V::VectorEntryType)==sizeof(typename Vector< T, Abi >::VectorEntryType) &&sizeof(V)==sizeof(Vector< T, Abi >) &&alignof(V)<=alignof(Vector< T, Abi >)), V > reinterpret_components_cast(const Vector< T, Abi > &x)
Constructs a new Vector object of type V from the Vector x, reinterpreting the bits of x for the new ...
result_vector_type< L, R > operator+(L &&lhs, R &&rhs)
Applies + component-wise and concurrently.
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.
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.