42 #ifndef STOKHOS_MP_VECTOR_MASKTRAITS_HPP
43 #define STOKHOS_MP_VECTOR_MASKTRAITS_HPP
51 static const std::size_t
size = 1;
53 KOKKOS_INLINE_FUNCTION
55 KOKKOS_INLINE_FUNCTION
61 static const std::size_t
size = S::static_size ? S::static_size : 1;
63 KOKKOS_INLINE_FUNCTION
65 return x.fastAccessCoeff(i);
67 KOKKOS_INLINE_FUNCTION
69 return x.fastAccessCoeff(i);
92 auto st_array = st.begin();
113 auto st_array = st.begin();
116 data = st_array[0]+st_array[1];
133 auto st_array = st.begin();
136 data = st_array[0]-st_array[1];
153 auto st_array = st.begin();
156 data = st_array[0]*st_array[1];
173 auto st_array = st.begin();
176 data = st_array[0]/st_array[1];
184 template<
typename scalar>
class Mask;
199 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
202 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
203 #pragma vector aligned
205 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
208 for(std::size_t i=0; i<size; ++i)
217 auto st_array = st.begin();
218 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
221 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
222 #pragma vector aligned
224 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
227 for(std::size_t i=0; i<size; ++i)
229 data[i] = st_array[0][i];
231 data[i] = st_array[1][i];
239 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
242 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
243 #pragma vector aligned
245 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
248 for(std::size_t i=0; i<size; ++i)
257 auto st_array = st.begin();
258 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
261 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
262 #pragma vector aligned
264 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
267 for(std::size_t i=0; i<size; ++i)
269 data[i] = st_array[0][i]+st_array[1][i];
271 data[i] = st_array[2][i];
278 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
281 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
282 #pragma vector aligned
284 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
287 for(std::size_t i=0; i<size; ++i)
296 auto st_array = st.begin();
297 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
300 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
301 #pragma vector aligned
303 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
306 for(std::size_t i=0; i<size; ++i)
308 data[i] = st_array[0][i]-st_array[1][i];
310 data[i] = st_array[2][i];
317 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
320 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
321 #pragma vector aligned
323 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
326 for(std::size_t i=0; i<size; ++i)
335 auto st_array = st.begin();
336 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
339 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
340 #pragma vector aligned
342 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
345 for(std::size_t i=0; i<size; ++i)
347 data[i] = st_array[0][i]*st_array[1][i];
349 data[i] = st_array[2][i];
356 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
359 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
360 #pragma vector aligned
362 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
365 for(std::size_t i=0; i<size; ++i)
374 auto st_array = st.begin();
375 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
378 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
379 #pragma vector aligned
381 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
384 for(std::size_t i=0; i<size; ++i)
386 data[i] = st_array[0][i]/st_array[1][i];
388 data[i] = st_array[2][i];
394 template <
typename ordinal_t,
typename value_t,
typename device_t>
class MaskedAssign< Sacado::MP::Vector<Stokhos::DynamicStorage<ordinal_t,value_t,device_t>> >
415 auto st_array = st.begin();
436 auto st_array = st.begin();
439 data = st_array[0]+st_array[1];
456 auto st_array = st.begin();
459 data = st_array[0]-st_array[1];
476 auto st_array = st.begin();
479 data = st_array[0]*st_array[1];
496 auto st_array = st.begin();
499 data = st_array[0]/st_array[1];
507 template<
typename scalar>
class Mask
517 for(std::size_t i=0; i<
size; ++i)
521 KOKKOS_INLINE_FUNCTION
Mask(
bool a){
522 for(std::size_t i=0; i<
size; ++i)
527 for(std::size_t i=0; i<
size; ++i)
536 for(std::size_t i=0; i<
size; ++i)
537 sum = sum + this->
get(i);
545 for(std::size_t i=0; i<
size; ++i)
546 sum = sum + this->
get(i);
554 for(std::size_t i=0; i<
size; ++i)
555 sum = sum + this->
get(i);
557 return sum >= v*
size;
563 for(std::size_t i=0; i<
size; ++i)
564 sum = sum + this->
get(i);
566 return sum <= v*
size;
572 for(std::size_t i=0; i<
size; ++i)
573 sum = sum + this->
get(i);
575 return sum == v*
size;
581 for(std::size_t i=0; i<
size; ++i)
582 sum = sum + this->
get(i);
584 return sum != v*
size;
590 for (std::size_t i = 0; i <
size; ++i) {
591 all = all && (this->
get(i) == m2.
get(i));
604 for(std::size_t i=0; i<
size; ++i)
605 m3.
set(i,(this->get(i) && m2.
get(i)));
612 for(std::size_t i=0; i<
size; ++i)
613 m3.
set(i,(this->get(i) || m2.
get(i)));
621 for(std::size_t i=0; i<
size; ++i)
622 m3.
set(i,(this->get(i) && m2));
629 for(std::size_t i=0; i<
size; ++i)
630 m3.
set(i,(this->get(i) || m2));
638 for(std::size_t i=0; i<
size; ++i)
639 m3.
set(i,(this->get(i) + m2.
get(i)));
647 for(std::size_t i=0; i<
size; ++i)
648 m3.
set(i,(this->get(i) - m2.
get(i)));
653 KOKKOS_INLINE_FUNCTION scalar
operator* (
const scalar &v)
657 for(std::size_t i=0; i<
size; ++i)
658 ET::coeff(v2,i) = ET::coeff(v,i)*this->
get(i);
663 KOKKOS_INLINE_FUNCTION
bool get (
int i)
const
665 return this->
data[i];
668 KOKKOS_INLINE_FUNCTION
void set (
int i,
bool b)
676 for(std::size_t i=0; i<
size; ++i)
677 m2.
set(i,!(this->get(i)));
681 KOKKOS_INLINE_FUNCTION
operator bool()
const
686 KOKKOS_INLINE_FUNCTION
operator double()
const
689 for(std::size_t i=0; i<
size; ++i)
690 sum = sum + this->
get(i);
696 template<
typename scalar> KOKKOS_INLINE_FUNCTION std::ostream &operator<<(std::ostream &os, const Mask<scalar>& m) {
698 for(std::size_t i=0; i<m.getSize(); ++i)
699 os << m.get(i) <<
" ";
707 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
710 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
711 #pragma vector aligned
713 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
716 for(std::size_t i=0; i<ET::size; ++i){
717 ET::coeff(mul,i) = ET::coeff(a1,i)*m.get(i);
726 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
729 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
730 #pragma vector aligned
732 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
735 for(std::size_t i=0; i<ET::size; ++i){
736 ET::coeff(mul,i) = m.get(i)*a1;
745 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
748 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
749 #pragma vector aligned
751 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
754 for(std::size_t i=0; i<ET::size; ++i){
755 ET::coeff(mul,i) = m.get(i)*a1;
795 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
798 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
799 #pragma vector aligned
801 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
804 for(std::size_t i=0; i<ET::size; ++i){
805 ET::coeff(a_out,i) =
copysign(ET::coeff(a1,i),ET::coeff(a2,i));
820 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
823 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
824 #pragma vector aligned
826 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
829 for(std::size_t i=0; i<ET::size; ++i)
830 mask.
set(i, signbit(ET::coeff(a1,i)));
902 #if STOKHOS_USE_MP_VECTOR_SFS_SPEC
934 template<
typename T> KOKKOS_INLINE_FUNCTION
bool OR(
Mask<T> m){
935 return (((
double) m)!=0.);
938 KOKKOS_INLINE_FUNCTION
bool OR(
bool m){
942 template<
typename T> KOKKOS_INLINE_FUNCTION
bool XOR(
Mask<T> m){
943 return (((
double) m)==1./m.getSize());
946 KOKKOS_INLINE_FUNCTION
bool XOR(
bool m){
950 template<
typename T> KOKKOS_INLINE_FUNCTION
bool AND(
Mask<T> m){
951 return (((
double) m)==1.);
954 KOKKOS_INLINE_FUNCTION
bool AND(
bool m){
960 #endif // STOKHOS_MP_VECTOR_MASKTRAITS_HPP
KOKKOS_INLINE_FUNCTION Vector< S > copysign(const Vector< S > &a1, const Vector< S > &a2)
KOKKOS_INLINE_FUNCTION bool operator>=(double v)
static const std::size_t size
KOKKOS_INLINE_FUNCTION bool operator<=(double v)
KOKKOS_INLINE_FUNCTION bool get(int i) const
KOKKOS_INLINE_FUNCTION Mask(const Mask &a)
KOKKOS_INLINE_FUNCTION bool OR(Mask< T > m)
KOKKOS_INLINE_FUNCTION MaskedAssign< scalar > & operator*=(const scalar &KOKKOS_RESTRICT s)
KOKKOS_INLINE_FUNCTION Mask()
KOKKOS_INLINE_FUNCTION MaskedAssign< scalar > mask_assign(bool b, scalar *s)
static KOKKOS_INLINE_FUNCTION const value_type & coeff(const Sacado::MP::Vector< S > &x, int i)
KOKKOS_INLINE_FUNCTION void set(int i, bool b)
KOKKOS_INLINE_FUNCTION MaskedAssign< scalar > & operator=(const scalar &KOKKOS_RESTRICT s)
KOKKOS_INLINE_FUNCTION Mask< scalar > operator+(const Mask< scalar > &m2)
KOKKOS_INLINE_FUNCTION MaskedAssign(scalar &data_, Mask< scalar > m_)
static const std::size_t size
KOKKOS_INLINE_FUNCTION Mask< scalar > operator||(const Mask< scalar > &m2)
KOKKOS_INLINE_FUNCTION bool operator<(double v)
KOKKOS_INLINE_FUNCTION MaskedAssign(scalar &data_, bool m_)
KOKKOS_INLINE_FUNCTION bool operator>(double v)
KOKKOS_INLINE_FUNCTION scalar operator*(const scalar &v)
static KOKKOS_INLINE_FUNCTION value_type & coeff(T &x, int i)
KOKKOS_INLINE_FUNCTION bool operator!=(double v)
static KOKKOS_INLINE_FUNCTION const value_type & coeff(const T &x, int i)
Sacado::MP::Vector< S > scalar
KOKKOS_INLINE_FUNCTION bool operator==(double v)
KOKKOS_INLINE_FUNCTION Mask< scalar > operator-(const Mask< scalar > &m2)
KOKKOS_INLINE_FUNCTION MaskedAssign< scalar > & operator-=(const scalar &KOKKOS_RESTRICT s)
KOKKOS_INLINE_FUNCTION bool AND(Mask< T > m)
Sacado::MP::Vector< Stokhos::DynamicStorage< ordinal_t, value_t, device_t > > scalar
KOKKOS_INLINE_FUNCTION Mask(bool a)
KOKKOS_INLINE_FUNCTION MaskedAssign< scalar > & operator/=(const scalar &KOKKOS_RESTRICT s)
KOKKOS_INLINE_FUNCTION bool XOR(Mask< T > m)
KOKKOS_INLINE_FUNCTION MaskedAssign(scalar &data_, Mask< scalar > m_)
KOKKOS_INLINE_FUNCTION Mask< scalar > operator!()
KOKKOS_INLINE_FUNCTION PCE< Storage > operator*(const PCE< Storage > &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION Mask< scalar > operator&&(const Mask< scalar > &m2)
static KOKKOS_INLINE_FUNCTION value_type & coeff(Sacado::MP::Vector< S > &x, int i)
KOKKOS_INLINE_FUNCTION MaskedAssign< scalar > & operator+=(const scalar &KOKKOS_RESTRICT s)
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)
KOKKOS_INLINE_FUNCTION Mask< Sacado::MP::Vector< S > > signbit_v(const Sacado::MP::Vector< S > &a1)
KOKKOS_INLINE_FUNCTION std::size_t getSize() const