35#ifndef _BLAZE_MATH_VIEWS_BAND_DENSE_H_
36#define _BLAZE_MATH_VIEWS_BAND_DENSE_H_
115class Band<MT,TF,true,false,CBAs...>
116 :
public View< DenseVector< Band<MT,TF,true,false,CBAs...>, TF > >
117 ,
private BandData<CBAs...>
121 using RT = ResultType_t<MT>;
122 using DataType = BandData<CBAs...>;
123 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
129 using This = Band<MT,TF,
true,
false,CBAs...>;
132 using BaseType = View< DenseVector<This,TF> >;
134 using ViewedType = MT;
136 using TransposeType = TransposeType_t<ResultType>;
137 using ElementType = ElementType_t<MT>;
138 using ReturnType = ReturnType_t<MT>;
141 using CompositeType = If_t< RequiresEvaluation_v<MT>,
const ResultType,
const Band& >;
144 using ConstReference = ConstReference_t<MT>;
147 using Reference = If_t< IsConst_v<MT>, ConstReference, Reference_t<MT> >;
150 using ConstPointer = ConstPointer_t<MT>;
153 using Pointer = If_t< IsConst_v<MT> || !HasMutableDataAccess_v<MT>, ConstPointer, Pointer_t<MT> >;
159 template<
typename MatrixType
160 ,
typename IteratorType >
166 using IteratorCategory =
typename std::iterator_traits<IteratorType>::iterator_category;
169 using ValueType =
typename std::iterator_traits<IteratorType>::value_type;
172 using PointerType =
typename std::iterator_traits<IteratorType>::pointer;
175 using ReferenceType =
typename std::iterator_traits<IteratorType>::reference;
178 using DifferenceType =
typename std::iterator_traits<IteratorType>::difference_type;
181 using iterator_category = IteratorCategory;
182 using value_type = ValueType;
183 using pointer = PointerType;
184 using reference = ReferenceType;
185 using difference_type = DifferenceType;
191 inline BandIterator() noexcept
206 inline BandIterator( MatrixType& matrix,
size_t rowIndex,
size_t columnIndex ) noexcept
209 , column_( columnIndex )
212 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
213 pos_ = matrix_->begin( row_ ) + column_;
214 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
215 pos_ = matrix_->begin( column_ ) + row_;
224 template<
typename MatrixType2,
typename IteratorType2 >
225 inline BandIterator(
const BandIterator<MatrixType2,IteratorType2>& it ) noexcept
226 : matrix_( it.matrix_ )
228 , column_( it.column_ )
239 inline BandIterator&
operator+=(
size_t inc )
noexcept {
245 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
246 pos_ = matrix_->begin( row_ ) + column_;
247 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
248 pos_ = matrix_->begin( column_ ) + row_;
261 inline BandIterator&
operator-=(
size_t dec )
noexcept {
267 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
268 pos_ = matrix_->begin( row_ ) + column_;
269 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
270 pos_ = matrix_->begin( column_ ) + row_;
282 inline BandIterator& operator++() noexcept {
288 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
289 pos_ = matrix_->begin( row_ ) + column_;
290 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
291 pos_ = matrix_->begin( column_ ) + row_;
303 inline const BandIterator operator++(
int )
noexcept {
304 const BandIterator tmp( *
this );
315 inline BandIterator& operator--() noexcept {
321 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
322 pos_ = matrix_->begin( row_ ) + column_;
323 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
324 pos_ = matrix_->begin( column_ ) + row_;
336 inline const BandIterator operator--(
int )
noexcept {
337 const BandIterator tmp( *
this );
349 inline ReferenceType operator[](
size_t index )
const {
352 const IteratorType pos( IsRowMajorMatrix_v<MatrixType>
353 ? matrix_->begin( row_+index ) + column_ + index
354 : matrix_->begin( column_+index ) + row_ + index );
374 inline PointerType operator->()
const {
385 template<
typename MatrixType2,
typename IteratorType2 >
386 inline bool operator==(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
387 return row_ == rhs.row_;
397 template<
typename MatrixType2,
typename IteratorType2 >
398 inline bool operator!=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
399 return !( *
this == rhs );
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 row_ > rhs.row_;
433 template<
typename MatrixType2,
typename IteratorType2 >
434 inline bool operator<=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
435 return row_ <= rhs.row_;
445 template<
typename MatrixType2,
typename IteratorType2 >
446 inline bool operator>=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
447 return row_ >= rhs.row_;
457 inline DifferenceType
operator-(
const BandIterator& rhs )
const noexcept {
458 return row_ - rhs.row_;
469 friend inline const BandIterator
operator+(
const BandIterator& it,
size_t inc )
noexcept {
470 return BandIterator( *it.matrix_, it.row_+inc, it.column_+inc );
481 friend inline const BandIterator
operator+(
size_t inc,
const BandIterator& it )
noexcept {
482 return BandIterator( *it.matrix_, it.row_+inc, it.column_+inc );
493 friend inline const BandIterator
operator-(
const BandIterator& it,
size_t dec )
noexcept {
494 return BandIterator( *it.matrix_, it.row_-dec, it.column_-dec );
507 template<
typename MatrixType2,
typename IteratorType2 >
friend class BandIterator;
514 using ConstIterator = BandIterator< const MT, ConstIterator_t<MT> >;
517 using Iterator = If_t< IsConst_v<MT>, ConstIterator, BandIterator< MT, Iterator_t<MT> > >;
522 static constexpr bool simdEnabled =
false;
525 static constexpr bool smpAssignable = MT::smpAssignable;
528 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
534 template<
typename... RBAs >
535 explicit inline Band( MT& matrix, RBAs... args );
537 Band(
const Band& ) =
default;
551 inline Reference operator[](
size_t index );
552 inline ConstReference operator[](
size_t index )
const;
553 inline Reference at(
size_t index );
554 inline ConstReference at(
size_t index )
const;
555 inline Pointer
data () noexcept;
556 inline ConstPointer
data () const noexcept;
557 inline Iterator
begin ();
558 inline ConstIterator
begin () const;
559 inline ConstIterator
cbegin() const;
560 inline Iterator
end ();
561 inline ConstIterator
end () const;
562 inline ConstIterator
cend () const;
569 inline Band& operator=( const ElementType& rhs );
571 inline Band& operator=( const Band& rhs );
573 template< typename VT > inline Band& operator= ( const Vector<VT,TF>& rhs );
574 template< typename VT > inline Band& operator+=( const Vector<VT,TF>& rhs );
575 template< typename VT > inline Band& operator-=( const Vector<VT,TF>& rhs );
576 template< typename VT > inline Band& operator*=( const Vector<VT,TF>& rhs );
577 template< typename VT > inline Band& operator/=( const DenseVector<VT,TF>& rhs );
578 template< typename VT > inline Band& operator%=( const Vector<VT,TF>& rhs );
585 using DataType::
band;
589 inline MT& operand() noexcept;
590 inline const MT& operand() const noexcept;
592 inline
size_t size() const noexcept;
593 inline
size_t spacing() const noexcept;
594 inline
size_t capacity() const noexcept;
603 template< typename Other > inline Band& scale( const Other& scalar );
610 template< typename Other >
611 inline
bool canAlias( const Other* alias ) const noexcept;
613 template< typename MT2,
ptrdiff_t... CBAs2 >
614 inline
bool canAlias( const Band<MT2,TF,true,false,CBAs2...>* alias ) const noexcept;
616 template< typename Other >
617 inline
bool isAliased( const Other* alias ) const noexcept;
619 template< typename MT2,
ptrdiff_t... CBAs2 >
620 inline
bool isAliased( const Band<MT2,TF,true,false,CBAs2...>* alias ) const noexcept;
622 inline
bool isAligned () const noexcept;
623 inline
bool canSMPAssign() const noexcept;
625 template< typename VT > inline
void assign ( const DenseVector <VT,TF>& rhs );
626 template< typename VT > inline
void assign ( const SparseVector<VT,TF>& rhs );
627 template< typename VT > inline
void addAssign ( const DenseVector <VT,TF>& rhs );
628 template< typename VT > inline
void addAssign ( const SparseVector<VT,TF>& rhs );
629 template< typename VT > inline
void subAssign ( const DenseVector <VT,TF>& rhs );
630 template< typename VT > inline
void subAssign ( const SparseVector<VT,TF>& rhs );
631 template< typename VT > inline
void multAssign( const DenseVector <VT,TF>& rhs );
632 template< typename VT > inline
void multAssign( const SparseVector<VT,TF>& rhs );
633 template< typename VT > inline
void divAssign ( const DenseVector <VT,TF>& rhs );
646 template< typename MT2,
bool TF2,
bool DF2,
bool MF2,
ptrdiff_t... CBAs2 > friend class Band;
685template< typename... RBAs >
686inline Band<MT,TF,true,false,CBAs...>::Band( MT& matrix, RBAs... args )
687 : DataType( args... )
691 if( (
band() > 0L &&
column() >= matrix.columns() ) ||
692 (
band() < 0L &&
row() >= matrix.rows() ) ) {
726inline typename Band<MT,TF,
true,
false,CBAs...>::Reference
727 Band<MT,TF,true,false,CBAs...>::operator[](
size_t index )
730 return matrix_(
row()+index,
column()+index);
749inline typename Band<MT,TF,
true,
false,CBAs...>::ConstReference
750 Band<MT,TF,true,false,CBAs...>::operator[](
size_t index )
const
753 return const_cast<const MT&
>( matrix_ )(
row()+index,
column()+index);
773inline typename Band<MT,TF,
true,
false,CBAs...>::Reference
774 Band<MT,TF,true,false,CBAs...>::at(
size_t index )
776 if( index >=
size() ) {
779 return (*
this)[index];
799inline typename Band<MT,TF,
true,
false,CBAs...>::ConstReference
800 Band<MT,TF,true,false,CBAs...>::at(
size_t index )
const
802 if( index >=
size() ) {
805 return (*
this)[index];
823inline typename Band<MT,TF,
true,
false,CBAs...>::Pointer
826 if( IsRowMajorMatrix_v<MT> )
827 return matrix_.data() +
row() * matrix_.spacing() +
column();
829 return matrix_.data() +
row() +
column() * matrix_.spacing();
847inline typename Band<MT,TF,
true,
false,CBAs...>::ConstPointer
850 if( IsRowMajorMatrix_v<MT> )
851 return matrix_.data() +
row() * matrix_.spacing() +
column();
853 return matrix_.data() +
row() +
column() * matrix_.spacing();
870inline typename Band<MT,TF,
true,
false,CBAs...>::Iterator
873 return Iterator( matrix_,
row(),
column() );
890inline typename Band<MT,TF,
true,
false,CBAs...>::ConstIterator
893 return ConstIterator( matrix_,
row(),
column() );
910inline typename Band<MT,TF,
true,
false,CBAs...>::ConstIterator
913 return ConstIterator( matrix_,
row(),
column() );
930inline typename Band<MT,TF,
true,
false,CBAs...>::Iterator
933 const size_t n(
size() );
934 return Iterator( matrix_,
row()+n,
column()+n );
951inline typename Band<MT,TF,
true,
false,CBAs...>::ConstIterator
954 const size_t n(
size() );
955 return ConstIterator( matrix_,
row()+n,
column()+n );
972inline typename Band<MT,TF,
true,
false,CBAs...>::ConstIterator
975 const size_t n(
size() );
976 return ConstIterator( matrix_,
row()+n,
column()+n );
1001template<
typename MT
1004inline Band<MT,TF,
true,
false,CBAs...>&
1005 Band<MT,TF,true,false,CBAs...>::operator=(
const ElementType& rhs )
1007 decltype(
auto) left( derestrict( matrix_ ) );
1009 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1010 ( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> ) &&
row() == 0UL ) ||
1011 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1012 ( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> ) &&
column() == 0UL ) )
1015 const size_t n(
size() );
1016 for(
size_t i=0UL; i<n; ++i ) {
1017 if( !IsRestricted_v<MT> || IsTriangular_v<MT> || trySet( matrix_,
row()+i,
column()+i, rhs ) )
1042template<
typename MT
1045inline Band<MT,TF,
true,
false,CBAs...>&
1048 if( list.size() >
size() ) {
1052 if( IsRestricted_v<MT> ) {
1053 const InitializerVector<ElementType,false> tmp( list,
size() );
1059 decltype(
auto) left( derestrict( *
this ) );
1061 std::fill( std::copy( list.begin(), list.end(), left.begin() ), left.end(), ElementType() );
1085template<
typename MT
1088inline Band<MT,TF,
true,
false,CBAs...>&
1089 Band<MT,TF,true,false,CBAs...>::operator=(
const Band& rhs )
1091 if( &rhs ==
this )
return *
this;
1093 if(
size() != rhs.size() ) {
1101 decltype(
auto) left( derestrict( *
this ) );
1103 if( IsExpression_v<MT> && rhs.canAlias(
this ) ) {
1104 const ResultType tmp( rhs );
1133template<
typename MT
1136template<
typename VT >
1137inline Band<MT,TF,
true,
false,CBAs...>&
1138 Band<MT,TF,true,false,CBAs...>::operator=(
const Vector<VT,TF>& rhs )
1143 if(
size() != (*rhs).size() ) {
1147 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1148 Right right( *rhs );
1150 if( !tryAssign( matrix_, right,
band(),
row(),
column() ) ) {
1154 decltype(
auto) left( derestrict( *
this ) );
1156 if( IsReference_v<Right> && right.canAlias(
this ) ) {
1157 const ResultType_t<VT> tmp( right );
1161 if( IsSparseVector_v<VT> )
1188template<
typename MT
1191template<
typename VT >
1192inline Band<MT,TF,
true,
false,CBAs...>&
1198 if(
size() != (*rhs).size() ) {
1202 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1203 Right right( *rhs );
1205 if( !tryAddAssign( matrix_, right,
band(),
row(),
column() ) ) {
1209 decltype(
auto) left( derestrict( *
this ) );
1211 if( IsReference_v<Right> && right.canAlias(
this ) ) {
1212 const ResultType_t<VT> tmp( right );
1241template<
typename MT
1244template<
typename VT >
1245inline Band<MT,TF,
true,
false,CBAs...>&
1251 if(
size() != (*rhs).size() ) {
1255 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1256 Right right( *rhs );
1258 if( !trySubAssign( matrix_, right,
band(),
row(),
column() ) ) {
1262 decltype(
auto) left( derestrict( *
this ) );
1264 if( IsReference_v<Right> && right.canAlias(
this ) ) {
1265 const ResultType_t<VT> tmp( right );
1293template<
typename MT
1296template<
typename VT >
1297inline Band<MT,TF,
true,
false,CBAs...>&
1306 if(
size() != (*rhs).size() ) {
1310 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1311 Right right( *rhs );
1313 if( !tryMultAssign( matrix_, right,
band(),
row(),
column() ) ) {
1317 decltype(
auto) left( derestrict( *
this ) );
1319 if( IsReference_v<Right> && right.canAlias(
this ) ) {
1320 const ResultType_t<VT> tmp( right );
1347template<
typename MT
1350template<
typename VT >
1351inline Band<MT,TF,
true,
false,CBAs...>&
1357 if(
size() != (*rhs).size() ) {
1361 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1362 Right right( *rhs );
1364 if( !tryDivAssign( matrix_, right,
band(),
row(),
column() ) ) {
1368 decltype(
auto) left( derestrict( *
this ) );
1370 if( IsReference_v<Right> && right.canAlias(
this ) ) {
1371 const ResultType_t<VT> tmp( right );
1399template<
typename MT
1402template<
typename VT >
1403inline Band<MT,TF,
true,
false,CBAs...>&
1404 Band<MT,TF,true,false,CBAs...>::operator%=(
const Vector<VT,TF>& rhs )
1406 using blaze::assign;
1411 using CrossType = CrossTrait_t< ResultType, ResultType_t<VT> >;
1417 if(
size() != 3UL || (*rhs).size() != 3UL ) {
1421 const CrossType right( *
this % (*rhs) );
1423 if( !tryAssign( matrix_, right,
band(),
row(),
column() ) ) {
1427 decltype(
auto) left( derestrict( *
this ) );
1429 assign( left, right );
1453template<
typename MT
1456inline MT& Band<MT,TF,true,false,CBAs...>::operand() noexcept
1470template<
typename MT
1473inline const MT& Band<MT,TF,true,false,CBAs...>::operand() const noexcept
1487template<
typename MT
1492 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
1507template<
typename MT
1524template<
typename MT
1544template<
typename MT
1549 const size_t n(
size() );
1550 size_t nonzeros( 0UL );
1552 for(
size_t i=0UL; i<n; ++i )
1568template<
typename MT
1575 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1576 ( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> ) &&
row() == 0UL ) ||
1577 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1578 ( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> ) &&
column() == 0UL ) )
1581 const size_t n(
size() );
1582 for(
size_t i=0UL; i<n; ++i )
1610template<
typename MT
1613template<
typename Other >
1614inline Band<MT,TF,
true,
false,CBAs...>&
1615 Band<MT,TF,true,false,CBAs...>::scale(
const Other& scalar )
1619 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1620 ( IsStrictlyLower_v<MT> &&
row() == 0UL ) ||
1621 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1622 ( IsStrictlyUpper_v<MT> &&
column() == 0UL ) )
1625 const size_t n(
size() );
1626 for(
size_t i=0UL; i<n; ++i ) {
1655template<
typename MT
1658template<
typename Other >
1659inline bool Band<MT,TF,true,false,CBAs...>::canAlias(
const Other* alias )
const noexcept
1661 return matrix_.isAliased( &unview( *alias ) );
1678template<
typename MT
1681template<
typename MT2
1684 Band<MT,TF,true,false,CBAs...>::canAlias(
const Band<MT2,TF,true,false,CBAs2...>* alias )
const noexcept
1686 return matrix_.isAliased( &alias->matrix_ ) && (
band() == alias->band() );
1703template<
typename MT
1706template<
typename Other >
1707inline bool Band<MT,TF,true,false,CBAs...>::isAliased(
const Other* alias )
const noexcept
1709 return matrix_.isAliased( &unview( *alias ) );
1726template<
typename MT
1729template<
typename MT2
1732 Band<MT,TF,true,false,CBAs...>::isAliased(
const Band<MT2,TF,true,false,CBAs2...>* alias )
const noexcept
1734 return matrix_.isAliased( &alias->matrix_ ) && (
band() == alias->band() );
1750template<
typename MT
1753inline bool Band<MT,TF,true,false,CBAs...>::isAligned() const noexcept
1772template<
typename MT
1775inline bool Band<MT,TF,true,false,CBAs...>::canSMPAssign() const noexcept
1777 return (
size() > SMP_DVECASSIGN_THRESHOLD );
1795template<
typename MT
1798template<
typename VT >
1799inline void Band<MT,TF,true,false,CBAs...>::assign(
const DenseVector<VT,TF>& rhs )
1803 const size_t ipos(
prevMultiple( (*rhs).size(), 2UL ) );
1806 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1807 matrix_(
row()+i ,
column()+i ) = (*rhs)[i ];
1808 matrix_(
row()+i+1UL,
column()+i+1UL) = (*rhs)[i+1UL];
1810 if( ipos < (*rhs).size() ) {
1811 matrix_(
row()+ipos,
column()+ipos) = (*rhs)[ipos];
1830template<
typename MT
1833template<
typename VT >
1834inline void Band<MT,TF,true,false,CBAs...>::assign(
const SparseVector<VT,TF>& rhs )
1838 for( ConstIterator_t<VT> element=(*rhs).begin(); element!=(*rhs).end(); ++element ) {
1839 const size_t index( element->index() );
1840 matrix_(
row()+index,
column()+index) = element->value();
1859template<
typename MT
1862template<
typename VT >
1863inline void Band<MT,TF,true,false,CBAs...>::addAssign(
const DenseVector<VT,TF>& rhs )
1867 const size_t ipos(
prevMultiple( (*rhs).size(), 2UL ) );
1870 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1871 matrix_(
row()+i ,
column()+i ) += (*rhs)[i ];
1872 matrix_(
row()+i+1UL,
column()+i+1UL) += (*rhs)[i+1UL];
1874 if( ipos < (*rhs).size() ) {
1875 matrix_(
row()+ipos,
column()+ipos) += (*rhs)[ipos];
1894template<
typename MT
1897template<
typename VT >
1898inline void Band<MT,TF,true,false,CBAs...>::addAssign(
const SparseVector<VT,TF>& rhs )
1902 for( ConstIterator_t<VT> element=(*rhs).begin(); element!=(*rhs).end(); ++element ) {
1903 const size_t index( element->index() );
1904 matrix_(
row()+index,
column()+index) += element->value();
1923template<
typename MT
1926template<
typename VT >
1927inline void Band<MT,TF,true,false,CBAs...>::subAssign(
const DenseVector<VT,TF>& rhs )
1931 const size_t ipos(
prevMultiple( (*rhs).size(), 2UL ) );
1934 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1935 matrix_(
row()+i ,
column()+i ) -= (*rhs)[i ];
1936 matrix_(
row()+i+1UL,
column()+i+1UL) -= (*rhs)[i+1UL];
1938 if( ipos < (*rhs).size() ) {
1939 matrix_(
row()+ipos,
column()+ipos) -= (*rhs)[ipos];
1958template<
typename MT
1961template<
typename VT >
1962inline void Band<MT,TF,true,false,CBAs...>::subAssign(
const SparseVector<VT,TF>& rhs )
1966 for( ConstIterator_t<VT> element=(*rhs).begin(); element!=(*rhs).end(); ++element ) {
1967 const size_t index( element->index() );
1968 matrix_(
row()+index,
column()+index) -= element->value();
1987template<
typename MT
1990template<
typename VT >
1991inline void Band<MT,TF,true,false,CBAs...>::multAssign(
const DenseVector<VT,TF>& rhs )
1995 const size_t ipos(
prevMultiple( (*rhs).size(), 2UL ) );
1998 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1999 matrix_(
row()+i ,
column()+i ) *= (*rhs)[i ];
2000 matrix_(
row()+i+1UL,
column()+i+1UL) *= (*rhs)[i+1UL];
2002 if( ipos < (*rhs).size() ) {
2003 matrix_(
row()+ipos,
column()+ipos) *= (*rhs)[ipos];
2022template<
typename MT
2025template<
typename VT >
2026inline void Band<MT,TF,true,false,CBAs...>::multAssign(
const SparseVector<VT,TF>& rhs )
2034 for( ConstIterator_t<VT> element=(*rhs).begin(); element!=(*rhs).end(); ++element ) {
2035 const size_t index( element->index() );
2036 for( ; i<index; ++i )
2038 matrix_(
row()+index,
column()+index) *= element->value();
2042 for( ; i<
size(); ++i ) {
2062template<
typename MT
2065template<
typename VT >
2066inline void Band<MT,TF,true,false,CBAs...>::divAssign(
const DenseVector<VT,TF>& rhs )
2070 const size_t ipos(
prevMultiple( (*rhs).size(), 2UL ) );
2073 for(
size_t i=0UL; i<ipos; i+=2UL ) {
2074 matrix_(
row()+i ,
column()+i ) /= (*rhs)[i ];
2075 matrix_(
row()+i+1UL,
column()+i+1UL) /= (*rhs)[i+1UL];
2077 if( ipos < (*rhs).size() ) {
2078 matrix_(
row()+ipos,
column()+ipos) /= (*rhs)[ipos];
2101template<
typename MT
2104class Band<MT,TF,true,true,CBAs...>
2105 :
public View< DenseVector< Band<MT,TF,true,true,CBAs...>, TF > >
2106 ,
private BandData<CBAs...>
2107 ,
private Computation
2112 using DataType = BandData<CBAs...>;
2115 using LeftOperand = RemoveReference_t< LeftOperand_t<MT> >;
2118 using RightOperand = RemoveReference_t< RightOperand_t<MT> >;
2124 using This = Band<MT,TF,
true,
true,CBAs...>;
2127 using BaseType = View< DenseVector<This,TF> >;
2130 using ViewedType = MT;
2133 using ResultType = BandTrait_t<ResultType_t<MT>,CBAs...>;
2135 using TransposeType = TransposeType_t<ResultType>;
2136 using ElementType = ElementType_t<ResultType>;
2137 using ReturnType = ReturnType_t<MT>;
2140 using CompositeType = If_t< RequiresEvaluation_v<LeftOperand> ||
2141 RequiresEvaluation_v<RightOperand>
2142 ,
const ResultType,
const Band& >;
2145 using LT = If_t< IsSparseMatrix_v<LeftOperand> && IsColumnMajorMatrix_v<LeftOperand>
2146 , OppositeType_t<LeftOperand>
2147 , CompositeType_t<LeftOperand> >;
2150 using RT = If_t< IsSparseMatrix_v<RightOperand> && IsRowMajorMatrix_v<RightOperand>
2151 , OppositeType_t<RightOperand>
2152 , CompositeType_t<RightOperand> >;
2157 static constexpr bool simdEnabled =
false;
2160 static constexpr bool smpAssignable =
false;
2163 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
2173 template<
typename... RBAs >
2174 explicit inline Band(
const MT& mmm, RBAs... args )
2175 : DataType( args... )
2179 if( (
band() > 0L &&
column() >= mmm.columns() ) ||
2180 (
band() < 0L &&
row() >= mmm.rows() ) ) {
2197 inline ReturnType operator[](
size_t index )
const {
2199 return matrix_(
row()+index,
column()+index);
2210 inline ReturnType at(
size_t index )
const {
2211 if( index >=
size() ) {
2214 return (*
this)[index];
2223 inline size_t size() const noexcept {
2224 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
2239 inline const MT& operand() const noexcept {
2250 template<
typename T >
2251 inline bool canAlias(
const T* alias )
const noexcept {
2252 return matrix_.isAliased( &unview( *alias ) );
2262 template<
typename T >
2263 inline bool isAliased(
const T* alias )
const noexcept {
2264 return matrix_.isAliased( &unview( *alias ) );
2273 constexpr bool isAligned() const noexcept {
2294 template<
typename VT >
2295 friend inline void assign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2304 LT A(
serial( rhs.operand().leftOperand() ) );
2305 RT B(
serial( rhs.operand().rightOperand() ) );
2307 const size_t n( rhs.size() );
2308 for(
size_t i=0UL; i<n; ++i ) {
2325 template<
typename VT >
2326 friend inline void assign( SparseVector<VT,TF>& lhs,
const Band& rhs )
2336 const ResultType tmp(
serial( rhs ) );
2337 assign( *lhs, tmp );
2352 template<
typename VT >
2353 friend inline void addAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2362 LT A(
serial( rhs.operand().leftOperand() ) );
2363 RT B(
serial( rhs.operand().rightOperand() ) );
2365 const size_t n( rhs.size() );
2366 for(
size_t i=0UL; i<n; ++i ) {
2387 template<
typename VT >
2388 friend inline void subAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2397 LT A(
serial( rhs.operand().leftOperand() ) );
2398 RT B(
serial( rhs.operand().rightOperand() ) );
2400 const size_t n( rhs.size() );
2401 for(
size_t i=0UL; i<n; ++i ) {
2423 template<
typename VT >
2424 friend inline void multAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2433 LT A(
serial( rhs.operand().leftOperand() ) );
2434 RT B(
serial( rhs.operand().rightOperand() ) );
2436 const size_t n( rhs.size() );
2437 for(
size_t i=0UL; i<n; ++i ) {
2458 template<
typename VT >
2459 friend inline void divAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2468 LT A(
serial( rhs.operand().leftOperand() ) );
2469 RT B(
serial( rhs.operand().rightOperand() ) );
2471 const size_t n( rhs.size() );
2472 for(
size_t i=0UL; i<n; ++i ) {
2509template<
typename MT
2514class Band< DMatRepeatExpr<MT,SO,CRAs...>, TF, true, false, CBAs... >
2515 :
public View< DenseVector< Band< DMatRepeatExpr<MT,SO,CRAs...>, TF, true, false, CBAs... >, TF > >
2516 ,
private BandData<CBAs...>
2517 ,
private Computation
2522 using RE = DMatRepeatExpr<MT,SO,CRAs...>;
2525 using DataType = BandData<CBAs...>;
2531 using This = Band<RE,TF,
true,
false,CBAs...>;
2534 using BaseType = View< DenseVector<This,TF> >;
2537 using ViewedType = RE;
2540 using ResultType = BandTrait_t<ResultType_t<RE>,CBAs...>;
2542 using TransposeType = TransposeType_t<ResultType>;
2543 using ElementType = ElementType_t<ResultType>;
2544 using ReturnType = ReturnType_t<MT>;
2545 using CompositeType =
const ResultType;
2550 static constexpr bool simdEnabled =
false;
2553 static constexpr bool smpAssignable =
false;
2556 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
2566 template<
typename... RBAs >
2567 explicit inline Band(
const RE& re, RBAs... args )
2568 : DataType( args... )
2572 if( (
band() > 0L &&
column() >= re.columns() ) ||
2573 (
band() < 0L &&
row() >= re.rows() ) ) {
2590 inline ReturnType operator[](
size_t index )
const {
2592 return matrix_(
row()+index,
column()+index);
2603 inline ReturnType at(
size_t index )
const {
2604 if( index >=
size() ) {
2607 return (*
this)[index];
2616 inline size_t size() const noexcept {
2617 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
2632 inline const MT& operand() const noexcept {
2643 template<
typename T >
2644 inline bool canAlias(
const T* alias )
const noexcept {
2645 return matrix_.isAliased( &unview( *alias ) );
2655 template<
typename T >
2656 inline bool isAliased(
const T* alias )
const noexcept {
2657 return matrix_.isAliased( &unview( *alias ) );
2666 constexpr bool isAligned() const noexcept {
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
constexpr const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:719
Header file for the HasMutableDataAccess type trait.
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 IsLower type trait.
Header file for the IsReference type trait.
Header file for the IsRestricted type trait.
Header file for the IsRowMajorMatrix type trait.
Header file for the IsSparseMatrix type trait.
Header file for the IsSparseVector type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsTriangular type trait.
Header file for the IsUniLower type trait.
Header file for the IsUniUpper type trait.
Header file for the IsUpper type trait.
Constraint on the data type.
Header file for the prevMultiple shim.
Constraint on the data type.
Header file for the RemoveReference type 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.
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
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:182
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
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:265
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
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition: DiagonalMatrix.h:169
#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_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#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
BLAZE_ALWAYS_INLINE constexpr auto prevMultiple(T1 value, T2 factor) noexcept
Rounds down an integral value to the previous multiple of a given factor.
Definition: PrevMultiple.h:68
constexpr bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:370
constexpr bool operator==(const NegativeAccuracy< A > &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)
Less-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:332
constexpr bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:446
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 bool operator<=(const NegativeAccuracy< A > &, const T &rhs)
Less-or-equal-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:408
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
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:644
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
auto smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:221
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
auto smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP multiplication assignment of a vector to a dense vector.
Definition: DenseVector.h:192
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
#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
#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.
Header file for the extended initializer_list functionality.
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Header file for the clear shim.
Header file for the reset shim.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.
Header file for the generic min algorithm.
Header file for the implementation of the Band base template.