35 #ifndef _BLAZE_MATH_VIEWS_BAND_SPARSE_H_ 36 #define _BLAZE_MATH_VIEWS_BAND_SPARSE_H_ 108 template<
typename MT
110 , ptrdiff_t... CBAs >
111 class 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_<MT>;
118 using DataType = BandData<CBAs...>;
119 using Operand = If_< IsExpression<MT>, MT, MT& >;
125 using This = Band<MT,TF,
false,
false,CBAs...>;
127 using BaseType = SparseVector<This,TF>;
128 using ViewedType = MT;
147 template<
typename MatrixType
148 ,
typename IteratorType >
150 :
private SparseElement
159 inline BandElement( IteratorType pos,
size_t index )
171 template<
typename T >
inline BandElement& operator=(
const T& v ) {
183 template<
typename T >
inline BandElement&
operator+=(
const T& v ) {
195 template<
typename T >
inline BandElement&
operator-=(
const T& v ) {
207 template<
typename T >
inline BandElement&
operator*=(
const T& v ) {
219 template<
typename T >
inline BandElement&
operator/=(
const T& v ) {
230 inline const BandElement* operator->()
const {
240 inline decltype(
auto) value()
const {
241 return pos_->value();
250 inline size_t index()
const {
266 template<
typename MatrixType
267 ,
typename IteratorType >
272 using IteratorCategory = std::forward_iterator_tag;
273 using ValueType = BandElement<MatrixType,IteratorType>;
274 using PointerType = ValueType;
275 using ReferenceType = ValueType;
276 using DifferenceType = ptrdiff_t;
279 using iterator_category = IteratorCategory;
280 using value_type = ValueType;
281 using pointer = PointerType;
282 using reference = ReferenceType;
283 using difference_type = DifferenceType;
289 inline BandIterator()
304 inline BandIterator( MatrixType& matrix,
size_t rowIndex,
size_t columnIndex )
307 , column_( columnIndex )
310 for( ; row_ < matrix_->rows() && column_ < matrix_->columns(); ++row_, ++column_ ) {
311 pos_ = matrix_->find( row_, column_ );
312 if( pos_ != matrix_->end( IsRowMajorMatrix<MatrixType>::value ? row_ : column_ ) )
326 inline BandIterator( MatrixType& matrix,
size_t rowIndex,
size_t columnIndex, IteratorType pos )
329 , column_( columnIndex )
341 template<
typename MatrixType2,
typename IteratorType2 >
342 inline BandIterator(
const BandIterator<MatrixType2,IteratorType2>& it )
343 : matrix_( it.matrix_ )
345 , column_( it.column_ )
355 inline BandIterator& operator++() {
359 for( ; row_ < matrix_->rows() && column_ < matrix_->columns(); ++row_, ++column_ ) {
360 pos_ = matrix_->find( row_, column_ );
361 if( pos_ != matrix_->end( IsRowMajorMatrix<MatrixType>::value ? row_ : column_ ) )
374 inline const BandIterator operator++(
int ) {
375 const BandIterator tmp( *
this );
387 return ReferenceType( pos_,
min( row_, column_ ) );
396 inline PointerType operator->()
const {
397 return PointerType( pos_,
min( row_, column_ ) );
407 template<
typename MatrixType2,
typename IteratorType2 >
408 inline bool operator==(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
409 return row_ == rhs.row_;
419 template<
typename MatrixType2,
typename IteratorType2 >
420 inline bool operator!=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
421 return !( *
this == rhs );
431 inline DifferenceType
operator-(
const BandIterator& rhs )
const {
432 size_t counter( 0UL );
433 size_t row( rhs.row_ );
434 size_t column( rhs.column_ );
437 const auto end( matrix_->end( IsRowMajorMatrix<MatrixType>::value ?
row :
column ) );
438 if( matrix_->find(
row, column ) !=
end )
455 template<
typename MatrixType2,
typename IteratorType2 >
friend class BandIterator;
456 template<
typename MT2,
bool DF2,
bool TF2,
bool MF2, ptrdiff_t... CBAs2 >
friend class Band;
463 using ConstIterator = BandIterator< const MT, ConstIterator_<MT> >;
471 enum :
bool { smpAssignable =
false };
477 template<
typename... RBAs >
478 explicit inline Band( MT& matrix, RBAs... args );
490 inline Reference operator[](
size_t index );
491 inline ConstReference operator[](
size_t index )
const;
493 inline ConstReference at(
size_t index )
const;
495 inline ConstIterator
begin ()
const;
496 inline ConstIterator
cbegin()
const;
498 inline ConstIterator
end ()
const;
499 inline ConstIterator
cend ()
const;
506 inline Band& operator= ( initializer_list<ElementType> list );
507 inline Band& operator= (
const Band& rhs );
508 template<
typename VT >
inline Band& operator= (
const Vector<VT,TF>& rhs );
509 template<
typename VT >
inline Band&
operator+=(
const Vector<VT,TF>& rhs );
510 template<
typename VT >
inline Band&
operator-=(
const Vector<VT,TF>& rhs );
511 template<
typename VT >
inline Band&
operator*=(
const Vector<VT,TF>& rhs );
512 template<
typename VT >
inline Band&
operator/=(
const DenseVector<VT,TF>& rhs );
513 template<
typename VT >
inline Band& operator%=(
const Vector<VT,TF>& rhs );
524 inline MT& operand() noexcept;
525 inline const MT& operand() const noexcept;
527 inline
size_t size() const noexcept;
528 inline
size_t capacity() const noexcept;
531 inline
void reserve(
size_t n );
540 inline
void append(
size_t index, const
ElementType& value,
bool check=false );
547 inline
void erase(
size_t index );
551 template< typename Pred, typename =
DisableIf_< IsIntegral<Pred> > >
552 inline
void erase( Pred predicate );
554 template< typename Pred >
562 inline
Iterator find (
size_t index );
563 inline ConstIterator find (
size_t index ) const;
564 inline
Iterator lowerBound(
size_t index );
565 inline ConstIterator lowerBound(
size_t index ) const;
566 inline
Iterator upperBound(
size_t index );
567 inline ConstIterator upperBound(
size_t index ) const;
574 template< typename Other > inline Band& scale( const Other& scalar );
581 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
582 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
584 template< typename VT > inline
void assign ( const DenseVector <VT,TF>& rhs );
585 template< typename VT > inline
void assign ( const SparseVector<VT,TF>& rhs );
586 template< typename VT > inline
void addAssign( const Vector<VT,TF>& rhs );
587 template< typename VT > inline
void subAssign( const Vector<VT,TF>& rhs );
632 template< typename MT
634 , ptrdiff_t... CBAs >
635 template< typename... RBAs >
636 inline Band<MT,TF,false,false,CBAs...>::Band( MT& matrix, RBAs... args )
637 : DataType( args... )
640 if( !Contains< TypeList<RBAs...>,
Unchecked >::value ) {
641 if( (
band() > 0L &&
column() >= matrix.columns() ) ||
642 (
band() < 0L &&
row() >= matrix.rows() ) ) {
673 template<
typename MT
675 , ptrdiff_t... CBAs >
676 inline typename Band<MT,TF,
false,
false,CBAs...>
::Reference 677 Band<MT,TF,false,false,CBAs...>::operator[](
size_t index )
680 return matrix_(
row()+index,
column()+index);
696 template<
typename MT
698 , ptrdiff_t... CBAs >
700 Band<MT,TF,false,false,CBAs...>::operator[](
size_t index )
const 703 return const_cast<const MT&
>( matrix_ )(
row()+index,
column()+index);
720 template<
typename MT
722 , ptrdiff_t... CBAs >
723 inline typename Band<MT,TF,
false,
false,CBAs...>
::Reference 724 Band<MT,TF,false,false,CBAs...>::at(
size_t index )
726 if( index >=
size() ) {
729 return (*
this)[index];
746 template<
typename MT
748 , ptrdiff_t... CBAs >
750 Band<MT,TF,false,false,CBAs...>::at(
size_t index )
const 752 if( index >=
size() ) {
755 return (*
this)[index];
769 template<
typename MT
771 , ptrdiff_t... CBAs >
772 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 789 template<
typename MT
791 , ptrdiff_t... CBAs >
809 template<
typename MT
811 , ptrdiff_t... CBAs >
829 template<
typename MT
831 , ptrdiff_t... CBAs >
832 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 835 const size_t n(
size() );
850 template<
typename MT
852 , ptrdiff_t... CBAs >
856 const size_t n(
size() );
871 template<
typename MT
873 , ptrdiff_t... CBAs >
877 const size_t n(
size() );
907 template<
typename MT
909 , ptrdiff_t... CBAs >
910 inline Band<MT,TF,
false,
false,CBAs...>&
911 Band<MT,TF,false,false,CBAs...>::operator=( initializer_list<ElementType> list )
915 if( list.size() >
size() ) {
919 const InitializerVector<ElementType,false> tmp( list,
size() );
925 decltype(
auto) left( derestrict( *this ) );
951 template< typename MT
953 , ptrdiff_t... CBAs >
954 inline Band<MT,TF,false,false,CBAs...>&
955 Band<MT,TF,false,false,CBAs...>::operator=( const Band& rhs )
963 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ &&
band() == rhs.band() ) )
966 if(
size() != rhs.size() ) {
974 decltype(
auto) left( derestrict( *this ) );
976 if( rhs.canAlias( &matrix_ ) ) {
977 const ResultType tmp( rhs );
1006 template<
typename MT
1008 , ptrdiff_t... CBAs >
1009 template<
typename VT >
1010 inline Band<MT,TF,
false,
false,CBAs...>&
1011 Band<MT,TF,false,false,CBAs...>::operator=(
const Vector<VT,TF>& rhs )
1013 using blaze::assign;
1019 const CompositeType_<VT> tmp( ~rhs );
1025 decltype(
auto) left( derestrict( *this ) );
1027 assign( left, tmp );
1051 template< typename MT
1053 , ptrdiff_t... CBAs >
1054 template< typename VT >
1055 inline Band<MT,TF,false,false,CBAs...>&
1056 Band<MT,TF,false,false,CBAs...>::operator+=( const Vector<VT,TF>& rhs )
1058 using blaze::assign;
1066 using AddType = AddTrait_< ResultType, ResultType_<VT> >;
1075 const AddType tmp( *
this + (~rhs) );
1081 decltype(
auto) left( derestrict( *this ) );
1083 assign( left, tmp );
1107 template< typename MT
1109 , ptrdiff_t... CBAs >
1110 template< typename VT >
1111 inline Band<MT,TF,false,false,CBAs...>&
1112 Band<MT,TF,false,false,CBAs...>::operator-=( const Vector<VT,TF>& rhs )
1114 using blaze::assign;
1122 using SubType = SubTrait_< ResultType, ResultType_<VT> >;
1131 const SubType tmp( *
this - (~rhs) );
1137 decltype(
auto) left( derestrict( *this ) );
1139 assign( left, tmp );
1162 template< typename MT
1164 , ptrdiff_t... CBAs >
1165 template< typename VT >
1166 inline Band<MT,TF,false,false,CBAs...>&
1167 Band<MT,TF,false,false,CBAs...>::operator*=( const Vector<VT,TF>& rhs )
1169 using blaze::assign;
1177 using MultType = MultTrait_< ResultType, ResultType_<VT> >;
1186 const MultType tmp( *
this * (~rhs) );
1192 decltype(
auto) left( derestrict( *this ) );
1194 assign( left, tmp );
1216 template< typename MT
1218 , ptrdiff_t... CBAs >
1219 template< typename VT >
1220 inline Band<MT,TF,false,false,CBAs...>&
1221 Band<MT,TF,false,false,CBAs...>::operator/=( const DenseVector<VT,TF>& rhs )
1223 using blaze::assign;
1232 using DivType = DivTrait_< ResultType, ResultType_<VT> >;
1242 const DivType tmp( *
this / (~rhs) );
1248 decltype(
auto) left( derestrict( *this ) );
1250 assign( left, tmp );
1273 template< typename MT
1275 , ptrdiff_t... CBAs >
1276 template< typename VT >
1277 inline Band<MT,TF,false,false,CBAs...>&
1278 Band<MT,TF,false,false,CBAs...>::operator%=( const Vector<VT,TF>& rhs )
1280 using blaze::assign;
1285 using CrossType = CrossTrait_< ResultType, ResultType_<VT> >;
1291 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
1295 const CrossType tmp( *
this % (~rhs) );
1301 decltype(
auto) left( derestrict( *this ) );
1303 assign( left, tmp );
1327 template< typename MT
1329 , ptrdiff_t... CBAs >
1330 inline MT& Band<MT,TF,false,false,CBAs...>::operand() noexcept
1344 template<
typename MT
1346 , ptrdiff_t... CBAs >
1347 inline const MT& Band<MT,TF,false,false,CBAs...>::operand() const noexcept
1361 template<
typename MT
1363 , ptrdiff_t... CBAs >
1366 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
1378 template<
typename MT
1380 , ptrdiff_t... CBAs >
1398 template<
typename MT
1400 , ptrdiff_t... CBAs >
1415 template<
typename MT
1417 , ptrdiff_t... CBAs >
1422 if( ( IsLower<MT>::value &&
column() > 0UL ) ||
1423 ( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value ) &&
row() == 0UL ) ||
1424 ( IsUpper<MT>::value &&
row() > 0UL ) ||
1425 ( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value ) &&
column() == 0UL ) )
1428 const size_t n(
size() );
1429 for(
size_t i=0UL; i<n; ++i )
1446 template<
typename MT
1448 , ptrdiff_t... CBAs >
1449 void Band<MT,TF,false,false,CBAs...>::reserve(
size_t n )
1479 template<
typename MT
1481 , ptrdiff_t... CBAs >
1482 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1485 const size_t rowIndex (
row() + index );
1486 const size_t columnIndex(
column() + index );
1487 return Iterator( matrix_, rowIndex, columnIndex, matrix_.set( rowIndex, columnIndex, value ) );
1506 template<
typename MT
1508 , ptrdiff_t... CBAs >
1509 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1510 Band<MT,TF,false,false,CBAs...>::insert(
size_t index,
const ElementType& value )
1512 const size_t rowIndex (
row() + index );
1513 const size_t columnIndex(
column() + index );
1514 return Iterator( matrix_, rowIndex, columnIndex, matrix_.insert( rowIndex, columnIndex, value ) );
1545 template<
typename MT
1547 , ptrdiff_t... CBAs >
1548 inline void Band<MT,TF,false,false,CBAs...>::append(
size_t index,
const ElementType& value,
bool check )
1550 if( !check || !isDefault<strict>( value ) )
1551 matrix_.insert(
row()+index,
column()+index, value );
1574 template<
typename MT
1576 , ptrdiff_t... CBAs >
1577 inline void Band<MT,TF,false,false,CBAs...>::erase(
size_t index )
1579 matrix_.erase(
row()+index,
column()+index );
1594 template<
typename MT
1596 , ptrdiff_t... CBAs >
1597 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1598 Band<MT,TF,false,false,CBAs...>::erase(
Iterator pos )
1600 const size_t rowIndex ( pos.row_ );
1601 const size_t columnIndex( pos.column_ );
1603 if( rowIndex == matrix_.rows() || columnIndex == matrix_.columns() )
1606 matrix_.erase( ( IsRowMajorMatrix<MT>::value ? rowIndex : columnIndex ), pos.pos_ );
1607 return Iterator( matrix_, rowIndex+1UL, columnIndex+1UL );
1623 template<
typename MT
1625 , ptrdiff_t... CBAs >
1626 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1629 for( ; first!=last; ++first ) {
1630 const size_t index( IsRowMajorMatrix<MT>::value ? first.row_ : first.column_ );
1631 matrix_.erase( index, first.pos_ );
1662 template<
typename MT
1664 , ptrdiff_t... CBAs >
1665 template<
typename Pred
1667 inline void Band<MT,TF,false,false,CBAs...>::erase( Pred predicate )
1670 if( predicate( element->value() ) ) {
1671 const size_t index( IsRowMajorMatrix<MT>::value ? element.row_ : element.column_ );
1672 matrix_.erase( index, element.pos_ );
1705 template<
typename MT
1707 , ptrdiff_t... CBAs >
1708 template<
typename Pred >
1709 inline void Band<MT,TF,false,false,CBAs...>::erase(
Iterator first,
Iterator last, Pred predicate )
1711 for( ; first!=last; ++first ) {
1712 if( predicate( first->value() ) ) {
1713 const size_t index( IsRowMajorMatrix<MT>::value ? first.row_ : first.column_ );
1714 matrix_.erase( index, first.pos_ );
1744 template<
typename MT
1746 , ptrdiff_t... CBAs >
1747 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1748 Band<MT,TF,false,false,CBAs...>::find(
size_t index )
1750 const size_t rowIndex (
row()+index );
1751 const size_t columnIndex(
column()+index );
1752 const Iterator_<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1754 if( pos != matrix_.end( IsRowMajorMatrix<MT>::value ? rowIndex : columnIndex ) )
1755 return Iterator( matrix_, rowIndex, columnIndex, pos );
1777 template<
typename MT
1779 , ptrdiff_t... CBAs >
1781 Band<MT,TF,false,false,CBAs...>::find(
size_t index )
const 1783 const size_t rowIndex (
row()+index );
1784 const size_t columnIndex(
column()+index );
1785 const ConstIterator_<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1787 if( pos != matrix_.end( IsRowMajorMatrix<MT>::value ? rowIndex : columnIndex ) )
1788 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1809 template<
typename MT
1811 , ptrdiff_t... CBAs >
1812 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1813 Band<MT,TF,false,false,CBAs...>::lowerBound(
size_t index )
1815 for(
size_t i=index; i<
size(); ++i )
1817 const size_t rowIndex (
row()+i );
1818 const size_t columnIndex(
column()+i );
1819 const Iterator_<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1821 if( pos != matrix_.end( IsRowMajorMatrix<MT>::value ? rowIndex : columnIndex ) )
1822 return Iterator( matrix_, rowIndex, columnIndex, pos );
1844 template<
typename MT
1846 , ptrdiff_t... CBAs >
1848 Band<MT,TF,false,false,CBAs...>::lowerBound(
size_t index )
const 1850 for(
size_t i=index; i<
size(); ++i )
1852 const size_t rowIndex (
row()+i );
1853 const size_t columnIndex(
column()+i );
1854 const ConstIterator_<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1856 if( pos != matrix_.end( IsRowMajorMatrix<MT>::value ? rowIndex : columnIndex ) )
1857 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1879 template<
typename MT
1881 , ptrdiff_t... CBAs >
1882 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1883 Band<MT,TF,false,false,CBAs...>::upperBound(
size_t index )
1885 for(
size_t i=index+1UL; i<
size(); ++i )
1887 const size_t rowIndex (
row()+i );
1888 const size_t columnIndex(
column()+i );
1889 const Iterator_<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1891 if( pos != matrix_.end( IsRowMajorMatrix<MT>::value ? rowIndex : columnIndex ) )
1892 return Iterator( matrix_, rowIndex, columnIndex, pos );
1914 template<
typename MT
1916 , ptrdiff_t... CBAs >
1918 Band<MT,TF,false,false,CBAs...>::upperBound(
size_t index )
const 1920 for(
size_t i=index+1UL; i<
size(); ++i )
1922 const size_t rowIndex (
row()+i );
1923 const size_t columnIndex(
column()+i );
1924 const ConstIterator_<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1926 if( pos != matrix_.end( IsRowMajorMatrix<MT>::value ? rowIndex : columnIndex ) )
1927 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1957 template<
typename MT
1959 , ptrdiff_t... CBAs >
1960 template<
typename Other >
1961 inline Band<MT,TF,
false,
false,CBAs...>&
1962 Band<MT,TF,false,false,CBAs...>::scale(
const Other& scalar )
1966 if( ( IsLower<MT>::value &&
column() > 0UL ) ||
1967 ( IsStrictlyLower<MT>::value &&
row() == 0UL ) ||
1968 ( IsUpper<MT>::value &&
row() > 0UL ) ||
1969 ( IsStrictlyUpper<MT>::value &&
column() == 0UL ) )
1973 element->value() *= scalar;
2000 template<
typename MT
2002 , ptrdiff_t... CBAs >
2003 template<
typename Other >
2004 inline bool Band<MT,TF,false,false,CBAs...>::canAlias(
const Other* alias )
const noexcept
2006 return matrix_.isAliased( alias );
2023 template<
typename MT
2025 , ptrdiff_t... CBAs >
2026 template<
typename Other >
2027 inline bool Band<MT,TF,false,false,CBAs...>::isAliased(
const Other* alias )
const noexcept
2029 return matrix_.isAliased( alias );
2047 template<
typename MT
2049 , ptrdiff_t... CBAs >
2050 template<
typename VT >
2051 inline void Band<MT,TF,false,false,CBAs...>::assign(
const DenseVector<VT,TF>& rhs )
2055 for(
size_t i=0UL; i<(~rhs).
size(); ++i ) {
2056 matrix_(
row()+i,
column()+i) = (~rhs)[i];
2075 template<
typename MT
2077 , ptrdiff_t... CBAs >
2078 template<
typename VT >
2079 inline void Band<MT,TF,false,false,CBAs...>::assign(
const SparseVector<VT,TF>& rhs )
2085 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
2086 for( ; i<element->index(); ++i )
2088 matrix_(
row()+i,
column()+i) = element->value();
2091 for( ; i<
size(); ++i ) {
2111 template<
typename MT
2113 , ptrdiff_t... CBAs >
2114 template<
typename VT >
2115 inline void Band<MT,TF,false,false,CBAs...>::addAssign(
const Vector<VT,TF>& rhs )
2117 using AddType = AddTrait_< ResultType, ResultType_<VT> >;
2124 const AddType tmp(
serial( *
this + (~rhs) ) );
2143 template<
typename MT
2145 , ptrdiff_t... CBAs >
2146 template<
typename VT >
2147 inline void Band<MT,TF,false,false,CBAs...>::subAssign(
const Vector<VT,TF>& rhs )
2149 using SubType = SubTrait_< ResultType, ResultType_<VT> >;
2156 const SubType tmp(
serial( *
this - (~rhs) ) );
2179 template<
typename MT
2181 , ptrdiff_t... CBAs >
2182 class Band<MT,TF,false,true,CBAs...>
2183 :
public View< SparseVector< Band<MT,TF,false,true,CBAs...>, TF > >
2184 ,
private BandData<CBAs...>
2185 ,
private Computation
2190 using DataType = BandData<CBAs...>;
2193 using LeftOperand = RemoveReference_< LeftOperand_<MT> >;
2196 using RightOperand = RemoveReference_< RightOperand_<MT> >;
2202 using This = Band<MT,TF,
false,
true,CBAs...>;
2205 using BaseType = SparseVector<This,TF>;
2208 using ViewedType = MT;
2211 using ResultType = BandTrait_<ResultType_<MT>,CBAs...>;
2219 using LT = If_< And< IsSparseMatrix<LeftOperand>, IsColumnMajorMatrix<LeftOperand> >
2220 , ResultType_<LeftOperand>
2221 , CompositeType_<LeftOperand> >;
2224 using RT = If_< And< IsSparseMatrix<RightOperand>, IsRowMajorMatrix<RightOperand> >
2225 , ResultType_<RightOperand>
2226 , CompositeType_<RightOperand> >;
2231 enum :
bool { smpAssignable =
false };
2241 template<
typename... RBAs >
2242 explicit inline Band(
const MT& mmm, RBAs... args )
2243 : DataType( args... )
2246 if( !Contains< TypeList<RBAs...>,
Unchecked >::value ) {
2247 if( (
band() > 0L &&
column() >= mmm.columns() ) ||
2248 (
band() < 0L &&
row() >= mmm.rows() ) ) {
2265 inline ReturnType operator[](
size_t index )
const {
2267 return matrix_(
row()+index,
column()+index);
2279 if( index >=
size() ) {
2282 return (*
this)[index];
2291 inline size_t size() const noexcept {
2292 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
2317 inline const MT& operand() const noexcept {
2328 template<
typename T >
2329 inline bool canAlias(
const T* alias )
const noexcept {
2330 return matrix_.isAliased( alias );
2340 template<
typename T >
2341 inline bool isAliased(
const T* alias )
const noexcept {
2342 return matrix_.isAliased( alias );
2363 template<
typename VT >
2364 friend inline void assign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2373 LT A(
serial( rhs.operand().leftOperand() ) );
2374 RT B(
serial( rhs.operand().rightOperand() ) );
2376 const size_t n( rhs.size() );
2377 for(
size_t i=0UL; i<n; ++i ) {
2396 template<
typename VT >
2397 friend inline void assign( SparseVector<VT,TF>& lhs,
const Band& rhs )
2406 LT A(
serial( rhs.operand().leftOperand() ) );
2407 RT B(
serial( rhs.operand().rightOperand() ) );
2409 const size_t n( rhs.size() );
2410 ElementType_<VT> tmp{};
2411 size_t nonzeros( 0UL );
2413 for(
size_t i=0UL; i<n; ++i ) {
2415 if( !isDefault<strict>( tmp ) ) {
2416 if( (~lhs).capacity() <= nonzeros ) {
2419 (~lhs).append( i, tmp,
false );
2439 template<
typename VT >
2440 friend inline void addAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2449 LT A(
serial( rhs.operand().leftOperand() ) );
2450 RT B(
serial( rhs.operand().rightOperand() ) );
2452 const size_t n( rhs.size() );
2453 for(
size_t i=0UL; i<n; ++i ) {
2476 template<
typename VT >
2477 friend inline void subAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2486 LT A(
serial( rhs.operand().leftOperand() ) );
2487 RT B(
serial( rhs.operand().rightOperand() ) );
2489 const size_t n( rhs.size() );
2490 for(
size_t i=0UL; i<n; ++i ) {
2514 template<
typename VT >
2515 friend inline void multAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2524 LT A(
serial( rhs.operand().leftOperand() ) );
2525 RT B(
serial( rhs.operand().rightOperand() ) );
2527 const size_t n( rhs.size() );
2528 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:131
Headerfile for the generic min algorithm.
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
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:522
Header file for basic type definitions.
Header file for the SparseVector base class.
Header file for the View base class.
Header file for the IsSparseMatrix type trait.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:265
#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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3076
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:364
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3074
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:588
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
Header file for the IsIntegral type trait.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3078
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1903
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
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3083
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:560
Header file for the implementation of the Band base template.
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:733
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3084
#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.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1950
BLAZE_ALWAYS_INLINE 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:474
BLAZE_ALWAYS_INLINE 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:408
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.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3082
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:3075
#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
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3079
#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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Header file for the IsLower type trait.
#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.
BLAZE_ALWAYS_INLINE 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:430
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:8893
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Constraint on the data type.
Constraint on the data type.
typename BandTrait< MT, CBAs... >::Type BandTrait_
Auxiliary alias declaration for the BandTrait type trait.The BandTrait_ alias declaration provides a ...
Definition: BandTrait.h:145
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:608
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:134
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:67
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
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 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:131
#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, a compilation error is created.
Definition: Reference.h:79
Header file for the isDefault shim.
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:816
#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
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
#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
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
Header file for the IsRowMajorMatrix type trait.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3081
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:254
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 IsUpper type trait.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
#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, 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
#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.