35 #ifndef _BLAZE_MATH_VIEWS_BAND_SPARSE_H_ 36 #define _BLAZE_MATH_VIEWS_BAND_SPARSE_H_ 109 template<
typename MT
111 , ptrdiff_t... CBAs >
112 class Band<MT,TF,false,false,CBAs...>
113 :
public View< SparseVector< Band<MT,TF,false,false,CBAs...>, TF > >
114 ,
private BandData<CBAs...>
118 using RT = ResultType_t<MT>;
119 using DataType = BandData<CBAs...>;
120 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
126 using This = Band<MT,TF,
false,
false,CBAs...>;
128 using BaseType = SparseVector<This,TF>;
129 using ViewedType = MT;
131 using TransposeType = TransposeType_t<ResultType>;
132 using ElementType = ElementType_t<MT>;
133 using ReturnType = ReturnType_t<MT>;
136 using CompositeType = If_t< RequiresEvaluation_v<MT>,
const ResultType,
const Band& >;
139 using ConstReference = ConstReference_t<MT>;
142 using Reference = If_t< IsConst_v<MT>, ConstReference, Reference_t<MT> >;
148 template<
typename MatrixType
149 ,
typename IteratorType >
151 :
private SparseElement
160 inline BandElement( IteratorType pos,
size_t index )
172 template<
typename T >
inline BandElement& operator=(
const T& v ) {
184 template<
typename T >
inline BandElement&
operator+=(
const T& v ) {
196 template<
typename T >
inline BandElement&
operator-=(
const T& v ) {
208 template<
typename T >
inline BandElement&
operator*=(
const T& v ) {
220 template<
typename T >
inline BandElement&
operator/=(
const T& v ) {
231 inline const BandElement* operator->()
const {
241 inline decltype(
auto) value()
const {
242 return pos_->value();
251 inline size_t index()
const {
267 template<
typename MatrixType
268 ,
typename IteratorType >
273 using IteratorCategory = std::forward_iterator_tag;
274 using ValueType = BandElement<MatrixType,IteratorType>;
275 using PointerType = ValueType;
276 using ReferenceType = ValueType;
277 using DifferenceType = ptrdiff_t;
280 using iterator_category = IteratorCategory;
281 using value_type = ValueType;
282 using pointer = PointerType;
283 using reference = ReferenceType;
284 using difference_type = DifferenceType;
290 inline BandIterator()
305 inline BandIterator( MatrixType& matrix,
size_t rowIndex,
size_t columnIndex )
308 , column_( columnIndex )
311 for( ; row_ < matrix_->rows() && column_ < matrix_->columns(); ++row_, ++column_ ) {
312 pos_ = matrix_->find( row_, column_ );
313 if( pos_ != matrix_->end( IsRowMajorMatrix_v<MatrixType> ? row_ : column_ ) )
327 inline BandIterator( MatrixType& matrix,
size_t rowIndex,
size_t columnIndex, IteratorType pos )
330 , column_( columnIndex )
342 template<
typename MatrixType2,
typename IteratorType2 >
343 inline BandIterator(
const BandIterator<MatrixType2,IteratorType2>& it )
344 : matrix_( it.matrix_ )
346 , column_( it.column_ )
356 inline BandIterator& operator++() {
360 for( ; row_ < matrix_->rows() && column_ < matrix_->columns(); ++row_, ++column_ ) {
361 pos_ = matrix_->find( row_, column_ );
362 if( pos_ != matrix_->end( IsRowMajorMatrix_v<MatrixType> ? row_ : column_ ) )
375 inline const BandIterator operator++(
int ) {
376 const BandIterator tmp( *
this );
388 return ReferenceType( pos_,
min( row_, column_ ) );
397 inline PointerType operator->()
const {
398 return PointerType( pos_,
min( row_, column_ ) );
408 template<
typename MatrixType2,
typename IteratorType2 >
409 inline bool operator==(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
410 return row_ == rhs.row_;
420 template<
typename MatrixType2,
typename IteratorType2 >
421 inline bool operator!=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
422 return !( *
this == rhs );
432 inline DifferenceType
operator-(
const BandIterator& rhs )
const {
433 size_t counter( 0UL );
434 size_t row( rhs.row_ );
435 size_t column( rhs.column_ );
438 const auto end( matrix_->end( IsRowMajorMatrix_v<MatrixType> ?
row :
column ) );
456 template<
typename MatrixType2,
typename IteratorType2 >
friend class BandIterator;
457 template<
typename MT2,
bool DF2,
bool TF2,
bool MF2, ptrdiff_t... CBAs2 >
friend class Band;
464 using ConstIterator = BandIterator< const MT, ConstIterator_t<MT> >;
467 using Iterator = If_t< IsConst_v<MT>, ConstIterator, BandIterator< MT, Iterator_t<MT> > >;
472 static constexpr
bool smpAssignable =
false;
475 static constexpr
bool compileTimeArgs = DataType::compileTimeArgs;
481 template<
typename... RBAs >
482 explicit inline Band( MT& matrix, RBAs... args );
484 Band(
const Band& ) =
default;
498 inline Reference operator[](
size_t index );
499 inline ConstReference operator[](
size_t index )
const;
500 inline Reference at(
size_t index );
501 inline ConstReference at(
size_t index )
const;
502 inline Iterator
begin ();
503 inline ConstIterator
begin ()
const;
504 inline ConstIterator
cbegin()
const;
505 inline Iterator
end ();
506 inline ConstIterator
end ()
const;
507 inline ConstIterator
cend ()
const;
514 inline Band& operator= ( initializer_list<ElementType> list );
515 inline Band& operator= (
const Band& rhs );
516 template<
typename VT >
inline Band& operator= (
const Vector<VT,TF>& rhs );
517 template<
typename VT >
inline Band&
operator+=(
const Vector<VT,TF>& rhs );
518 template<
typename VT >
inline Band&
operator-=(
const Vector<VT,TF>& rhs );
519 template<
typename VT >
inline Band&
operator*=(
const Vector<VT,TF>& rhs );
520 template<
typename VT >
inline Band&
operator/=(
const DenseVector<VT,TF>& rhs );
521 template<
typename VT >
inline Band& operator%=(
const Vector<VT,TF>& rhs );
532 inline MT& operand() noexcept;
533 inline const MT& operand() const noexcept;
535 inline
size_t size() const noexcept;
536 inline
size_t capacity() const noexcept;
539 inline
void reserve(
size_t n );
546 inline Iterator
set (
size_t index, const ElementType& value );
547 inline Iterator insert(
size_t index, const ElementType& value );
548 inline
void append(
size_t index, const ElementType& value,
bool check=false );
555 inline
void erase(
size_t index );
556 inline Iterator erase( Iterator pos );
557 inline Iterator erase( Iterator first, Iterator last );
560 inline
void erase( Pred predicate );
562 template< typename Pred >
563 inline
void erase( Iterator first, Iterator last, Pred predicate );
570 inline Iterator find (
size_t index );
571 inline ConstIterator find (
size_t index ) const;
572 inline Iterator lowerBound(
size_t index );
573 inline ConstIterator lowerBound(
size_t index ) const;
574 inline Iterator upperBound(
size_t index );
575 inline ConstIterator upperBound(
size_t index ) const;
582 template< typename Other > inline Band& scale( const Other& scalar );
589 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
590 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
592 template< typename VT > inline
void assign ( const DenseVector <VT,TF>& rhs );
593 template< typename VT > inline
void assign ( const SparseVector<VT,TF>& rhs );
594 template< typename VT > inline
void addAssign( const Vector<VT,TF>& rhs );
595 template< typename VT > inline
void subAssign( const Vector<VT,TF>& rhs );
640 template< typename MT
642 , ptrdiff_t... CBAs >
643 template< typename... RBAs >
644 inline Band<MT,TF,false,false,CBAs...>::Band( MT& matrix, RBAs... args )
645 : DataType( args... )
649 if( (
band() > 0L &&
column() >= matrix.columns() ) ||
650 (
band() < 0L &&
row() >= matrix.rows() ) ) {
681 template<
typename MT
683 , ptrdiff_t... CBAs >
684 inline typename Band<MT,TF,
false,
false,CBAs...>::Reference
685 Band<MT,TF,false,false,CBAs...>::operator[](
size_t index )
688 return matrix_(
row()+index,
column()+index);
704 template<
typename MT
706 , ptrdiff_t... CBAs >
707 inline typename Band<MT,TF,
false,
false,CBAs...>::ConstReference
708 Band<MT,TF,false,false,CBAs...>::operator[](
size_t index )
const 711 return const_cast<const MT&>( matrix_ )(
row()+index,
column()+index);
728 template<
typename MT
730 , ptrdiff_t... CBAs >
731 inline typename Band<MT,TF,
false,
false,CBAs...>::Reference
732 Band<MT,TF,false,false,CBAs...>::at(
size_t index )
734 if( index >=
size() ) {
737 return (*
this)[index];
754 template<
typename MT
756 , ptrdiff_t... CBAs >
757 inline typename Band<MT,TF,
false,
false,CBAs...>::ConstReference
758 Band<MT,TF,false,false,CBAs...>::at(
size_t index )
const 760 if( index >=
size() ) {
763 return (*
this)[index];
777 template<
typename MT
779 , ptrdiff_t... CBAs >
780 inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
783 return Iterator( matrix_,
row(),
column() );
797 template<
typename MT
799 , ptrdiff_t... CBAs >
800 inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
803 return ConstIterator( matrix_,
row(),
column() );
817 template<
typename MT
819 , ptrdiff_t... CBAs >
820 inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
823 return ConstIterator( matrix_,
row(),
column() );
837 template<
typename MT
839 , ptrdiff_t... CBAs >
840 inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
843 const size_t n(
size() );
844 return Iterator( matrix_,
row()+n,
column()+n );
858 template<
typename MT
860 , ptrdiff_t... CBAs >
861 inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
864 const size_t n(
size() );
865 return ConstIterator( matrix_,
row()+n,
column()+n );
879 template<
typename MT
881 , ptrdiff_t... CBAs >
882 inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
885 const size_t n(
size() );
886 return ConstIterator( matrix_,
row()+n,
column()+n );
915 template<
typename MT
917 , ptrdiff_t... CBAs >
918 inline Band<MT,TF,
false,
false,CBAs...>&
919 Band<MT,TF,false,false,CBAs...>::operator=( initializer_list<ElementType> list )
923 if( list.size() >
size() ) {
927 const InitializerVector<ElementType,false> tmp( list,
size() );
933 decltype(
auto) left( derestrict( *this ) );
959 template< typename MT
961 , ptrdiff_t... CBAs >
962 inline Band<MT,TF,false,false,CBAs...>&
963 Band<MT,TF,false,false,CBAs...>::operator=( const Band& rhs )
971 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ &&
band() == rhs.band() ) )
974 if(
size() != rhs.size() ) {
982 decltype(
auto) left( derestrict( *this ) );
984 if( rhs.canAlias( &matrix_ ) ) {
985 const ResultType tmp( rhs );
1014 template<
typename MT
1016 , ptrdiff_t... CBAs >
1017 template<
typename VT >
1018 inline Band<MT,TF,
false,
false,CBAs...>&
1019 Band<MT,TF,false,false,CBAs...>::operator=(
const Vector<VT,TF>& rhs )
1021 using blaze::assign;
1027 const CompositeType_t<VT> tmp( ~rhs );
1033 decltype(
auto) left( derestrict( *this ) );
1035 assign( left, tmp );
1059 template< typename MT
1061 , ptrdiff_t... CBAs >
1062 template< typename VT >
1063 inline Band<MT,TF,false,false,CBAs...>&
1064 Band<MT,TF,false,false,CBAs...>::operator+=( const Vector<VT,TF>& rhs )
1066 using blaze::assign;
1074 using AddType = AddTrait_t< ResultType, ResultType_t<VT> >;
1083 const AddType tmp( *
this + (~rhs) );
1089 decltype(
auto) left( derestrict( *this ) );
1091 assign( left, tmp );
1115 template< typename MT
1117 , ptrdiff_t... CBAs >
1118 template< typename VT >
1119 inline Band<MT,TF,false,false,CBAs...>&
1120 Band<MT,TF,false,false,CBAs...>::operator-=( const Vector<VT,TF>& rhs )
1122 using blaze::assign;
1130 using SubType = SubTrait_t< ResultType, ResultType_t<VT> >;
1139 const SubType tmp( *
this - (~rhs) );
1145 decltype(
auto) left( derestrict( *this ) );
1147 assign( left, tmp );
1170 template< typename MT
1172 , ptrdiff_t... CBAs >
1173 template< typename VT >
1174 inline Band<MT,TF,false,false,CBAs...>&
1175 Band<MT,TF,false,false,CBAs...>::operator*=( const Vector<VT,TF>& rhs )
1177 using blaze::assign;
1185 using MultType = MultTrait_t< ResultType, ResultType_t<VT> >;
1194 const MultType tmp( *
this * (~rhs) );
1200 decltype(
auto) left( derestrict( *this ) );
1202 assign( left, tmp );
1224 template< typename MT
1226 , ptrdiff_t... CBAs >
1227 template< typename VT >
1228 inline Band<MT,TF,false,false,CBAs...>&
1229 Band<MT,TF,false,false,CBAs...>::operator/=( const DenseVector<VT,TF>& rhs )
1231 using blaze::assign;
1240 using DivType = DivTrait_t< ResultType, ResultType_t<VT> >;
1250 const DivType tmp( *
this / (~rhs) );
1256 decltype(
auto) left( derestrict( *this ) );
1258 assign( left, tmp );
1281 template< typename MT
1283 , ptrdiff_t... CBAs >
1284 template< typename VT >
1285 inline Band<MT,TF,false,false,CBAs...>&
1286 Band<MT,TF,false,false,CBAs...>::operator%=( const Vector<VT,TF>& rhs )
1288 using blaze::assign;
1293 using CrossType = CrossTrait_t< ResultType, ResultType_t<VT> >;
1299 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
1303 const CrossType tmp( *
this % (~rhs) );
1309 decltype(
auto) left( derestrict( *this ) );
1311 assign( left, tmp );
1335 template< typename MT
1337 , ptrdiff_t... CBAs >
1338 inline MT& Band<MT,TF,false,false,CBAs...>::operand() noexcept
1352 template<
typename MT
1354 , ptrdiff_t... CBAs >
1355 inline const MT& Band<MT,TF,false,false,CBAs...>::operand() const noexcept
1369 template<
typename MT
1371 , ptrdiff_t... CBAs >
1374 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
1386 template<
typename MT
1388 , ptrdiff_t... CBAs >
1406 template<
typename MT
1408 , ptrdiff_t... CBAs >
1423 template<
typename MT
1425 , ptrdiff_t... CBAs >
1430 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1431 ( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> ) &&
row() == 0UL ) ||
1432 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1433 ( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> ) &&
column() == 0UL ) )
1436 const size_t n(
size() );
1437 for(
size_t i=0UL; i<n; ++i )
1454 template<
typename MT
1456 , ptrdiff_t... CBAs >
1457 void Band<MT,TF,false,false,CBAs...>::reserve(
size_t n )
1487 template<
typename MT
1489 , ptrdiff_t... CBAs >
1490 inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1493 const size_t rowIndex (
row() + index );
1494 const size_t columnIndex(
column() + index );
1495 return Iterator( matrix_, rowIndex, columnIndex, matrix_.set( rowIndex, columnIndex, value ) );
1514 template<
typename MT
1516 , ptrdiff_t... CBAs >
1517 inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1518 Band<MT,TF,false,false,CBAs...>::insert(
size_t index,
const ElementType& value )
1520 const size_t rowIndex (
row() + index );
1521 const size_t columnIndex(
column() + index );
1522 return Iterator( matrix_, rowIndex, columnIndex, matrix_.insert( rowIndex, columnIndex, value ) );
1553 template<
typename MT
1555 , ptrdiff_t... CBAs >
1556 inline void Band<MT,TF,false,false,CBAs...>::append(
size_t index,
const ElementType& value,
bool check )
1558 if( !check || !isDefault<strict>( value ) )
1559 matrix_.insert(
row()+index,
column()+index, value );
1582 template<
typename MT
1584 , ptrdiff_t... CBAs >
1585 inline void Band<MT,TF,false,false,CBAs...>::erase(
size_t index )
1587 matrix_.erase(
row()+index,
column()+index );
1602 template<
typename MT
1604 , ptrdiff_t... CBAs >
1605 inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1606 Band<MT,TF,false,false,CBAs...>::erase( Iterator pos )
1608 const size_t rowIndex ( pos.row_ );
1609 const size_t columnIndex( pos.column_ );
1611 if( rowIndex == matrix_.rows() || columnIndex == matrix_.columns() )
1614 matrix_.erase( ( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ), pos.pos_ );
1615 return Iterator( matrix_, rowIndex+1UL, columnIndex+1UL );
1631 template<
typename MT
1633 , ptrdiff_t... CBAs >
1634 inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1635 Band<MT,TF,false,false,CBAs...>::erase( Iterator first, Iterator last )
1637 for( ; first!=last; ++first ) {
1638 const size_t index( IsRowMajorMatrix<MT>::value ? first.row_ : first.column_ );
1639 matrix_.erase( index, first.pos_ );
1670 template<
typename MT
1672 , ptrdiff_t... CBAs >
1673 template<
typename Pred
1675 inline void Band<MT,TF,false,false,CBAs...>::erase( Pred predicate )
1677 for( Iterator element=
begin(); element!=
end(); ++element ) {
1678 if( predicate( element->value() ) ) {
1679 const size_t index( IsRowMajorMatrix<MT>::value ? element.row_ : element.column_ );
1680 matrix_.erase( index, element.pos_ );
1713 template<
typename MT
1715 , ptrdiff_t... CBAs >
1716 template<
typename Pred >
1717 inline void Band<MT,TF,false,false,CBAs...>::erase( Iterator first, Iterator last, Pred predicate )
1719 for( ; first!=last; ++first ) {
1720 if( predicate( first->value() ) ) {
1721 const size_t index( IsRowMajorMatrix<MT>::value ? first.row_ : first.column_ );
1722 matrix_.erase( index, first.pos_ );
1752 template<
typename MT
1754 , ptrdiff_t... CBAs >
1755 inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1756 Band<MT,TF,false,false,CBAs...>::find(
size_t index )
1758 const size_t rowIndex (
row()+index );
1759 const size_t columnIndex(
column()+index );
1760 const Iterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1762 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1763 return Iterator( matrix_, rowIndex, columnIndex, pos );
1785 template<
typename MT
1787 , ptrdiff_t... CBAs >
1788 inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
1789 Band<MT,TF,false,false,CBAs...>::find(
size_t index )
const 1791 const size_t rowIndex (
row()+index );
1792 const size_t columnIndex(
column()+index );
1793 const ConstIterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1795 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1796 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1817 template<
typename MT
1819 , ptrdiff_t... CBAs >
1820 inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1821 Band<MT,TF,false,false,CBAs...>::lowerBound(
size_t index )
1823 for(
size_t i=index; i<
size(); ++i )
1825 const size_t rowIndex (
row()+i );
1826 const size_t columnIndex(
column()+i );
1827 const Iterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1829 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1830 return Iterator( matrix_, rowIndex, columnIndex, pos );
1852 template<
typename MT
1854 , ptrdiff_t... CBAs >
1855 inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
1856 Band<MT,TF,false,false,CBAs...>::lowerBound(
size_t index )
const 1858 for(
size_t i=index; i<
size(); ++i )
1860 const size_t rowIndex (
row()+i );
1861 const size_t columnIndex(
column()+i );
1862 const ConstIterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1864 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1865 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1887 template<
typename MT
1889 , ptrdiff_t... CBAs >
1890 inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1891 Band<MT,TF,false,false,CBAs...>::upperBound(
size_t index )
1893 for(
size_t i=index+1UL; i<
size(); ++i )
1895 const size_t rowIndex (
row()+i );
1896 const size_t columnIndex(
column()+i );
1897 const Iterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1899 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1900 return Iterator( matrix_, rowIndex, columnIndex, pos );
1922 template<
typename MT
1924 , ptrdiff_t... CBAs >
1925 inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
1926 Band<MT,TF,false,false,CBAs...>::upperBound(
size_t index )
const 1928 for(
size_t i=index+1UL; i<
size(); ++i )
1930 const size_t rowIndex (
row()+i );
1931 const size_t columnIndex(
column()+i );
1932 const ConstIterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1934 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1935 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1965 template<
typename MT
1967 , ptrdiff_t... CBAs >
1968 template<
typename Other >
1969 inline Band<MT,TF,
false,
false,CBAs...>&
1970 Band<MT,TF,false,false,CBAs...>::scale(
const Other& scalar )
1974 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1975 ( IsStrictlyLower_v<MT> &&
row() == 0UL ) ||
1976 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1977 ( IsStrictlyUpper_v<MT> &&
column() == 0UL ) )
1980 for( Iterator element=
begin(); element!=
end(); ++element )
1981 element->value() *= scalar;
2008 template<
typename MT
2010 , ptrdiff_t... CBAs >
2011 template<
typename Other >
2012 inline bool Band<MT,TF,false,false,CBAs...>::canAlias(
const Other* alias )
const noexcept
2014 return matrix_.isAliased( alias );
2031 template<
typename MT
2033 , ptrdiff_t... CBAs >
2034 template<
typename Other >
2035 inline bool Band<MT,TF,false,false,CBAs...>::isAliased(
const Other* alias )
const noexcept
2037 return matrix_.isAliased( alias );
2055 template<
typename MT
2057 , ptrdiff_t... CBAs >
2058 template<
typename VT >
2059 inline void Band<MT,TF,false,false,CBAs...>::assign(
const DenseVector<VT,TF>& rhs )
2063 for(
size_t i=0UL; i<(~rhs).
size(); ++i ) {
2064 matrix_(
row()+i,
column()+i) = (~rhs)[i];
2083 template<
typename MT
2085 , ptrdiff_t... CBAs >
2086 template<
typename VT >
2087 inline void Band<MT,TF,false,false,CBAs...>::assign(
const SparseVector<VT,TF>& rhs )
2093 for( ConstIterator_t<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
2094 for( ; i<element->index(); ++i )
2096 matrix_(
row()+i,
column()+i) = element->value();
2099 for( ; i<
size(); ++i ) {
2119 template<
typename MT
2121 , ptrdiff_t... CBAs >
2122 template<
typename VT >
2123 inline void Band<MT,TF,false,false,CBAs...>::addAssign(
const Vector<VT,TF>& rhs )
2125 using AddType = AddTrait_t< ResultType, ResultType_t<VT> >;
2132 const AddType tmp(
serial( *
this + (~rhs) ) );
2151 template<
typename MT
2153 , ptrdiff_t... CBAs >
2154 template<
typename VT >
2155 inline void Band<MT,TF,false,false,CBAs...>::subAssign(
const Vector<VT,TF>& rhs )
2157 using SubType = SubTrait_t< ResultType, ResultType_t<VT> >;
2164 const SubType tmp(
serial( *
this - (~rhs) ) );
2187 template<
typename MT
2189 , ptrdiff_t... CBAs >
2190 class Band<MT,TF,false,true,CBAs...>
2191 :
public View< SparseVector< Band<MT,TF,false,true,CBAs...>, TF > >
2192 ,
private BandData<CBAs...>
2193 ,
private Computation
2198 using DataType = BandData<CBAs...>;
2201 using LeftOperand = RemoveReference_t< LeftOperand_t<MT> >;
2204 using RightOperand = RemoveReference_t< RightOperand_t<MT> >;
2210 using This = Band<MT,TF,
false,
true,CBAs...>;
2213 using BaseType = SparseVector<This,TF>;
2216 using ViewedType = MT;
2219 using ResultType = BandTrait_t<ResultType_t<MT>,CBAs...>;
2221 using TransposeType = TransposeType_t<ResultType>;
2222 using ElementType = ElementType_t<ResultType>;
2223 using ReturnType = ReturnType_t<MT>;
2224 using CompositeType =
const ResultType;
2227 using LT = If_t< IsSparseMatrix_v<LeftOperand> && IsColumnMajorMatrix_v<LeftOperand>
2228 , ResultType_t<LeftOperand>
2229 , CompositeType_t<LeftOperand> >;
2232 using RT = If_t< IsSparseMatrix_v<RightOperand> && IsRowMajorMatrix_v<RightOperand>
2233 , ResultType_t<RightOperand>
2234 , CompositeType_t<RightOperand> >;
2239 static constexpr
bool smpAssignable =
false;
2242 static constexpr
bool compileTimeArgs = DataType::compileTimeArgs;
2252 template<
typename... RBAs >
2253 explicit inline Band(
const MT& mmm, RBAs... args )
2254 : DataType( args... )
2258 if( (
band() > 0L &&
column() >= mmm.columns() ) ||
2259 (
band() < 0L &&
row() >= mmm.rows() ) ) {
2276 inline ReturnType operator[](
size_t index )
const {
2278 return matrix_(
row()+index,
column()+index);
2289 inline ReturnType at(
size_t index )
const {
2290 if( index >=
size() ) {
2293 return (*
this)[index];
2302 inline size_t size() const noexcept {
2303 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
2328 inline const MT& operand() const noexcept {
2339 template<
typename T >
2340 inline bool canAlias(
const T* alias )
const noexcept {
2341 return matrix_.isAliased( alias );
2351 template<
typename T >
2352 inline bool isAliased(
const T* alias )
const noexcept {
2353 return matrix_.isAliased( alias );
2374 template<
typename VT >
2375 friend inline void assign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2384 LT A(
serial( rhs.operand().leftOperand() ) );
2385 RT B(
serial( rhs.operand().rightOperand() ) );
2387 const size_t n( rhs.size() );
2388 for(
size_t i=0UL; i<n; ++i ) {
2407 template<
typename VT >
2408 friend inline void assign( SparseVector<VT,TF>& lhs,
const Band& rhs )
2417 LT A(
serial( rhs.operand().leftOperand() ) );
2418 RT B(
serial( rhs.operand().rightOperand() ) );
2420 const size_t n( rhs.size() );
2421 ElementType_t<VT> tmp{};
2422 size_t nonzeros( 0UL );
2424 for(
size_t i=0UL; i<n; ++i ) {
2426 if( !isDefault<strict>( tmp ) ) {
2427 if( (~lhs).capacity() <= nonzeros ) {
2430 (~lhs).append( i, tmp,
false );
2450 template<
typename VT >
2451 friend inline void addAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2460 LT A(
serial( rhs.operand().leftOperand() ) );
2461 RT B(
serial( rhs.operand().rightOperand() ) );
2463 const size_t n( rhs.size() );
2464 for(
size_t i=0UL; i<n; ++i ) {
2487 template<
typename VT >
2488 friend inline void subAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2497 LT A(
serial( rhs.operand().leftOperand() ) );
2498 RT B(
serial( rhs.operand().rightOperand() ) );
2500 const size_t n( rhs.size() );
2501 for(
size_t i=0UL; i<n; ++i ) {
2525 template<
typename VT >
2526 friend inline void multAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2535 LT A(
serial( rhs.operand().leftOperand() ) );
2536 RT B(
serial( rhs.operand().rightOperand() ) );
2538 const size_t n( rhs.size() );
2539 for(
size_t i=0UL; i<n; ++i ) {
#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.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Headerfile for the generic min algorithm.
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
Header file for the IsUniUpper type trait.
Header file for the subtraction trait.
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
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
Header file for the SparseVector base class.
Header file for the View base class.
Header file for the IsSparseMatrix type trait.
#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
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
Header file for the IsColumnMajorMatrix type trait.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
Header file for the IsIntegral type trait.
Header file for the DenseVector base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
Header file for the MAYBE_UNUSED function template.
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 implementation of the Band base template.
#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 IsUniLower type 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
Header file for the band trait.
Constraint on the data type.
Constraint on the data type.
Headerfile for the generic max algorithm.
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
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_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1162
#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
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
Header file for the IsLower type trait.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type,...
Definition: SparseVector.h:61
Constraint on the data type.
Header file for the SparseElement base class.
Constraint on the data type.
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1198
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.
Constraint on the data type.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:137
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_MATMATMULTEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is not a matrix/matrix multiplication expre...
Definition: MatMatMultExpr.h:63
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 IsConst type trait.
Header file for run time assertion macros.
Header file for the relaxation flag types.
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
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
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type,...
Definition: Reference.h:79
Header file for the isDefault shim.
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Constraint on the data type.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
#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 RemoveReference type trait.
#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
Header file for the IsRowMajorMatrix type trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
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
constexpr bool IsIntegral_v
Auxiliary variable template for the IsIntegral type trait.The IsIntegral_v variable template provides...
Definition: IsIntegral.h:95
Header file for the IsUpper type trait.
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
typename BandTrait< MT, CBAs... >::Type BandTrait_t
Auxiliary alias declaration for the BandTrait type trait.The BandTrait_t alias declaration provides a...
Definition: BandTrait.h:170
#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
#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
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type,...
Definition: SparseMatrix.h:61
Header file for the IsExpression type trait class.
Header file for the implementation of the BandData class template.