ROOT  6.06/09
Reference Guide
writemaskedvector.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 VC_SCALAR_WRITEMASKEDVECTOR_H
21 #define VC_SCALAR_WRITEMASKEDVECTOR_H
22 
23 namespace ROOT {
24 namespace Vc
25 {
26 namespace Scalar
27 {
28 
29 template<typename T> class WriteMaskedVector
30 {
31  friend class Vector<T>;
32  typedef typename Vector<T>::Mask Mask;
33  typedef typename Vector<T>::EntryType EntryType;
34  public:
35  //prefix
36  Vc_ALWAYS_INLINE Vector<T> &operator++() { if (mask) ++vec->m_data; return *vec; }
37  Vc_ALWAYS_INLINE Vector<T> &operator--() { if (mask) --vec->m_data; return *vec; }
38  //postfix
39  Vc_ALWAYS_INLINE Vector<T> operator++(int) { if (mask) vec->m_data++; return *vec; }
40  Vc_ALWAYS_INLINE Vector<T> operator--(int) { if (mask) vec->m_data--; return *vec; }
41 
42  Vc_ALWAYS_INLINE Vector<T> &operator+=(Vector<T> x) { if (mask) vec->m_data += x.m_data; return *vec; }
43  Vc_ALWAYS_INLINE Vector<T> &operator-=(Vector<T> x) { if (mask) vec->m_data -= x.m_data; return *vec; }
44  Vc_ALWAYS_INLINE Vector<T> &operator*=(Vector<T> x) { if (mask) vec->m_data *= x.m_data; return *vec; }
45  Vc_ALWAYS_INLINE Vector<T> &operator/=(Vector<T> x) { if (mask) vec->m_data /= x.m_data; return *vec; }
46 
48  vec->assign(x, mask);
49  return *vec;
50  }
51 
52  Vc_ALWAYS_INLINE Vector<T> &operator+=(EntryType x) { if (mask) vec->m_data += x; return *vec; }
53  Vc_ALWAYS_INLINE Vector<T> &operator-=(EntryType x) { if (mask) vec->m_data -= x; return *vec; }
54  Vc_ALWAYS_INLINE Vector<T> &operator*=(EntryType x) { if (mask) vec->m_data *= x; return *vec; }
55  Vc_ALWAYS_INLINE Vector<T> &operator/=(EntryType x) { if (mask) vec->m_data /= x; return *vec; }
56 
58  vec->assign(Vector<T>(x), mask);
59  return *vec;
60  }
61 
62  template<typename F> Vc_ALWAYS_INLINE void call(const F &f) const {
63  vec->call(f, mask);
64  }
65  template<typename F> Vc_ALWAYS_INLINE void call(F &f) const {
66  vec->call(f, mask);
67  }
68  template<typename F> Vc_ALWAYS_INLINE Vector<T> apply(const F &f) const {
69  if (mask) {
70  return Vector<T>(f(vec->m_data));
71  } else {
72  return *vec;
73  }
74  }
75  template<typename F> Vc_ALWAYS_INLINE Vector<T> apply(F &f) const {
76  if (mask) {
77  return Vector<T>(f(vec->m_data));
78  } else {
79  return *vec;
80  }
81  }
82  private:
84  Vector<T> *const vec;
85  Mask mask;
86 };
87 
88 } // namespace Scalar
89 } // namespace Vc
90 } // namespace ROOT
91 #endif // VC_SCALAR_WRITEMASKEDVECTOR_H
Vc_ALWAYS_INLINE void call(const F &f) const
Vc_ALWAYS_INLINE Vector< T > & operator/=(EntryType x)
Vc_ALWAYS_INLINE Vector< T > & operator++()
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
Vc_ALWAYS_INLINE Vector< T > & operator/=(Vector< T > x)
double T(double x)
Definition: ChebyshevPol.h:34
Vc_ALWAYS_INLINE Vector< T > & operator--()
Vc_ALWAYS_INLINE Vector< T > apply(const F &f) const
Vc_ALWAYS_INLINE Vector< T > & operator+=(EntryType x)
Double_t x[n]
Definition: legend1.C:17
Vc_ALWAYS_INLINE Vector< T > operator--(int)
Vc_ALWAYS_INLINE void call(F &f) const
#define F(x, y, z)
Vc_ALWAYS_INLINE Vector< T > & operator*=(Vector< T > x)
SVector< double, 2 > v
Definition: Dict.h:5
Vc_ALWAYS_INLINE Vector< T > & operator-=(EntryType x)
#define Scalar
Definition: global.h:83
#define Vc_ALWAYS_INLINE
Definition: macros.h:130
Vc_ALWAYS_INLINE Vector< T > & operator*=(EntryType x)
double f(double x)
Vc_ALWAYS_INLINE Vector< T > operator++(int)
Vc_ALWAYS_INLINE Vector< T > & operator-=(Vector< T > x)
Vc_ALWAYS_INLINE Vector< T > apply(F &f) const
Vc_ALWAYS_INLINE Vector< T > & operator+=(Vector< T > x)
Definition: casts.h:28
Vc_ALWAYS_INLINE Vector< T > & operator=(Vector< T > x)
DetermineEntryType< T >::Type EntryType
Definition: vector.h:49
Vc_ALWAYS_INLINE Vector< T > & operator=(EntryType x)
Vc_ALWAYS_INLINE WriteMaskedVector(Vector< T > *v, Mask k)