Loading src/TNL/Containers/DistributedVector.h +10 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,11 @@ public: typename = std::enable_if_t< ! HasSubscriptOperator<Scalar>::value > > DistributedVector& operator/=( Scalar c ); template< typename Scalar, typename..., typename = std::enable_if_t< ! HasSubscriptOperator<Scalar>::value > > DistributedVector& operator%=( Scalar c ); template< typename Vector, typename..., typename = std::enable_if_t< HasSubscriptOperator<Vector>::value > > Loading @@ -174,6 +179,11 @@ public: typename..., typename = std::enable_if_t< HasSubscriptOperator<Vector>::value > > DistributedVector& operator/=( const Vector& vector ); template< typename Vector, typename..., typename = std::enable_if_t< HasSubscriptOperator<Vector>::value > > DistributedVector& operator%=( const Vector& vector ); }; // Enable expression templates for DistributedVector Loading src/TNL/Containers/DistributedVector.hpp +26 −0 Original line number Diff line number Diff line Loading @@ -184,6 +184,19 @@ operator/=( const Vector& vector ) return *this; } template< typename Real, typename Device, typename Index, typename Allocator > template< typename Vector, typename..., typename > DistributedVector< Real, Device, Index, Allocator >& DistributedVector< Real, Device, Index, Allocator >:: operator%=( const Vector& vector ) { getView() %= vector; return *this; } template< typename Real, typename Device, typename Index, Loading Loading @@ -249,5 +262,18 @@ operator/=( Scalar c ) return *this; } template< typename Real, typename Device, typename Index, typename Allocator > template< typename Scalar, typename..., typename > DistributedVector< Real, Device, Index, Allocator >& DistributedVector< Real, Device, Index, Allocator >:: operator%=( Scalar c ) { getView() %= c; return *this; } } // namespace Containers } // namespace TNL src/TNL/Containers/DistributedVectorView.h +10 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,11 @@ public: typename = std::enable_if_t< ! HasSubscriptOperator<Scalar>::value > > DistributedVectorView& operator/=( Scalar c ); template< typename Scalar, typename..., typename = std::enable_if_t< ! HasSubscriptOperator<Scalar>::value > > DistributedVectorView& operator%=( Scalar c ); template< typename Vector, typename..., typename = std::enable_if_t< HasSubscriptOperator<Vector>::value > > Loading @@ -145,6 +150,11 @@ public: typename..., typename = std::enable_if_t< HasSubscriptOperator<Vector>::value > > DistributedVectorView& operator/=( const Vector& vector ); template< typename Vector, typename..., typename = std::enable_if_t< HasSubscriptOperator<Vector>::value > > DistributedVectorView& operator%=( const Vector& vector ); }; // Enable expression templates for DistributedVector Loading src/TNL/Containers/DistributedVectorView.hpp +41 −0 Original line number Diff line number Diff line Loading @@ -212,6 +212,32 @@ operator/=( const Vector& vector ) return *this; } template< typename Real, typename Device, typename Index > template< typename Vector, typename..., typename > DistributedVectorView< Real, Device, Index >& DistributedVectorView< Real, Device, Index >:: operator%=( const Vector& vector ) { TNL_ASSERT_EQ( this->getSize(), vector.getSize(), "Vector sizes must be equal." ); TNL_ASSERT_EQ( this->getLocalRange(), vector.getLocalRange(), "Multiary operations are supported only on vectors which are distributed the same way." ); TNL_ASSERT_EQ( this->getGhosts(), vector.getGhosts(), "Ghosts must be equal, views are not resizable." ); TNL_ASSERT_EQ( this->getCommunicationGroup(), vector.getCommunicationGroup(), "Multiary operations are supported only on vectors within the same communication group." ); if( this->getCommunicationGroup() != MPI::NullGroup() ) { // TODO: it might be better to split the local and ghost parts and synchronize in the middle this->waitForSynchronization(); vector.waitForSynchronization(); getLocalViewWithGhosts() %= vector.getConstLocalViewWithGhosts(); } return *this; } template< typename Real, typename Device, typename Index > Loading Loading @@ -287,5 +313,20 @@ operator/=( Scalar c ) return *this; } template< typename Real, typename Device, typename Index > template< typename Scalar, typename..., typename > DistributedVectorView< Real, Device, Index >& DistributedVectorView< Real, Device, Index >:: operator%=( Scalar c ) { if( this->getCommunicationGroup() != MPI::NullGroup() ) { getLocalView() %= c; this->startSynchronization(); } return *this; } } // namespace Containers } // namespace TNL src/TNL/Containers/StaticVector.h +27 −15 Original line number Diff line number Diff line Loading @@ -158,6 +158,18 @@ public: __cuda_callable__ StaticVector& operator/=( const VectorExpression& expression ); /** * \brief Elementwise modulo by a vector expression. * * The vector expression can be even just static vector. * * \param expression is the vector expression * \return reference to this vector */ template< typename VectorExpression > __cuda_callable__ StaticVector& operator%=( const VectorExpression& expression ); /** * \brief Cast operator for changing of the \e Value type. * Loading Loading
src/TNL/Containers/DistributedVector.h +10 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,11 @@ public: typename = std::enable_if_t< ! HasSubscriptOperator<Scalar>::value > > DistributedVector& operator/=( Scalar c ); template< typename Scalar, typename..., typename = std::enable_if_t< ! HasSubscriptOperator<Scalar>::value > > DistributedVector& operator%=( Scalar c ); template< typename Vector, typename..., typename = std::enable_if_t< HasSubscriptOperator<Vector>::value > > Loading @@ -174,6 +179,11 @@ public: typename..., typename = std::enable_if_t< HasSubscriptOperator<Vector>::value > > DistributedVector& operator/=( const Vector& vector ); template< typename Vector, typename..., typename = std::enable_if_t< HasSubscriptOperator<Vector>::value > > DistributedVector& operator%=( const Vector& vector ); }; // Enable expression templates for DistributedVector Loading
src/TNL/Containers/DistributedVector.hpp +26 −0 Original line number Diff line number Diff line Loading @@ -184,6 +184,19 @@ operator/=( const Vector& vector ) return *this; } template< typename Real, typename Device, typename Index, typename Allocator > template< typename Vector, typename..., typename > DistributedVector< Real, Device, Index, Allocator >& DistributedVector< Real, Device, Index, Allocator >:: operator%=( const Vector& vector ) { getView() %= vector; return *this; } template< typename Real, typename Device, typename Index, Loading Loading @@ -249,5 +262,18 @@ operator/=( Scalar c ) return *this; } template< typename Real, typename Device, typename Index, typename Allocator > template< typename Scalar, typename..., typename > DistributedVector< Real, Device, Index, Allocator >& DistributedVector< Real, Device, Index, Allocator >:: operator%=( Scalar c ) { getView() %= c; return *this; } } // namespace Containers } // namespace TNL
src/TNL/Containers/DistributedVectorView.h +10 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,11 @@ public: typename = std::enable_if_t< ! HasSubscriptOperator<Scalar>::value > > DistributedVectorView& operator/=( Scalar c ); template< typename Scalar, typename..., typename = std::enable_if_t< ! HasSubscriptOperator<Scalar>::value > > DistributedVectorView& operator%=( Scalar c ); template< typename Vector, typename..., typename = std::enable_if_t< HasSubscriptOperator<Vector>::value > > Loading @@ -145,6 +150,11 @@ public: typename..., typename = std::enable_if_t< HasSubscriptOperator<Vector>::value > > DistributedVectorView& operator/=( const Vector& vector ); template< typename Vector, typename..., typename = std::enable_if_t< HasSubscriptOperator<Vector>::value > > DistributedVectorView& operator%=( const Vector& vector ); }; // Enable expression templates for DistributedVector Loading
src/TNL/Containers/DistributedVectorView.hpp +41 −0 Original line number Diff line number Diff line Loading @@ -212,6 +212,32 @@ operator/=( const Vector& vector ) return *this; } template< typename Real, typename Device, typename Index > template< typename Vector, typename..., typename > DistributedVectorView< Real, Device, Index >& DistributedVectorView< Real, Device, Index >:: operator%=( const Vector& vector ) { TNL_ASSERT_EQ( this->getSize(), vector.getSize(), "Vector sizes must be equal." ); TNL_ASSERT_EQ( this->getLocalRange(), vector.getLocalRange(), "Multiary operations are supported only on vectors which are distributed the same way." ); TNL_ASSERT_EQ( this->getGhosts(), vector.getGhosts(), "Ghosts must be equal, views are not resizable." ); TNL_ASSERT_EQ( this->getCommunicationGroup(), vector.getCommunicationGroup(), "Multiary operations are supported only on vectors within the same communication group." ); if( this->getCommunicationGroup() != MPI::NullGroup() ) { // TODO: it might be better to split the local and ghost parts and synchronize in the middle this->waitForSynchronization(); vector.waitForSynchronization(); getLocalViewWithGhosts() %= vector.getConstLocalViewWithGhosts(); } return *this; } template< typename Real, typename Device, typename Index > Loading Loading @@ -287,5 +313,20 @@ operator/=( Scalar c ) return *this; } template< typename Real, typename Device, typename Index > template< typename Scalar, typename..., typename > DistributedVectorView< Real, Device, Index >& DistributedVectorView< Real, Device, Index >:: operator%=( Scalar c ) { if( this->getCommunicationGroup() != MPI::NullGroup() ) { getLocalView() %= c; this->startSynchronization(); } return *this; } } // namespace Containers } // namespace TNL
src/TNL/Containers/StaticVector.h +27 −15 Original line number Diff line number Diff line Loading @@ -158,6 +158,18 @@ public: __cuda_callable__ StaticVector& operator/=( const VectorExpression& expression ); /** * \brief Elementwise modulo by a vector expression. * * The vector expression can be even just static vector. * * \param expression is the vector expression * \return reference to this vector */ template< typename VectorExpression > __cuda_callable__ StaticVector& operator%=( const VectorExpression& expression ); /** * \brief Cast operator for changing of the \e Value type. * Loading