35#ifndef _BLAZE_MATH_VIEWS_BAND_SPARSE_H_
36#define _BLAZE_MATH_VIEWS_BAND_SPARSE_H_
111class Band<MT,TF,false,false,CBAs...>
112 :
public View< SparseVector< Band<MT,TF,false,false,CBAs...>, TF > >
113 ,
private BandData<CBAs...>
117 using RT = ResultType_t<MT>;
118 using DataType = BandData<CBAs...>;
119 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
125 using This = Band<MT,TF,
false,
false,CBAs...>;
128 using BaseType = View< SparseVector<This,TF> >;
130 using ViewedType = MT;
132 using TransposeType = TransposeType_t<ResultType>;
133 using ElementType = ElementType_t<MT>;
134 using ReturnType = ReturnType_t<MT>;
137 using CompositeType = If_t< RequiresEvaluation_v<MT>,
const ResultType,
const Band& >;
140 using ConstReference = ConstReference_t<MT>;
143 using Reference = If_t< IsConst_v<MT>, ConstReference, Reference_t<MT> >;
149 template<
typename MatrixType
150 ,
typename IteratorType >
152 :
private SparseElement
161 inline BandElement( IteratorType pos,
size_t index )
173 template<
typename T >
inline BandElement& operator=(
const T& v ) {
185 template<
typename T >
inline BandElement&
operator+=(
const T& v ) {
197 template<
typename T >
inline BandElement&
operator-=(
const T& v ) {
209 template<
typename T >
inline BandElement&
operator*=(
const T& v ) {
221 template<
typename T >
inline BandElement&
operator/=(
const T& v ) {
232 inline const BandElement* operator->()
const {
242 inline decltype(
auto) value()
const {
243 return pos_->value();
252 inline size_t index()
const {
268 template<
typename MatrixType
269 ,
typename IteratorType >
274 using IteratorCategory = std::forward_iterator_tag;
275 using ValueType = BandElement<MatrixType,IteratorType>;
276 using PointerType = ValueType;
277 using ReferenceType = ValueType;
281 using iterator_category = IteratorCategory;
282 using value_type = ValueType;
283 using pointer = PointerType;
284 using reference = ReferenceType;
285 using difference_type = DifferenceType;
291 inline BandIterator()
306 inline BandIterator( MatrixType& matrix,
size_t rowIndex,
size_t columnIndex )
309 , column_( columnIndex )
312 for( ; row_ < matrix_->rows() && column_ < matrix_->
columns(); ++row_, ++column_ ) {
313 pos_ = matrix_->find( row_, column_ );
314 if( pos_ != matrix_->end( IsRowMajorMatrix_v<MatrixType> ? row_ : column_ ) )
328 inline BandIterator( MatrixType& matrix,
size_t rowIndex,
size_t columnIndex, IteratorType pos )
331 , column_( columnIndex )
343 template<
typename MatrixType2,
typename IteratorType2 >
344 inline BandIterator(
const BandIterator<MatrixType2,IteratorType2>& it )
345 : matrix_( it.matrix_ )
347 , column_( it.column_ )
357 inline BandIterator& operator++() {
361 for( ; row_ < matrix_->rows() && column_ < matrix_->
columns(); ++row_, ++column_ ) {
362 pos_ = matrix_->find( row_, column_ );
363 if( pos_ != matrix_->end( IsRowMajorMatrix_v<MatrixType> ? row_ : column_ ) )
376 inline const BandIterator operator++(
int ) {
377 const BandIterator tmp( *
this );
389 return ReferenceType( pos_,
min( row_, column_ ) );
398 inline PointerType operator->()
const {
399 return PointerType( pos_,
min( row_, column_ ) );
409 template<
typename MatrixType2,
typename IteratorType2 >
410 inline bool operator==(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
411 return row_ == rhs.row_;
421 template<
typename MatrixType2,
typename IteratorType2 >
422 inline bool operator!=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
423 return !( *
this == rhs );
433 inline DifferenceType
operator-(
const BandIterator& rhs )
const {
434 size_t counter( 0UL );
435 size_t row( rhs.row_ );
436 size_t column( rhs.column_ );
439 const auto end( matrix_->end( IsRowMajorMatrix_v<MatrixType> ?
row :
column ) );
457 template<
typename MatrixType2,
typename IteratorType2 >
friend class BandIterator;
458 template<
typename MT2,
bool DF2,
bool TF2,
bool MF2,
ptrdiff_t... CBAs2 >
friend class Band;
465 using ConstIterator = BandIterator< const MT, ConstIterator_t<MT> >;
468 using Iterator = If_t< IsConst_v<MT>, ConstIterator, BandIterator< MT, Iterator_t<MT> > >;
473 static constexpr bool smpAssignable =
false;
476 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
482 template<
typename... RBAs >
483 explicit inline Band( MT& matrix, RBAs... args );
485 Band(
const Band& ) =
default;
499 inline Reference operator[](
size_t index );
500 inline ConstReference operator[](
size_t index )
const;
501 inline Reference at(
size_t index );
502 inline ConstReference at(
size_t index )
const;
503 inline Iterator
begin ();
504 inline ConstIterator
begin ()
const;
505 inline ConstIterator
cbegin()
const;
506 inline Iterator
end ();
507 inline ConstIterator
end ()
const;
508 inline ConstIterator
cend ()
const;
516 inline Band& operator= (
const Band& 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 Vector<VT,TF>& rhs );
521 template<
typename VT >
inline Band&
operator/=(
const DenseVector<VT,TF>& rhs );
522 template<
typename VT >
inline Band& operator%=(
const Vector<VT,TF>& rhs );
533 inline MT& operand() noexcept;
534 inline const MT& operand() const noexcept;
536 inline
size_t size() const noexcept;
537 inline
size_t capacity() const noexcept;
540 inline
void reserve(
size_t n );
547 inline Iterator
set (
size_t index, const ElementType& value );
548 inline Iterator insert(
size_t index, const ElementType& value );
549 inline
void append(
size_t index, const ElementType& value,
bool check=false );
556 inline
void erase(
size_t index );
557 inline Iterator erase( Iterator pos );
558 inline Iterator erase( Iterator first, Iterator last );
561 inline
void erase( Pred predicate );
563 template< typename Pred >
564 inline
void erase( Iterator first, Iterator last, Pred predicate );
571 inline Iterator
find (
size_t index );
572 inline ConstIterator
find (
size_t index ) const;
574 inline ConstIterator
lowerBound(
size_t index ) const;
576 inline ConstIterator
upperBound(
size_t index ) const;
583 template< typename Other > inline Band& scale( const Other& scalar );
590 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
591 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
593 template< typename VT > inline
void assign ( const DenseVector <VT,TF>& rhs );
594 template< typename VT > inline
void assign ( const SparseVector<VT,TF>& rhs );
595 template< typename VT > inline
void addAssign( const Vector<VT,TF>& rhs );
596 template< typename VT > inline
void subAssign( const Vector<VT,TF>& rhs );
644template< typename... RBAs >
645inline Band<MT,TF,false,false,CBAs...>::Band( MT& matrix, RBAs... args )
646 : DataType( args... )
650 if( (
band() > 0L &&
column() >= matrix.columns() ) ||
651 (
band() < 0L &&
row() >= matrix.rows() ) ) {
685inline typename Band<MT,TF,
false,
false,CBAs...>::Reference
686 Band<MT,TF,false,false,CBAs...>::operator[](
size_t index )
689 return matrix_(
row()+index,
column()+index);
708inline typename Band<MT,TF,
false,
false,CBAs...>::ConstReference
709 Band<MT,TF,false,false,CBAs...>::operator[](
size_t index )
const
712 return const_cast<const MT&
>( matrix_ )(
row()+index,
column()+index);
732inline typename Band<MT,TF,
false,
false,CBAs...>::Reference
733 Band<MT,TF,false,false,CBAs...>::at(
size_t index )
735 if( index >=
size() ) {
738 return (*
this)[index];
758inline typename Band<MT,TF,
false,
false,CBAs...>::ConstReference
759 Band<MT,TF,false,false,CBAs...>::at(
size_t index )
const
761 if( index >=
size() ) {
764 return (*
this)[index];
781inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
784 return Iterator( matrix_,
row(),
column() );
801inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
804 return ConstIterator( matrix_,
row(),
column() );
821inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
824 return ConstIterator( matrix_,
row(),
column() );
841inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
844 const size_t n(
size() );
845 return Iterator( matrix_,
row()+n,
column()+n );
862inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
865 const size_t n(
size() );
866 return ConstIterator( matrix_,
row()+n,
column()+n );
883inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
886 const size_t n(
size() );
887 return ConstIterator( matrix_,
row()+n,
column()+n );
919inline Band<MT,TF,
false,
false,CBAs...>&
924 if( list.size() >
size() ) {
928 const InitializerVector<ElementType,false> tmp( list,
size() );
934 decltype(
auto) left( derestrict( *
this ) );
963inline Band<MT,TF,
false,
false,CBAs...>&
964 Band<MT,TF,false,false,CBAs...>::operator=(
const Band& rhs )
972 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ &&
band() == rhs.band() ) )
975 if(
size() != rhs.size() ) {
983 decltype(
auto) left( derestrict( *
this ) );
985 if( rhs.canAlias(
this ) ) {
986 const ResultType tmp( rhs );
1015template<
typename MT
1018template<
typename VT >
1019inline Band<MT,TF,
false,
false,CBAs...>&
1020 Band<MT,TF,false,false,CBAs...>::operator=(
const Vector<VT,TF>& rhs )
1022 using blaze::assign;
1024 if(
size() != (*rhs).size() ) {
1028 const CompositeType_t<VT> tmp( *rhs );
1034 decltype(
auto) left( derestrict( *
this ) );
1036 assign( left, tmp );
1060template<
typename MT
1063template<
typename VT >
1064inline Band<MT,TF,
false,
false,CBAs...>&
1067 using blaze::assign;
1075 using AddType = AddTrait_t< ResultType, ResultType_t<VT> >;
1080 if(
size() != (*rhs).size() ) {
1084 const AddType tmp( *
this + (*rhs) );
1090 decltype(
auto) left( derestrict( *
this ) );
1092 assign( left, tmp );
1116template<
typename MT
1119template<
typename VT >
1120inline Band<MT,TF,
false,
false,CBAs...>&
1123 using blaze::assign;
1131 using SubType = SubTrait_t< ResultType, ResultType_t<VT> >;
1136 if(
size() != (*rhs).size() ) {
1140 const SubType tmp( *
this - (*rhs) );
1146 decltype(
auto) left( derestrict( *
this ) );
1148 assign( left, tmp );
1171template<
typename MT
1174template<
typename VT >
1175inline Band<MT,TF,
false,
false,CBAs...>&
1178 using blaze::assign;
1186 using MultType = MultTrait_t< ResultType, ResultType_t<VT> >;
1191 if(
size() != (*rhs).size() ) {
1195 const MultType tmp( *
this * (*rhs) );
1201 decltype(
auto) left( derestrict( *
this ) );
1203 assign( left, tmp );
1225template<
typename MT
1228template<
typename VT >
1229inline Band<MT,TF,
false,
false,CBAs...>&
1232 using blaze::assign;
1241 using DivType = DivTrait_t< ResultType, ResultType_t<VT> >;
1247 if(
size() != (*rhs).size() ) {
1251 const DivType tmp( *
this / (*rhs) );
1257 decltype(
auto) left( derestrict( *
this ) );
1259 assign( left, tmp );
1282template<
typename MT
1285template<
typename VT >
1286inline Band<MT,TF,
false,
false,CBAs...>&
1287 Band<MT,TF,false,false,CBAs...>::operator%=(
const Vector<VT,TF>& rhs )
1289 using blaze::assign;
1294 using CrossType = CrossTrait_t< ResultType, ResultType_t<VT> >;
1300 if(
size() != 3UL || (*rhs).size() != 3UL ) {
1304 const CrossType tmp( *
this % (*rhs) );
1310 decltype(
auto) left( derestrict( *
this ) );
1312 assign( left, tmp );
1336template<
typename MT
1339inline MT& Band<MT,TF,false,false,CBAs...>::operand() noexcept
1353template<
typename MT
1356inline const MT& Band<MT,TF,false,false,CBAs...>::operand() const noexcept
1370template<
typename MT
1375 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
1387template<
typename MT
1407template<
typename MT
1424template<
typename MT
1431 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1432 ( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> ) &&
row() == 0UL ) ||
1433 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1434 ( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> ) &&
column() == 0UL ) )
1437 const size_t n(
size() );
1438 for(
size_t i=0UL; i<n; ++i )
1455template<
typename MT
1458void Band<MT,TF,false,false,CBAs...>::reserve(
size_t n )
1488template<
typename MT
1491inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1494 const size_t rowIndex (
row() + index );
1495 const size_t columnIndex(
column() + index );
1496 return Iterator( matrix_, rowIndex, columnIndex, matrix_.set( rowIndex, columnIndex, value ) );
1515template<
typename MT
1518inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1519 Band<MT,TF,false,false,CBAs...>::insert(
size_t index,
const ElementType& value )
1521 const size_t rowIndex (
row() + index );
1522 const size_t columnIndex(
column() + index );
1523 return Iterator( matrix_, rowIndex, columnIndex, matrix_.insert( rowIndex, columnIndex, value ) );
1554template<
typename MT
1557inline void Band<MT,TF,false,false,CBAs...>::append(
size_t index,
const ElementType& value,
bool check )
1559 if( !check || !isDefault<strict>( value ) )
1560 matrix_.insert(
row()+index,
column()+index, value );
1583template<
typename MT
1586inline void Band<MT,TF,false,false,CBAs...>::erase(
size_t index )
1588 matrix_.erase(
row()+index,
column()+index );
1603template<
typename MT
1606inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1607 Band<MT,TF,false,false,CBAs...>::erase( Iterator pos )
1609 const size_t rowIndex ( pos.row_ );
1610 const size_t columnIndex( pos.column_ );
1612 if( rowIndex == matrix_.rows() || columnIndex == matrix_.columns() )
1615 matrix_.erase( ( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ), pos.pos_ );
1616 return Iterator( matrix_, rowIndex+1UL, columnIndex+1UL );
1632template<
typename MT
1635inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1636 Band<MT,TF,false,false,CBAs...>::erase( Iterator first, Iterator last )
1638 for( ; first!=last; ++first ) {
1639 const size_t index( IsRowMajorMatrix<MT>::value ? first.row_ : first.column_ );
1640 matrix_.erase( index, first.pos_ );
1671template<
typename MT
1674template<
typename Pred
1676inline void Band<MT,TF,false,false,CBAs...>::erase( Pred predicate )
1678 for( Iterator element=
begin(); element!=
end(); ++element ) {
1679 if( predicate( element->value() ) ) {
1680 const size_t index( IsRowMajorMatrix<MT>::value ? element.row_ : element.column_ );
1681 matrix_.erase( index, element.pos_ );
1714template<
typename MT
1717template<
typename Pred >
1718inline void Band<MT,TF,false,false,CBAs...>::erase( Iterator first, Iterator last, Pred predicate )
1720 for( ; first!=last; ++first ) {
1721 if( predicate( first->value() ) ) {
1722 const size_t index( IsRowMajorMatrix<MT>::value ? first.row_ : first.column_ );
1723 matrix_.erase( index, first.pos_ );
1753template<
typename MT
1756inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1759 const size_t rowIndex (
row()+index );
1760 const size_t columnIndex(
column()+index );
1761 const Iterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1763 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1764 return Iterator( matrix_, rowIndex, columnIndex, pos );
1786template<
typename MT
1789inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
1792 const size_t rowIndex (
row()+index );
1793 const size_t columnIndex(
column()+index );
1794 const ConstIterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1796 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1797 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1818template<
typename MT
1821inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1824 for(
size_t i=index; i<
size(); ++i )
1826 const size_t rowIndex (
row()+i );
1827 const size_t columnIndex(
column()+i );
1828 const Iterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1830 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1831 return Iterator( matrix_, rowIndex, columnIndex, pos );
1853template<
typename MT
1856inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
1859 for(
size_t i=index; i<
size(); ++i )
1861 const size_t rowIndex (
row()+i );
1862 const size_t columnIndex(
column()+i );
1863 const ConstIterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1865 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1866 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1888template<
typename MT
1891inline typename Band<MT,TF,
false,
false,CBAs...>::Iterator
1894 for(
size_t i=index+1UL; i<
size(); ++i )
1896 const size_t rowIndex (
row()+i );
1897 const size_t columnIndex(
column()+i );
1898 const Iterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1900 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1901 return Iterator( matrix_, rowIndex, columnIndex, pos );
1923template<
typename MT
1926inline typename Band<MT,TF,
false,
false,CBAs...>::ConstIterator
1929 for(
size_t i=index+1UL; i<
size(); ++i )
1931 const size_t rowIndex (
row()+i );
1932 const size_t columnIndex(
column()+i );
1933 const ConstIterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1935 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1936 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1966template<
typename MT
1969template<
typename Other >
1970inline Band<MT,TF,
false,
false,CBAs...>&
1971 Band<MT,TF,false,false,CBAs...>::scale(
const Other& scalar )
1975 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1976 ( IsStrictlyLower_v<MT> &&
row() == 0UL ) ||
1977 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1978 ( IsStrictlyUpper_v<MT> &&
column() == 0UL ) )
1981 for( Iterator element=
begin(); element!=
end(); ++element )
1982 element->value() *= scalar;
2009template<
typename MT
2012template<
typename Other >
2013inline bool Band<MT,TF,false,false,CBAs...>::canAlias(
const Other* alias )
const noexcept
2015 return matrix_.isAliased( &unview( *alias ) );
2032template<
typename MT
2035template<
typename Other >
2036inline bool Band<MT,TF,false,false,CBAs...>::isAliased(
const Other* alias )
const noexcept
2038 return matrix_.isAliased( &unview( *alias ) );
2056template<
typename MT
2059template<
typename VT >
2060inline void Band<MT,TF,false,false,CBAs...>::assign(
const DenseVector<VT,TF>& rhs )
2064 for(
size_t i=0UL; i<(*rhs).size(); ++i ) {
2065 matrix_(
row()+i,
column()+i) = (*rhs)[i];
2084template<
typename MT
2087template<
typename VT >
2088inline void Band<MT,TF,false,false,CBAs...>::assign(
const SparseVector<VT,TF>& rhs )
2094 for( ConstIterator_t<VT> element=(*rhs).begin(); element!=(*rhs).end(); ++element ) {
2095 for( ; i<element->index(); ++i )
2097 matrix_(
row()+i,
column()+i) = element->value();
2100 for( ; i<
size(); ++i ) {
2120template<
typename MT
2123template<
typename VT >
2124inline void Band<MT,TF,false,false,CBAs...>::addAssign(
const Vector<VT,TF>& rhs )
2126 using AddType = AddTrait_t< ResultType, ResultType_t<VT> >;
2133 const AddType tmp(
serial( *
this + (*rhs) ) );
2152template<
typename MT
2155template<
typename VT >
2156inline void Band<MT,TF,false,false,CBAs...>::subAssign(
const Vector<VT,TF>& rhs )
2158 using SubType = SubTrait_t< ResultType, ResultType_t<VT> >;
2165 const SubType tmp(
serial( *
this - (*rhs) ) );
2188template<
typename MT
2191class Band<MT,TF,false,true,CBAs...>
2192 :
public View< SparseVector< Band<MT,TF,false,true,CBAs...>, TF > >
2193 ,
private BandData<CBAs...>
2194 ,
private Computation
2199 using DataType = BandData<CBAs...>;
2202 using LeftOperand = RemoveReference_t< LeftOperand_t<MT> >;
2205 using RightOperand = RemoveReference_t< RightOperand_t<MT> >;
2211 using This = Band<MT,TF,
false,
true,CBAs...>;
2214 using BaseType = View< SparseVector<This,TF> >;
2217 using ViewedType = MT;
2220 using ResultType = BandTrait_t<ResultType_t<MT>,CBAs...>;
2222 using TransposeType = TransposeType_t<ResultType>;
2223 using ElementType = ElementType_t<ResultType>;
2224 using ReturnType = ReturnType_t<MT>;
2225 using CompositeType =
const ResultType;
2228 using LT = If_t< IsSparseMatrix_v<LeftOperand> && IsColumnMajorMatrix_v<LeftOperand>
2229 , OppositeType_t<LeftOperand>
2230 , CompositeType_t<LeftOperand> >;
2233 using RT = If_t< IsSparseMatrix_v<RightOperand> && IsRowMajorMatrix_v<RightOperand>
2234 , OppositeType_t<RightOperand>
2235 , CompositeType_t<RightOperand> >;
2240 static constexpr bool smpAssignable =
false;
2243 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
2253 template<
typename... RBAs >
2254 explicit inline Band(
const MT& mmm, RBAs... args )
2255 : DataType( args... )
2259 if( (
band() > 0L &&
column() >= mmm.columns() ) ||
2260 (
band() < 0L &&
row() >= mmm.rows() ) ) {
2277 inline ReturnType operator[](
size_t index )
const {
2279 return matrix_(
row()+index,
column()+index);
2290 inline ReturnType at(
size_t index )
const {
2291 if( index >=
size() ) {
2294 return (*
this)[index];
2303 inline size_t size() const noexcept {
2304 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
2329 inline const MT& operand() const noexcept {
2340 template<
typename T >
2341 inline bool canAlias(
const T* alias )
const noexcept {
2342 return matrix_.isAliased( &unview( *alias ) );
2352 template<
typename T >
2353 inline bool isAliased(
const T* alias )
const noexcept {
2354 return matrix_.isAliased( &unview( *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 ) {
2405 template<
typename VT >
2406 friend inline void assign( SparseVector<VT,TF>& lhs,
const Band& rhs )
2415 LT A(
serial( rhs.operand().leftOperand() ) );
2416 RT B(
serial( rhs.operand().rightOperand() ) );
2418 const size_t n( rhs.size() );
2419 ElementType_t<VT> tmp{};
2420 size_t nonzeros( 0UL );
2422 for(
size_t i=0UL; i<n; ++i ) {
2424 if( !isDefault<strict>( tmp ) ) {
2425 if( (*lhs).capacity() <= nonzeros ) {
2426 (*lhs).reserve(
min(
max( 2UL*(*lhs).capacity(), 7UL ), (*lhs).size() ) );
2428 (*lhs).append( i, tmp,
false );
2446 template<
typename VT >
2447 friend inline void addAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2456 LT A(
serial( rhs.operand().leftOperand() ) );
2457 RT B(
serial( rhs.operand().rightOperand() ) );
2459 const size_t n( rhs.size() );
2460 for(
size_t i=0UL; i<n; ++i ) {
2481 template<
typename VT >
2482 friend inline void subAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2491 LT A(
serial( rhs.operand().leftOperand() ) );
2492 RT B(
serial( rhs.operand().rightOperand() ) );
2494 const size_t n( rhs.size() );
2495 for(
size_t i=0UL; i<n; ++i ) {
2517 template<
typename VT >
2518 friend inline void multAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2527 LT A(
serial( rhs.operand().leftOperand() ) );
2528 RT B(
serial( rhs.operand().rightOperand() ) );
2530 const size_t n( rhs.size() );
2531 for(
size_t i=0UL; i<n; ++i ) {
2568template<
typename MT
2573class Band< SMatRepeatExpr<MT,SO,CRAs...>, TF, false, false, CBAs... >
2574 :
public View< SparseVector< Band< SMatRepeatExpr<MT,SO,CRAs...>, TF, false, false, CBAs... >, TF > >
2575 ,
private BandData<CBAs...>
2576 ,
private Computation
2581 using RE = SMatRepeatExpr<MT,SO,CRAs...>;
2584 using DataType = BandData<CBAs...>;
2590 using This = Band<RE,TF,
false,
false,CBAs...>;
2593 using BaseType = View< SparseVector<This,TF> >;
2596 using ViewedType = RE;
2599 using ResultType = BandTrait_t<ResultType_t<RE>,CBAs...>;
2601 using TransposeType = TransposeType_t<ResultType>;
2602 using ElementType = ElementType_t<ResultType>;
2603 using ReturnType = ReturnType_t<MT>;
2604 using CompositeType =
const ResultType;
2609 static constexpr bool smpAssignable =
false;
2612 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
2622 template<
typename... RBAs >
2623 explicit inline Band(
const RE& re, RBAs... args )
2624 : DataType( args... )
2628 if( (
band() > 0L &&
column() >= re.columns() ) ||
2629 (
band() < 0L &&
row() >= re.rows() ) ) {
2646 inline ReturnType operator[](
size_t index )
const {
2648 return matrix_(
row()+index,
column()+index);
2659 inline ReturnType at(
size_t index )
const {
2660 if( index >=
size() ) {
2663 return (*
this)[index];
2672 inline size_t size() const noexcept {
2673 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
2698 inline const MT& operand() const noexcept {
2709 template<
typename T >
2710 inline bool canAlias(
const T* alias )
const noexcept {
2711 return matrix_.isAliased( &unview( *alias ) );
2721 template<
typename T >
2722 inline bool isAliased(
const T* alias )
const noexcept {
2723 return matrix_.isAliased( &unview( *alias ) );
2743 template<
typename VT >
2744 friend inline void assign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2750 const size_t n( rhs.size() );
2751 for(
size_t i=0UL; i<n; ++i ) {
2768 template<
typename VT >
2769 friend inline void assign( SparseVector<VT,TF>& lhs,
const Band& rhs )
2775 const size_t n( rhs.size() );
2776 ElementType_t<VT> tmp{};
2777 size_t nonzeros( 0UL );
2779 for(
size_t i=0UL; i<n; ++i ) {
2781 if( !isDefault<strict>( tmp ) ) {
2782 if( (*lhs).capacity() <= nonzeros ) {
2783 (*lhs).reserve(
min(
max( 2UL*(*lhs).capacity(), 7UL ), (*lhs).size() ) );
2785 (*lhs).append( i, tmp,
false );
2804 template<
typename VT >
2805 friend inline void addAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2811 const size_t n( rhs.size() );
2812 for(
size_t i=0UL; i<n; ++i ) {
2813 (*lhs)[i] += rhs[i];
2834 template<
typename VT >
2835 friend inline void subAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2841 const size_t n( rhs.size() );
2842 for(
size_t i=0UL; i<n; ++i ) {
2843 (*lhs)[i] -= rhs[i];
2864 template<
typename VT >
2865 friend inline void multAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2871 const size_t n( rhs.size() );
2872 for(
size_t i=0UL; i<n; ++i ) {
2873 (*lhs)[i] *= rhs[i];
Header file for the addition trait.
Header file for auxiliary alias declarations.
Header file for run time assertion macros.
Header file for the implementation of the BandData class template.
Header file for the band trait.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the cross product trait.
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:751
Header file for the division trait.
Header file for the EnableIf class template.
Header file for the If class template.
Header file for the IsColumnMajorMatrix type trait.
Header file for the IsConst type trait.
Header file for the isDefault shim.
Header file for the IsExpression type trait class.
Header file for the IsIntegral type trait.
Header file for the IsLower type trait.
Header file for the IsRowMajorMatrix type trait.
Header file for the IsSparseMatrix type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsUniLower type trait.
Header file for the IsUniUpper type trait.
Header file for the IsUpper type trait.
Header file for the MAYBE_UNUSED function template.
Header file for the multiplication trait.
Constraint on the data type.
Constraint on the data type.
Header file for the RemoveReference type trait.
Header file for the subtraction trait.
Constraint on the data type.
Initializer list type of the Blaze library.
Pointer difference type of the Blaze library.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the implementation of a vector representation of an initializer list.
Header file for the DenseVector base class.
Header file for the SparseVector base class.
Header file for the View base class.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:140
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:137
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.
Definition: Pointer.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.
Definition: Reference.h:79
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( ).
Definition: DenseMatrix.h:574
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:1339
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:1375
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:386
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:510
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
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:9640
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:448
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_MATMATMULTEXPR_TYPE(T)
Constraint on the data type.
Definition: MatMatMultExpr.h:63
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.
Definition: TransExpr.h:81
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.
Definition: TransposeFlag.h:63
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: SparseVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: DenseVector.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: UniTriangular.h:81
typename BandTrait< MT, CBAs... >::Type BandTrait_t
Auxiliary alias declaration for the BandTrait type trait.
Definition: BandTrait.h:145
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 operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition: Matrix.h:960
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:628
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:730
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:562
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:692
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:660
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:584
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:518
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:137
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition: Assert.h:117
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
MT::Iterator upperBound(SparseMatrix< MT, SO > &sm, size_t i, size_t j)
Returns an iterator to the first index greater than the given index.
Definition: SparseMatrix.h:244
MT::Iterator lowerBound(SparseMatrix< MT, SO > &sm, size_t i, size_t j)
Returns an iterator to the first index not less than the given index.
Definition: SparseMatrix.h:194
MT::Iterator find(SparseMatrix< MT, SO > &sm, size_t i, size_t j)
Searches for a specific matrix element.
Definition: SparseMatrix.h:144
constexpr bool IsIntegral_v
Auxiliary variable template for the IsIntegral type trait.
Definition: IsIntegral.h:95
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:175
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
constexpr bool isChecked(const Ts &... args)
Extracting blaze::Check arguments from a given list of arguments.
Definition: Check.h:225
constexpr Unchecked unchecked
Global Unchecked instance.
Definition: Check.h:146
Header file for the exception macros of the math module.
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Header file for the SparseElement base class.
Header file for basic type definitions.
Header file for the generic max algorithm.
Header file for the generic min algorithm.
Header file for the implementation of the Band base template.