/* This file is part of the Vc library. Copyright (C) 2009-2012 Matthias Kretz Vc is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Vc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Vc. If not, see . */ #ifndef VC_SCALAR_WRITEMASKEDVECTOR_H #define VC_SCALAR_WRITEMASKEDVECTOR_H namespace ROOT { namespace Vc { namespace Scalar { template class WriteMaskedVector { friend class Vector; typedef typename Vector::Mask Mask; typedef typename Vector::EntryType EntryType; public: //prefix Vc_ALWAYS_INLINE Vector &operator++() { if (mask) ++vec->m_data; return *vec; } Vc_ALWAYS_INLINE Vector &operator--() { if (mask) --vec->m_data; return *vec; } //postfix Vc_ALWAYS_INLINE Vector operator++(int) { if (mask) vec->m_data++; return *vec; } Vc_ALWAYS_INLINE Vector operator--(int) { if (mask) vec->m_data--; return *vec; } Vc_ALWAYS_INLINE Vector &operator+=(Vector x) { if (mask) vec->m_data += x.m_data; return *vec; } Vc_ALWAYS_INLINE Vector &operator-=(Vector x) { if (mask) vec->m_data -= x.m_data; return *vec; } Vc_ALWAYS_INLINE Vector &operator*=(Vector x) { if (mask) vec->m_data *= x.m_data; return *vec; } Vc_ALWAYS_INLINE Vector &operator/=(Vector x) { if (mask) vec->m_data /= x.m_data; return *vec; } Vc_ALWAYS_INLINE Vector &operator=(Vector x) { vec->assign(x, mask); return *vec; } Vc_ALWAYS_INLINE Vector &operator+=(EntryType x) { if (mask) vec->m_data += x; return *vec; } Vc_ALWAYS_INLINE Vector &operator-=(EntryType x) { if (mask) vec->m_data -= x; return *vec; } Vc_ALWAYS_INLINE Vector &operator*=(EntryType x) { if (mask) vec->m_data *= x; return *vec; } Vc_ALWAYS_INLINE Vector &operator/=(EntryType x) { if (mask) vec->m_data /= x; return *vec; } Vc_ALWAYS_INLINE Vector &operator=(EntryType x) { vec->assign(Vector(x), mask); return *vec; } template Vc_ALWAYS_INLINE void call(const F &f) const { vec->call(f, mask); } template Vc_ALWAYS_INLINE void call(F &f) const { vec->call(f, mask); } template Vc_ALWAYS_INLINE Vector apply(const F &f) const { if (mask) { return Vector(f(vec->m_data)); } else { return *vec; } } template Vc_ALWAYS_INLINE Vector apply(F &f) const { if (mask) { return Vector(f(vec->m_data)); } else { return *vec; } } private: Vc_ALWAYS_INLINE WriteMaskedVector(Vector *v, Mask k) : vec(v), mask(k) {} Vector *const vec; Mask mask; }; } // namespace Scalar } // namespace Vc } // namespace ROOT #endif // VC_SCALAR_WRITEMASKEDVECTOR_H