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_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...>;
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_v<MatrixType> ? 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_v<MatrixType> ? 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_v<MatrixType> ?
row :
column ) );
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_t<MT> >;
477 template<
typename... RBAs >
478 explicit inline Band( MT& matrix, RBAs... args );
480 Band(
const Band& ) =
default;
494 inline Reference operator[](
size_t index );
510 inline Band& operator= ( initializer_list<ElementType> list );
511 inline Band& operator= (
const Band& rhs );
512 template<
typename VT >
inline Band& operator= (
const Vector<VT,TF>& rhs );
513 template<
typename VT >
inline Band&
operator+=(
const Vector<VT,TF>& rhs );
514 template<
typename VT >
inline Band&
operator-=(
const Vector<VT,TF>& rhs );
515 template<
typename VT >
inline Band&
operator*=(
const Vector<VT,TF>& rhs );
516 template<
typename VT >
inline Band&
operator/=(
const DenseVector<VT,TF>& rhs );
517 template<
typename VT >
inline Band& operator%=(
const Vector<VT,TF>& rhs );
528 inline MT& operand() noexcept;
529 inline const MT& operand() const noexcept;
531 inline
size_t size() const noexcept;
532 inline
size_t capacity() const noexcept;
535 inline
void reserve(
size_t n );
544 inline
void append(
size_t index, const
ElementType& value,
bool check=false );
551 inline
void erase(
size_t index );
556 inline
void erase( Pred predicate );
558 template< typename Pred >
566 inline
Iterator find (
size_t index );
568 inline
Iterator lowerBound(
size_t index );
570 inline
Iterator upperBound(
size_t index );
578 template< typename Other > inline Band& scale( const Other& scalar );
585 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
586 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
588 template< typename VT > inline
void assign ( const DenseVector <VT,TF>& rhs );
589 template< typename VT > inline
void assign ( const SparseVector<VT,TF>& rhs );
590 template< typename VT > inline
void addAssign( const Vector<VT,TF>& rhs );
591 template< typename VT > inline
void subAssign( const Vector<VT,TF>& rhs );
636 template< typename MT
638 , ptrdiff_t... CBAs >
639 template< typename... RBAs >
640 inline Band<MT,TF,false,false,CBAs...>::Band( MT& matrix, RBAs... args )
641 : DataType( args... )
645 if( (
band() > 0L &&
column() >= matrix.columns() ) ||
646 (
band() < 0L &&
row() >= matrix.rows() ) ) {
677 template<
typename MT
679 , ptrdiff_t... CBAs >
680 inline typename Band<MT,TF,
false,
false,CBAs...>
::Reference 681 Band<MT,TF,false,false,CBAs...>::operator[](
size_t index )
684 return matrix_(
row()+index,
column()+index);
700 template<
typename MT
702 , ptrdiff_t... CBAs >
704 Band<MT,TF,false,false,CBAs...>::operator[](
size_t index )
const 707 return const_cast<const MT&
>( matrix_ )(
row()+index,
column()+index);
724 template<
typename MT
726 , ptrdiff_t... CBAs >
727 inline typename Band<MT,TF,
false,
false,CBAs...>
::Reference 728 Band<MT,TF,false,false,CBAs...>::at(
size_t index )
730 if( index >=
size() ) {
733 return (*
this)[index];
750 template<
typename MT
752 , ptrdiff_t... CBAs >
754 Band<MT,TF,false,false,CBAs...>::at(
size_t index )
const 756 if( index >=
size() ) {
759 return (*
this)[index];
773 template<
typename MT
775 , ptrdiff_t... CBAs >
776 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 793 template<
typename MT
795 , ptrdiff_t... CBAs >
813 template<
typename MT
815 , ptrdiff_t... CBAs >
833 template<
typename MT
835 , ptrdiff_t... CBAs >
836 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 839 const size_t n(
size() );
854 template<
typename MT
856 , ptrdiff_t... CBAs >
860 const size_t n(
size() );
875 template<
typename MT
877 , ptrdiff_t... CBAs >
881 const size_t n(
size() );
911 template<
typename MT
913 , ptrdiff_t... CBAs >
914 inline Band<MT,TF,
false,
false,CBAs...>&
915 Band<MT,TF,false,false,CBAs...>::operator=( initializer_list<ElementType> list )
919 if( list.size() >
size() ) {
923 const InitializerVector<ElementType,false> tmp( list,
size() );
929 decltype(
auto) left( derestrict( *this ) );
955 template< typename MT
957 , ptrdiff_t... CBAs >
958 inline Band<MT,TF,false,false,CBAs...>&
959 Band<MT,TF,false,false,CBAs...>::operator=( const Band& rhs )
967 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ &&
band() == rhs.band() ) )
970 if(
size() != rhs.size() ) {
978 decltype(
auto) left( derestrict( *this ) );
980 if( rhs.canAlias( &matrix_ ) ) {
1010 template<
typename MT
1012 , ptrdiff_t... CBAs >
1013 template<
typename VT >
1014 inline Band<MT,TF,
false,
false,CBAs...>&
1015 Band<MT,TF,false,false,CBAs...>::operator=(
const Vector<VT,TF>& rhs )
1017 using blaze::assign;
1023 const CompositeType_t<VT> tmp( ~rhs );
1029 decltype(
auto) left( derestrict( *this ) );
1031 assign( left, tmp );
1055 template< typename MT
1057 , ptrdiff_t... CBAs >
1058 template< typename VT >
1059 inline Band<MT,TF,false,false,CBAs...>&
1060 Band<MT,TF,false,false,CBAs...>::operator+=( const Vector<VT,TF>& rhs )
1062 using blaze::assign;
1070 using AddType = AddTrait_t< ResultType, ResultType_t<VT> >;
1079 const AddType tmp( *
this + (~rhs) );
1085 decltype(
auto) left( derestrict( *this ) );
1087 assign( left, tmp );
1111 template< typename MT
1113 , ptrdiff_t... CBAs >
1114 template< typename VT >
1115 inline Band<MT,TF,false,false,CBAs...>&
1116 Band<MT,TF,false,false,CBAs...>::operator-=( const Vector<VT,TF>& rhs )
1118 using blaze::assign;
1126 using SubType = SubTrait_t< ResultType, ResultType_t<VT> >;
1135 const SubType tmp( *
this - (~rhs) );
1141 decltype(
auto) left( derestrict( *this ) );
1143 assign( left, tmp );
1166 template< typename MT
1168 , ptrdiff_t... CBAs >
1169 template< typename VT >
1170 inline Band<MT,TF,false,false,CBAs...>&
1171 Band<MT,TF,false,false,CBAs...>::operator*=( const Vector<VT,TF>& rhs )
1173 using blaze::assign;
1181 using MultType = MultTrait_t< ResultType, ResultType_t<VT> >;
1190 const MultType tmp( *
this * (~rhs) );
1196 decltype(
auto) left( derestrict( *this ) );
1198 assign( left, tmp );
1220 template< typename MT
1222 , ptrdiff_t... CBAs >
1223 template< typename VT >
1224 inline Band<MT,TF,false,false,CBAs...>&
1225 Band<MT,TF,false,false,CBAs...>::operator/=( const DenseVector<VT,TF>& rhs )
1227 using blaze::assign;
1236 using DivType = DivTrait_t< ResultType, ResultType_t<VT> >;
1246 const DivType tmp( *
this / (~rhs) );
1252 decltype(
auto) left( derestrict( *this ) );
1254 assign( left, tmp );
1277 template< typename MT
1279 , ptrdiff_t... CBAs >
1280 template< typename VT >
1281 inline Band<MT,TF,false,false,CBAs...>&
1282 Band<MT,TF,false,false,CBAs...>::operator%=( const Vector<VT,TF>& rhs )
1284 using blaze::assign;
1289 using CrossType = CrossTrait_t< ResultType, ResultType_t<VT> >;
1295 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
1299 const CrossType tmp( *
this % (~rhs) );
1305 decltype(
auto) left( derestrict( *this ) );
1307 assign( left, tmp );
1331 template< typename MT
1333 , ptrdiff_t... CBAs >
1334 inline MT& Band<MT,TF,false,false,CBAs...>::operand() noexcept
1348 template<
typename MT
1350 , ptrdiff_t... CBAs >
1351 inline const MT& Band<MT,TF,false,false,CBAs...>::operand() const noexcept
1365 template<
typename MT
1367 , ptrdiff_t... CBAs >
1370 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
1382 template<
typename MT
1384 , ptrdiff_t... CBAs >
1402 template<
typename MT
1404 , ptrdiff_t... CBAs >
1419 template<
typename MT
1421 , ptrdiff_t... CBAs >
1426 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1427 ( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> ) &&
row() == 0UL ) ||
1428 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1429 ( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> ) &&
column() == 0UL ) )
1432 const size_t n(
size() );
1433 for(
size_t i=0UL; i<n; ++i )
1450 template<
typename MT
1452 , ptrdiff_t... CBAs >
1453 void Band<MT,TF,false,false,CBAs...>::reserve(
size_t n )
1483 template<
typename MT
1485 , ptrdiff_t... CBAs >
1486 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1489 const size_t rowIndex (
row() + index );
1490 const size_t columnIndex(
column() + index );
1491 return Iterator( matrix_, rowIndex, columnIndex, matrix_.set( rowIndex, columnIndex, value ) );
1510 template<
typename MT
1512 , ptrdiff_t... CBAs >
1513 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1514 Band<MT,TF,false,false,CBAs...>::insert(
size_t index,
const ElementType& value )
1516 const size_t rowIndex (
row() + index );
1517 const size_t columnIndex(
column() + index );
1518 return Iterator( matrix_, rowIndex, columnIndex, matrix_.insert( rowIndex, columnIndex, value ) );
1549 template<
typename MT
1551 , ptrdiff_t... CBAs >
1552 inline void Band<MT,TF,false,false,CBAs...>::append(
size_t index,
const ElementType& value,
bool check )
1554 if( !check || !isDefault<strict>( value ) )
1555 matrix_.insert(
row()+index,
column()+index, value );
1578 template<
typename MT
1580 , ptrdiff_t... CBAs >
1581 inline void Band<MT,TF,false,false,CBAs...>::erase(
size_t index )
1583 matrix_.erase(
row()+index,
column()+index );
1598 template<
typename MT
1600 , ptrdiff_t... CBAs >
1601 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1602 Band<MT,TF,false,false,CBAs...>::erase(
Iterator pos )
1604 const size_t rowIndex ( pos.row_ );
1605 const size_t columnIndex( pos.column_ );
1607 if( rowIndex == matrix_.rows() || columnIndex == matrix_.columns() )
1610 matrix_.erase( ( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ), pos.pos_ );
1611 return Iterator( matrix_, rowIndex+1UL, columnIndex+1UL );
1627 template<
typename MT
1629 , ptrdiff_t... CBAs >
1630 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1633 for( ; first!=last; ++first ) {
1634 const size_t index( IsRowMajorMatrix<MT>::value ? first.row_ : first.column_ );
1635 matrix_.erase( index, first.pos_ );
1666 template<
typename MT
1668 , ptrdiff_t... CBAs >
1669 template<
typename Pred
1671 inline void Band<MT,TF,false,false,CBAs...>::erase( Pred predicate )
1674 if( predicate( element->value() ) ) {
1675 const size_t index( IsRowMajorMatrix<MT>::value ? element.row_ : element.column_ );
1676 matrix_.erase( index, element.pos_ );
1709 template<
typename MT
1711 , ptrdiff_t... CBAs >
1712 template<
typename Pred >
1713 inline void Band<MT,TF,false,false,CBAs...>::erase(
Iterator first,
Iterator last, Pred predicate )
1715 for( ; first!=last; ++first ) {
1716 if( predicate( first->value() ) ) {
1717 const size_t index( IsRowMajorMatrix<MT>::value ? first.row_ : first.column_ );
1718 matrix_.erase( index, first.pos_ );
1748 template<
typename MT
1750 , ptrdiff_t... CBAs >
1751 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1752 Band<MT,TF,false,false,CBAs...>::find(
size_t index )
1754 const size_t rowIndex (
row()+index );
1755 const size_t columnIndex(
column()+index );
1756 const Iterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1758 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1759 return Iterator( matrix_, rowIndex, columnIndex, pos );
1781 template<
typename MT
1783 , ptrdiff_t... CBAs >
1785 Band<MT,TF,false,false,CBAs...>::find(
size_t index )
const 1787 const size_t rowIndex (
row()+index );
1788 const size_t columnIndex(
column()+index );
1789 const ConstIterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1791 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1792 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1813 template<
typename MT
1815 , ptrdiff_t... CBAs >
1816 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1817 Band<MT,TF,false,false,CBAs...>::lowerBound(
size_t index )
1819 for(
size_t i=index; i<
size(); ++i )
1821 const size_t rowIndex (
row()+i );
1822 const size_t columnIndex(
column()+i );
1823 const Iterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1825 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1826 return Iterator( matrix_, rowIndex, columnIndex, pos );
1848 template<
typename MT
1850 , ptrdiff_t... CBAs >
1852 Band<MT,TF,false,false,CBAs...>::lowerBound(
size_t index )
const 1854 for(
size_t i=index; i<
size(); ++i )
1856 const size_t rowIndex (
row()+i );
1857 const size_t columnIndex(
column()+i );
1858 const ConstIterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1860 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1861 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1883 template<
typename MT
1885 , ptrdiff_t... CBAs >
1886 inline typename Band<MT,TF,
false,
false,CBAs...>
::Iterator 1887 Band<MT,TF,false,false,CBAs...>::upperBound(
size_t index )
1889 for(
size_t i=index+1UL; i<
size(); ++i )
1891 const size_t rowIndex (
row()+i );
1892 const size_t columnIndex(
column()+i );
1893 const Iterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1895 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1896 return Iterator( matrix_, rowIndex, columnIndex, pos );
1918 template<
typename MT
1920 , ptrdiff_t... CBAs >
1922 Band<MT,TF,false,false,CBAs...>::upperBound(
size_t index )
const 1924 for(
size_t i=index+1UL; i<
size(); ++i )
1926 const size_t rowIndex (
row()+i );
1927 const size_t columnIndex(
column()+i );
1928 const ConstIterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1930 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1931 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1961 template<
typename MT
1963 , ptrdiff_t... CBAs >
1964 template<
typename Other >
1965 inline Band<MT,TF,
false,
false,CBAs...>&
1966 Band<MT,TF,false,false,CBAs...>::scale(
const Other& scalar )
1970 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1971 ( IsStrictlyLower_v<MT> &&
row() == 0UL ) ||
1972 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1973 ( IsStrictlyUpper_v<MT> &&
column() == 0UL ) )
1977 element->value() *= scalar;
2004 template<
typename MT
2006 , ptrdiff_t... CBAs >
2007 template<
typename Other >
2008 inline bool Band<MT,TF,false,false,CBAs...>::canAlias(
const Other* alias )
const noexcept
2010 return matrix_.isAliased( alias );
2027 template<
typename MT
2029 , ptrdiff_t... CBAs >
2030 template<
typename Other >
2031 inline bool Band<MT,TF,false,false,CBAs...>::isAliased(
const Other* alias )
const noexcept
2033 return matrix_.isAliased( alias );
2051 template<
typename MT
2053 , ptrdiff_t... CBAs >
2054 template<
typename VT >
2055 inline void Band<MT,TF,false,false,CBAs...>::assign(
const DenseVector<VT,TF>& rhs )
2059 for(
size_t i=0UL; i<(~rhs).
size(); ++i ) {
2060 matrix_(
row()+i,
column()+i) = (~rhs)[i];
2079 template<
typename MT
2081 , ptrdiff_t... CBAs >
2082 template<
typename VT >
2083 inline void Band<MT,TF,false,false,CBAs...>::assign(
const SparseVector<VT,TF>& rhs )
2089 for( ConstIterator_t<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
2090 for( ; i<element->index(); ++i )
2092 matrix_(
row()+i,
column()+i) = element->value();
2095 for( ; i<
size(); ++i ) {
2115 template<
typename MT
2117 , ptrdiff_t... CBAs >
2118 template<
typename VT >
2119 inline void Band<MT,TF,false,false,CBAs...>::addAssign(
const Vector<VT,TF>& rhs )
2121 using AddType = AddTrait_t< ResultType, ResultType_t<VT> >;
2128 const AddType tmp(
serial( *
this + (~rhs) ) );
2147 template<
typename MT
2149 , ptrdiff_t... CBAs >
2150 template<
typename VT >
2151 inline void Band<MT,TF,false,false,CBAs...>::subAssign(
const Vector<VT,TF>& rhs )
2153 using SubType = SubTrait_t< ResultType, ResultType_t<VT> >;
2160 const SubType tmp(
serial( *
this - (~rhs) ) );
2183 template<
typename MT
2185 , ptrdiff_t... CBAs >
2186 class Band<MT,TF,false,true,CBAs...>
2187 :
public View< SparseVector< Band<MT,TF,false,true,CBAs...>, TF > >
2188 ,
private BandData<CBAs...>
2189 ,
private Computation
2194 using DataType = BandData<CBAs...>;
2197 using LeftOperand = RemoveReference_t< LeftOperand_t<MT> >;
2200 using RightOperand = RemoveReference_t< RightOperand_t<MT> >;
2206 using This = Band<MT,TF,
false,
true,CBAs...>;
2209 using BaseType = SparseVector<This,TF>;
2212 using ViewedType = MT;
2215 using ResultType = BandTrait_t<ResultType_t<MT>,CBAs...>;
2223 using LT = If_t< IsSparseMatrix_v<LeftOperand> && IsColumnMajorMatrix_v<LeftOperand>
2224 , ResultType_t<LeftOperand>
2225 , CompositeType_t<LeftOperand> >;
2228 using RT = If_t< IsSparseMatrix_v<RightOperand> && IsRowMajorMatrix_v<RightOperand>
2229 , ResultType_t<RightOperand>
2230 , CompositeType_t<RightOperand> >;
2245 template<
typename... RBAs >
2246 explicit inline Band(
const MT& mmm, RBAs... args )
2247 : DataType( args... )
2251 if( (
band() > 0L &&
column() >= mmm.columns() ) ||
2252 (
band() < 0L &&
row() >= mmm.rows() ) ) {
2269 inline ReturnType operator[](
size_t index )
const {
2271 return matrix_(
row()+index,
column()+index);
2283 if( index >=
size() ) {
2286 return (*
this)[index];
2295 inline size_t size() const noexcept {
2296 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
2321 inline const MT& operand() const noexcept {
2332 template<
typename T >
2333 inline bool canAlias(
const T* alias )
const noexcept {
2334 return matrix_.isAliased( alias );
2344 template<
typename T >
2345 inline bool isAliased(
const T* alias )
const noexcept {
2346 return matrix_.isAliased( alias );
2367 template<
typename VT >
2368 friend inline void assign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2377 LT A(
serial( rhs.operand().leftOperand() ) );
2378 RT B(
serial( rhs.operand().rightOperand() ) );
2380 const size_t n( rhs.size() );
2381 for(
size_t i=0UL; i<n; ++i ) {
2400 template<
typename VT >
2401 friend inline void assign( SparseVector<VT,TF>& lhs,
const Band& rhs )
2410 LT A(
serial( rhs.operand().leftOperand() ) );
2411 RT B(
serial( rhs.operand().rightOperand() ) );
2413 const size_t n( rhs.size() );
2414 ElementType_t<VT> tmp{};
2415 size_t nonzeros( 0UL );
2417 for(
size_t i=0UL; i<n; ++i ) {
2419 if( !isDefault<strict>( tmp ) ) {
2420 if( (~lhs).capacity() <= nonzeros ) {
2423 (~lhs).append( i, tmp,
false );
2443 template<
typename VT >
2444 friend inline void addAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2453 LT A(
serial( rhs.operand().leftOperand() ) );
2454 RT B(
serial( rhs.operand().rightOperand() ) );
2456 const size_t n( rhs.size() );
2457 for(
size_t i=0UL; i<n; ++i ) {
2480 template<
typename VT >
2481 friend inline void subAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2490 LT A(
serial( rhs.operand().leftOperand() ) );
2491 RT B(
serial( rhs.operand().rightOperand() ) );
2493 const size_t n( rhs.size() );
2494 for(
size_t i=0UL; i<n; ++i ) {
2518 template<
typename VT >
2519 friend inline void multAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2528 LT A(
serial( rhs.operand().leftOperand() ) );
2529 RT B(
serial( rhs.operand().rightOperand() ) );
2531 const size_t n( rhs.size() );
2532 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.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:354
Header file for the UNUSED_PARAMETER function template.
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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
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:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
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.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3079
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:3084
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.
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.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.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
Header file for the implementation of a vector representation of an initializer list.
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
#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:3080
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:1147
#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:3086
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:253
constexpr bool Contains_v
Auxiliary variable template for the Contains type trait.The Contains_v variable template provides a c...
Definition: Contains.h:139
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.
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:1179
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8908
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
Constraint on the data type.
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:611
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:135
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
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: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, a compilation error is created.
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
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
Header file for the IsRowMajorMatrix type trait.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3082
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:290
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
constexpr bool IsIntegral_v
Auxiliary variable template for the IsIntegral type trait.The IsIntegral_v variable template provides...
Definition: IsIntegral.h:95
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.
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, 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.