ROOT  6.06/09
Reference Guide
vector.h
Go to the documentation of this file.
1 /* This file is part of the Vc library.
2 
3  Copyright (C) 2009-2012 Matthias Kretz <kretz@kde.org>
4 
5  Vc is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as
7  published by the Free Software Foundation, either version 3 of
8  the License, or (at your option) any later version.
9 
10  Vc is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with Vc. If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 
20 #ifndef SSE_VECTOR_H
21 #define SSE_VECTOR_H
22 
23 #include "intrinsics.h"
24 #include "types.h"
25 #include "vectorhelper.h"
26 #include "mask.h"
27 #include "../common/aliasingentryhelper.h"
28 #include "../common/memoryfwd.h"
29 #include <algorithm>
30 #include <cmath>
31 
32 #include "macros.h"
33 
34 #ifdef isfinite
35 #undef isfinite
36 #endif
37 #ifdef isnan
38 #undef isnan
39 #endif
40 
41 namespace ROOT {
42 namespace Vc
43 {
44 namespace SSE
45 {
46 template<typename T>
47 class WriteMaskedVector
48 {
49  friend class Vector<T>;
50  typedef typename VectorTraits<T>::MaskType Mask;
51  typedef typename Vector<T>::EntryType EntryType;
52  public:
54  //prefix
55  Vc_INTRINSIC Vector<T> &operator++() {
56  vec->data() = VectorHelper<T>::add(vec->data(),
58  );
59  return *vec;
60  }
62  vec->data() = VectorHelper<T>::sub(vec->data(),
64  );
65  return *vec;
66  }
67  //postfix
69  Vector<T> ret(*vec);
70  vec->data() = VectorHelper<T>::add(vec->data(),
72  );
73  return ret;
74  }
76  Vector<T> ret(*vec);
77  vec->data() = VectorHelper<T>::sub(vec->data(),
79  );
80  return ret;
81  }
82 
84  vec->data() = VectorHelper<T>::add(vec->data(), VectorHelper<T>::notMaskedToZero(x.data(), mask.data()));
85  return *vec;
86  }
88  vec->data() = VectorHelper<T>::sub(vec->data(), VectorHelper<T>::notMaskedToZero(x.data(), mask.data()));
89  return *vec;
90  }
92  vec->assign(VectorHelper<T>::mul(vec->data(), x.data()), mask);
93  return *vec;
94  }
96 
98  return operator+=(Vector<T>(x));
99  }
101  return operator-=(Vector<T>(x));
102  }
104  return operator*=(Vector<T>(x));
105  }
107  return operator/=(Vector<T>(x));
108  }
109 
111  vec->assign(x, mask);
112  return *vec;
113  }
114 
116  vec->assign(Vector<T>(x), mask);
117  return *vec;
118  }
119 
120  template<typename F> Vc_INTRINSIC void call(const F &f) const {
121  return vec->call(f, mask);
122  }
123  template<typename F> Vc_INTRINSIC void call(F &f) const {
124  return vec->call(f, mask);
125  }
126  template<typename F> Vc_INTRINSIC Vector<T> apply(const F &f) const {
127  return vec->apply(f, mask);
128  }
129  template<typename F> Vc_INTRINSIC Vector<T> apply(F &f) const {
130  return vec->apply(f, mask);
131  }
132 
133  private:
134  Vc_ALWAYS_INLINE WriteMaskedVector(Vector<T> *v, const Mask &k) : vec(v), mask(k) {}
135  Vector<T> *const vec;
136  Mask mask;
137 };
138 
139 template<typename T> class Vector
140 {
141  friend class WriteMaskedVector<T>;
142  protected:
143 #ifdef VC_COMPILE_BENCHMARKS
144  public:
145 #endif
147  StorageType d;
151  public:
153 
158  typedef typename VectorTraits<T>::MaskType Mask;
159  typedef typename Mask::Argument MaskArg;
160  typedef Vc::Memory<Vector<T>, Size> Memory;
161 #ifdef VC_PASSING_VECTOR_BY_VALUE_IS_BROKEN
162  typedef const Vector<T> &AsArg;
163 #else
164  typedef const Vector<T> AsArg;
165 #endif
166 
167  typedef T _T;
168 
169  ///////////////////////////////////////////////////////////////////////////////////////////
170  // uninitialized
172 
173  ///////////////////////////////////////////////////////////////////////////////////////////
174  // constants
176  explicit Vc_INTRINSIC_L Vector(VectorSpecialInitializerOne::OEnum) Vc_INTRINSIC_R;
177  explicit Vc_INTRINSIC_L Vector(VectorSpecialInitializerIndexesFromZero::IEnum) Vc_INTRINSIC_R;
178  static Vc_INTRINSIC_L Vector Zero() Vc_INTRINSIC_R;
179  static Vc_INTRINSIC_L Vector One() Vc_INTRINSIC_R;
180  static Vc_INTRINSIC_L Vector IndexesFromZero() Vc_INTRINSIC_R;
181  static Vc_INTRINSIC_L Vector Random() Vc_INTRINSIC_R;
182 
183  ///////////////////////////////////////////////////////////////////////////////////////////
184  // internal: required to enable returning objects of VectorType
185  Vc_ALWAYS_INLINE Vector(const VectorType &x) : d(x) {}
186 
187  ///////////////////////////////////////////////////////////////////////////////////////////
188  // static_cast / copy ctor
189  template<typename OtherT> explicit Vc_INTRINSIC_L Vector(const Vector<OtherT> &x) Vc_INTRINSIC_R;
190 
191  // implicit cast
192  template<typename OtherT> Vc_INTRINSIC_L Vector &operator=(const Vector<OtherT> &x) Vc_INTRINSIC_R;
193 
194  // copy assignment
195  Vc_ALWAYS_INLINE Vector &operator=(AsArg v) { d.v() = v.d.v(); return *this; }
196 
197  ///////////////////////////////////////////////////////////////////////////////////////////
198  // broadcast
199  explicit Vc_INTRINSIC_L Vector(EntryType a) Vc_INTRINSIC_R;
200  template<typename TT> Vc_INTRINSIC Vector(TT x, VC_EXACT_TYPE(TT, EntryType, void *) = 0) : d(HT::set(x)) {}
201  static Vc_INTRINSIC Vector broadcast4(const EntryType *x) { return Vector<T>(x); }
202  Vc_ALWAYS_INLINE Vector &operator=(EntryType a) { d.v() = HT::set(a); return *this; }
203 
204  ///////////////////////////////////////////////////////////////////////////////////////////
205  // load ctors
206  explicit Vc_INTRINSIC_L
207  Vector(const EntryType *x) Vc_INTRINSIC_R;
208  template<typename Alignment> Vc_INTRINSIC_L
209  Vector(const EntryType *x, Alignment align) Vc_INTRINSIC_R;
210  template<typename OtherT> explicit Vc_INTRINSIC_L
211  Vector(const OtherT *x) Vc_INTRINSIC_R;
212  template<typename OtherT, typename Alignment> Vc_INTRINSIC_L
213  Vector(const OtherT *x, Alignment align) Vc_INTRINSIC_R;
214 
215  ///////////////////////////////////////////////////////////////////////////////////////////
216  // load member functions
218  void load(const EntryType *mem) Vc_INTRINSIC_R;
219  template<typename Alignment> Vc_INTRINSIC_L
220  void load(const EntryType *mem, Alignment align) Vc_INTRINSIC_R;
221  template<typename OtherT> Vc_INTRINSIC_L
222  void load(const OtherT *mem) Vc_INTRINSIC_R;
223  template<typename OtherT, typename Alignment> Vc_INTRINSIC_L
224  void load(const OtherT *mem, Alignment align) Vc_INTRINSIC_R;
225 
226  ///////////////////////////////////////////////////////////////////////////////////////////
227  // expand 1 float_v to 2 double_v XXX rationale? remove it for release? XXX
228  explicit Vc_INTRINSIC_L Vector(const Vector<typename CtorTypeHelper<T>::Type> *a) Vc_INTRINSIC_R;
229  inline void expand(Vector<typename ExpandTypeHelper<T>::Type> *x) const;
230 
231  ///////////////////////////////////////////////////////////////////////////////////////////
232  // zeroing
233  Vc_INTRINSIC_L void setZero() Vc_INTRINSIC_R;
234  Vc_INTRINSIC_L void setZero(const Mask &k) Vc_INTRINSIC_R;
235 
236  Vc_INTRINSIC_L void setQnan() Vc_INTRINSIC_R;
237  Vc_INTRINSIC_L void setQnan(typename Mask::Argument k) Vc_INTRINSIC_R;
238 
239  ///////////////////////////////////////////////////////////////////////////////////////////
240  // stores
241  Vc_INTRINSIC_L void store(EntryType *mem) const Vc_INTRINSIC_R;
242  Vc_INTRINSIC_L void store(EntryType *mem, const Mask &mask) const Vc_INTRINSIC_R;
243  template<typename A> Vc_INTRINSIC_L void store(EntryType *mem, A align) const Vc_INTRINSIC_R;
244  template<typename A> Vc_INTRINSIC_L void store(EntryType *mem, const Mask &mask, A align) const Vc_INTRINSIC_R;
245 
246  ///////////////////////////////////////////////////////////////////////////////////////////
247  // swizzles
248  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> &abcd() const Vc_INTRINSIC_R Vc_PURE_R;
249  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> cdab() const Vc_INTRINSIC_R Vc_PURE_R;
250  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> badc() const Vc_INTRINSIC_R Vc_PURE_R;
251  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> aaaa() const Vc_INTRINSIC_R Vc_PURE_R;
252  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> bbbb() const Vc_INTRINSIC_R Vc_PURE_R;
253  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> cccc() const Vc_INTRINSIC_R Vc_PURE_R;
254  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> dddd() const Vc_INTRINSIC_R Vc_PURE_R;
255  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> bcad() const Vc_INTRINSIC_R Vc_PURE_R;
256  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> bcda() const Vc_INTRINSIC_R Vc_PURE_R;
257  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> dabc() const Vc_INTRINSIC_R Vc_PURE_R;
258  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> acbd() const Vc_INTRINSIC_R Vc_PURE_R;
259  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> dbca() const Vc_INTRINSIC_R Vc_PURE_R;
260  Vc_INTRINSIC_L Vc_PURE_L const Vector<T> dcba() const Vc_INTRINSIC_R Vc_PURE_R;
261 
262  ///////////////////////////////////////////////////////////////////////////////////////////
263  // gathers
264  template<typename IndexT> Vector(const EntryType *mem, const IndexT *indexes);
265  template<typename IndexT> Vector(const EntryType *mem, VC_ALIGNED_PARAMETER(Vector<IndexT>) indexes);
266  template<typename IndexT> Vector(const EntryType *mem, const IndexT *indexes, MaskArg mask);
267  template<typename IndexT> Vector(const EntryType *mem, VC_ALIGNED_PARAMETER(Vector<IndexT>) indexes, MaskArg mask);
268  template<typename S1, typename IT> Vector(const S1 *array, const EntryType S1::* member1, VC_ALIGNED_PARAMETER(IT) indexes);
269  template<typename S1, typename IT> Vector(const S1 *array, const EntryType S1::* member1, VC_ALIGNED_PARAMETER(IT) indexes, MaskArg mask);
270  template<typename S1, typename S2, typename IT> Vector(const S1 *array, const S2 S1::* member1, const EntryType S2::* member2, VC_ALIGNED_PARAMETER(IT) indexes);
271  template<typename S1, typename S2, typename IT> Vector(const S1 *array, const S2 S1::* member1, const EntryType S2::* member2, VC_ALIGNED_PARAMETER(IT) indexes, MaskArg mask);
272  template<typename S1, typename IT1, typename IT2> Vector(const S1 *array, const EntryType *const S1::* ptrMember1, VC_ALIGNED_PARAMETER(IT1) outerIndexes, VC_ALIGNED_PARAMETER(IT2) innerIndexes);
273  template<typename S1, typename IT1, typename IT2> Vector(const S1 *array, const EntryType *const S1::* ptrMember1, VC_ALIGNED_PARAMETER(IT1) outerIndexes, VC_ALIGNED_PARAMETER(IT2) innerIndexes, MaskArg mask);
274  template<typename Index> void gather(const EntryType *mem, VC_ALIGNED_PARAMETER(Index) indexes);
275  template<typename Index> void gather(const EntryType *mem, VC_ALIGNED_PARAMETER(Index) indexes, MaskArg mask);
276 #ifdef VC_USE_SET_GATHERS
277  template<typename IT> void gather(const EntryType *mem, VC_ALIGNED_PARAMETER(Vector<IT>) indexes, MaskArg mask);
278 #endif
279  template<typename S1, typename IT> void gather(const S1 *array, const EntryType S1::* member1, VC_ALIGNED_PARAMETER(IT) indexes);
280  template<typename S1, typename IT> void gather(const S1 *array, const EntryType S1::* member1, VC_ALIGNED_PARAMETER(IT) indexes, MaskArg mask);
281  template<typename S1, typename S2, typename IT> void gather(const S1 *array, const S2 S1::* member1, const EntryType S2::* member2, VC_ALIGNED_PARAMETER(IT) indexes);
282  template<typename S1, typename S2, typename IT> void gather(const S1 *array, const S2 S1::* member1, const EntryType S2::* member2, VC_ALIGNED_PARAMETER(IT) indexes, MaskArg mask);
283  template<typename S1, typename IT1, typename IT2> void gather(const S1 *array, const EntryType *const S1::* ptrMember1, VC_ALIGNED_PARAMETER(IT1) outerIndexes, VC_ALIGNED_PARAMETER(IT2) innerIndexes);
284  template<typename S1, typename IT1, typename IT2> void gather(const S1 *array, const EntryType *const S1::* ptrMember1, VC_ALIGNED_PARAMETER(IT1) outerIndexes, VC_ALIGNED_PARAMETER(IT2) innerIndexes, MaskArg mask);
285 
286  ///////////////////////////////////////////////////////////////////////////////////////////
287  // scatters
288  template<typename Index> void scatter(EntryType *mem, VC_ALIGNED_PARAMETER(Index) indexes) const;
289  template<typename Index> void scatter(EntryType *mem, VC_ALIGNED_PARAMETER(Index) indexes, MaskArg mask) const;
290  template<typename S1, typename IT> void scatter(S1 *array, EntryType S1::* member1, VC_ALIGNED_PARAMETER(IT) indexes) const;
291  template<typename S1, typename IT> void scatter(S1 *array, EntryType S1::* member1, VC_ALIGNED_PARAMETER(IT) indexes, MaskArg mask) const;
292  template<typename S1, typename S2, typename IT> void scatter(S1 *array, S2 S1::* member1, EntryType S2::* member2, VC_ALIGNED_PARAMETER(IT) indexes) const;
293  template<typename S1, typename S2, typename IT> void scatter(S1 *array, S2 S1::* member1, EntryType S2::* member2, VC_ALIGNED_PARAMETER(IT) indexes, MaskArg mask) const;
294  template<typename S1, typename IT1, typename IT2> void scatter(S1 *array, EntryType *S1::* ptrMember1, VC_ALIGNED_PARAMETER(IT1) outerIndexes, VC_ALIGNED_PARAMETER(IT2) innerIndexes) const;
295  template<typename S1, typename IT1, typename IT2> void scatter(S1 *array, EntryType *S1::* ptrMember1, VC_ALIGNED_PARAMETER(IT1) outerIndexes, VC_ALIGNED_PARAMETER(IT2) innerIndexes, MaskArg mask) const;
296 
297  //prefix
300  //postfix
303 
305 #if defined(VC_GCC) && VC_GCC >= 0x40300 && VC_GCC < 0x40400
307 #endif
308  return d.m(index);
309  }
310  Vc_INTRINSIC_L EntryType operator[](size_t index) const Vc_PURE Vc_INTRINSIC_R;
311 
314  Vc_INTRINSIC Vector Vc_PURE operator+() const { return *this; }
315 
316 #define OP(symbol, fun) \
317  Vc_INTRINSIC Vector &operator symbol##=(const Vector<T> &x) { data() = VectorHelper<T>::fun(data(), x.data()); return *this; } \
318  Vc_INTRINSIC Vector &operator symbol##=(EntryType x) { return operator symbol##=(Vector<T>(x)); } \
319  Vc_INTRINSIC Vector Vc_PURE operator symbol(const Vector<T> &x) const { return HT::fun(data(), x.data()); } \
320  template<typename TT> Vc_INTRINSIC VC_EXACT_TYPE(TT, EntryType, Vector) Vc_PURE operator symbol(TT x) const { return operator symbol(Vector(x)); }
321 
322  OP(+, add)
323  OP(-, sub)
324  OP(*, mul)
325 #undef OP
326 
328  Vc_INTRINSIC_L Vector operator<< (AsArg shift) const Vc_INTRINSIC_R;
332  Vc_INTRINSIC_L Vector operator>> (AsArg shift) const Vc_INTRINSIC_R;
335 
339  template<typename TT> Vc_INTRINSIC_L VC_EXACT_TYPE(TT, typename DetermineEntryType<T>::Type, Vector<T>) operator/(TT x) const Vc_PURE Vc_INTRINSIC_R;
340 
341 #define OP(symbol, fun) \
342  Vc_INTRINSIC_L Vector &operator symbol##=(const Vector<T> &x) Vc_INTRINSIC_R; \
343  Vc_INTRINSIC_L Vector operator symbol(const Vector<T> &x) const Vc_PURE Vc_INTRINSIC_R; \
344  Vc_INTRINSIC Vector &operator symbol##=(EntryType x) { return operator symbol##=(Vector(x)); } \
345  template<typename TT> Vc_INTRINSIC VC_EXACT_TYPE(TT, EntryType, Vector) Vc_PURE operator symbol(TT x) const { return operator symbol(Vector(x)); }
346  OP(|, or_)
347  OP(&, and_)
348  OP(^, xor_)
349 #undef OP
350 #define OPcmp(symbol, fun) \
351  Vc_INTRINSIC Mask Vc_PURE operator symbol(const Vector<T> &x) const { return VectorHelper<T>::fun(data(), x.data()); } \
352  template<typename TT> Vc_INTRINSIC VC_EXACT_TYPE(TT, EntryType, Mask) Vc_PURE operator symbol(TT x) const { return operator symbol(Vector(x)); }
353 
354  OPcmp(==, cmpeq)
355  OPcmp(!=, cmpneq)
356  OPcmp(>=, cmpnlt)
357  OPcmp(>, cmpnle)
358  OPcmp(<, cmplt)
359  OPcmp(<=, cmple)
360 #undef OPcmp
361  Vc_INTRINSIC_L Vc_PURE_L Mask isNegative() const Vc_PURE_R Vc_INTRINSIC_R;
362 
363  Vc_ALWAYS_INLINE void fusedMultiplyAdd(const Vector<T> &factor, const Vector<T> &summand) {
364  VectorHelper<T>::fma(data(), factor.data(), summand.data());
365  }
366 
367  Vc_ALWAYS_INLINE void assign( const Vector<T> &v, const Mask &mask ) {
368  const VectorType k = mm128_reinterpret_cast<VectorType>(mask.data());
370  }
371 
373  template<typename V2> Vc_ALWAYS_INLINE Vc_PURE V2 reinterpretCast() const { return mm128_reinterpret_cast<typename V2::VectorType>(data()); }
374 
376 
377  /**
378  * \return \p true This vector was completely filled. m2 might be 0 or != 0. You still have
379  * to test this.
380  * \p false This vector was not completely filled. m2 is all 0.
381  */
382  //inline bool pack(Mask &m1, Vector<T> &v2, Mask &m2) {
383  //return VectorHelper<T>::pack(data(), m1.data, v2.data(), m2.data);
384  //}
385 
386  Vc_ALWAYS_INLINE Vc_PURE VectorType &data() { return d.v(); }
387  Vc_ALWAYS_INLINE Vc_PURE const VectorType &data() const { return d.v(); }
388 
389  Vc_INTRINSIC EntryType min() const { return VectorHelper<T>::min(data()); }
390  Vc_INTRINSIC EntryType max() const { return VectorHelper<T>::max(data()); }
391  Vc_INTRINSIC EntryType product() const { return VectorHelper<T>::mul(data()); }
392  Vc_INTRINSIC EntryType sum() const { return VectorHelper<T>::add(data()); }
393  Vc_INTRINSIC_L EntryType min(MaskArg m) const Vc_INTRINSIC_R;
394  Vc_INTRINSIC_L EntryType max(MaskArg m) const Vc_INTRINSIC_R;
395  Vc_INTRINSIC_L EntryType product(MaskArg m) const Vc_INTRINSIC_R;
396  Vc_INTRINSIC_L EntryType sum(MaskArg m) const Vc_INTRINSIC_R;
397 
398  Vc_INTRINSIC_L Vector shifted(int amount) const Vc_INTRINSIC_R;
399  Vc_INTRINSIC_L Vector rotated(int amount) const Vc_INTRINSIC_R;
401 
402  template<typename F> void callWithValuesSorted(F &f) {
403  EntryType value = d.m(0);
404  f(value);
405  for (int i = 1; i < Size; ++i) {
406  if (d.m(i) != value) {
407  value = d.m(i);
408  f(value);
409  }
410  }
411  }
412 
413  template<typename F> Vc_INTRINSIC void call(const F &f) const {
415  f(EntryType(d.m(i)));
416  );
417  }
418  template<typename F> Vc_INTRINSIC void call(F &f) const {
420  f(EntryType(d.m(i)));
421  );
422  }
423 
424  template<typename F> Vc_INTRINSIC void call(const F &f, const Mask &mask) const {
425  Vc_foreach_bit(size_t i, mask) {
426  f(EntryType(d.m(i)));
427  }
428  }
429  template<typename F> Vc_INTRINSIC void call(F &f, const Mask &mask) const {
430  Vc_foreach_bit(size_t i, mask) {
431  f(EntryType(d.m(i)));
432  }
433  }
434 
435  template<typename F> Vc_INTRINSIC Vector<T> apply(const F &f) const {
436  Vector<T> r;
438  r.d.m(i) = f(EntryType(d.m(i)));
439  );
440  return r;
441  }
442  template<typename F> Vc_INTRINSIC Vector<T> apply(F &f) const {
443  Vector<T> r;
445  r.d.m(i) = f(EntryType(d.m(i)));
446  );
447  return r;
448  }
449 
450  template<typename F> Vc_INTRINSIC Vector<T> apply(const F &f, const Mask &mask) const {
451  Vector<T> r(*this);
452  Vc_foreach_bit (size_t i, mask) {
453  r.d.m(i) = f(EntryType(r.d.m(i)));
454  }
455  return r;
456  }
457  template<typename F> Vc_INTRINSIC Vector<T> apply(F &f, const Mask &mask) const {
458  Vector<T> r(*this);
459  Vc_foreach_bit (size_t i, mask) {
460  r.d.m(i) = f(EntryType(r.d.m(i)));
461  }
462  return r;
463  }
464 
465  template<typename IndexT> Vc_INTRINSIC void fill(EntryType (&f)(IndexT)) {
467  d.m(i) = f(i);
468  );
469  }
470  Vc_INTRINSIC void fill(EntryType (&f)()) {
472  d.m(i) = f();
473  );
474  }
475 
476  Vc_INTRINSIC_L Vector copySign(typename Vector::AsArg reference) const Vc_INTRINSIC_R;
477  Vc_INTRINSIC_L Vector exponent() const Vc_INTRINSIC_R;
478 };
479 
480 typedef Vector<double> double_v;
481 typedef Vector<float> float_v;
483 typedef Vector<int> int_v;
484 typedef Vector<unsigned int> uint_v;
485 typedef Vector<short> short_v;
486 typedef Vector<unsigned short> ushort_v;
487 typedef double_v::Mask double_m;
488 typedef float_v::Mask float_m;
489 typedef sfloat_v::Mask sfloat_m;
490 typedef int_v::Mask int_m;
491 typedef uint_v::Mask uint_m;
492 typedef short_v::Mask short_m;
493 typedef ushort_v::Mask ushort_m;
494 
497  return Vector<float8>(M256::create(v, v));
498 }
499 
500 template<typename T> class SwizzledVector : public Vector<T> {};
501 
502 static Vc_ALWAYS_INLINE Vc_PURE int_v min(const int_v &x, const int_v &y) { return mm_min_epi32(x.data(), y.data()); }
503 static Vc_ALWAYS_INLINE Vc_PURE uint_v min(const uint_v &x, const uint_v &y) { return mm_min_epu32(x.data(), y.data()); }
504 static Vc_ALWAYS_INLINE Vc_PURE short_v min(const short_v &x, const short_v &y) { return _mm_min_epi16(x.data(), y.data()); }
505 static Vc_ALWAYS_INLINE Vc_PURE ushort_v min(const ushort_v &x, const ushort_v &y) { return mm_min_epu16(x.data(), y.data()); }
506 static Vc_ALWAYS_INLINE Vc_PURE float_v min(const float_v &x, const float_v &y) { return _mm_min_ps(x.data(), y.data()); }
507 static Vc_ALWAYS_INLINE Vc_PURE double_v min(const double_v &x, const double_v &y) { return _mm_min_pd(x.data(), y.data()); }
508 static Vc_ALWAYS_INLINE Vc_PURE int_v max(const int_v &x, const int_v &y) { return mm_max_epi32(x.data(), y.data()); }
509 static Vc_ALWAYS_INLINE Vc_PURE uint_v max(const uint_v &x, const uint_v &y) { return mm_max_epu32(x.data(), y.data()); }
510 static Vc_ALWAYS_INLINE Vc_PURE short_v max(const short_v &x, const short_v &y) { return _mm_max_epi16(x.data(), y.data()); }
511 static Vc_ALWAYS_INLINE Vc_PURE ushort_v max(const ushort_v &x, const ushort_v &y) { return mm_max_epu16(x.data(), y.data()); }
512 static Vc_ALWAYS_INLINE Vc_PURE float_v max(const float_v &x, const float_v &y) { return _mm_max_ps(x.data(), y.data()); }
513 static Vc_ALWAYS_INLINE Vc_PURE double_v max(const double_v &x, const double_v &y) { return _mm_max_pd(x.data(), y.data()); }
514 
515 static Vc_ALWAYS_INLINE Vc_PURE sfloat_v min(const sfloat_v &x, const sfloat_v &y) {
516  return M256::create(_mm_min_ps(x.data()[0], y.data()[0]), _mm_min_ps(x.data()[1], y.data()[1]));
517 }
518 static Vc_ALWAYS_INLINE Vc_PURE sfloat_v max(const sfloat_v &x, const sfloat_v &y) {
519  return M256::create(_mm_max_ps(x.data()[0], y.data()[0]), _mm_max_ps(x.data()[1], y.data()[1]));
520 }
521 
522  template<typename T> static Vc_ALWAYS_INLINE Vc_PURE Vector<T> sqrt (const Vector<T> &x) { return VectorHelper<T>::sqrt(x.data()); }
523  template<typename T> static Vc_ALWAYS_INLINE Vc_PURE Vector<T> rsqrt(const Vector<T> &x) { return VectorHelper<T>::rsqrt(x.data()); }
524  template<typename T> static Vc_ALWAYS_INLINE Vc_PURE Vector<T> abs (const Vector<T> &x) { return VectorHelper<T>::abs(x.data()); }
525  template<typename T> static Vc_ALWAYS_INLINE Vc_PURE Vector<T> reciprocal(const Vector<T> &x) { return VectorHelper<T>::reciprocal(x.data()); }
526  template<typename T> static Vc_ALWAYS_INLINE Vc_PURE Vector<T> round(const Vector<T> &x) { return VectorHelper<T>::round(x.data()); }
527 
528  template<typename T> static Vc_ALWAYS_INLINE Vc_PURE typename Vector<T>::Mask isfinite(const Vector<T> &x) { return VectorHelper<T>::isFinite(x.data()); }
529  template<typename T> static Vc_ALWAYS_INLINE Vc_PURE typename Vector<T>::Mask isnan(const Vector<T> &x) { return VectorHelper<T>::isNaN(x.data()); }
530 
531 #include "forceToRegisters.tcc"
532 #ifdef VC_GNU_ASM
533 template<>
534 Vc_ALWAYS_INLINE void forceToRegisters(const Vector<float8> &x1) {
535  __asm__ __volatile__(""::"x"(x1.data()[0]), "x"(x1.data()[1]));
536 }
537 #elif defined(VC_MSVC)
538 #pragma optimize("g", off)
539 template<>
540 Vc_ALWAYS_INLINE void forceToRegisters(const Vector<float8> &/*x1*/) {
541 }
542 #endif
543 } // namespace SSE
544 } // namespace Vc
545 } // namespace ROOT
546 
547 #include "undomacros.h"
548 #include "vector.tcc"
549 #include "math.h"
550 #endif // SSE_VECTOR_H
VectorTraits< T >::StorageType StorageType
Definition: vector.h:146
Vc_ALWAYS_INLINE_L Vector< typename NegateTypeHelper< T >::Type > operator-() const Vc_ALWAYS_INLINE_R
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > cdab() const Vc_INTRINSIC_R Vc_PURE_R
VectorTraits< T >::EntryType EntryType
Definition: vector.h:156
Vc_INTRINSIC Vector< T > & operator*=(EntryType x)
Definition: vector.h:103
static Vc_CONST_L VectorType sort(VectorType) Vc_CONST_R
Vc_ALWAYS_INLINE Vector & operator=(EntryType a)
Definition: vector.h:202
Vc_INTRINSIC void fill(EntryType(&f)(IndexT))
Definition: vector.h:465
DetermineEntryType< T >::Type EntryType
Definition: types.h:137
DetermineGatherMask< MaskType >::Type GatherMaskType
Definition: types.h:143
#define Vc_foreach_bit(_it_, _mask_)
Definition: mask.h:202
Small helper to encapsulate whether to return the value pointed to by the iterator or its address...
static Vc_ALWAYS_INLINE Vc_PURE Vector< T > sqrt(const Vector< T > &x)
Definition: vector.h:522
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
Vc_INTRINSIC Vector operator--(int)
Definition: vector.h:302
Vc_ALWAYS_INLINE Vc_PURE V2 staticCast() const
Definition: vector.h:372
Vc_INTRINSIC Vector Vc_PURE operator~() const
Definition: vector.h:312
Vc_INTRINSIC_L Vector copySign(typename Vector::AsArg reference) const Vc_INTRINSIC_R
Vc_INTRINSIC void call(F &f) const
Definition: vector.h:123
double T(double x)
Definition: ChebyshevPol.h:34
Vc_INTRINSIC_L void setZero() Vc_INTRINSIC_R
#define FREE_STORE_OPERATORS_ALIGNED(alignment)
Definition: macros.h:165
static Vc_ALWAYS_INLINE Vc_PURE Vector< T >::Mask isnan(const Vector< T > &x)
Definition: vector.h:529
StorageType d
Definition: vector.h:147
Vc_INTRINSIC Vector & operator++()
Definition: vector.h:298
static Vc_INTRINSIC_L Vector Random() Vc_INTRINSIC_R
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > bcad() const Vc_INTRINSIC_R Vc_PURE_R
Vc_INTRINSIC EntryType product() const
Definition: vector.h:391
Vc_INTRINSIC Vector< T > & operator=(EntryType x)
Definition: vector.h:115
Vc_INTRINSIC Vector< T > apply(const F &f) const
Definition: vector.h:126
Vc_ALWAYS_INLINE Vc_PURE _M128 data() const
Definition: mask.h:134
VectorTraits< T >::MaskType Mask
Definition: vector.h:50
#define Vc_PURE_L
Definition: macros.h:137
TArc * a
Definition: textangle.C:12
Vc_INTRINSIC_L VC_EXACT_TYPE(TT, typename DetermineEntryType< T >::Type, Vector< T >) operator/(TT x) const Vc_PURE Vc_INTRINSIC_R
Vc_INTRINSIC Vector< T > apply(const F &f, const Mask &mask) const
Definition: vector.h:450
static Vc_INTRINSIC Vc_CONST M256 create(_M128 a, _M128 b)
Definition: types.h:70
Vc_INTRINSIC_L Vector operator>>(AsArg shift) const Vc_INTRINSIC_R
Vc_INTRINSIC_L void setQnan() Vc_INTRINSIC_R
#define Vc_INTRINSIC
Definition: macros.h:139
Vc_INTRINSIC_L Vector shifted(int amount) const Vc_INTRINSIC_R
Vc_ALWAYS_INLINE Vc_PURE AliasingEntryType & m(size_t index)
Definition: storage.h:86
Vc_INTRINSIC void call(const F &f, const Mask &mask) const
Definition: vector.h:424
Vc_INTRINSIC void call(F &f, const Mask &mask) const
Definition: vector.h:429
Vc_INTRINSIC WriteMaskedVector< T > operator()(const Mask &k)
Definition: vector.h:375
static double A[]
Vc_INTRINSIC EntryType sum() const
Definition: vector.h:392
VectorTraits< T >::GatherMaskType GatherMask
Definition: vector.h:148
Vc_INTRINSIC Vector(TT x, VC_EXACT_TYPE(TT, EntryType, void *)=0)
Definition: vector.h:200
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > bbbb() const Vc_INTRINSIC_R Vc_PURE_R
Vc_INTRINSIC Vector< T > & operator=(const Vector< T > &x)
Definition: vector.h:110
Vc_INTRINSIC_L Vector & operator/=(const Vector< T > &x) Vc_INTRINSIC_R
VECTOR_NAMESPACE::short_v short_v
Definition: vector.h:90
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > acbd() const Vc_INTRINSIC_R Vc_PURE_R
static Vc_ALWAYS_INLINE void forceToRegisters(const Vector< T1 > &, const Vector< T2 > &, const Vector< T3 > &, const Vector< T4 > &, const Vector< T5 > &, const Vector< T6 > &, const Vector< T7 > &, const Vector< T8 > &, const Vector< T9 > &, const Vector< T10 > &, const Vector< T11 > &, const Vector< T12 > &, const Vector< T13 > &, const Vector< T14 > &, const Vector< T15 > &, const Vector< T16 > &)
Definition: vector.h:462
void _operator_bracket_warning()
Definition: const.cpp:512
static Vc_INTRINSIC __m128i Vc_CONST mm_max_epu32(__m128i a, __m128i b)
Definition: intrinsics.h:432
double sqrt(double)
void gather(const EntryType *mem, VC_ALIGNED_PARAMETER(Index) indexes)
Double_t x[n]
Definition: legend1.C:17
Vector< T >::EntryType EntryType
Definition: vector.h:51
static Vc_INTRINSIC_L Vector Zero() Vc_INTRINSIC_R
Vc_INTRINSIC_L Vector & operator=(const Vector< OtherT > &x) Vc_INTRINSIC_R
static Vc_ALWAYS_INLINE Vc_PURE Vector< T > abs(const Vector< T > &x)
Definition: vector.h:524
#define for_all_vector_entries(_it_, _code_)
Definition: macros.h:202
Vector< T > *const vec
Definition: vector.h:135
static Vc_ALWAYS_INLINE Vc_PURE m256 xor_(param256 a, param256 b)
Definition: mask.h:211
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > dbca() const Vc_INTRINSIC_R Vc_PURE_R
cmpneq cmpnle cmple Vc_INTRINSIC_L Vc_PURE_L Mask isNegative() const Vc_PURE_R Vc_INTRINSIC_R
Vc_INTRINSIC Common::AliasingEntryHelper< StorageType > operator[](size_t index)
Definition: vector.h:304
Vc_ALWAYS_INLINE Vc_PURE V2 reinterpretCast() const
Definition: vector.h:373
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > cccc() const Vc_INTRINSIC_R Vc_PURE_R
static Vc_INTRINSIC __m128i Vc_CONST mm_max_epu16(__m128i a, __m128i b)
Definition: intrinsics.h:429
Vc_INTRINSIC Vector< T > operator++(int)
Definition: vector.h:68
void scatter(EntryType *mem, VC_ALIGNED_PARAMETER(Index) indexes) const
static Vc_ALWAYS_INLINE Vc_PURE Vector< T > round(const Vector< T > &x)
Definition: vector.h:526
Vc_ALWAYS_INLINE void fusedMultiplyAdd(const Vector< T > &factor, const Vector< T > &summand)
Definition: vector.h:363
Vc_ALWAYS_INLINE void assign(const Vector< T > &v, const Mask &mask)
Definition: vector.h:367
Vc_INTRINSIC Vector operator++(int)
Definition: vector.h:301
#define Vc_PURE
Definition: macros.h:136
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > bcda() const Vc_INTRINSIC_R Vc_PURE_R
#define Vc_ALWAYS_INLINE_R
Definition: macros.h:132
Vc_ALWAYS_INLINE Vc_PURE VectorType & v()
Definition: storage.h:83
Vc_INTRINSIC EntryType max() const
Definition: vector.h:390
#define F(x, y, z)
#define VC_ALIGNED_PARAMETER(_Type)
Definition: macros.h:368
Vc_INTRINSIC_L void store(EntryType *mem) const Vc_INTRINSIC_R
ROOT::R::TRInterface & r
Definition: Object.C:4
SVector< double, 2 > v
Definition: Dict.h:5
VectorTraits< T >::MaskType Mask
Definition: vector.h:158
#define Vc_INTRINSIC_R
Definition: macros.h:141
Vc_INTRINSIC Vector< T > & operator/=(const Vector< T > &x)
def cast(some_object, new_type)
Vc_INTRINSIC Vector< T > apply(const F &f) const
Definition: vector.h:435
TMarker * m
Definition: textangle.C:8
static Vc_INTRINSIC_L Vector IndexesFromZero() Vc_INTRINSIC_R
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > dddd() const Vc_INTRINSIC_R Vc_PURE_R
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > badc() const Vc_INTRINSIC_R Vc_PURE_R
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > dabc() const Vc_INTRINSIC_R Vc_PURE_R
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > aaaa() const Vc_INTRINSIC_R Vc_PURE_R
#define _M128
Definition: macros.h:27
static Vc_INTRINSIC Vector broadcast4(const EntryType *x)
Definition: vector.h:201
static Vc_INTRINSIC_L Vector One() Vc_INTRINSIC_R
Vc_INTRINSIC Vector< T > & operator+=(EntryType x)
Definition: vector.h:97
void callWithValuesSorted(F &f)
Definition: vector.h:402
static Vc_ALWAYS_INLINE Vc_PURE Vector< T > rsqrt(const Vector< T > &x)
Definition: vector.h:523
Vc_ALWAYS_INLINE WriteMaskedVector(Vector< T > *v, const Mask &k)
Definition: vector.h:134
static Vc_INTRINSIC __m128i Vc_CONST mm_min_epu16(__m128i a, __m128i b)
Definition: intrinsics.h:438
VectorHelper< typename VectorTraits< T >::VectorType > HV
Definition: vector.h:149
Vc_INTRINSIC Vector< T > apply(F &f, const Mask &mask) const
Definition: vector.h:457
Type
enumeration specifying the integration types.
static Vc_ALWAYS_INLINE Vc_PURE Vector< T > reciprocal(const Vector< T > &x)
Definition: vector.h:525
VectorTypeHelper< T >::Type VectorType
Definition: types.h:136
#define blend
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > dcba() const Vc_INTRINSIC_R Vc_PURE_R
VectorTraits< T >::IndexType IndexType
Definition: vector.h:157
Vc::Memory< Vector< T >, Size > Memory
Definition: vector.h:160
#define Vc_ALWAYS_INLINE
Definition: macros.h:130
RooCmdArg Index(RooCategory &icat)
static Vc_ALWAYS_INLINE Vc_PURE sfloat_v max(const sfloat_v &x, const sfloat_v &y)
Definition: vector.h:518
static Vc_INTRINSIC __m128i Vc_CONST mm_min_epi32(__m128i a, __m128i b)
Definition: intrinsics.h:447
static Vc_ALWAYS_INLINE Vc_PURE m256 or_(param256 a, param256 b)
Definition: mask.h:210
static const double x1[5]
Vc_INTRINSIC_L Vector rotated(int amount) const Vc_INTRINSIC_R
Vc_INTRINSIC_L Vc_PURE_L const Vector< T > & abcd() const Vc_INTRINSIC_R Vc_PURE_R
double f(double x)
static Vc_ALWAYS_INLINE Vc_PURE m256 and_(param256 a, param256 b)
Definition: mask.h:209
Vc_INTRINSIC_L Vector operator<<(AsArg shift) const Vc_INTRINSIC_R
Vc_INTRINSIC_L Vector & operator>>=(AsArg shift) Vc_INTRINSIC_R
Vc_INTRINSIC Vector< T > & operator+=(const Vector< T > &x)
Definition: vector.h:83
Vc_INTRINSIC Vector< T > apply(F &f) const
Definition: vector.h:442
#define Vc_ALWAYS_INLINE_L
Definition: macros.h:131
Vc_INTRINSIC_L Vector exponent() const Vc_INTRINSIC_R
static Vc_INTRINSIC __m128i Vc_CONST mm_min_epu32(__m128i a, __m128i b)
Definition: intrinsics.h:441
#define Vc_INTRINSIC_L
Definition: macros.h:140
Vc_INTRINSIC Vector< T > & operator-=(const Vector< T > &x)
Definition: vector.h:87
VectorTraits< T >::VectorType VectorType
Definition: vector.h:155
cmpneq cmpnle OPcmp(<, cmplt) OPcmp(<
#define SSE
Definition: global.h:84
Vc_INTRINSIC Vector< T > & operator*=(const Vector< T > &x)
Definition: vector.h:91
static Vc_ALWAYS_INLINE Vc_PURE sfloat_v min(const sfloat_v &x, const sfloat_v &y)
Definition: vector.h:515
Vc_ALWAYS_INLINE Vector()
Definition: vector.h:171
void expand(Vector< typename ExpandTypeHelper< T >::Type > *x) const
Vc_INTRINSIC Vector< T > & operator/=(EntryType x)
Definition: vector.h:106
Vc_INTRINSIC Vector< T > & operator--()
Definition: vector.h:61
Vc_INTRINSIC Vector< T > operator--(int)
Definition: vector.h:75
VectorHelper< T > HT
Definition: vector.h:150
Vc_ALWAYS_INLINE Vc_PURE const VectorType & data() const
Definition: vector.h:387
Vc_INTRINSIC void call(F &f) const
Definition: vector.h:418
const Vector< T > AsArg
Definition: vector.h:164
Vc_INTRINSIC_L void load(const EntryType *mem) Vc_INTRINSIC_R
#define OP(symbol, fun)
Definition: vector.h:341
Vc_ALWAYS_INLINE Vector & operator=(AsArg v)
Definition: vector.h:195
Vc_INTRINSIC_L Vector & operator<<=(AsArg shift) Vc_INTRINSIC_R
static Vc_INTRINSIC __m128i Vc_CONST mm_max_epi32(__m128i a, __m128i b)
Definition: intrinsics.h:423
static Vc_ALWAYS_INLINE Vc_PURE Vector< T >::Mask isfinite(const Vector< T > &x)
Definition: vector.h:528
Vc_INTRINSIC void call(const F &f) const
Definition: vector.h:413
Definition: casts.h:28
Vc_INTRINSIC Vector< T > & operator-=(EntryType x)
Definition: vector.h:100
Vc_INTRINSIC Vector< T > apply(F &f) const
Definition: vector.h:129
Vc_INTRINSIC_L Vector operator/(const Vector< T > &x) const Vc_PURE Vc_INTRINSIC_R
Vc_INTRINSIC void fill(EntryType(&f)())
Definition: vector.h:470
Vc_INTRINSIC void call(const F &f) const
Definition: vector.h:120
float value
Definition: math.cpp:443
Vc_PURE Vector sorted() const
Definition: vector.h:400
static Vc_ALWAYS_INLINE To Vc_CONST mm128_reinterpret_cast(VC_ALIGNED_PARAMETER(From) v)
Definition: casts.h:31
Mask::Argument MaskArg
Definition: vector.h:159
Vc_INTRINSIC Vector & operator--()
Definition: vector.h:299
void fma()
Vc_ALWAYS_INLINE Vc_PURE VectorType & data()
Definition: vector.h:386
Vc_INTRINSIC EntryType min() const
Definition: vector.h:389