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;
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> >;
461 static constexpr
bool simdEnabled =
false;
470 template<
typename... REAs >
471 explicit inline Elements( VT& vector, REAs... args );
473 Elements(
const Elements& ) =
default;
474 Elements( Elements&& ) =
default;
481 ~Elements() =
default;
488 inline Reference operator[](
size_t index );
492 inline Pointer
data () noexcept;
493 inline ConstPointer
data () const noexcept;
506 inline Elements& operator= ( const
ElementType& rhs );
507 inline Elements& operator= ( initializer_list<
ElementType> list );
508 inline Elements& operator= ( const Elements& rhs );
509 template< typename VT2 > inline Elements& operator= ( const Vector<VT2,TF>& rhs );
510 template< typename VT2 > inline Elements& operator+=( const Vector<VT2,TF>& rhs );
511 template< typename VT2 > inline Elements& operator-=( const Vector<VT2,TF>& rhs );
512 template< typename VT2 > inline Elements& operator*=( const Vector<VT2,TF>& rhs );
513 template< typename VT2 > inline Elements& operator/=( const DenseVector<VT2,TF>& rhs );
514 template< typename VT2 > inline Elements& operator%=( const Vector<VT2,TF>& rhs );
521 using DataType::idces;
523 using DataType::
size;
525 inline VT& operand() noexcept;
526 inline const VT& operand() const noexcept;
528 inline
size_t spacing() const noexcept;
529 inline
size_t capacity() const noexcept;
538 template< typename Other > inline Elements& scale( const Other& scalar );
545 template< typename Other >
546 inline
bool canAlias( const Other* alias ) const noexcept;
548 template< typename Other >
549 inline
bool isAliased( const Other* alias ) const noexcept;
551 inline
bool isAligned () const noexcept;
552 inline
bool canSMPAssign() const noexcept;
554 template< typename VT2 > inline
void assign ( const DenseVector <VT2,TF>& rhs );
555 template< typename VT2 > inline
void assign ( const SparseVector<VT2,TF>& rhs );
556 template< typename VT2 > inline
void addAssign ( const DenseVector <VT2,TF>& rhs );
557 template< typename VT2 > inline
void addAssign ( const SparseVector<VT2,TF>& rhs );
558 template< typename VT2 > inline
void subAssign ( const DenseVector <VT2,TF>& rhs );
559 template< typename VT2 > inline
void subAssign ( const SparseVector<VT2,TF>& rhs );
560 template< typename VT2 > inline
void multAssign( const DenseVector <VT2,TF>& rhs );
561 template< typename VT2 > inline
void multAssign( const SparseVector<VT2,TF>& rhs );
562 template< typename VT2 > inline
void divAssign ( const DenseVector <VT2,TF>& rhs );
607 template< typename VT
610 template< typename... REAs >
611 inline Elements<VT,TF,true,CEAs...>::Elements( VT& vector, REAs... args )
612 : DataType( args... )
616 for(
size_t i=0UL; i<
size(); ++i ) {
617 if( vector_.size() <= idx(i) ) {
645 template<
typename VT
648 inline typename Elements<VT,TF,
true,CEAs...>
::Reference 649 Elements<VT,TF,true,CEAs...>::operator[](
size_t index )
652 return vector_[idx(index)];
668 template<
typename VT
672 Elements<VT,TF,true,CEAs...>::operator[](
size_t index )
const 675 return const_cast<const VT&
>( vector_ )[idx(index)];
692 template<
typename VT
695 inline typename Elements<VT,TF,
true,CEAs...>
::Reference 696 Elements<VT,TF,true,CEAs...>::at(
size_t index )
698 if( index >=
size() ) {
701 return (*
this)[index];
718 template<
typename VT
722 Elements<VT,TF,true,CEAs...>::at(
size_t index )
const 724 if( index >=
size() ) {
727 return (*
this)[index];
741 template<
typename VT
744 inline typename Elements<VT,TF,
true,CEAs...>::Pointer
747 return vector_.data() + idx(0UL);
761 template<
typename VT
764 inline typename Elements<VT,TF,
true,CEAs...>::ConstPointer
767 return vector_.data() + idx(0UL);
781 template<
typename VT
784 inline typename Elements<VT,TF,
true,CEAs...>
::Iterator 801 template<
typename VT
821 template<
typename VT
841 template<
typename VT
844 inline typename Elements<VT,TF,
true,CEAs...>
::Iterator 861 template<
typename VT
881 template<
typename VT
908 template<
typename VT
911 inline Elements<VT,TF,
true,CEAs...>&
912 Elements<VT,TF,true,CEAs...>::operator=(
const ElementType& rhs )
914 decltype(
auto) left( derestrict( vector_ ) );
916 for(
size_t i=0UL; i<
size(); ++i ) {
917 const size_t index( idx(i) );
918 if( !IsRestricted_v<VT> || trySet( vector_, index, rhs ) )
944 template<
typename VT
947 inline Elements<VT,TF,
true,CEAs...>&
948 Elements<VT,TF,true,CEAs...>::operator=( initializer_list<ElementType> list )
950 if( list.size() >
size() ) {
954 const InitializerVector<ElementType,TF> tmp( list,
size() );
956 if( IsRestricted_v<VT> ) {
957 for(
size_t i=0UL; i<
size(); ++i ) {
958 if( !trySet( vector_, idx(i), tmp[i] ) ) {
964 decltype(
auto) left( derestrict( vector_ ) );
965 for(
size_t i=0UL; i<
size(); ++i ) {
966 left[idx(i)] = tmp[i];
989 template<
typename VT
992 inline Elements<VT,TF,
true,CEAs...>&
993 Elements<VT,TF,true,CEAs...>::operator=(
const Elements& rhs )
998 if( &rhs ==
this || ( &vector_ == &rhs.vector_ && compareIndices( *
this, rhs ) ) )
1001 if(
size() != rhs.size() ) {
1005 if( IsRestricted_v<VT> ) {
1006 for(
size_t i=0UL; i<
size(); ++i ) {
1007 if( !trySet( vector_, idx(i), rhs[i] ) ) {
1013 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1015 if( rhs.canAlias( &vector_ ) ) {
1043 template<
typename VT
1045 ,
typename... CEAs >
1046 template<
typename VT2 >
1047 inline Elements<VT,TF,
true,CEAs...>&
1048 Elements<VT,TF,true,CEAs...>::operator=(
const Vector<VT2,TF>& rhs )
1057 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>,
const VT2& >;
1058 Right right( ~rhs );
1060 if( IsRestricted_v<VT> ) {
1061 for(
size_t i=0UL; i<
size(); ++i ) {
1062 if( !trySet( vector_, idx(i), right[i] ) ) {
1068 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1070 if( IsReference_v<Right> && right.canAlias( &vector_ ) ) {
1071 const ResultType_t<VT2> tmp( right );
1075 if( IsSparseVector_v<VT2> )
1100 template<
typename VT
1102 ,
typename... CEAs >
1103 template<
typename VT2 >
1104 inline Elements<VT,TF,
true,CEAs...>&
1114 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>,
const VT2& >;
1115 Right right( ~rhs );
1117 if( IsRestricted_v<VT> ) {
1118 for(
size_t i=0UL; i<
size(); ++i ) {
1119 if( !tryAdd( vector_, idx(i), right[i] ) ) {
1125 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1127 if( IsReference_v<Right> && right.canAlias( &vector_ ) ) {
1128 const ResultType_t<VT2> tmp( right );
1155 template<
typename VT
1157 ,
typename... CEAs >
1158 template<
typename VT2 >
1159 inline Elements<VT,TF,
true,CEAs...>&
1169 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>,
const VT2& >;
1170 Right right( ~rhs );
1172 if( IsRestricted_v<VT> ) {
1173 for(
size_t i=0UL; i<
size(); ++i ) {
1174 if( !trySub( vector_, idx(i), right[i] ) ) {
1180 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1182 if( IsReference_v<Right> && right.canAlias( &vector_ ) ) {
1183 const ResultType_t<VT2> tmp( right );
1211 template<
typename VT
1213 ,
typename... CEAs >
1214 template<
typename VT2 >
1215 inline Elements<VT,TF,
true,CEAs...>&
1225 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>,
const VT2& >;
1226 Right right( ~rhs );
1228 if( IsRestricted_v<VT> ) {
1229 for(
size_t i=0UL; i<
size(); ++i ) {
1230 if( !tryMult( vector_, idx(i), right[i] ) ) {
1236 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1238 if( IsReference_v<Right> && right.canAlias( &vector_ ) ) {
1239 const ResultType_t<VT2> tmp( right );
1266 template<
typename VT
1268 ,
typename... CEAs >
1269 template<
typename VT2 >
1270 inline Elements<VT,TF,
true,CEAs...>&
1280 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>,
const VT2& >;
1281 Right right( ~rhs );
1283 if( IsRestricted_v<VT> ) {
1284 for(
size_t i=0UL; i<
size(); ++i ) {
1285 if( !tryDiv( vector_, idx(i), right[i] ) ) {
1291 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1293 if( IsReference_v<Right> && right.canAlias( &vector_ ) ) {
1294 const ResultType_t<VT2> tmp( right );
1322 template<
typename VT
1324 ,
typename... CEAs >
1325 template<
typename VT2 >
1326 inline Elements<VT,TF,
true,CEAs...>&
1327 Elements<VT,TF,true,CEAs...>::operator%=(
const Vector<VT2,TF>& rhs )
1329 using blaze::assign;
1334 using CrossType = CrossTrait_t< ResultType, ResultType_t<VT2> >;
1340 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
1344 const CrossType tmp( *
this % (~rhs) );
1346 if( IsRestricted_v<VT> ) {
1347 for(
size_t i=0UL; i<
size(); ++i ) {
1348 if( !trySet( vector_, idx(i), tmp[i] ) ) {
1354 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1356 assign( left, tmp );
1380 template<
typename VT
1382 ,
typename... CEAs >
1383 inline VT& Elements<VT,TF,true,CEAs...>::operand() noexcept
1397 template<
typename VT
1399 ,
typename... CEAs >
1400 inline const VT& Elements<VT,TF,true,CEAs...>::operand() const noexcept
1414 template<
typename VT
1416 ,
typename... CEAs >
1431 template<
typename VT
1433 ,
typename... CEAs >
1451 template<
typename VT
1453 ,
typename... CEAs >
1456 size_t nonzeros( 0 );
1458 for(
size_t i=0UL; i<
size(); ++i ) {
1475 template<
typename VT
1477 ,
typename... CEAs >
1482 for(
size_t i=0UL; i<
size(); ++i )
1483 clear( vector_[idx(i)] );
1508 template<
typename VT
1510 ,
typename... CEAs >
1511 template<
typename Other >
1512 inline Elements<VT,TF,
true,CEAs...>&
1513 Elements<VT,TF,true,CEAs...>::scale(
const Other& scalar )
1515 for(
size_t i=0UL; i<
size(); ++i )
1516 vector_[idx(i)] *= scalar;
1542 template<
typename VT
1544 ,
typename... CEAs >
1545 template<
typename Other >
1546 inline bool Elements<VT,TF,true,CEAs...>::canAlias(
const Other* alias )
const noexcept
1548 return vector_.isAliased( alias );
1565 template<
typename VT
1567 ,
typename... CEAs >
1568 template<
typename Other >
1569 inline bool Elements<VT,TF,true,CEAs...>::isAliased(
const Other* alias )
const noexcept
1571 return vector_.isAliased( alias );
1587 template<
typename VT
1589 ,
typename... CEAs >
1590 inline bool Elements<VT,TF,true,CEAs...>::isAligned() const noexcept
1609 template<
typename VT
1611 ,
typename... CEAs >
1612 inline bool Elements<VT,TF,true,CEAs...>::canSMPAssign() const noexcept
1614 return (
size() > SMP_DVECASSIGN_THRESHOLD );
1632 template<
typename VT
1634 ,
typename... CEAs >
1635 template<
typename VT2 >
1636 inline void Elements<VT,TF,true,CEAs...>::assign(
const DenseVector<VT2,TF>& rhs )
1640 const size_t ipos(
size() &
size_t(-2) );
1641 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1642 vector_[idx(i )] = (~rhs)[i ];
1643 vector_[idx(i+1UL)] = (~rhs)[i+1UL];
1645 if( ipos <
size() ) {
1646 vector_[idx(ipos)] = (~rhs)[ipos];
1665 template<
typename VT
1667 ,
typename... CEAs >
1668 template<
typename VT2 >
1669 inline void Elements<VT,TF,true,CEAs...>::assign(
const SparseVector<VT2,TF>& rhs )
1673 for( ConstIterator_t<VT2> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
1674 vector_[idx(element->index())] = element->value();
1692 template<
typename VT
1694 ,
typename... CEAs >
1695 template<
typename VT2 >
1696 inline void Elements<VT,TF,true,CEAs...>::addAssign(
const DenseVector<VT2,TF>& rhs )
1700 const size_t ipos(
size() &
size_t(-2) );
1701 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1702 vector_[idx(i )] += (~rhs)[i ];
1703 vector_[idx(i+1UL)] += (~rhs)[i+1UL];
1705 if( ipos <
size() ) {
1706 vector_[idx(ipos)] += (~rhs)[ipos];
1725 template<
typename VT
1727 ,
typename... CEAs >
1728 template<
typename VT2 >
1729 inline void Elements<VT,TF,true,CEAs...>::addAssign(
const SparseVector<VT2,TF>& rhs )
1733 for( ConstIterator_t<VT2> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
1734 vector_[idx(element->index())] += element->value();
1752 template<
typename VT
1754 ,
typename... CEAs >
1755 template<
typename VT2 >
1756 inline void Elements<VT,TF,true,CEAs...>::subAssign(
const DenseVector<VT2,TF>& rhs )
1760 const size_t ipos(
size() &
size_t(-2) );
1761 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1762 vector_[idx(i )] -= (~rhs)[i ];
1763 vector_[idx(i+1UL)] -= (~rhs)[i+1UL];
1765 if( ipos <
size() ) {
1766 vector_[idx(ipos)] -= (~rhs)[ipos];
1785 template<
typename VT
1787 ,
typename... CEAs >
1788 template<
typename VT2 >
1789 inline void Elements<VT,TF,true,CEAs...>::subAssign(
const SparseVector<VT2,TF>& rhs )
1793 for( ConstIterator_t<VT2> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
1794 vector_[idx(element->index())] -= element->value();
1812 template<
typename VT
1814 ,
typename... CEAs >
1815 template<
typename VT2 >
1816 inline void Elements<VT,TF,true,CEAs...>::multAssign(
const DenseVector<VT2,TF>& rhs )
1820 const size_t ipos(
size() &
size_t(-2) );
1821 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1822 vector_[idx(i )] *= (~rhs)[i ];
1823 vector_[idx(i+1UL)] *= (~rhs)[i+1UL];
1825 if( ipos <
size() ) {
1826 vector_[idx(ipos)] *= (~rhs)[ipos];
1845 template<
typename VT
1847 ,
typename... CEAs >
1848 template<
typename VT2 >
1849 inline void Elements<VT,TF,true,CEAs...>::multAssign(
const SparseVector<VT2,TF>& rhs )
1857 for( ConstIterator_t<VT2> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1858 const size_t index( element->index() );
1859 for( ; i<index; ++i )
1860 reset( vector_[idx(i)] );
1861 vector_[idx(i)] *= element->value();
1865 for( ; i<
size(); ++i ) {
1866 reset( vector_[idx(i)] );
1885 template<
typename VT
1887 ,
typename... CEAs >
1888 template<
typename VT2 >
1889 inline void Elements<VT,TF,true,CEAs...>::divAssign(
const DenseVector<VT2,TF>& rhs )
1893 const size_t ipos(
size() &
size_t(-2) );
1894 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1895 vector_[idx(i )] /= (~rhs)[i ];
1896 vector_[idx(i+1UL)] /= (~rhs)[i+1UL];
1898 if( ipos <
size() ) {
1899 vector_[idx(ipos)] /= (~rhs)[ipos];
1926 template<
typename VT1
1929 ,
typename... CEAs >
1930 class Elements< DVecDVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >
1931 :
public View< DenseVector< Elements< DVecDVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >, TF > >
1932 ,
private ElementsData<CEAs...>
1936 using CPE = DVecDVecCrossExpr<VT1,VT2,TF>;
1937 using RT = ResultType_t<CPE>;
1938 using DataType = ElementsData<CEAs...>;
1948 using This = Elements<CPE,TF,
true,CEAs...>;
1950 using BaseType = DenseVector<This,TF>;
1951 using ViewedType = CPE;
1961 static constexpr
bool simdEnabled =
false;
1974 template<
typename... REAs >
1975 explicit inline Elements(
const CPE& vector, REAs... args )
1976 : DataType( args... )
1977 , vector_ ( vector )
1980 for(
size_t i=0UL; i<
size(); ++i ) {
1981 if( vector_.size() <= idx(i) ) {
1995 inline ReturnType operator[](
size_t index )
const {
1997 return vector_[idx(index)];
2009 if( index >=
size() ) {
2012 return (*
this)[index];
2017 using DataType::idces;
2018 using DataType::idx;
2027 inline CPE operand() const noexcept {
2038 template<
typename T >
2039 inline bool canAlias(
const T* alias )
const noexcept {
2040 return vector_.canAlias( alias );
2050 template<
typename T >
2051 inline bool isAliased(
const T* alias )
const noexcept {
2052 return vector_.isAliased( alias );
2085 template<
typename VT1
2088 ,
typename... CEAs >
2089 class Elements< DVecSVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >
2090 :
public View< DenseVector< Elements< DVecSVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >, TF > >
2091 ,
private ElementsData<CEAs...>
2095 using CPE = DVecSVecCrossExpr<VT1,VT2,TF>;
2096 using RT = ResultType_t<CPE>;
2097 using DataType = ElementsData<CEAs...>;
2107 using This = Elements<CPE,TF,
true,CEAs...>;
2109 using BaseType = DenseVector<This,TF>;
2110 using ViewedType = CPE;
2120 static constexpr
bool simdEnabled =
false;
2133 template<
typename... REAs >
2134 explicit inline Elements(
const CPE& vector, REAs... args )
2135 : DataType( args... )
2136 , vector_ ( vector )
2139 for(
size_t i=0UL; i<
size(); ++i ) {
2140 if( vector_.size() <= idx(i) ) {
2154 inline ReturnType operator[](
size_t index )
const {
2156 return vector_[idx(index)];
2168 if( index >=
size() ) {
2171 return (*
this)[index];
2176 using DataType::idces;
2177 using DataType::idx;
2186 inline CPE operand() const noexcept {
2197 template<
typename T >
2198 inline bool canAlias(
const T* alias )
const noexcept {
2199 return vector_.canAlias( alias );
2209 template<
typename T >
2210 inline bool isAliased(
const T* alias )
const noexcept {
2211 return vector_.isAliased( alias );
2244 template<
typename VT1
2247 ,
typename... CEAs >
2248 class Elements< SVecDVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >
2249 :
public View< DenseVector< Elements< SVecDVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >, TF > >
2250 ,
private ElementsData<CEAs...>
2254 using CPE = SVecDVecCrossExpr<VT1,VT2,TF>;
2255 using RT = ResultType_t<CPE>;
2256 using DataType = ElementsData<CEAs...>;
2266 using This = Elements<CPE,TF,
true,CEAs...>;
2268 using BaseType = DenseVector<This,TF>;
2269 using ViewedType = CPE;
2279 static constexpr
bool simdEnabled =
false;
2292 template<
typename... REAs >
2293 explicit inline Elements(
const CPE& vector, REAs... args )
2294 : DataType( args... )
2295 , vector_ ( vector )
2298 for(
size_t i=0UL; i<
size(); ++i ) {
2299 if( vector_.size() <= idx(i) ) {
2313 inline ReturnType operator[](
size_t index )
const {
2315 return vector_[idx(index)];
2327 if( index >=
size() ) {
2330 return (*
this)[index];
2335 using DataType::idces;
2336 using DataType::idx;
2345 inline CPE operand() const noexcept {
2356 template<
typename T >
2357 inline bool canAlias(
const T* alias )
const noexcept {
2358 return vector_.canAlias( alias );
2368 template<
typename T >
2369 inline bool isAliased(
const T* alias )
const noexcept {
2370 return vector_.isAliased( alias );
2403 template<
typename VT1
2406 ,
typename... CEAs >
2407 class Elements< SVecSVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >
2408 :
public View< DenseVector< Elements< SVecSVecCrossExpr<VT1,VT2,TF>, TF, true, CEAs... >, TF > >
2409 ,
private ElementsData<CEAs...>
2413 using CPE = SVecSVecCrossExpr<VT1,VT2,TF>;
2414 using RT = ResultType_t<CPE>;
2415 using DataType = ElementsData<CEAs...>;
2425 using This = Elements<CPE,TF,
true,CEAs...>;
2427 using BaseType = DenseVector<This,TF>;
2428 using ViewedType = CPE;
2438 static constexpr
bool simdEnabled =
false;
2451 template<
typename... REAs >
2452 explicit inline Elements(
const CPE& vector, REAs... args )
2453 : DataType( args... )
2454 , vector_ ( vector )
2457 for(
size_t i=0UL; i<
size(); ++i ) {
2458 if( vector_.size() <= idx(i) ) {
2472 inline ReturnType operator[](
size_t index )
const {
2474 return vector_[idx(index)];
2486 if( index >=
size() ) {
2489 return (*
this)[index];
2494 using DataType::idces;
2495 using DataType::idx;
2504 inline CPE operand() const noexcept {
2515 template<
typename T >
2516 inline bool canAlias(
const T* alias )
const noexcept {
2517 return vector_.canAlias( alias );
2527 template<
typename T >
2528 inline bool isAliased(
const T* alias )
const noexcept {
2529 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.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
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:354
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:169
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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
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
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3079
Header file for the DenseVector base class.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
Constraint on the data type.
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.
Header file for the decltype(auto) workaround.
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
#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:252
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
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.
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3080
#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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
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:139
#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:135
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
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:8908
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.
Header file for all forward declarations for expression class templates.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
Header file for the IsSparseVector type trait.
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
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 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
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
#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
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
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3082
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:290
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
Header file for the implementation of the ElementsData class template.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
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, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
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.