35#ifndef _BLAZE_MATH_VIEWS_BAND_DENSE_H_
36#define _BLAZE_MATH_VIEWS_BAND_DENSE_H_
114 , ptrdiff_t... CBAs >
115class Band<MT,TF,true,false,CBAs...>
116 :
public View< DenseVector< Band<MT,TF,true,false,CBAs...>, TF > >
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 );
570 inline Band& operator=( initializer_list<ElementType> list );
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;
587 using DataType::column;
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;
595 inline
size_t nonZeros() const;
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;
684 , ptrdiff_t... CBAs >
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() ) ) {
693 BLAZE_THROW_INVALID_ARGUMENT(
"Invalid band access index" );
725 , ptrdiff_t... CBAs >
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);
748 , ptrdiff_t... CBAs >
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);
772 , ptrdiff_t... CBAs >
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];
798 , ptrdiff_t... CBAs >
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];
822 , ptrdiff_t... CBAs >
823inline typename Band<MT,TF,
true,
false,CBAs...>::Pointer
824 Band<MT,TF,true,false,CBAs...>::data() noexcept
827 return matrix_.data() +
row() * matrix_.spacing() +
column();
829 return matrix_.data() +
row() +
column() * matrix_.spacing();
846 , ptrdiff_t... CBAs >
847inline typename Band<MT,TF,
true,
false,CBAs...>::ConstPointer
848 Band<MT,TF,true,false,CBAs...>::data() const noexcept
851 return matrix_.data() +
row() * matrix_.spacing() +
column();
853 return matrix_.data() +
row() +
column() * matrix_.spacing();
869 , ptrdiff_t... CBAs >
870inline typename Band<MT,TF,
true,
false,CBAs...>::Iterator
871 Band<MT,TF,true,false,CBAs...>::begin()
873 return Iterator( matrix_,
row(),
column() );
889 , ptrdiff_t... CBAs >
890inline typename Band<MT,TF,
true,
false,CBAs...>::ConstIterator
891 Band<MT,TF,true,false,CBAs...>::begin()
const
893 return ConstIterator( matrix_,
row(),
column() );
909 , ptrdiff_t... CBAs >
910inline typename Band<MT,TF,
true,
false,CBAs...>::ConstIterator
911 Band<MT,TF,true,false,CBAs...>::cbegin()
const
913 return ConstIterator( matrix_,
row(),
column() );
929 , ptrdiff_t... CBAs >
930inline typename Band<MT,TF,
true,
false,CBAs...>::Iterator
931 Band<MT,TF,true,false,CBAs...>::end()
933 const size_t n(
size() );
934 return Iterator( matrix_,
row()+n,
column()+n );
950 , ptrdiff_t... CBAs >
951inline typename Band<MT,TF,
true,
false,CBAs...>::ConstIterator
952 Band<MT,TF,true,false,CBAs...>::end()
const
954 const size_t n(
size() );
955 return ConstIterator( matrix_,
row()+n,
column()+n );
971 , ptrdiff_t... CBAs >
972inline typename Band<MT,TF,
true,
false,CBAs...>::ConstIterator
973 Band<MT,TF,true,false,CBAs...>::cend()
const
975 const size_t n(
size() );
976 return ConstIterator( matrix_,
row()+n,
column()+n );
1001template<
typename MT
1003 , ptrdiff_t... CBAs >
1004inline Band<MT,TF,
true,
false,CBAs...>&
1005 Band<MT,TF,true,false,CBAs...>::operator=(
const ElementType& rhs )
1007 decltype(
auto) left( derestrict( matrix_ ) );
1015 const size_t n(
size() );
1016 for(
size_t i=0UL; i<n; ++i ) {
1042template<
typename MT
1044 , ptrdiff_t... CBAs >
1045inline Band<MT,TF,
true,
false,CBAs...>&
1046 Band<MT,TF,true,false,CBAs...>::operator=( initializer_list<ElementType> list )
1048 if( list.size() >
size() ) {
1059 decltype(
auto) left( derestrict( *
this ) );
1061 std::fill( std::copy( list.begin(), list.end(), left.begin() ), left.end(), ElementType() );
1085template<
typename MT
1087 , ptrdiff_t... CBAs >
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 ) );
1104 const ResultType tmp( rhs );
1133template<
typename MT
1135 , ptrdiff_t... CBAs >
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() ) {
1148 Right right( *rhs );
1150 if( !tryAssign( matrix_, right,
band(),
row(),
column() ) ) {
1154 decltype(
auto) left( derestrict( *
this ) );
1188template<
typename MT
1190 , ptrdiff_t... CBAs >
1191template<
typename VT >
1192inline Band<MT,TF,
true,
false,CBAs...>&
1193 Band<MT,TF,true,false,CBAs...>::operator+=(
const Vector<VT,TF>& rhs )
1198 if(
size() != (*rhs).size() ) {
1203 Right right( *rhs );
1205 if( !tryAddAssign( matrix_, right,
band(),
row(),
column() ) ) {
1209 decltype(
auto) left( derestrict( *
this ) );
1241template<
typename MT
1243 , ptrdiff_t... CBAs >
1244template<
typename VT >
1245inline Band<MT,TF,
true,
false,CBAs...>&
1246 Band<MT,TF,true,false,CBAs...>::operator-=(
const Vector<VT,TF>& rhs )
1251 if(
size() != (*rhs).size() ) {
1256 Right right( *rhs );
1258 if( !trySubAssign( matrix_, right,
band(),
row(),
column() ) ) {
1262 decltype(
auto) left( derestrict( *
this ) );
1293template<
typename MT
1295 , ptrdiff_t... CBAs >
1296template<
typename VT >
1297inline Band<MT,TF,
true,
false,CBAs...>&
1298 Band<MT,TF,true,false,CBAs...>::operator*=(
const Vector<VT,TF>& rhs )
1306 if(
size() != (*rhs).size() ) {
1311 Right right( *rhs );
1313 if( !tryMultAssign( matrix_, right,
band(),
row(),
column() ) ) {
1317 decltype(
auto) left( derestrict( *
this ) );
1347template<
typename MT
1349 , ptrdiff_t... CBAs >
1350template<
typename VT >
1351inline Band<MT,TF,
true,
false,CBAs...>&
1357 if(
size() != (*rhs).size() ) {
1362 Right right( *rhs );
1364 if( !tryDivAssign( matrix_, right,
band(),
row(),
column() ) ) {
1368 decltype(
auto) left( derestrict( *
this ) );
1399template<
typename MT
1401 , ptrdiff_t... CBAs >
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;
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
1455 , ptrdiff_t... CBAs >
1456inline MT& Band<MT,TF,true,false,CBAs...>::operand() noexcept
1470template<
typename MT
1472 , ptrdiff_t... CBAs >
1473inline const MT& Band<MT,TF,true,false,CBAs...>::operand() const noexcept
1487template<
typename MT
1489 , ptrdiff_t... CBAs >
1490inline size_t Band<MT,TF,true,false,CBAs...>::size() const noexcept
1492 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
1507template<
typename MT
1509 , ptrdiff_t... CBAs >
1510inline size_t Band<MT,TF,true,false,CBAs...>::spacing() const noexcept
1524template<
typename MT
1526 , ptrdiff_t... CBAs >
1527inline size_t Band<MT,TF,true,false,CBAs...>::capacity() const noexcept
1544template<
typename MT
1546 , ptrdiff_t... CBAs >
1547inline size_t Band<MT,TF,true,false,CBAs...>::nonZeros()
const
1549 const size_t n(
size() );
1550 size_t nonzeros( 0UL );
1552 for(
size_t i=0UL; i<n; ++i )
1568template<
typename MT
1570 , ptrdiff_t... CBAs >
1571inline void Band<MT,TF,true,false,CBAs...>::reset()
1581 const size_t n(
size() );
1582 for(
size_t i=0UL; i<n; ++i )
1610template<
typename MT
1612 , ptrdiff_t... CBAs >
1613template<
typename Other >
1614inline Band<MT,TF,
true,
false,CBAs...>&
1615 Band<MT,TF,true,false,CBAs...>::scale(
const Other& scalar )
1625 const size_t n(
size() );
1626 for(
size_t i=0UL; i<n; ++i ) {
1655template<
typename MT
1657 , ptrdiff_t... CBAs >
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
1680 , ptrdiff_t... CBAs >
1681template<
typename MT2
1682 , ptrdiff_t... CBAs2 >
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
1705 , ptrdiff_t... CBAs >
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
1728 , ptrdiff_t... CBAs >
1729template<
typename MT2
1730 , ptrdiff_t... CBAs2 >
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
1752 , ptrdiff_t... CBAs >
1753inline bool Band<MT,TF,true,false,CBAs...>::isAligned() const noexcept
1772template<
typename MT
1774 , ptrdiff_t... CBAs >
1775inline bool Band<MT,TF,true,false,CBAs...>::canSMPAssign() const noexcept
1777 return (
size() > SMP_DVECASSIGN_THRESHOLD );
1795template<
typename MT
1797 , ptrdiff_t... CBAs >
1798template<
typename VT >
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
1832 , ptrdiff_t... CBAs >
1833template<
typename VT >
1839 const size_t index( element->index() );
1840 matrix_(
row()+index,
column()+index) = element->value();
1859template<
typename MT
1861 , ptrdiff_t... CBAs >
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
1896 , ptrdiff_t... CBAs >
1897template<
typename VT >
1903 const size_t index( element->index() );
1904 matrix_(
row()+index,
column()+index) += element->value();
1923template<
typename MT
1925 , ptrdiff_t... CBAs >
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
1960 , ptrdiff_t... CBAs >
1961template<
typename VT >
1967 const size_t index( element->index() );
1968 matrix_(
row()+index,
column()+index) -= element->value();
1987template<
typename MT
1989 , ptrdiff_t... CBAs >
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
2024 , ptrdiff_t... CBAs >
2025template<
typename VT >
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
2064 , ptrdiff_t... CBAs >
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
2103 , ptrdiff_t... CBAs >
2104class Band<MT,TF,true,true,CBAs...>
2105 :
public View< DenseVector< Band<MT,TF,true,true,CBAs...>, TF > >
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() ) ) {
2181 BLAZE_THROW_INVALID_ARGUMENT(
"Invalid band access index" );
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() );
2229 using DataType::band;
2230 using DataType::row;
2231 using DataType::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 >
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 >
2336 const ResultType tmp(
serial( rhs ) );
2337 assign( *lhs, tmp );
2352 template<
typename VT >
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 >
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 >
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 >
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() ) ) {
2574 BLAZE_THROW_INVALID_ARGUMENT(
"Invalid band access index" );
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() );
2622 using DataType::band;
2623 using DataType::row;
2624 using DataType::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.
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.
Definition Aliases.h:130
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition Aliases.h:110
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition Aliases.h:450
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.
Auxiliary class template for the data members of the Band class.
Definition BandData.h:65
Base class for N-dimensional dense vectors.
Definition DenseVector.h:77
Dense vector representation of an initializer list.
Definition InitializerVector.h:182
Base class for sparse vectors.
Definition SparseVector.h:72
Base class for N-dimensional vectors.
Definition Vector.h:82
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
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
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition DMatSerialExpr.h:812
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition DMatDMatMultExpr.h:9640
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition DenseMatrix.h:448
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition DiagonalMatrix.h:207
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 CrossTrait< T1, T2 >::Type CrossTrait_t
Auxiliary alias declaration for the CrossTrait class template.
Definition CrossTrait.h:138
typename BandTrait< MT, CBAs... >::Type BandTrait_t
Auxiliary alias declaration for the BandTrait type trait.
Definition BandTrait.h:145
constexpr bool IsStrictlyUpper_v
Auxiliary variable template for the IsStrictlyUpper type trait.
Definition IsStrictlyUpper.h:173
constexpr bool IsExpression_v
Auxiliary variable template for the IsExpression type trait.
Definition IsExpression.h:114
constexpr bool IsTriangular_v
Auxiliary variable template for the IsTriangular type trait.
Definition IsTriangular.h:106
constexpr bool IsUniUpper_v
Auxiliary variable template for the IsUniUpper type trait.
Definition IsUniUpper.h:173
constexpr bool IsStrictlyLower_v
Auxiliary variable template for the IsStrictlyLower type trait.
Definition IsStrictlyLower.h:173
constexpr bool IsRowMajorMatrix_v
Auxiliary variable template for the IsRowMajorMatrix type trait.
Definition IsRowMajorMatrix.h:129
constexpr bool IsUpper_v
Auxiliary variable template for the IsUpper type trait.
Definition IsUpper.h:175
constexpr bool IsSparseVector_v
Auxiliary variable template for the IsSparseVector type trait.
Definition IsSparseVector.h:124
constexpr bool IsRestricted_v
Auxiliary variable template for the IsRestricted type trait.
Definition IsRestricted.h:140
constexpr bool IsLower_v
Auxiliary variable template for the IsLower type trait.
Definition IsLower.h:175
constexpr bool IsUniLower_v
Auxiliary variable template for the IsUniLower type trait.
Definition IsUniLower.h:173
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
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition Matrix.h:644
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
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
constexpr bool IsReference_v
Auxiliary variable template for the IsReference type trait.
Definition IsReference.h:95
#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
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition If.h:108
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.
Base class for all compute expression templates.
Definition Computation.h:68
Base class for all views.
Definition View.h:67
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.