ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
mask.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_MASK_H
21 #define VC_SCALAR_MASK_H
22 
23 #include "types.h"
24 
25 namespace ROOT {
26 namespace Vc
27 {
28 namespace Scalar
29 {
30 template<unsigned int VectorSize = 1> class Mask
31 {
32  public:
34  Vc_ALWAYS_INLINE explicit Mask(bool b) : m(b) {}
38 
39  Vc_ALWAYS_INLINE Mask &operator=(const Mask &rhs) { m = rhs.m; return *this; }
40  Vc_ALWAYS_INLINE Mask &operator=(bool rhs) { m = rhs; return *this; }
41 
42  Vc_ALWAYS_INLINE void expand(Mask *x) { x[0].m = m; }
43 
44  Vc_ALWAYS_INLINE bool operator==(const Mask &rhs) const { return Mask(m == rhs.m); }
45  Vc_ALWAYS_INLINE bool operator!=(const Mask &rhs) const { return Mask(m != rhs.m); }
46 
47  Vc_ALWAYS_INLINE Mask operator&&(const Mask &rhs) const { return Mask(m && rhs.m); }
48  Vc_ALWAYS_INLINE Mask operator& (const Mask &rhs) const { return Mask(m && rhs.m); }
49  Vc_ALWAYS_INLINE Mask operator||(const Mask &rhs) const { return Mask(m || rhs.m); }
50  Vc_ALWAYS_INLINE Mask operator| (const Mask &rhs) const { return Mask(m || rhs.m); }
51  Vc_ALWAYS_INLINE Mask operator^ (const Mask &rhs) const { return Mask(m ^ rhs.m); }
52  Vc_ALWAYS_INLINE Mask operator!() const { return Mask(!m); }
53 
54  Vc_ALWAYS_INLINE Mask &operator&=(const Mask &rhs) { m &= rhs.m; return *this; }
55  Vc_ALWAYS_INLINE Mask &operator|=(const Mask &rhs) { m |= rhs.m; return *this; }
56  Vc_ALWAYS_INLINE Mask &operator^=(const Mask &rhs) { m ^= rhs.m; return *this; }
57 
58  Vc_ALWAYS_INLINE bool isFull () const { return m; }
59  Vc_ALWAYS_INLINE bool isEmpty() const { return !m; }
60  Vc_ALWAYS_INLINE bool isMix () const { return false; }
61 
62  Vc_ALWAYS_INLINE bool data () const { return m; }
63  Vc_ALWAYS_INLINE bool dataI() const { return m; }
64  Vc_ALWAYS_INLINE bool dataD() const { return m; }
65 
66 #ifndef VC_NO_AUTOMATIC_BOOL_FROM_MASK
67  Vc_ALWAYS_INLINE operator bool() const { return isFull(); }
68 #endif
69 
70  template<unsigned int OtherSize>
71  Vc_ALWAYS_INLINE Mask cast() const { return *this; }
72 
73  Vc_ALWAYS_INLINE bool operator[](int) const { return m; }
74 
75  Vc_ALWAYS_INLINE int count() const { return m ? 1 : 0; }
76 
77  /**
78  * Returns the index of the first one in the mask.
79  *
80  * The return value is undefined if the mask is empty.
81  */
82  Vc_ALWAYS_INLINE int firstOne() const { return 0; }
83 
84  private:
85  bool m;
86 };
87 
89 {
90  bool continu;
91  Vc_ALWAYS_INLINE ForeachHelper(bool mask) : continu(mask) {}
92  Vc_ALWAYS_INLINE void next() { continu = false; }
93 };
94 
95 #define Vc_foreach_bit(_it_, _mask_) \
96  for (Vc::Scalar::ForeachHelper Vc__make_unique(foreach_bit_obj)(_mask_); Vc__make_unique(foreach_bit_obj).continu; Vc__make_unique(foreach_bit_obj).next()) \
97  for (_it_ = 0; Vc__make_unique(foreach_bit_obj).continu; Vc__make_unique(foreach_bit_obj).next())
98 
99 } // namespace Scalar
100 } // namespace Vc
101 } // namespace ROOT
102 
103 #endif // VC_SCALAR_MASK_H
Vc_ALWAYS_INLINE bool isFull() const
Definition: mask.h:58
Vc_ALWAYS_INLINE int count() const
Definition: mask.h:75
Vc_ALWAYS_INLINE bool dataD() const
Definition: mask.h:64
Vc_ALWAYS_INLINE Mask(bool b)
Definition: mask.h:34
Vc_ALWAYS_INLINE bool isEmpty() const
Definition: mask.h:59
Vc_ALWAYS_INLINE bool isMix() const
Definition: mask.h:60
Vc_ALWAYS_INLINE Mask(VectorSpecialInitializerOne::OEnum)
Definition: mask.h:36
Vc_ALWAYS_INLINE Mask & operator^=(const Mask &rhs)
Definition: mask.h:56
Vc_ALWAYS_INLINE void next()
Definition: mask.h:92
TArc * a
Definition: textangle.C:12
Vc_ALWAYS_INLINE bool dataI() const
Definition: mask.h:63
Vc_ALWAYS_INLINE Mask & operator|=(const Mask &rhs)
Definition: mask.h:55
ClassImp(TIterator) Bool_t TIterator return false
Compare two iterator objects.
Definition: TIterator.cxx:21
Vc_ALWAYS_INLINE Mask & operator&=(const Mask &rhs)
Definition: mask.h:54
Vc_ALWAYS_INLINE Mask & operator=(bool rhs)
Definition: mask.h:40
Double_t x[n]
Definition: legend1.C:17
Vc_ALWAYS_INLINE Mask & operator=(const Mask &rhs)
Definition: mask.h:39
Vc_ALWAYS_INLINE bool operator!=(const Mask &rhs) const
Definition: mask.h:45
Vc_ALWAYS_INLINE ForeachHelper(bool mask)
Definition: mask.h:91
Vc_ALWAYS_INLINE Mask()
Definition: mask.h:33
Vc_ALWAYS_INLINE Mask operator!() const
Definition: mask.h:52
Vc_ALWAYS_INLINE Mask operator&&(const Mask &rhs) const
Definition: mask.h:47
Vc_ALWAYS_INLINE bool data() const
Definition: mask.h:62
Vc_ALWAYS_INLINE Mask(VectorSpecialInitializerZero::ZEnum)
Definition: mask.h:35
Vc_ALWAYS_INLINE Mask operator&(const Mask &rhs) const
Definition: mask.h:48
Vc_ALWAYS_INLINE Mask operator||(const Mask &rhs) const
Definition: mask.h:49
#define Scalar
Definition: global.h:83
Vc_ALWAYS_INLINE Mask cast() const
Definition: mask.h:71
Vc_ALWAYS_INLINE bool operator[](int) const
Definition: mask.h:73
Vc_ALWAYS_INLINE bool operator==(const Mask &rhs) const
Definition: mask.h:44
#define Vc_ALWAYS_INLINE
Definition: macros.h:130
Vc_ALWAYS_INLINE Mask(const Mask< VectorSize > *a)
Definition: mask.h:37
Vc_ALWAYS_INLINE Mask operator^(const Mask &rhs) const
Definition: mask.h:51
Vc_ALWAYS_INLINE void expand(Mask *x)
Definition: mask.h:42
Vc_ALWAYS_INLINE int firstOne() const
Returns the index of the first one in the mask.
Definition: mask.h:82
Vc_ALWAYS_INLINE Mask operator|(const Mask &rhs) const
Definition: mask.h:50