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)
532 for(std::size_t i=0; i<
size; ++i)
533 this->data[i] = a.
data[i];
542 for(std::size_t i=0; i<
size; ++i)
551 for(std::size_t i=0; i<
size; ++i)
560 for(std::size_t i=0; i<
size; ++i)
569 for(std::size_t i=0; i<
size; ++i)
578 for(std::size_t i=0; i<
size; ++i)
587 for(std::size_t i=0; i<
size; ++i)
596 for (std::size_t i = 0; i <
size; ++i) {
597 all = all && (this->
get(i) == m2.
get(i));
610 for(std::size_t i=0; i<
size; ++i)
611 m3.
set(i,(this->get(i) && m2.
get(i)));
618 for(std::size_t i=0; i<
size; ++i)
619 m3.
set(i,(this->get(i) || m2.
get(i)));
627 for(std::size_t i=0; i<
size; ++i)
628 m3.
set(i,(this->get(i) && m2));
635 for(std::size_t i=0; i<
size; ++i)
636 m3.
set(i,(this->get(i) || m2));
644 for(std::size_t i=0; i<
size; ++i)
645 m3.
set(i,(this->get(i) + m2.
get(i)));
653 for(std::size_t i=0; i<
size; ++i)
654 m3.
set(i,(this->get(i) - m2.
get(i)));
659 KOKKOS_INLINE_FUNCTION scalar
operator* (
const scalar &v)
663 for(std::size_t i=0; i<
size; ++i)
664 ET::coeff(v2,i) = ET::coeff(v,i)*this->
get(i);
669 KOKKOS_INLINE_FUNCTION
bool get (
int i)
const 671 return this->data[i];
674 KOKKOS_INLINE_FUNCTION
void set (
int i,
bool b)
682 for(std::size_t i=0; i<
size; ++i)
683 m2.
set(i,!(this->get(i)));
687 KOKKOS_INLINE_FUNCTION
operator bool()
const 692 KOKKOS_INLINE_FUNCTION
operator double()
const 695 for(std::size_t i=0; i<
size; ++i)
702 template<
typename scalar> std::ostream &operator<<(std::ostream &os, const Mask<scalar>& m) {
704 for(std::size_t i=0; i<m.getSize(); ++i)
705 os << m.get(i) <<
" ";
713 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 716 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 717 #pragma vector aligned 719 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 722 for(std::size_t i=0; i<ET::size; ++i){
723 ET::coeff(mul,i) = ET::coeff(a1,i)*m.get(i);
732 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 735 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 736 #pragma vector aligned 738 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 741 for(std::size_t i=0; i<ET::size; ++i){
742 ET::coeff(mul,i) = m.get(i)*a1;
751 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 754 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 755 #pragma vector aligned 757 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 760 for(std::size_t i=0; i<ET::size; ++i){
761 ET::coeff(mul,i) = m.get(i)*a1;
801 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 804 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 805 #pragma vector aligned 807 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 810 for(std::size_t i=0; i<ET::size; ++i){
811 ET::coeff(a_out,i) =
copysign(ET::coeff(a1,i),ET::coeff(a2,i));
826 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 829 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 830 #pragma vector aligned 832 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 835 for(std::size_t i=0; i<ET::size; ++i)
836 mask.
set(i, signbit(ET::coeff(a1,i)));
908 #if STOKHOS_USE_MP_VECTOR_SFS_SPEC 940 template<
typename T> KOKKOS_INLINE_FUNCTION
bool OR(
Mask<T> m){
941 return (((
double) m)!=0.);
944 KOKKOS_INLINE_FUNCTION
bool OR(
bool m){
948 template<
typename T> KOKKOS_INLINE_FUNCTION
bool XOR(
Mask<T> m){
949 return (((
double) m)==1./m.getSize());
952 KOKKOS_INLINE_FUNCTION
bool XOR(
bool m){
956 template<
typename T> KOKKOS_INLINE_FUNCTION
bool AND(
Mask<T> m){
957 return (((
double) m)==1.);
960 KOKKOS_INLINE_FUNCTION
bool AND(
bool m){
966 #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)
KOKKOS_INLINE_FUNCTION Sacado::MP::Vector< S > operator*(const Sacado::MP::Vector< S > &a1, const Mask< Sacado::MP::Vector< S >> &m)
KOKKOS_INLINE_FUNCTION Mask< scalar > operator &&(const Mask< scalar > &m2)
static const std::size_t size
KOKKOS_INLINE_FUNCTION bool operator<=(double v)
KOKKOS_INLINE_FUNCTION Mask & operator=(const Mask &a)
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)
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()
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
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
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 bool get(int i) const
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)
KOKKOS_INLINE_FUNCTION std::size_t getSize() const
KOKKOS_INLINE_FUNCTION Mask< Sacado::MP::Vector< S > > signbit_v(const Sacado::MP::Vector< S > &a1)