42 #ifndef STOKHOS_MP_VECTOR_MASKTRAITS_HPP
43 #define STOKHOS_MP_VECTOR_MASKTRAITS_HPP
59 static const int size = S::static_size;
62 return x.fastAccessCoeff(i);
65 return x.fastAccessCoeff(i);
69 template<
typename scalar>
class Mask
77 for(
int i=0; i<
size; ++i)
82 for(
int i=0; i<
size; ++i)
91 for(
int i=0; i<
size; ++i)
92 sum = sum + this->
data[i];
100 for(
int i=0; i<
size; ++i)
101 sum = sum + this->
data[i];
109 for(
int i=0; i<
size; ++i)
110 sum = sum + this->
data[i];
112 return sum >= v*
size;
118 for(
int i=0; i<
size; ++i)
119 sum = sum + this->
data[i];
121 return sum <= v*
size;
127 for(
int i=0; i<
size; ++i)
128 sum = sum + this->
data[i];
130 return sum == v*
size;
136 for(
int i=0; i<
size; ++i)
137 sum = sum + this->
data[i];
139 return sum != v*
size;
145 for (
int i = 0; i <
size; ++i) {
146 all = all && (this->
data[i] == m2.
data[i]);
159 for(
int i=0; i<
size; ++i)
160 m3.
data[i] = (this->data[i] && m2.
data[i]);
168 for(
int i=0; i<
size; ++i)
169 m3.
data[i] = (this->data[i] || m2.
data[i]);
177 for(
int i=0; i<
size; ++i)
178 m3.
data[i] = (this->data[i] && m2);
186 for(
int i=0; i<
size; ++i)
187 m3.
data[i] = (this->data[i] || m2);
195 for(
int i=0; i<
size; ++i)
196 m3.
data[i] = (this->data[i] + m2.
data[i]);
204 for(
int i=0; i<
size; ++i)
205 m3.
data[i] = (this->data[i] - m2.
data[i]);
214 for(
int i=0; i<
size; ++i)
215 ET::coeff(v2,i) = ET::coeff(v,i)*this->
data[i];
222 return this->
data[i];
227 return this->
data[i];
233 for(
int i=0; i<
size; ++i)
234 m2.
data[i] = !(this->data[i]);
239 operator bool()
const
241 return this->
data[0];
247 for(
int i=0; i<
size; ++i)
248 sum = sum + this->
data[i];
254 template<
typename scalar> std::ostream &operator<<(std::ostream &os, const Mask<scalar>& m) {
256 for(
int i=0; i<m.getSize(); ++i)
265 for(
int i=0; i<ET::size; ++i){
266 ET::coeff(mul,i) = ET::coeff(a1,i)*m[i];
275 for(
int i=0; i<ET::size; ++i){
276 ET::coeff(mul,i) = m[i]*a1;
285 for(
int i=0; i<ET::size; ++i){
286 ET::coeff(mul,i) = m[i]*a1;
300 for(
int i=0; i<ET::size; ++i){
301 ET::coeff(a_out,i) =
copysign(ET::coeff(a1,i),ET::coeff(a2,i));
316 for(
int i=0; i<ET::size; ++i)
317 mask[i] = signbit(ET::coeff(a1,i));
328 for(
int i=0; i<ET::size; ++i)
329 mask[i] = ET::coeff(a1,i) > ET::coeff(a2,i);
338 for(
int i=0; i<ET::size; ++i)
339 mask[i] = ET::coeff(a1,i) >= ET::coeff(a2,i);
348 for(
int i=0; i<ET::size; ++i)
349 mask[i] = ET::coeff(a1,i) < ET::coeff(a2,i);
358 for(
int i=0; i<ET::size; ++i)
359 mask[i] = ET::coeff(a1,i) <= ET::coeff(a2,i);
370 for(
int i=0; i<ET::size; ++i)
371 mask[i] = ET::coeff(a1,i) > a2;
380 for(
int i=0; i<ET::size; ++i)
381 mask[i] = ET::coeff(a1,i) >= a2;
390 for(
int i=0; i<ET::size; ++i)
391 mask[i] = ET::coeff(a1,i) < a2;
400 for(
int i=0; i<ET::size; ++i)
401 mask[i] = ET::coeff(a1,i) <= a2;
412 for(
int i=0; i<ET::size; ++i)
413 mask[i] = a2 > ET::coeff(a1,i);
422 for(
int i=0; i<ET::size; ++i)
423 mask[i] = a2 >= ET::coeff(a1,i);
432 for(
int i=0; i<ET::size; ++i)
433 mask[i] = a2 < ET::coeff(a1,i);
442 for(
int i=0; i<ET::size; ++i)
443 mask[i] = a2 <= ET::coeff(a1,i);
463 template<
typename T>
OR(T m){
467 operator bool()
const
487 template<
typename T>
XOR(T m){
491 operator bool()
const
511 template<
typename T>
AND(T m){
515 operator bool()
const
521 #endif // STOKHOS_MP_VECTOR_MASKTRAITS_HPP
Vector< S > copysign(const Vector< S > &a1, const Vector< S > &a2)
bool operator==(double v)
bool operator>=(double v)
bool operator<=(double v)
bool operator[](int i) const
Mask< scalar > operator!()
KOKKOS_INLINE_FUNCTION bool operator>(const PCE< Storage > &a, const PCE< Storage > &b)
bool operator!=(double v)
KOKKOS_INLINE_FUNCTION bool operator>=(const PCE< Storage > &a, const PCE< Storage > &b)
static value_type & coeff(T &x, int i)
static value_type & coeff(Sacado::MP::Vector< S > &x, int i)
Mask< scalar > operator&&(const Mask< scalar > &m2)
Mask< scalar > operator+(const Mask< scalar > &m2)
Mask< scalar > operator||(const Mask< scalar > &m2)
static const value_type & coeff(const T &x, int i)
KOKKOS_INLINE_FUNCTION PCE< Storage > operator*(const PCE< Storage > &a, const PCE< Storage > &b)
static const value_type & coeff(const Sacado::MP::Vector< S > &x, int i)
scalar operator*(const scalar &v)
Mask< scalar > operator-(const Mask< scalar > &m2)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< RD, RP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type sum(const Kokkos::View< RD, RP...> &r, const Kokkos::View< XD, XP...> &x)
Mask< Sacado::MP::Vector< S > > signbit_v(const Sacado::MP::Vector< S > &a1)