Loading src/TNL/Containers/Array.h +35 −30 Original line number Diff line number Diff line Loading @@ -256,21 +256,26 @@ class Array /** * \brief Returns a modifiable view of the array. * * \param begin is the index of the first element of the ArrayView * \param end is the index of the element after the last one in the ArrayView. * By default it is -1 which means that whole array will be covered by the ArrayView. * If \e begin and \e end is set, view for sub-interval [ \e begin, \e end ) * is returned. * * \param begin is the beginning of the Array sub-interval, 0 by default. * \param end is the end of the Array sub-interval. Default value is 0 which is, * however, replaced with the Array size. */ ViewType getView( IndexType begin = 0, IndexType end = -1 ); ViewType getView( IndexType begin = 0, IndexType end = 0 ); /** * \brief Returns a non-modifiable view of the array. * * \param begin is the index of the first element of the ArrayView * \param end is the index of the element after the last one in the ArrayView. * By default it is -1 which means that whole array will be covered by the ArrayView. * If \e begin and \e end is set, view for sub-interval [ \e begin, \e end ) * is returned. * * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. */ ConstViewType getConstView( IndexType begin = 0, IndexType end = -1 ) const; ConstViewType getConstView( IndexType begin = 0, IndexType end = 0 ) const; /** * \brief Conversion operator to a modifiable view of the array. Loading Loading @@ -470,65 +475,65 @@ class Array /** * \brief Sets the array elements to given value. * * Sets whole array values or just a subinterval to \e v. * Sets whole array or just its sub-interval [ \e begin, end ) to value \e v. * * \param v Reference to a value. * \param begin is the index of the first element to be changed * \param end is the index of the element after the last one to be changed. * By default it is -1 which means that whole array is considered. * By default it is 0 which means that whole array is considered. */ void setValue( const Value& v, const Index begin = 0, Index end = -1 ); Index end = 0 ); /** * \brief Sets the array elements using given lambda function. * * Sets all the array values to \e v. * Evaluates a lambda function \e f on whole array or just on its sub-interval [ \e begin, end ). * * \param v Reference to a value. * \param begin is the index of the first element to be changed * \param begin is * \param end is the index of the element after the last one to be changed. * By default it is -1 which means that whole array is considered. * By default it is 0 which means that whole array is considered. */ template< typename Function > void evaluate( const Function& f, const Index begin = 0, Index end = -1 ); Index end = 0 ); /** * \brief Checks if there is an element with value \e v. * * By default, the method checks all array elements. By setting indexes * \e begin and \e end, only elements in given interval are checked. * Checks, if there is an element with value \e value in the ArrayView or in * its sub-interval [\e begin, \e end ). * * \param v is reference to the value. * \param begin is the first element to be checked * \param end is the last element to be checked. If \e end equals -1, its * value is replaces by the array size. * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the Array size. * * \return True if there is **at least one** array element in interval [\e begin, \e end ) having value \e v. * \return True if there is **at least one** array element in sub-interval [\e begin, \e end) having value \e v. */ bool containsValue( const Value& v, const Index begin = 0, Index end = -1 ) const; Index end = 0 ) const; /** * \brief Checks if all elements have the same value \e v. * * By default, the method checks all array elements. By setting indexes * \e begin and \e end, only elements in given interval are checked. * Checks, if all elements in the ArrayView or in its sub-interval [\e begin, \e end ) * have the same value \e value. * * \param v Reference to a value. * \param begin is the first element to be checked * \param end is the last element to be checked. If \e end equals -1, its * value is replaces by the array size. * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. * * \return True if there **all** array elements in interval [\e begin, \e end ) have value \e v. * \return True if **all** all array elements or elements in sub-interval [\e begin, \e end ) have value \e v. */ bool containsOnlyValue( const Value& v, const Index begin = 0, Index end = -1 ) const; Index end = 0 ) const; /** * \brief Returns true if non-zero size is set. Loading src/TNL/Containers/Array.hpp +5 −5 Original line number Diff line number Diff line Loading @@ -337,7 +337,7 @@ typename Array< Value, Device, Index >::ViewType Array< Value, Device, Index >:: getView( IndexType begin, IndexType end ) { if( end == -1 ) if( end == 0 ) end = getSize(); return ViewType( &getData()[ begin ], end - begin ); } Loading @@ -349,7 +349,7 @@ typename Array< Value, Device, Index >::ConstViewType Array< Value, Device, Index >:: getConstView( IndexType begin, IndexType end ) const { if( end == -1 ) if( end == 0 ) end = getSize(); return ConstViewType( &getData()[ begin ], end - begin ); } Loading Loading @@ -598,7 +598,7 @@ void Array< Value, Device, Index >::setValue( const ValueType& e, Index end ) { TNL_ASSERT_TRUE( this->getData(), "Attempted to set a value of an empty array." ); if( end == -1 ) if( end == 0 ) end = this->getSize(); Algorithms::ArrayOperations< Device >::setMemory( &this->getData()[ begin ], e, end - begin ); } Loading @@ -625,7 +625,7 @@ containsValue( const Value& v, Index end ) const { TNL_ASSERT_TRUE( this->getData(), "Attempted to check a value of an empty array." ); if( end == -1 ) if( end == 0 ) end = this->getSize(); return Algorithms::ArrayOperations< Device >::containsValue( &this->getData()[ begin ], end - begin, v ); Loading @@ -641,7 +641,7 @@ containsOnlyValue( const Value& v, Index end ) const { TNL_ASSERT_TRUE( this->getData(), "Attempted to check a value of an empty array." ); if( end == -1 ) if( end == 0 ) end = this->getSize(); return Algorithms::ArrayOperations< Device >::containsOnlyValue( &this->getData()[ begin ], end - begin, v ); Loading src/TNL/Containers/ArrayView.h +38 −35 Original line number Diff line number Diff line Loading @@ -171,22 +171,28 @@ public: /** * \brief Returns a modifiable view of the array view. * * \param begin is the index of the first element of the ArrayView * \param end is the index of the element after the last one in the ArrayView. * By default it is -1 which means that whole array will be covered by the ArrayView. * If \e begin and \e end is set, view for sub-interval [ \e begin, \e end ) * is returned. * * \param begin is the beginning of the ArrayView sub-interval, 0 by default. * \param end is the end of the ArrayView sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. */ __cuda_callable__ ViewType getView( const IndexType begin = 0, IndexType end = -1 ); ViewType getView( const IndexType begin = 0, IndexType end = 0 ); /** * \brief Returns a non-modifiable view of the array view. * * \param begin is the index of the first element of the ArrayView * \param end is the index of the element after the last one in the ArrayView. * By default it is -1 which means that whole array will be covered by the ArrayView. * If \e begin and \e end is set, view for sub-interval [ \e begin, \e end ) * is returned. * * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. */ __cuda_callable__ ConstViewType getConstView( const IndexType begin = 0, IndexType end = -1 ) const; ConstViewType getConstView( const IndexType begin = 0, IndexType end = 0 ) const; /** * \brief Assignment operator. Loading Loading @@ -371,65 +377,65 @@ public: /** * \brief Sets the array view elements to given value. * * Sets all the array values to \e v. * Sets whole array values or just its sub-interval [ \e begin, end ) to value \e v. * * \param v Reference to a value. * \param begin is the index of the first element to be changed * \param end is the index of the element after the last one to be changed. * By default it is -1 which means that whole array is considered. * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. */ void setValue( Value value, const Index begin = 0, Index end = -1 ); Index end = 0 ); /** * \brief Sets the array elements using given lambda function. * * Sets all the array values to \e v. * Evaluates a lambda function \e f on whole array or just on its sub-interval [\e begin, \e end). * * \param v Reference to a value. * \param begin is the index of the first element to be changed * \param end is the index of the element after the last one to be changed. * By default it is -1 which means that whole array is considered. * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. */ template< typename Function > void evaluate( const Function& f, const Index begin = 0, Index end = -1 ); Index end = 0 ); /** * \brief Checks if there is an element with value \e v. * * By default, the method checks all array view elements. By setting indexes * \e begin and \e end, only elements in given interval are checked. * Checks, if there is an element with value \e value in the ArrayView or in * its sub-interval [\e begin, \e end ). * * \param v is reference to the value. * \param begin is the first element to be checked * \param end is the last element to be checked. If \e end equals -1, its * value is replaces by the array size. * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. * * \return True if there is **at least one** array element in interval [\e begin, \e end ) having value \e v. * \return True if there is **at least one** array element in sub-interval [\e begin, \e end) having value \e v. */ bool containsValue( Value value, const Index begin = 0, Index end = -1 ) const; Index end = 0 ) const; /** * \brief Checks if all elements have the same value \e v. * * By default, the method checks all array view elements. By setting indexes * \e begin and \e end, only elements in given interval are checked. * Checks, if all elements in the ArrayView or in its sub-interval [\e begin, \e end ) * have the same value \e value. * * \param v Reference to a value. * \param begin is the first element to be checked * \param end is the last element to be checked. If \e end equals -1, its * value is replaces by the array size. * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. * * \return True if there **all** array elements in interval [\e begin, \e end ) have value \e v. * \return True if **all** all array elements or elements in sub-interval [\e begin, \e end ) have value \e v. */ bool containsOnlyValue( Value value, const Index begin = 0, Index end = -1 ) const; Index end = 0 ) const; /** * \brief Returns true if non-zero size is set. Loading @@ -437,9 +443,6 @@ public: * This method can be called from device kernels. * * \return Returns \e true if array view size is zero, \e false otherwise. * \param begin is the index of the first element to be changed * \param end is the index of the element after the last one to be changed. * By default it is -1 which means that whole array is considered. */ __cuda_callable__ bool empty() const; Loading src/TNL/Containers/ArrayView.hpp +6 −6 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ typename ArrayView< Value, Device, Index >::ViewType ArrayView< Value, Device, Index >:: getView( const IndexType begin, IndexType end ) { if( end == -1 ) if( end == 0 ) end = this->getSize(); return ViewType( &getData()[ begin ], end - begin );; } Loading @@ -105,7 +105,7 @@ typename ArrayView< Value, Device, Index >::ConstViewType ArrayView< Value, Device, Index >:: getConstView( const IndexType begin, IndexType end ) const { if( end == -1 ) if( end == 0 ) end = this->getSize(); return ConstViewType( &getData()[ begin ], end - begin ); } Loading Loading @@ -302,7 +302,7 @@ ArrayView< Value, Device, Index >:: setValue( Value value, const Index begin, Index end ) { TNL_ASSERT_GT( size, 0, "Attempted to set value to an empty array view." ); if( end == -1 ) if( end == 0 ) end = this->getSize(); Algorithms::ArrayOperations< Device >::setMemory( &getData()[ begin ], value, end - begin ); } Loading @@ -322,7 +322,7 @@ evaluate( const Function& f, const Index begin, Index end ) d[ i ] = f( i ); }; if( end == -1 ) if( end == 0 ) end = this->getSize(); ParallelFor< DeviceType >::exec( begin, end, eval ); Loading @@ -337,7 +337,7 @@ containsValue( Value value, const Index begin, Index end ) const { if( end == -1 ) if( end == 0 ) end = this->getSize(); return Algorithms::ArrayOperations< Device >::containsValue( &this->getData()[ begin ], end - begin, value ); } Loading @@ -351,7 +351,7 @@ containsOnlyValue( Value value, const Index begin, Index end ) const { if( end == -1 ) if( end == 0 ) end = this->getSize(); return Algorithms::ArrayOperations< Device >::containsOnlyValue( &this->getData()[ begin ], end - begin, value ); } Loading src/TNL/Containers/Vector.h +21 −7 Original line number Diff line number Diff line Loading @@ -99,7 +99,7 @@ public: */ Vector( Vector& vector, const IndexType& begin = 0, const IndexType& size = -1 ); const IndexType& size = 0 ); /** * \brief Move constructor. Loading Loading @@ -139,13 +139,27 @@ public: /** * \brief Returns a modifiable view of the vector. * * If \e begin and \e end is set, view for sub-interval [ \e begin, \e end ) * is returned. * * \param begin is the beginning of the Vector sub-interval, 0 by default. * \param end is the end of the Vector sub-interval. Default value is 0 which is, * however, replaced with the Vector size. */ ViewType getView( IndexType begin = 0, IndexType end = -1 ); ViewType getView( IndexType begin = 0, IndexType end = 0 ); /** * \brief Returns a non-modifiable view of the vector. * * If \e begin and \e end is set, view for sub-interval [ \e begin, \e end ) * is returned. * * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the Vector size. */ ConstViewType getConstView( IndexType begin = 0, IndexType end = -1 ) const; ConstViewType getConstView( IndexType begin = 0, IndexType end = 0 ) const; /** * \brief Conversion operator to a modifiable view of the vector. Loading Loading @@ -375,20 +389,20 @@ public: * \param end Index of the element in this vector which to end with. */ template< Algorithms::PrefixSumType Type = Algorithms::PrefixSumType::Inclusive > void prefixSum( const IndexType begin = - 1, const IndexType end = -1 ); void prefixSum( const IndexType begin = 0, const IndexType end = 0 ); template< Algorithms::PrefixSumType Type = Algorithms::PrefixSumType::Inclusive, typename FlagsArray > void segmentedPrefixSum( FlagsArray& flags, const IndexType begin = -1, const IndexType end = -1 ); void segmentedPrefixSum( FlagsArray& flags, const IndexType begin = 0, const IndexType end = 0 ); template< Algorithms::PrefixSumType Type = Algorithms::PrefixSumType::Inclusive, typename VectorExpression > void prefixSum( const VectorExpression& expression, const IndexType begin = - 1, const IndexType end = -1 ); void prefixSum( const VectorExpression& expression, const IndexType begin = 0, const IndexType end = 0 ); template< Algorithms::PrefixSumType Type = Algorithms::PrefixSumType::Inclusive, typename VectorExpression, typename FlagsArray > void segmentedPrefixSum( const VectorExpression& expression, FlagsArray& flags, const IndexType begin = -1, const IndexType end = -1 ); void segmentedPrefixSum( const VectorExpression& expression, FlagsArray& flags, const IndexType begin = 0, const IndexType end = 0 ); }; } // namespace Containers Loading Loading
src/TNL/Containers/Array.h +35 −30 Original line number Diff line number Diff line Loading @@ -256,21 +256,26 @@ class Array /** * \brief Returns a modifiable view of the array. * * \param begin is the index of the first element of the ArrayView * \param end is the index of the element after the last one in the ArrayView. * By default it is -1 which means that whole array will be covered by the ArrayView. * If \e begin and \e end is set, view for sub-interval [ \e begin, \e end ) * is returned. * * \param begin is the beginning of the Array sub-interval, 0 by default. * \param end is the end of the Array sub-interval. Default value is 0 which is, * however, replaced with the Array size. */ ViewType getView( IndexType begin = 0, IndexType end = -1 ); ViewType getView( IndexType begin = 0, IndexType end = 0 ); /** * \brief Returns a non-modifiable view of the array. * * \param begin is the index of the first element of the ArrayView * \param end is the index of the element after the last one in the ArrayView. * By default it is -1 which means that whole array will be covered by the ArrayView. * If \e begin and \e end is set, view for sub-interval [ \e begin, \e end ) * is returned. * * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. */ ConstViewType getConstView( IndexType begin = 0, IndexType end = -1 ) const; ConstViewType getConstView( IndexType begin = 0, IndexType end = 0 ) const; /** * \brief Conversion operator to a modifiable view of the array. Loading Loading @@ -470,65 +475,65 @@ class Array /** * \brief Sets the array elements to given value. * * Sets whole array values or just a subinterval to \e v. * Sets whole array or just its sub-interval [ \e begin, end ) to value \e v. * * \param v Reference to a value. * \param begin is the index of the first element to be changed * \param end is the index of the element after the last one to be changed. * By default it is -1 which means that whole array is considered. * By default it is 0 which means that whole array is considered. */ void setValue( const Value& v, const Index begin = 0, Index end = -1 ); Index end = 0 ); /** * \brief Sets the array elements using given lambda function. * * Sets all the array values to \e v. * Evaluates a lambda function \e f on whole array or just on its sub-interval [ \e begin, end ). * * \param v Reference to a value. * \param begin is the index of the first element to be changed * \param begin is * \param end is the index of the element after the last one to be changed. * By default it is -1 which means that whole array is considered. * By default it is 0 which means that whole array is considered. */ template< typename Function > void evaluate( const Function& f, const Index begin = 0, Index end = -1 ); Index end = 0 ); /** * \brief Checks if there is an element with value \e v. * * By default, the method checks all array elements. By setting indexes * \e begin and \e end, only elements in given interval are checked. * Checks, if there is an element with value \e value in the ArrayView or in * its sub-interval [\e begin, \e end ). * * \param v is reference to the value. * \param begin is the first element to be checked * \param end is the last element to be checked. If \e end equals -1, its * value is replaces by the array size. * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the Array size. * * \return True if there is **at least one** array element in interval [\e begin, \e end ) having value \e v. * \return True if there is **at least one** array element in sub-interval [\e begin, \e end) having value \e v. */ bool containsValue( const Value& v, const Index begin = 0, Index end = -1 ) const; Index end = 0 ) const; /** * \brief Checks if all elements have the same value \e v. * * By default, the method checks all array elements. By setting indexes * \e begin and \e end, only elements in given interval are checked. * Checks, if all elements in the ArrayView or in its sub-interval [\e begin, \e end ) * have the same value \e value. * * \param v Reference to a value. * \param begin is the first element to be checked * \param end is the last element to be checked. If \e end equals -1, its * value is replaces by the array size. * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. * * \return True if there **all** array elements in interval [\e begin, \e end ) have value \e v. * \return True if **all** all array elements or elements in sub-interval [\e begin, \e end ) have value \e v. */ bool containsOnlyValue( const Value& v, const Index begin = 0, Index end = -1 ) const; Index end = 0 ) const; /** * \brief Returns true if non-zero size is set. Loading
src/TNL/Containers/Array.hpp +5 −5 Original line number Diff line number Diff line Loading @@ -337,7 +337,7 @@ typename Array< Value, Device, Index >::ViewType Array< Value, Device, Index >:: getView( IndexType begin, IndexType end ) { if( end == -1 ) if( end == 0 ) end = getSize(); return ViewType( &getData()[ begin ], end - begin ); } Loading @@ -349,7 +349,7 @@ typename Array< Value, Device, Index >::ConstViewType Array< Value, Device, Index >:: getConstView( IndexType begin, IndexType end ) const { if( end == -1 ) if( end == 0 ) end = getSize(); return ConstViewType( &getData()[ begin ], end - begin ); } Loading Loading @@ -598,7 +598,7 @@ void Array< Value, Device, Index >::setValue( const ValueType& e, Index end ) { TNL_ASSERT_TRUE( this->getData(), "Attempted to set a value of an empty array." ); if( end == -1 ) if( end == 0 ) end = this->getSize(); Algorithms::ArrayOperations< Device >::setMemory( &this->getData()[ begin ], e, end - begin ); } Loading @@ -625,7 +625,7 @@ containsValue( const Value& v, Index end ) const { TNL_ASSERT_TRUE( this->getData(), "Attempted to check a value of an empty array." ); if( end == -1 ) if( end == 0 ) end = this->getSize(); return Algorithms::ArrayOperations< Device >::containsValue( &this->getData()[ begin ], end - begin, v ); Loading @@ -641,7 +641,7 @@ containsOnlyValue( const Value& v, Index end ) const { TNL_ASSERT_TRUE( this->getData(), "Attempted to check a value of an empty array." ); if( end == -1 ) if( end == 0 ) end = this->getSize(); return Algorithms::ArrayOperations< Device >::containsOnlyValue( &this->getData()[ begin ], end - begin, v ); Loading
src/TNL/Containers/ArrayView.h +38 −35 Original line number Diff line number Diff line Loading @@ -171,22 +171,28 @@ public: /** * \brief Returns a modifiable view of the array view. * * \param begin is the index of the first element of the ArrayView * \param end is the index of the element after the last one in the ArrayView. * By default it is -1 which means that whole array will be covered by the ArrayView. * If \e begin and \e end is set, view for sub-interval [ \e begin, \e end ) * is returned. * * \param begin is the beginning of the ArrayView sub-interval, 0 by default. * \param end is the end of the ArrayView sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. */ __cuda_callable__ ViewType getView( const IndexType begin = 0, IndexType end = -1 ); ViewType getView( const IndexType begin = 0, IndexType end = 0 ); /** * \brief Returns a non-modifiable view of the array view. * * \param begin is the index of the first element of the ArrayView * \param end is the index of the element after the last one in the ArrayView. * By default it is -1 which means that whole array will be covered by the ArrayView. * If \e begin and \e end is set, view for sub-interval [ \e begin, \e end ) * is returned. * * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. */ __cuda_callable__ ConstViewType getConstView( const IndexType begin = 0, IndexType end = -1 ) const; ConstViewType getConstView( const IndexType begin = 0, IndexType end = 0 ) const; /** * \brief Assignment operator. Loading Loading @@ -371,65 +377,65 @@ public: /** * \brief Sets the array view elements to given value. * * Sets all the array values to \e v. * Sets whole array values or just its sub-interval [ \e begin, end ) to value \e v. * * \param v Reference to a value. * \param begin is the index of the first element to be changed * \param end is the index of the element after the last one to be changed. * By default it is -1 which means that whole array is considered. * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. */ void setValue( Value value, const Index begin = 0, Index end = -1 ); Index end = 0 ); /** * \brief Sets the array elements using given lambda function. * * Sets all the array values to \e v. * Evaluates a lambda function \e f on whole array or just on its sub-interval [\e begin, \e end). * * \param v Reference to a value. * \param begin is the index of the first element to be changed * \param end is the index of the element after the last one to be changed. * By default it is -1 which means that whole array is considered. * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. */ template< typename Function > void evaluate( const Function& f, const Index begin = 0, Index end = -1 ); Index end = 0 ); /** * \brief Checks if there is an element with value \e v. * * By default, the method checks all array view elements. By setting indexes * \e begin and \e end, only elements in given interval are checked. * Checks, if there is an element with value \e value in the ArrayView or in * its sub-interval [\e begin, \e end ). * * \param v is reference to the value. * \param begin is the first element to be checked * \param end is the last element to be checked. If \e end equals -1, its * value is replaces by the array size. * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. * * \return True if there is **at least one** array element in interval [\e begin, \e end ) having value \e v. * \return True if there is **at least one** array element in sub-interval [\e begin, \e end) having value \e v. */ bool containsValue( Value value, const Index begin = 0, Index end = -1 ) const; Index end = 0 ) const; /** * \brief Checks if all elements have the same value \e v. * * By default, the method checks all array view elements. By setting indexes * \e begin and \e end, only elements in given interval are checked. * Checks, if all elements in the ArrayView or in its sub-interval [\e begin, \e end ) * have the same value \e value. * * \param v Reference to a value. * \param begin is the first element to be checked * \param end is the last element to be checked. If \e end equals -1, its * value is replaces by the array size. * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the ArrayView size. * * \return True if there **all** array elements in interval [\e begin, \e end ) have value \e v. * \return True if **all** all array elements or elements in sub-interval [\e begin, \e end ) have value \e v. */ bool containsOnlyValue( Value value, const Index begin = 0, Index end = -1 ) const; Index end = 0 ) const; /** * \brief Returns true if non-zero size is set. Loading @@ -437,9 +443,6 @@ public: * This method can be called from device kernels. * * \return Returns \e true if array view size is zero, \e false otherwise. * \param begin is the index of the first element to be changed * \param end is the index of the element after the last one to be changed. * By default it is -1 which means that whole array is considered. */ __cuda_callable__ bool empty() const; Loading
src/TNL/Containers/ArrayView.hpp +6 −6 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ typename ArrayView< Value, Device, Index >::ViewType ArrayView< Value, Device, Index >:: getView( const IndexType begin, IndexType end ) { if( end == -1 ) if( end == 0 ) end = this->getSize(); return ViewType( &getData()[ begin ], end - begin );; } Loading @@ -105,7 +105,7 @@ typename ArrayView< Value, Device, Index >::ConstViewType ArrayView< Value, Device, Index >:: getConstView( const IndexType begin, IndexType end ) const { if( end == -1 ) if( end == 0 ) end = this->getSize(); return ConstViewType( &getData()[ begin ], end - begin ); } Loading Loading @@ -302,7 +302,7 @@ ArrayView< Value, Device, Index >:: setValue( Value value, const Index begin, Index end ) { TNL_ASSERT_GT( size, 0, "Attempted to set value to an empty array view." ); if( end == -1 ) if( end == 0 ) end = this->getSize(); Algorithms::ArrayOperations< Device >::setMemory( &getData()[ begin ], value, end - begin ); } Loading @@ -322,7 +322,7 @@ evaluate( const Function& f, const Index begin, Index end ) d[ i ] = f( i ); }; if( end == -1 ) if( end == 0 ) end = this->getSize(); ParallelFor< DeviceType >::exec( begin, end, eval ); Loading @@ -337,7 +337,7 @@ containsValue( Value value, const Index begin, Index end ) const { if( end == -1 ) if( end == 0 ) end = this->getSize(); return Algorithms::ArrayOperations< Device >::containsValue( &this->getData()[ begin ], end - begin, value ); } Loading @@ -351,7 +351,7 @@ containsOnlyValue( Value value, const Index begin, Index end ) const { if( end == -1 ) if( end == 0 ) end = this->getSize(); return Algorithms::ArrayOperations< Device >::containsOnlyValue( &this->getData()[ begin ], end - begin, value ); } Loading
src/TNL/Containers/Vector.h +21 −7 Original line number Diff line number Diff line Loading @@ -99,7 +99,7 @@ public: */ Vector( Vector& vector, const IndexType& begin = 0, const IndexType& size = -1 ); const IndexType& size = 0 ); /** * \brief Move constructor. Loading Loading @@ -139,13 +139,27 @@ public: /** * \brief Returns a modifiable view of the vector. * * If \e begin and \e end is set, view for sub-interval [ \e begin, \e end ) * is returned. * * \param begin is the beginning of the Vector sub-interval, 0 by default. * \param end is the end of the Vector sub-interval. Default value is 0 which is, * however, replaced with the Vector size. */ ViewType getView( IndexType begin = 0, IndexType end = -1 ); ViewType getView( IndexType begin = 0, IndexType end = 0 ); /** * \brief Returns a non-modifiable view of the vector. * * If \e begin and \e end is set, view for sub-interval [ \e begin, \e end ) * is returned. * * \param begin is the beginning of the sub-interval, 0 by default. * \param end is the end of the sub-interval. Default value is 0 which is, * however, replaced with the Vector size. */ ConstViewType getConstView( IndexType begin = 0, IndexType end = -1 ) const; ConstViewType getConstView( IndexType begin = 0, IndexType end = 0 ) const; /** * \brief Conversion operator to a modifiable view of the vector. Loading Loading @@ -375,20 +389,20 @@ public: * \param end Index of the element in this vector which to end with. */ template< Algorithms::PrefixSumType Type = Algorithms::PrefixSumType::Inclusive > void prefixSum( const IndexType begin = - 1, const IndexType end = -1 ); void prefixSum( const IndexType begin = 0, const IndexType end = 0 ); template< Algorithms::PrefixSumType Type = Algorithms::PrefixSumType::Inclusive, typename FlagsArray > void segmentedPrefixSum( FlagsArray& flags, const IndexType begin = -1, const IndexType end = -1 ); void segmentedPrefixSum( FlagsArray& flags, const IndexType begin = 0, const IndexType end = 0 ); template< Algorithms::PrefixSumType Type = Algorithms::PrefixSumType::Inclusive, typename VectorExpression > void prefixSum( const VectorExpression& expression, const IndexType begin = - 1, const IndexType end = -1 ); void prefixSum( const VectorExpression& expression, const IndexType begin = 0, const IndexType end = 0 ); template< Algorithms::PrefixSumType Type = Algorithms::PrefixSumType::Inclusive, typename VectorExpression, typename FlagsArray > void segmentedPrefixSum( const VectorExpression& expression, FlagsArray& flags, const IndexType begin = -1, const IndexType end = -1 ); void segmentedPrefixSum( const VectorExpression& expression, FlagsArray& flags, const IndexType begin = 0, const IndexType end = 0 ); }; } // namespace Containers Loading