35 #ifndef _BLAZE_MATH_VIEWS_ELEMENTS_DENSE_H_ 36 #define _BLAZE_MATH_VIEWS_ELEMENTS_DENSE_H_ 96 class Elements<VT,TF,true,CEAs...>
97 :
public View< DenseVector< Elements<VT,TF,true,CEAs...>, TF > >
98 ,
private ElementsData<CEAs...>
102 using DataType = ElementsData<CEAs...>;
103 using Operand = If_t< IsExpression_v<VT>, VT, VT& >;
113 using This = Elements<VT,TF,
true,CEAs...>;
115 using BaseType = DenseVector<This,TF>;
116 using ViewedType = VT;
117 using ResultType = ElementsTrait_t<VT,N>;
118 using TransposeType = TransposeType_t<ResultType>;
119 using ElementType = ElementType_t<VT>;
120 using ReturnType = ReturnType_t<VT>;
121 using CompositeType =
const Elements&;
124 using ConstReference = ConstReference_t<VT>;
127 using Reference = If_t< IsConst_v<VT>, ConstReference, Reference_t<VT> >;
130 using ConstPointer = ConstPointer_t<VT>;
133 using Pointer = If_t< IsConst_v<VT> || !HasMutableDataAccess_v<VT>, ConstPointer, Pointer_t<VT> >;
139 template<
typename ElementsType
140 ,
typename IteratorType >
141 class ElementsIterator
146 using IteratorCategory =
typename std::iterator_traits<IteratorType>::iterator_category;
149 using ValueType =
typename std::iterator_traits<IteratorType>::value_type;
152 using PointerType =
typename std::iterator_traits<IteratorType>::pointer;
155 using ReferenceType =
typename std::iterator_traits<IteratorType>::reference;
158 using DifferenceType =
typename std::iterator_traits<IteratorType>::difference_type;
161 using iterator_category = IteratorCategory;
162 using value_type = ValueType;
163 using pointer = PointerType;
164 using reference = ReferenceType;
165 using difference_type = DifferenceType;
171 inline ElementsIterator()
172 : elements_( nullptr )
184 inline ElementsIterator( ElementsType*
elements,
size_t index )
189 if( index_ < elements_->
size() )
190 pos_ = elements_->operand().begin() + elements_->idx( index_ );
199 template<
typename ElementsType2,
typename IteratorType2 >
200 inline ElementsIterator(
const ElementsIterator<ElementsType2,IteratorType2>& it )
201 : elements_( it.elements_ )
202 , index_ ( it.index_ )
213 inline ElementsIterator&
operator+=(
size_t inc ) {
216 if( index_ < elements_->
size() )
217 pos_ = elements_->operand().begin() + elements_->idx( index_ );
229 inline ElementsIterator&
operator-=(
size_t dec ) {
232 if( index_ < elements_->
size() )
233 pos_ = elements_->operand().begin() + elements_->idx( index_ );
244 inline ElementsIterator& operator++() {
247 if( index_ < elements_->
size() )
248 pos_ = elements_->operand().begin() + elements_->idx( index_ );
259 inline const ElementsIterator operator++(
int ) {
260 const ElementsIterator tmp( *
this );
271 inline ElementsIterator& operator--() {
274 if( index_ < elements_->
size() )
275 pos_ = elements_->operand().begin() + elements_->idx( index_ );
286 inline const ElementsIterator operator--(
int ) {
287 const ElementsIterator tmp( *
this );
299 inline ReferenceType operator[](
size_t index )
const {
300 const IteratorType pos( elements_->operand().begin() + elements_->idx( index_ + index ) );
320 inline PointerType operator->()
const {
331 inline bool operator==(
const ElementsIterator& rhs )
const {
332 return index_ == rhs.index_;
342 inline bool operator!=(
const ElementsIterator& rhs )
const {
343 return index_ != rhs.index_;
353 inline bool operator<(
const ElementsIterator& rhs )
const {
354 return index_ < rhs.index_;
364 inline bool operator>(
const ElementsIterator& rhs )
const {
365 return index_ > rhs.index_;
375 inline bool operator<=(
const ElementsIterator& rhs )
const {
376 return index_ <= rhs.index_;
386 inline bool operator>=(
const ElementsIterator& rhs )
const {
387 return index_ >= rhs.index_;
397 inline DifferenceType
operator-(
const ElementsIterator& rhs )
const {
398 return index_ - rhs.index_;
409 friend inline const ElementsIterator
operator+(
const ElementsIterator& it,
size_t inc ) {
410 return ElementsIterator( it.elements_, it.index_ + inc );
421 friend inline const ElementsIterator
operator+(
size_t inc,
const ElementsIterator& it ) {
422 return ElementsIterator( it.elements_, it.index_ + inc );
433 friend inline const ElementsIterator
operator-(
const ElementsIterator& it,
size_t dec ) {
434 return ElementsIterator( it.elements_, it.index_ - dec );
440 ElementsType* elements_;
446 template<
typename ElementsType2,
typename IteratorType2 >
friend class ElementsIterator;
453 using ConstIterator = ElementsIterator< const This, ConstIterator_t<VT> >;
456 using Iterator = If_t< IsConst_v<VT>, ConstIterator, ElementsIterator< This, Iterator_t<VT> > >;
461 static constexpr
bool simdEnabled =
false;
464 static constexpr
bool smpAssignable = VT::smpAssignable;
467 static constexpr
bool compileTimeArgs = DataType::compileTimeArgs;
473 template<
typename... REAs >
474 explicit inline Elements( VT& vector, REAs... args );
476 Elements(
const Elements& ) =
default;
477 Elements( Elements&& ) =
default;
484 ~Elements() =
default;
491 inline Reference operator[](
size_t index );
492 inline ConstReference operator[](
size_t index )
const;
493 inline Reference at(
size_t index );
494 inline ConstReference at(
size_t index )
const;
495 inline Pointer
data () noexcept;
496 inline ConstPointer
data () const noexcept;
497 inline Iterator
begin ();
498 inline ConstIterator
begin () const;
499 inline ConstIterator
cbegin() const;
500 inline Iterator
end ();
501 inline ConstIterator
end () const;
502 inline ConstIterator
cend () const;
509 inline Elements& operator= ( const ElementType& rhs );
510 inline Elements& operator= ( initializer_list<ElementType> list );
511 inline Elements& operator= ( const Elements& rhs );
512 template< typename VT2 > inline Elements& operator= ( const Vector<VT2,TF>& rhs );
513 template< typename VT2 > inline Elements& operator+=( const Vector<VT2,TF>& rhs );
514 template< typename VT2 > inline Elements& operator-=( const Vector<VT2,TF>& rhs );
515 template< typename VT2 > inline Elements& operator*=( const Vector<VT2,TF>& rhs );
516 template< typename VT2 > inline Elements& operator/=( const DenseVector<VT2,TF>& rhs );
517 template< typename VT2 > inline Elements& operator%=( const Vector<VT2,TF>& rhs );
524 using DataType::idces;
526 using DataType::
size;
528 inline VT& operand() noexcept;
529 inline const VT& operand() const noexcept;
531 inline
size_t spacing() const noexcept;
532 inline
size_t capacity() const noexcept;
541 template< typename Other > inline Elements& scale( const Other& scalar );
548 template< typename Other >
549 inline
bool canAlias( const Other* alias ) const noexcept;
551 template< typename Other >
552 inline
bool isAliased( const Other* alias ) const noexcept;
554 inline
bool isAligned () const noexcept;
555 inline
bool canSMPAssign() const noexcept;
557 template< typename VT2 > inline
void assign ( const DenseVector <VT2,TF>& rhs );
558 template< typename VT2 > inline
void assign ( const SparseVector<VT2,TF>& rhs );
559 template< typename VT2 > inline
void addAssign ( const DenseVector <VT2,TF>& rhs );
560 template< typename VT2 > inline
void addAssign ( const SparseVector<VT2,TF>& rhs );
561 template< typename VT2 > inline
void subAssign ( const DenseVector <VT2,TF>& rhs );
562 template< typename VT2 > inline
void subAssign ( const SparseVector<VT2,TF>& rhs );
563 template< typename VT2 > inline
void multAssign( const DenseVector <VT2,TF>& rhs );
564 template< typename VT2 > inline
void multAssign( const SparseVector<VT2,TF>& rhs );
565 template< typename VT2 > inline
void divAssign ( const DenseVector <VT2,TF>& rhs );
611 template< typename VT
614 template< typename... REAs >
615 inline Elements<VT,TF,true,CEAs...>::Elements( VT& vector, REAs... args )
616 : DataType( args... )
620 for(
size_t i=0UL; i<
size(); ++i ) {
621 if( vector_.size() <= idx(i) ) {
649 template<
typename VT
652 inline typename Elements<VT,TF,
true,CEAs...>::Reference
653 Elements<VT,TF,true,CEAs...>::operator[](
size_t index )
656 return vector_[idx(index)];
672 template<
typename VT
675 inline typename Elements<VT,TF,
true,CEAs...>::ConstReference
676 Elements<VT,TF,true,CEAs...>::operator[](
size_t index )
const 679 return const_cast<const VT&>( vector_ )[idx(index)];
696 template<
typename VT
699 inline typename Elements<VT,TF,
true,CEAs...>::Reference
700 Elements<VT,TF,true,CEAs...>::at(
size_t index )
702 if( index >=
size() ) {
705 return (*
this)[index];
722 template<
typename VT
725 inline typename Elements<VT,TF,
true,CEAs...>::ConstReference
726 Elements<VT,TF,true,CEAs...>::at(
size_t index )
const 728 if( index >=
size() ) {
731 return (*
this)[index];
745 template<
typename VT
748 inline typename Elements<VT,TF,
true,CEAs...>::Pointer
751 return vector_.data() + idx(0UL);
765 template<
typename VT
768 inline typename Elements<VT,TF,
true,CEAs...>::ConstPointer
771 return vector_.data() + idx(0UL);
785 template<
typename VT
788 inline typename Elements<VT,TF,
true,CEAs...>::Iterator
791 return Iterator(
this, 0UL );
805 template<
typename VT
808 inline typename Elements<VT,TF,
true,CEAs...>::ConstIterator
811 return ConstIterator(
this, 0UL );
825 template<
typename VT
828 inline typename Elements<VT,TF,
true,CEAs...>::ConstIterator
831 return ConstIterator(
this, 0UL );
845 template<
typename VT
848 inline typename Elements<VT,TF,
true,CEAs...>::Iterator
851 return Iterator(
this,
size() );
865 template<
typename VT
868 inline typename Elements<VT,TF,
true,CEAs...>::ConstIterator
871 return ConstIterator(
this,
size() );
885 template<
typename VT
888 inline typename Elements<VT,TF,
true,CEAs...>::ConstIterator
891 return ConstIterator(
this,
size() );
912 template<
typename VT
915 inline Elements<VT,TF,
true,CEAs...>&
916 Elements<VT,TF,true,CEAs...>::operator=(
const ElementType& rhs )
918 decltype(
auto) left( derestrict( vector_ ) );
920 for(
size_t i=0UL; i<
size(); ++i ) {
921 const size_t index( idx(i) );
922 if( !IsRestricted_v<VT> || trySet( vector_, index, rhs ) )
948 template<
typename VT
951 inline Elements<VT,TF,
true,CEAs...>&
952 Elements<VT,TF,true,CEAs...>::operator=( initializer_list<ElementType> list )
954 if( list.size() >
size() ) {
958 const InitializerVector<ElementType,TF> tmp( list,
size() );
960 if( IsRestricted_v<VT> ) {
961 for(
size_t i=0UL; i<
size(); ++i ) {
962 if( !trySet( vector_, idx(i), tmp[i] ) ) {
968 decltype(
auto) left( derestrict( vector_ ) );
969 for(
size_t i=0UL; i<
size(); ++i ) {
970 left[idx(i)] = tmp[i];
993 template<
typename VT
996 inline Elements<VT,TF,
true,CEAs...>&
997 Elements<VT,TF,true,CEAs...>::operator=(
const Elements& rhs )
1002 if( &rhs ==
this || ( &vector_ == &rhs.vector_ && compareIndices( *
this, rhs ) ) )
1005 if(
size() != rhs.size() ) {
1009 if( IsRestricted_v<VT> ) {
1010 for(
size_t i=0UL; i<
size(); ++i ) {
1011 if( !trySet( vector_, idx(i), rhs[i] ) ) {
1017 decltype(
auto) left( derestrict( *this ) );
1019 if( rhs.canAlias( &vector_ ) ) {
1020 const ResultType tmp( rhs );
1047 template<
typename VT
1049 ,
typename... CEAs >
1050 template<
typename VT2 >
1051 inline Elements<VT,TF,
true,CEAs...>&
1052 Elements<VT,TF,true,CEAs...>::operator=(
const Vector<VT2,TF>& rhs )
1061 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>,
const VT2& >;
1062 Right right( ~rhs );
1064 if( IsRestricted_v<VT> ) {
1065 for(
size_t i=0UL; i<
size(); ++i ) {
1066 if( !trySet( vector_, idx(i), right[i] ) ) {
1072 decltype(
auto) left( derestrict( *this ) );
1075 const ResultType_t<VT2> tmp( right );
1079 if( IsSparseVector_v<VT2> )
1104 template<
typename VT
1106 ,
typename... CEAs >
1107 template<
typename VT2 >
1108 inline Elements<VT,TF,
true,CEAs...>&
1118 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>,
const VT2& >;
1119 Right right( ~rhs );
1121 if( IsRestricted_v<VT> ) {
1122 for(
size_t i=0UL; i<
size(); ++i ) {
1123 if( !tryAdd( vector_, idx(i), right[i] ) ) {
1129 decltype(
auto) left( derestrict( *this ) );
1132 const ResultType_t<VT2> tmp( right );
1159 template<
typename VT
1161 ,
typename... CEAs >
1162 template<
typename VT2 >
1163 inline Elements<VT,TF,
true,CEAs...>&
1173 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>,
const VT2& >;
1174 Right right( ~rhs );
1176 if( IsRestricted_v<VT> ) {
1177 for(
size_t i=0UL; i<
size(); ++i ) {
1178 if( !trySub( vector_, idx(i), right[i] ) ) {
1184 decltype(
auto) left( derestrict( *this ) );
1187 const ResultType_t<VT2> tmp( right );
1215 template<
typename VT
1217 ,
typename... CEAs >
1218 template<
typename VT2 >
1219 inline Elements<VT,TF,
true,CEAs...>&
1229 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>,
const VT2& >;
1230 Right right( ~rhs );
1232 if( IsRestricted_v<VT> ) {
1233 for(
size_t i=0UL; i<
size(); ++i ) {
1234 if( !tryMult( vector_, idx(i), right[i] ) ) {
1240 decltype(
auto) left( derestrict( *this ) );
1243 const ResultType_t<VT2> tmp( right );
1270 template<
typename VT
1272 ,
typename... CEAs >
1273 template<
typename VT2 >
1274 inline Elements<VT,TF,
true,CEAs...>&
1284 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>,
const VT2& >;
1285 Right right( ~rhs );
1287 if( IsRestricted_v<VT> ) {
1288 for(
size_t i=0UL; i<
size(); ++i ) {
1289 if( !tryDiv( vector_, idx(i), right[i] ) ) {
1295 decltype(
auto) left( derestrict( *this ) );
1298 const ResultType_t<VT2> tmp( right );
1326 template<
typename VT
1328 ,
typename... CEAs >
1329 template<
typename VT2 >
1330 inline Elements<VT,TF,
true,CEAs...>&
1331 Elements<VT,TF,true,CEAs...>::operator%=(
const Vector<VT2,TF>& rhs )
1333 using blaze::assign;
1338 using CrossType = CrossTrait_t< ResultType, ResultType_t<VT2> >;
1344 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
1348 const CrossType tmp( *
this % (~rhs) );
1350 if( IsRestricted_v<VT> ) {
1351 for(
size_t i=0UL; i<
size(); ++i ) {
1352 if( !trySet( vector_, idx(i), tmp[i] ) ) {
1358 decltype(
auto) left( derestrict( *this ) );
1360 assign( left, tmp );
1384 template< typename VT
1386 , typename... CEAs >
1387 inline VT& Elements<VT,TF,true,CEAs...>::operand() noexcept
1401 template<
typename VT
1403 ,
typename... CEAs >
1404 inline const VT& Elements<VT,TF,true,CEAs...>::operand() const noexcept
1418 template<
typename VT
1420 ,
typename... CEAs >
1435 template<
typename VT
1437 ,
typename... CEAs >
1455 template<
typename VT
1457 ,
typename... CEAs >
1460 size_t nonzeros( 0 );
1462 for(
size_t i=0UL; i<
size(); ++i ) {
1479 template<
typename VT
1481 ,
typename... CEAs >
1486 for(
size_t i=0UL; i<
size(); ++i )
1487 clear( vector_[idx(i)] );
1512 template<
typename VT
1514 ,
typename... CEAs >
1515 template<
typename Other >
1516 inline Elements<VT,TF,
true,CEAs...>&
1517 Elements<VT,TF,true,CEAs...>::scale(
const Other& scalar )
1519 for(
size_t i=0UL; i<
size(); ++i )
1520 vector_[idx(i)] *= scalar;
1546 template<
typename VT
1548 ,
typename... CEAs >
1549 template<
typename Other >
1550 inline bool Elements<VT,TF,true,CEAs...>::canAlias(
const Other* alias )
const noexcept
1552 return vector_.isAliased( alias );
1569 template<
typename VT
1571 ,
typename... CEAs >
1572 template<
typename Other >
1573 inline bool Elements<VT,TF,true,CEAs...>::isAliased(
const Other* alias )
const noexcept
1575 return vector_.isAliased( alias );
1591 template<
typename VT
1593 ,
typename... CEAs >
1594 inline bool Elements<VT,TF,true,CEAs...>::isAligned() const noexcept
1613 template<
typename VT
1615 ,
typename... CEAs >
1616 inline bool Elements<VT,TF,true,CEAs...>::canSMPAssign() const noexcept
1618 return (
size() > SMP_DVECASSIGN_THRESHOLD );
1636 template<
typename VT
1638 ,
typename... CEAs >
1639 template<
typename VT2 >
1640 inline void Elements<VT,TF,true,CEAs...>::assign(
const DenseVector<VT2,TF>& rhs )
1644 const size_t ipos(
size() &
size_t(-2) );
1645 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1646 vector_[idx(i )] = (~rhs)[i ];
1647 vector_[idx(i+1UL)] = (~rhs)[i+1UL];
1649 if( ipos <
size() ) {
1650 vector_[idx(ipos)] = (~rhs)[ipos];
1669 template<
typename VT
1671 ,
typename... CEAs >
1672 template<
typename VT2 >
1673 inline void Elements<VT,TF,true,CEAs...>::assign(
const SparseVector<VT2,TF>& rhs )
1677 for( ConstIterator_t<VT2> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
1678 vector_[idx(element->index())] = element->value();
1696 template<
typename VT
1698 ,
typename... CEAs >
1699 template<
typename VT2 >
1700 inline void Elements<VT,TF,true,CEAs...>::addAssign(
const DenseVector<VT2,TF>& rhs )
1704 const size_t ipos(
size() &
size_t(-2) );
1705 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1706 vector_[idx(i )] += (~rhs)[i ];
1707 vector_[idx(i+1UL)] += (~rhs)[i+1UL];
1709 if( ipos <
size() ) {
1710 vector_[idx(ipos)] += (~rhs)[ipos];
1729 template<
typename VT
1731 ,
typename... CEAs >
1732 template<
typename VT2 >
1733 inline void Elements<VT,TF,true,CEAs...>::addAssign(
const SparseVector<VT2,TF>& rhs )
1737 for( ConstIterator_t<VT2> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
1738 vector_[idx(element->index())] += element->value();
1756 template<
typename VT
1758 ,
typename... CEAs >
1759 template<
typename VT2 >
1760 inline void Elements<VT,TF,true,CEAs...>::subAssign(
const DenseVector<VT2,TF>& rhs )
1764 const size_t ipos(
size() &
size_t(-2) );
1765 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1766 vector_[idx(i )] -= (~rhs)[i ];
1767 vector_[idx(i+1UL)] -= (~rhs)[i+1UL];
1769 if( ipos <
size() ) {
1770 vector_[idx(ipos)] -= (~rhs)[ipos];
1789 template<
typename VT
1791 ,
typename... CEAs >
1792 template<
typename VT2 >
1793 inline void Elements<VT,TF,true,CEAs...>::subAssign(
const SparseVector<VT2,TF>& rhs )
1797 for( ConstIterator_t<VT2> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
1798 vector_[idx(element->index())] -= element->value();
1816 template<
typename VT
1818 ,
typename... CEAs >
1819 template<
typename VT2 >
1820 inline void Elements<VT,TF,true,CEAs...>::multAssign(
const DenseVector<VT2,TF>& rhs )
1824 const size_t ipos(
size() &
size_t(-2) );
1825 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1826 vector_[idx(i )] *= (~rhs)[i ];
1827 vector_[idx(i+1UL)] *= (~rhs)[i+1UL];
1829 if( ipos <
size() ) {
1830 vector_[idx(ipos)] *= (~rhs)[ipos];
1849 template<
typename VT
1851 ,
typename... CEAs >
1852 template<
typename VT2 >
1853 inline void Elements<VT,TF,true,CEAs...>::multAssign(
const SparseVector<VT2,TF>& rhs )
1861 for( ConstIterator_t<VT2> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1862 const size_t index( element->index() );
1863 for( ; i<index; ++i )
1864 reset( vector_[idx(i)] );
1865 vector_[idx(i)] *= element->value();
1869 for( ; i<
size(); ++i ) {
1870 reset( vector_[idx(i)] );
1889 template<
typename VT
1891 ,
typename... CEAs >
1892 template<
typename VT2 >
1893 inline void Elements<VT,TF,true,CEAs...>::divAssign(
const DenseVector<VT2,TF>& rhs )
1897 const size_t ipos(
size() &
size_t(-2) );
1898 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1899 vector_[idx(i )] /= (~rhs)[i ];
1900 vector_[idx(i+1UL)] /= (~rhs)[i+1UL];
1902 if( ipos <
size() ) {
1903 vector_[idx(ipos)] /= (~rhs)[ipos];
1930 template<
typename VT1
1933 ,
typename... CEAs >
1934 class Elements< const DVecDVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >
1935 :
public View< DenseVector< Elements< const DVecDVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >, TF > >
1936 ,
private ElementsData<CEAs...>
1940 using CPE = DVecDVecCrossExpr<VT1,VT2,TF>;
1941 using RT = ResultType_t<CPE>;
1942 using DataType = ElementsData<CEAs...>;
1952 using This = Elements<
const CPE,TF,
true,CEAs...>;
1954 using BaseType = DenseVector<This,TF>;
1955 using ViewedType = CPE;
1956 using ResultType = ElementsTrait_t<RT,N>;
1957 using TransposeType = TransposeType_t<ResultType>;
1958 using ElementType = ElementType_t<CPE>;
1959 using ReturnType = ReturnType_t<CPE>;
1960 using CompositeType =
const ResultType;
1965 static constexpr
bool simdEnabled =
false;
1968 static constexpr
bool smpAssignable =
false;
1971 static constexpr
bool compileTimeArgs = DataType::compileTimeArgs;
1981 template<
typename... REAs >
1982 explicit inline Elements(
const CPE& vector, REAs... args )
1983 : DataType( args... )
1984 , vector_ ( vector )
1987 for(
size_t i=0UL; i<
size(); ++i ) {
1988 if( vector_.size() <= idx(i) ) {
2002 inline ReturnType operator[](
size_t index )
const {
2004 return vector_[idx(index)];
2015 inline ReturnType at(
size_t index )
const {
2016 if( index >=
size() ) {
2019 return (*
this)[index];
2024 using DataType::idces;
2025 using DataType::idx;
2034 inline CPE operand() const noexcept {
2045 template<
typename T >
2046 inline bool canAlias(
const T* alias )
const noexcept {
2047 return vector_.canAlias( alias );
2057 template<
typename T >
2058 inline bool isAliased(
const T* alias )
const noexcept {
2059 return vector_.isAliased( alias );
2092 template<
typename VT1
2095 ,
typename... CEAs >
2096 class Elements< const DVecSVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >
2097 :
public View< DenseVector< Elements< const DVecSVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >, TF > >
2098 ,
private ElementsData<CEAs...>
2102 using CPE = DVecSVecCrossExpr<VT1,VT2,TF>;
2103 using RT = ResultType_t<CPE>;
2104 using DataType = ElementsData<CEAs...>;
2114 using This = Elements<
const CPE,TF,
true,CEAs...>;
2116 using BaseType = DenseVector<This,TF>;
2117 using ViewedType = CPE;
2118 using ResultType = ElementsTrait_t<RT,N>;
2119 using TransposeType = TransposeType_t<ResultType>;
2120 using ElementType = ElementType_t<CPE>;
2121 using ReturnType = ReturnType_t<CPE>;
2122 using CompositeType =
const ResultType;
2127 static constexpr
bool simdEnabled =
false;
2130 static constexpr
bool smpAssignable =
false;
2133 static constexpr
bool compileTimeArgs = DataType::compileTimeArgs;
2143 template<
typename... REAs >
2144 explicit inline Elements(
const CPE& vector, REAs... args )
2145 : DataType( args... )
2146 , vector_ ( vector )
2149 for(
size_t i=0UL; i<
size(); ++i ) {
2150 if( vector_.size() <= idx(i) ) {
2164 inline ReturnType operator[](
size_t index )
const {
2166 return vector_[idx(index)];
2177 inline ReturnType at(
size_t index )
const {
2178 if( index >=
size() ) {
2181 return (*
this)[index];
2186 using DataType::idces;
2187 using DataType::idx;
2196 inline CPE operand() const noexcept {
2207 template<
typename T >
2208 inline bool canAlias(
const T* alias )
const noexcept {
2209 return vector_.canAlias( alias );
2219 template<
typename T >
2220 inline bool isAliased(
const T* alias )
const noexcept {
2221 return vector_.isAliased( alias );
2254 template<
typename VT1
2257 ,
typename... CEAs >
2258 class Elements< const SVecDVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >
2259 :
public View< DenseVector< Elements< const SVecDVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >, TF > >
2260 ,
private ElementsData<CEAs...>
2264 using CPE = SVecDVecCrossExpr<VT1,VT2,TF>;
2265 using RT = ResultType_t<CPE>;
2266 using DataType = ElementsData<CEAs...>;
2276 using This = Elements<
const CPE,TF,
true,CEAs...>;
2278 using BaseType = DenseVector<This,TF>;
2279 using ViewedType = CPE;
2280 using ResultType = ElementsTrait_t<RT,N>;
2281 using TransposeType = TransposeType_t<ResultType>;
2282 using ElementType = ElementType_t<CPE>;
2283 using ReturnType = ReturnType_t<CPE>;
2284 using CompositeType =
const ResultType;
2289 static constexpr
bool simdEnabled =
false;
2292 static constexpr
bool smpAssignable =
false;
2295 static constexpr
bool compileTimeArgs = DataType::compileTimeArgs;
2305 template<
typename... REAs >
2306 explicit inline Elements(
const CPE& vector, REAs... args )
2307 : DataType( args... )
2308 , vector_ ( vector )
2311 for(
size_t i=0UL; i<
size(); ++i ) {
2312 if( vector_.size() <= idx(i) ) {
2326 inline ReturnType operator[](
size_t index )
const {
2328 return vector_[idx(index)];
2339 inline ReturnType at(
size_t index )
const {
2340 if( index >=
size() ) {
2343 return (*
this)[index];
2348 using DataType::idces;
2349 using DataType::idx;
2358 inline CPE operand() const noexcept {
2369 template<
typename T >
2370 inline bool canAlias(
const T* alias )
const noexcept {
2371 return vector_.canAlias( alias );
2381 template<
typename T >
2382 inline bool isAliased(
const T* alias )
const noexcept {
2383 return vector_.isAliased( alias );
2416 template<
typename VT1
2419 ,
typename... CEAs >
2420 class Elements< const SVecSVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >
2421 :
public View< DenseVector< Elements< const SVecSVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >, TF > >
2422 ,
private ElementsData<CEAs...>
2426 using CPE = SVecSVecCrossExpr<VT1,VT2,TF>;
2427 using RT = ResultType_t<CPE>;
2428 using DataType = ElementsData<CEAs...>;
2438 using This = Elements<
const CPE,TF,
true,CEAs...>;
2440 using BaseType = DenseVector<This,TF>;
2441 using ViewedType = CPE;
2442 using ResultType = ElementsTrait_t<RT,N>;
2443 using TransposeType = TransposeType_t<ResultType>;
2444 using ElementType = ElementType_t<CPE>;
2445 using ReturnType = ReturnType_t<CPE>;
2446 using CompositeType =
const ResultType;
2451 static constexpr
bool simdEnabled =
false;
2454 static constexpr
bool smpAssignable =
false;
2457 static constexpr
bool compileTimeArgs = DataType::compileTimeArgs;
2467 template<
typename... REAs >
2468 explicit inline Elements(
const CPE& vector, REAs... args )
2469 : DataType( args... )
2470 , vector_ ( vector )
2473 for(
size_t i=0UL; i<
size(); ++i ) {
2474 if( vector_.size() <= idx(i) ) {
2488 inline ReturnType operator[](
size_t index )
const {
2490 return vector_[idx(index)];
2501 inline ReturnType at(
size_t index )
const {
2502 if( index >=
size() ) {
2505 return (*
this)[index];
2510 using DataType::idces;
2511 using DataType::idx;
2520 inline CPE operand() const noexcept {
2531 template<
typename T >
2532 inline bool canAlias(
const T* alias )
const noexcept {
2533 return vector_.canAlias( alias );
2543 template<
typename T >
2544 inline bool isAliased(
const T* alias )
const noexcept {
2545 return vector_.isAliased( alias );
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
Header file for the blaze::checked and blaze::unchecked instances.
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:432
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
constexpr const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:750
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:170
Header file for the View base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i....
Definition: Computation.h:81
constexpr bool operator<(const NegativeAccuracy< A > &lhs, const T &rhs)
Less-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:332
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
Header file for the DenseVector base class.
Constraint on the data type.
constexpr bool IsReference_v
Auxiliary variable template for the IsReference type trait.The IsReference_v variable template provid...
Definition: IsReference.h:95
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Header file for the reset shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i....
Definition: TransExpr.h:81
Header file for the extended initializer_list functionality.
Header file for the elements trait.
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:482
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:416
auto smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:220
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:253
Constraint on the data type.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
Header file for the implementation of a vector representation of an initializer list.
decltype(auto) operator *(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:9091
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
constexpr bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:370
constexpr bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:446
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:370
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:253
constexpr bool Contains_v
Auxiliary variable template for the Contains type trait.The Contains_v variable template provides a c...
Definition: Contains.h:138
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ELEMENTS_TYPE(T)
Constraint on the data type.In case the given data type T is an element selection (i....
Definition: Elements.h:81
Constraint on the data type.
Header file for the implementation of the Elements base template.
Constraint on the data type.
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:139
Constraint on the data type.
Header file for the exception macros of the math module.
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
Constraint on the data type.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( ).
Definition: DenseMatrix.h:558
Header file for the IsSparseVector type trait.
Header file for the IsConst type trait.
Header file for run time assertion macros.
Header file for the cross product trait.
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
Header file for the Unique class template.
Check< false > Unchecked
Type of the blaze::unchecked instance.blaze::Unchecked is the type of the blaze::unchecked instance,...
Definition: Check.h:96
Header file for all forward declarations for expression class templates.
Header file for the isDefault shim.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
constexpr bool operator<=(const NegativeAccuracy< A > &, const T &rhs)
Less-or-equal-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:408
Header file for the HasMutableDataAccess type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the IsReference type trait.
constexpr const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:718
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type,...
Definition: DenseVector.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SUBVECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is a subvector type (i.e....
Definition: Subvector.h:81
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
Header file for the implementation of the ElementsData class template.
auto operator *=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:494
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
Header file for the IsRestricted type trait.
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.In case the given data type T is not a dense or sparse vector type and in...
Definition: TransposeFlag.h:63
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101
auto smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP multiplication assignment of a vector to a dense vector.
Definition: DenseVector.h:191
Header file for the clear shim.
Header file for the IsExpression type trait class.