35 #ifndef _BLAZE_MATH_VIEWS_BAND_DENSE_H_ 36 #define _BLAZE_MATH_VIEWS_BAND_DENSE_H_ 111 template<
typename MT
113 , ptrdiff_t... CBAs >
114 class Band<MT,TF,true,false,CBAs...>
115 :
public View< DenseVector< Band<MT,TF,true,false,CBAs...>, TF > >
116 ,
private BandData<CBAs...>
120 using RT = ResultType_t<MT>;
121 using DataType = BandData<CBAs...>;
122 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
128 using This = Band<MT,TF,
true,
false,CBAs...>;
130 using BaseType = DenseVector<This,TF>;
131 using ViewedType = MT;
133 using TransposeType = TransposeType_t<ResultType>;
134 using ElementType = ElementType_t<MT>;
135 using ReturnType = ReturnType_t<MT>;
138 using CompositeType = If_t< RequiresEvaluation_v<MT>,
const ResultType,
const Band& >;
141 using ConstReference = ConstReference_t<MT>;
144 using Reference = If_t< IsConst_v<MT>, ConstReference, Reference_t<MT> >;
147 using ConstPointer = ConstPointer_t<MT>;
150 using Pointer = If_t< IsConst_v<MT> || !HasMutableDataAccess_v<MT>, ConstPointer, Pointer_t<MT> >;
156 template<
typename MatrixType
157 ,
typename IteratorType >
163 using IteratorCategory =
typename std::iterator_traits<IteratorType>::iterator_category;
166 using ValueType =
typename std::iterator_traits<IteratorType>::value_type;
169 using PointerType =
typename std::iterator_traits<IteratorType>::pointer;
172 using ReferenceType =
typename std::iterator_traits<IteratorType>::reference;
175 using DifferenceType =
typename std::iterator_traits<IteratorType>::difference_type;
178 using iterator_category = IteratorCategory;
179 using value_type = ValueType;
180 using pointer = PointerType;
181 using reference = ReferenceType;
182 using difference_type = DifferenceType;
188 inline BandIterator() noexcept
203 inline BandIterator( MatrixType& matrix,
size_t rowIndex,
size_t columnIndex ) noexcept
206 , column_( columnIndex )
209 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
210 pos_ = matrix_->begin( row_ ) + column_;
211 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
212 pos_ = matrix_->begin( column_ ) + row_;
221 template<
typename MatrixType2,
typename IteratorType2 >
222 inline BandIterator(
const BandIterator<MatrixType2,IteratorType2>& it ) noexcept
223 : matrix_( it.matrix_ )
225 , column_( it.column_ )
236 inline BandIterator&
operator+=(
size_t inc ) noexcept {
242 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
243 pos_ = matrix_->begin( row_ ) + column_;
244 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
245 pos_ = matrix_->begin( column_ ) + row_;
258 inline BandIterator&
operator-=(
size_t dec ) noexcept {
264 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
265 pos_ = matrix_->begin( row_ ) + column_;
266 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
267 pos_ = matrix_->begin( column_ ) + row_;
279 inline BandIterator& operator++() noexcept {
285 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
286 pos_ = matrix_->begin( row_ ) + column_;
287 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
288 pos_ = matrix_->begin( column_ ) + row_;
300 inline const BandIterator operator++(
int ) noexcept {
301 const BandIterator tmp( *
this );
312 inline BandIterator& operator--() noexcept {
318 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
319 pos_ = matrix_->begin( row_ ) + column_;
320 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
321 pos_ = matrix_->begin( column_ ) + row_;
333 inline const BandIterator operator--(
int ) noexcept {
334 const BandIterator tmp( *
this );
346 inline ReferenceType operator[](
size_t index )
const {
349 const IteratorType pos( IsRowMajorMatrix_v<MatrixType>
350 ? matrix_->begin( row_+index ) + column_ + index
351 : matrix_->begin( column_+index ) + row_ + index );
371 inline PointerType operator->()
const {
382 template<
typename MatrixType2,
typename IteratorType2 >
383 inline bool operator==(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
384 return row_ == rhs.row_;
394 template<
typename MatrixType2,
typename IteratorType2 >
395 inline bool operator!=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
396 return !( *
this == rhs );
406 template<
typename MatrixType2,
typename IteratorType2 >
407 inline bool operator<(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
408 return row_ < rhs.row_;
418 template<
typename MatrixType2,
typename IteratorType2 >
419 inline bool operator>(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
420 return row_ > rhs.row_;
430 template<
typename MatrixType2,
typename IteratorType2 >
431 inline bool operator<=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
432 return row_ <= rhs.row_;
442 template<
typename MatrixType2,
typename IteratorType2 >
443 inline bool operator>=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
444 return row_ >= rhs.row_;
454 inline DifferenceType
operator-(
const BandIterator& rhs )
const noexcept {
455 return row_ - rhs.row_;
466 friend inline const BandIterator
operator+(
const BandIterator& it,
size_t inc ) noexcept {
467 return BandIterator( *it.matrix_, it.row_+inc, it.column_+inc );
478 friend inline const BandIterator
operator+(
size_t inc,
const BandIterator& it ) noexcept {
479 return BandIterator( *it.matrix_, it.row_+inc, it.column_+inc );
490 friend inline const BandIterator
operator-(
const BandIterator& it,
size_t dec ) noexcept {
491 return BandIterator( *it.matrix_, it.row_-dec, it.column_-dec );
504 template<
typename MatrixType2,
typename IteratorType2 >
friend class BandIterator;
511 using ConstIterator = BandIterator< const MT, ConstIterator_t<MT> >;
514 using Iterator = If_t< IsConst_v<MT>, ConstIterator, BandIterator< MT, Iterator_t<MT> > >;
519 static constexpr
bool simdEnabled =
false;
522 static constexpr
bool smpAssignable = MT::smpAssignable;
525 static constexpr
bool compileTimeArgs = DataType::compileTimeArgs;
531 template<
typename... RBAs >
532 explicit inline Band( MT& matrix, RBAs... args );
534 Band(
const Band& ) =
default;
548 inline Reference operator[](
size_t index );
549 inline ConstReference operator[](
size_t index )
const;
550 inline Reference at(
size_t index );
551 inline ConstReference at(
size_t index )
const;
552 inline Pointer
data () noexcept;
553 inline ConstPointer
data () const noexcept;
554 inline Iterator
begin ();
555 inline ConstIterator
begin () const;
556 inline ConstIterator
cbegin() const;
557 inline Iterator
end ();
558 inline ConstIterator
end () const;
559 inline ConstIterator
cend () const;
566 inline Band& operator=( const ElementType& rhs );
567 inline Band& operator=( initializer_list<ElementType> list );
568 inline Band& operator=( const Band& rhs );
570 template< typename VT > inline Band& operator= ( const Vector<VT,TF>& rhs );
571 template< typename VT > inline Band& operator+=( const Vector<VT,TF>& rhs );
572 template< typename VT > inline Band& operator-=( const Vector<VT,TF>& rhs );
573 template< typename VT > inline Band& operator*=( const Vector<VT,TF>& rhs );
574 template< typename VT > inline Band& operator/=( const DenseVector<VT,TF>& rhs );
575 template< typename VT > inline Band& operator%=( const Vector<VT,TF>& rhs );
582 using DataType::
band;
586 inline MT& operand() noexcept;
587 inline const MT& operand() const noexcept;
589 inline
size_t size() const noexcept;
590 inline
size_t spacing() const noexcept;
591 inline
size_t capacity() const noexcept;
600 template< typename Other > inline Band& scale( const Other& scalar );
607 template< typename Other >
608 inline
bool canAlias( const Other* alias ) const noexcept;
610 template< typename MT2, ptrdiff_t... CBAs2 >
611 inline
bool canAlias( const Band<MT2,TF,true,false,CBAs2...>* alias ) const noexcept;
613 template< typename Other >
614 inline
bool isAliased( const Other* alias ) const noexcept;
616 template< typename MT2, ptrdiff_t... CBAs2 >
617 inline
bool isAliased( const Band<MT2,TF,true,false,CBAs2...>* alias ) const noexcept;
619 inline
bool isAligned () const noexcept;
620 inline
bool canSMPAssign() const noexcept;
622 template< typename VT > inline
void assign ( const DenseVector <VT,TF>& rhs );
623 template< typename VT > inline
void assign ( const SparseVector<VT,TF>& rhs );
624 template< typename VT > inline
void addAssign ( const DenseVector <VT,TF>& rhs );
625 template< typename VT > inline
void addAssign ( const SparseVector<VT,TF>& rhs );
626 template< typename VT > inline
void subAssign ( const DenseVector <VT,TF>& rhs );
627 template< typename VT > inline
void subAssign ( const SparseVector<VT,TF>& rhs );
628 template< typename VT > inline
void multAssign( const DenseVector <VT,TF>& rhs );
629 template< typename VT > inline
void multAssign( const SparseVector<VT,TF>& rhs );
630 template< typename VT > inline
void divAssign ( const DenseVector <VT,TF>& rhs );
643 template< typename MT2,
bool TF2,
bool DF2,
bool MF2, ptrdiff_t... CBAs2 > friend class Band;
679 template< typename MT
681 , ptrdiff_t... CBAs >
682 template< typename... RBAs >
683 inline Band<MT,TF,true,false,CBAs...>::Band( MT& matrix, RBAs... args )
684 : DataType( args... )
688 if( (
band() > 0L &&
column() >= matrix.columns() ) ||
689 (
band() < 0L &&
row() >= matrix.rows() ) ) {
720 template<
typename MT
722 , ptrdiff_t... CBAs >
723 inline typename Band<MT,TF,
true,
false,CBAs...>::Reference
724 Band<MT,TF,true,false,CBAs...>::operator[](
size_t index )
727 return matrix_(
row()+index,
column()+index);
743 template<
typename MT
745 , ptrdiff_t... CBAs >
746 inline typename Band<MT,TF,
true,
false,CBAs...>::ConstReference
747 Band<MT,TF,true,false,CBAs...>::operator[](
size_t index )
const 750 return const_cast<const MT&>( matrix_ )(
row()+index,
column()+index);
767 template<
typename MT
769 , ptrdiff_t... CBAs >
770 inline typename Band<MT,TF,
true,
false,CBAs...>::Reference
771 Band<MT,TF,true,false,CBAs...>::at(
size_t index )
773 if( index >=
size() ) {
776 return (*
this)[index];
793 template<
typename MT
795 , ptrdiff_t... CBAs >
796 inline typename Band<MT,TF,
true,
false,CBAs...>::ConstReference
797 Band<MT,TF,true,false,CBAs...>::at(
size_t index )
const 799 if( index >=
size() ) {
802 return (*
this)[index];
817 template<
typename MT
819 , ptrdiff_t... CBAs >
820 inline typename Band<MT,TF,
true,
false,CBAs...>::Pointer
823 if( IsRowMajorMatrix_v<MT> )
824 return matrix_.data() +
row() * matrix_.spacing() +
column();
826 return matrix_.data() +
row() +
column() * matrix_.spacing();
841 template<
typename MT
843 , ptrdiff_t... CBAs >
844 inline typename Band<MT,TF,
true,
false,CBAs...>::ConstPointer
847 if( IsRowMajorMatrix_v<MT> )
848 return matrix_.data() +
row() * matrix_.spacing() +
column();
850 return matrix_.data() +
row() +
column() * matrix_.spacing();
864 template<
typename MT
866 , ptrdiff_t... CBAs >
867 inline typename Band<MT,TF,
true,
false,CBAs...>::Iterator
870 return Iterator( matrix_,
row(),
column() );
884 template<
typename MT
886 , ptrdiff_t... CBAs >
887 inline typename Band<MT,TF,
true,
false,CBAs...>::ConstIterator
890 return ConstIterator( matrix_,
row(),
column() );
904 template<
typename MT
906 , ptrdiff_t... CBAs >
907 inline typename Band<MT,TF,
true,
false,CBAs...>::ConstIterator
910 return ConstIterator( matrix_,
row(),
column() );
924 template<
typename MT
926 , ptrdiff_t... CBAs >
927 inline typename Band<MT,TF,
true,
false,CBAs...>::Iterator
930 const size_t n(
size() );
931 return Iterator( matrix_,
row()+n,
column()+n );
945 template<
typename MT
947 , ptrdiff_t... CBAs >
948 inline typename Band<MT,TF,
true,
false,CBAs...>::ConstIterator
951 const size_t n(
size() );
952 return ConstIterator( matrix_,
row()+n,
column()+n );
966 template<
typename MT
968 , ptrdiff_t... CBAs >
969 inline typename Band<MT,TF,
true,
false,CBAs...>::ConstIterator
972 const size_t n(
size() );
973 return ConstIterator( matrix_,
row()+n,
column()+n );
998 template<
typename MT
1000 , ptrdiff_t... CBAs >
1001 inline Band<MT,TF,
true,
false,CBAs...>&
1002 Band<MT,TF,true,false,CBAs...>::operator=(
const ElementType& rhs )
1004 decltype(
auto) left( derestrict( matrix_ ) );
1012 const
size_t n(
size() );
1013 for(
size_t i=0UL; i<n; ++i ) {
1014 if( !IsRestricted_v<MT> || IsTriangular_v<MT> || trySet( matrix_,
row()+i,
column()+i, rhs ) )
1039 template<
typename MT
1041 , ptrdiff_t... CBAs >
1042 inline Band<MT,TF,
true,
false,CBAs...>&
1043 Band<MT,TF,true,false,CBAs...>::operator=( initializer_list<ElementType> list )
1045 if( list.size() >
size() ) {
1049 if( IsRestricted_v<MT> ) {
1050 const InitializerVector<ElementType,false> tmp( list,
size() );
1056 decltype(
auto) left( derestrict( *this ) );
1058 std::fill( std::copy( list.
begin(), list.
end(), left.
begin() ), left.
end(), ElementType() );
1082 template< typename MT
1084 , ptrdiff_t... CBAs >
1085 inline Band<MT,TF,true,false,CBAs...>&
1086 Band<MT,TF,true,false,CBAs...>::operator=( const Band& rhs )
1088 if( &rhs ==
this )
return *
this;
1090 if(
size() != rhs.size() ) {
1098 decltype(
auto) left( derestrict( *this ) );
1101 const ResultType tmp( rhs );
1130 template<
typename MT
1132 , ptrdiff_t... CBAs >
1133 template<
typename VT >
1134 inline Band<MT,TF,
true,
false,CBAs...>&
1135 Band<MT,TF,true,false,CBAs...>::operator=(
const Vector<VT,TF>& rhs )
1144 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1145 Right right( ~rhs );
1147 if( !tryAssign( matrix_, right,
band(),
row(),
column() ) ) {
1151 decltype(
auto) left( derestrict( *this ) );
1154 const ResultType_t<VT> tmp( right );
1158 if( IsSparseVector_v<VT> )
1185 template<
typename MT
1187 , ptrdiff_t... CBAs >
1188 template<
typename VT >
1189 inline Band<MT,TF,
true,
false,CBAs...>&
1199 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1200 Right right( ~rhs );
1202 if( !tryAddAssign( matrix_, right,
band(),
row(),
column() ) ) {
1206 decltype(
auto) left( derestrict( *this ) );
1209 const ResultType_t<VT> tmp( right );
1238 template<
typename MT
1240 , ptrdiff_t... CBAs >
1241 template<
typename VT >
1242 inline Band<MT,TF,
true,
false,CBAs...>&
1252 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1253 Right right( ~rhs );
1255 if( !trySubAssign( matrix_, right,
band(),
row(),
column() ) ) {
1259 decltype(
auto) left( derestrict( *this ) );
1262 const ResultType_t<VT> tmp( right );
1290 template<
typename MT
1292 , ptrdiff_t... CBAs >
1293 template<
typename VT >
1294 inline Band<MT,TF,
true,
false,CBAs...>&
1307 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1308 Right right( ~rhs );
1310 if( !tryMultAssign( matrix_, right,
band(),
row(),
column() ) ) {
1314 decltype(
auto) left( derestrict( *this ) );
1317 const ResultType_t<VT> tmp( right );
1344 template<
typename MT
1346 , ptrdiff_t... CBAs >
1347 template<
typename VT >
1348 inline Band<MT,TF,
true,
false,CBAs...>&
1358 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1359 Right right( ~rhs );
1361 if( !tryDivAssign( matrix_, right,
band(),
row(),
column() ) ) {
1365 decltype(
auto) left( derestrict( *this ) );
1368 const ResultType_t<VT> tmp( right );
1396 template<
typename MT
1398 , ptrdiff_t... CBAs >
1399 template<
typename VT >
1400 inline Band<MT,TF,
true,
false,CBAs...>&
1401 Band<MT,TF,true,false,CBAs...>::operator%=(
const Vector<VT,TF>& rhs )
1403 using blaze::assign;
1408 using CrossType = CrossTrait_t< ResultType, ResultType_t<VT> >;
1414 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
1418 const CrossType right( *
this % (~rhs) );
1420 if( !tryAssign( matrix_, right,
band(),
row(),
column() ) ) {
1424 decltype(
auto) left( derestrict( *this ) );
1426 assign( left, right );
1450 template< typename MT
1452 , ptrdiff_t... CBAs >
1453 inline MT& Band<MT,TF,true,false,CBAs...>::operand() noexcept
1467 template<
typename MT
1469 , ptrdiff_t... CBAs >
1470 inline const MT& Band<MT,TF,true,false,CBAs...>::operand() const noexcept
1484 template<
typename MT
1486 , ptrdiff_t... CBAs >
1489 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
1504 template<
typename MT
1506 , ptrdiff_t... CBAs >
1521 template<
typename MT
1523 , ptrdiff_t... CBAs >
1541 template<
typename MT
1543 , ptrdiff_t... CBAs >
1546 const size_t n(
size() );
1547 size_t nonzeros( 0UL );
1549 for(
size_t i=0UL; i<n; ++i )
1565 template<
typename MT
1567 , ptrdiff_t... CBAs >
1572 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1573 ( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> ) &&
row() == 0UL ) ||
1574 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1575 ( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> ) &&
column() == 0UL ) )
1578 const size_t n(
size() );
1579 for(
size_t i=0UL; i<n; ++i )
1607 template<
typename MT
1609 , ptrdiff_t... CBAs >
1610 template<
typename Other >
1611 inline Band<MT,TF,
true,
false,CBAs...>&
1612 Band<MT,TF,true,false,CBAs...>::scale(
const Other& scalar )
1616 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1617 ( IsStrictlyLower_v<MT> &&
row() == 0UL ) ||
1618 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1619 ( IsStrictlyUpper_v<MT> &&
column() == 0UL ) )
1622 const size_t n(
size() );
1623 for(
size_t i=0UL; i<n; ++i ) {
1652 template<
typename MT
1654 , ptrdiff_t... CBAs >
1655 template<
typename Other >
1656 inline bool Band<MT,TF,true,false,CBAs...>::canAlias(
const Other* alias )
const noexcept
1658 return matrix_.isAliased( alias );
1675 template<
typename MT
1677 , ptrdiff_t... CBAs >
1678 template<
typename MT2
1679 , ptrdiff_t... CBAs2 >
1681 Band<MT,TF,true,false,CBAs...>::canAlias(
const Band<MT2,TF,true,false,CBAs2...>* alias )
const noexcept
1683 return matrix_.isAliased( &alias->matrix_ ) && (
band() == alias->band() );
1700 template<
typename MT
1702 , ptrdiff_t... CBAs >
1703 template<
typename Other >
1704 inline bool Band<MT,TF,true,false,CBAs...>::isAliased(
const Other* alias )
const noexcept
1706 return matrix_.isAliased( alias );
1723 template<
typename MT
1725 , ptrdiff_t... CBAs >
1726 template<
typename MT2
1727 , ptrdiff_t... CBAs2 >
1729 Band<MT,TF,true,false,CBAs...>::isAliased(
const Band<MT2,TF,true,false,CBAs2...>* alias )
const noexcept
1731 return matrix_.isAliased( &alias->matrix_ ) && (
band() == alias->band() );
1747 template<
typename MT
1749 , ptrdiff_t... CBAs >
1750 inline bool Band<MT,TF,true,false,CBAs...>::isAligned() const noexcept
1769 template<
typename MT
1771 , ptrdiff_t... CBAs >
1772 inline bool Band<MT,TF,true,false,CBAs...>::canSMPAssign() const noexcept
1774 return (
size() > SMP_DVECASSIGN_THRESHOLD );
1792 template<
typename MT
1794 , ptrdiff_t... CBAs >
1795 template<
typename VT >
1796 inline void Band<MT,TF,true,false,CBAs...>::assign(
const DenseVector<VT,TF>& rhs )
1800 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1801 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1802 matrix_(
row()+i ,
column()+i ) = (~rhs)[i ];
1803 matrix_(
row()+i+1UL,
column()+i+1UL) = (~rhs)[i+1UL];
1805 if( ipos < (~rhs).size() ) {
1806 matrix_(
row()+ipos,
column()+ipos) = (~rhs)[ipos];
1825 template<
typename MT
1827 , ptrdiff_t... CBAs >
1828 template<
typename VT >
1829 inline void Band<MT,TF,true,false,CBAs...>::assign(
const SparseVector<VT,TF>& rhs )
1833 for( ConstIterator_t<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1834 const size_t index( element->index() );
1835 matrix_(
row()+index,
column()+index) = element->value();
1854 template<
typename MT
1856 , ptrdiff_t... CBAs >
1857 template<
typename VT >
1858 inline void Band<MT,TF,true,false,CBAs...>::addAssign(
const DenseVector<VT,TF>& rhs )
1862 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1863 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1864 matrix_(
row()+i ,
column()+i ) += (~rhs)[i ];
1865 matrix_(
row()+i+1UL,
column()+i+1UL) += (~rhs)[i+1UL];
1867 if( ipos < (~rhs).size() ) {
1868 matrix_(
row()+ipos,
column()+ipos) += (~rhs)[ipos];
1887 template<
typename MT
1889 , ptrdiff_t... CBAs >
1890 template<
typename VT >
1891 inline void Band<MT,TF,true,false,CBAs...>::addAssign(
const SparseVector<VT,TF>& rhs )
1895 for( ConstIterator_t<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1896 const size_t index( element->index() );
1897 matrix_(
row()+index,
column()+index) += element->value();
1916 template<
typename MT
1918 , ptrdiff_t... CBAs >
1919 template<
typename VT >
1920 inline void Band<MT,TF,true,false,CBAs...>::subAssign(
const DenseVector<VT,TF>& rhs )
1924 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1925 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1926 matrix_(
row()+i ,
column()+i ) -= (~rhs)[i ];
1927 matrix_(
row()+i+1UL,
column()+i+1UL) -= (~rhs)[i+1UL];
1929 if( ipos < (~rhs).size() ) {
1930 matrix_(
row()+ipos,
column()+ipos) -= (~rhs)[ipos];
1949 template<
typename MT
1951 , ptrdiff_t... CBAs >
1952 template<
typename VT >
1953 inline void Band<MT,TF,true,false,CBAs...>::subAssign(
const SparseVector<VT,TF>& rhs )
1957 for( ConstIterator_t<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1958 const size_t index( element->index() );
1959 matrix_(
row()+index,
column()+index) -= element->value();
1978 template<
typename MT
1980 , ptrdiff_t... CBAs >
1981 template<
typename VT >
1982 inline void Band<MT,TF,true,false,CBAs...>::multAssign(
const DenseVector<VT,TF>& rhs )
1986 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1987 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1988 matrix_(
row()+i ,
column()+i ) *= (~rhs)[i ];
1989 matrix_(
row()+i+1UL,
column()+i+1UL) *= (~rhs)[i+1UL];
1991 if( ipos < (~rhs).size() ) {
1992 matrix_(
row()+ipos,
column()+ipos) *= (~rhs)[ipos];
2011 template<
typename MT
2013 , ptrdiff_t... CBAs >
2014 template<
typename VT >
2015 inline void Band<MT,TF,true,false,CBAs...>::multAssign(
const SparseVector<VT,TF>& rhs )
2023 for( ConstIterator_t<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
2024 const size_t index( element->index() );
2025 for( ; i<index; ++i )
2027 matrix_(
row()+index,
column()+index) *= element->value();
2031 for( ; i<
size(); ++i ) {
2051 template<
typename MT
2053 , ptrdiff_t... CBAs >
2054 template<
typename VT >
2055 inline void Band<MT,TF,true,false,CBAs...>::divAssign(
const DenseVector<VT,TF>& rhs )
2059 const size_t ipos( (~rhs).
size() &
size_t(-2) );
2060 for(
size_t i=0UL; i<ipos; i+=2UL ) {
2061 matrix_(
row()+i ,
column()+i ) /= (~rhs)[i ];
2062 matrix_(
row()+i+1UL,
column()+i+1UL) /= (~rhs)[i+1UL];
2064 if( ipos < (~rhs).size() ) {
2065 matrix_(
row()+ipos,
column()+ipos) /= (~rhs)[ipos];
2088 template<
typename MT
2090 , ptrdiff_t... CBAs >
2091 class Band<MT,TF,true,true,CBAs...>
2092 :
public View< DenseVector< Band<MT,TF,true,true,CBAs...>, TF > >
2093 ,
private BandData<CBAs...>
2094 ,
private Computation
2099 using DataType = BandData<CBAs...>;
2102 using LeftOperand = RemoveReference_t< LeftOperand_t<MT> >;
2105 using RightOperand = RemoveReference_t< RightOperand_t<MT> >;
2111 using This = Band<MT,TF,
true,
true,CBAs...>;
2114 using BaseType = DenseVector<This,TF>;
2117 using ViewedType = MT;
2120 using ResultType = BandTrait_t<ResultType_t<MT>,CBAs...>;
2122 using TransposeType = TransposeType_t<ResultType>;
2123 using ElementType = ElementType_t<ResultType>;
2124 using ReturnType = ReturnType_t<MT>;
2127 using CompositeType = If_t< RequiresEvaluation_v<LeftOperand> ||
2128 RequiresEvaluation_v<RightOperand>
2129 ,
const ResultType,
const Band& >;
2132 using LT = If_t< IsSparseMatrix_v<LeftOperand> && IsColumnMajorMatrix_v<LeftOperand>
2133 , ResultType_t<LeftOperand>
2134 , CompositeType_t<LeftOperand> >;
2137 using RT = If_t< IsSparseMatrix_v<RightOperand> && IsRowMajorMatrix_v<RightOperand>
2138 , ResultType_t<RightOperand>
2139 , CompositeType_t<RightOperand> >;
2144 static constexpr
bool simdEnabled =
false;
2147 static constexpr
bool smpAssignable =
false;
2150 static constexpr
bool compileTimeArgs = DataType::compileTimeArgs;
2160 template<
typename... RBAs >
2161 explicit inline Band(
const MT& mmm, RBAs... args )
2162 : DataType( args... )
2166 if( (
band() > 0L &&
column() >= mmm.columns() ) ||
2167 (
band() < 0L &&
row() >= mmm.rows() ) ) {
2184 inline ReturnType operator[](
size_t index )
const {
2186 return matrix_(
row()+index,
column()+index);
2197 inline ReturnType at(
size_t index )
const {
2198 if( index >=
size() ) {
2201 return (*
this)[index];
2210 inline size_t size() const noexcept {
2211 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
2226 inline const MT& operand() const noexcept {
2237 template<
typename T >
2238 inline bool canAlias(
const T* alias )
const noexcept {
2239 return matrix_.isAliased( alias );
2249 template<
typename T >
2250 inline bool isAliased(
const T* alias )
const noexcept {
2251 return matrix_.isAliased( alias );
2260 inline constexpr
bool isAligned() const noexcept {
2282 template<
typename VT >
2283 friend inline void assign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2292 LT A(
serial( rhs.operand().leftOperand() ) );
2293 RT B(
serial( rhs.operand().rightOperand() ) );
2295 const size_t n( rhs.size() );
2296 for(
size_t i=0UL; i<n; ++i ) {
2315 template<
typename VT >
2316 friend inline void assign( SparseVector<VT,TF>& lhs,
const Band& rhs )
2326 const ResultType tmp(
serial( rhs ) );
2327 assign( ~lhs, tmp );
2344 template<
typename VT >
2345 friend inline void addAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2354 LT A(
serial( rhs.operand().leftOperand() ) );
2355 RT B(
serial( rhs.operand().rightOperand() ) );
2357 const size_t n( rhs.size() );
2358 for(
size_t i=0UL; i<n; ++i ) {
2381 template<
typename VT >
2382 friend inline void subAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2391 LT A(
serial( rhs.operand().leftOperand() ) );
2392 RT B(
serial( rhs.operand().rightOperand() ) );
2394 const size_t n( rhs.size() );
2395 for(
size_t i=0UL; i<n; ++i ) {
2419 template<
typename VT >
2420 friend inline void multAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2429 LT A(
serial( rhs.operand().leftOperand() ) );
2430 RT B(
serial( rhs.operand().rightOperand() ) );
2432 const size_t n( rhs.size() );
2433 for(
size_t i=0UL; i<n; ++i ) {
2456 template<
typename VT >
2457 friend inline void divAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2466 LT A(
serial( rhs.operand().leftOperand() ) );
2467 RT B(
serial( rhs.operand().rightOperand() ) );
2469 const size_t n( rhs.size() );
2470 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.
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:432
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
Header file for the IsUniUpper type 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.
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:170
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
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type,...
Definition: DenseMatrix.h:61
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
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
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:595
constexpr bool IsUniUpper_v
Auxiliary variable template for the IsUniUpper type trait.The IsUniUpper_v variable template provides...
Definition: IsUniUpper.h:173
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 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
constexpr bool IsReference_v
Auxiliary variable template for the IsReference type trait.The IsReference_v variable template provid...
Definition: IsReference.h:95
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.
Header file for the reset shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i....
Definition: TransExpr.h:81
Header file for the RequiresEvaluation type trait.
constexpr bool IsLower_v
Auxiliary variable template for the IsLower type trait.The IsLower_v variable template provides a con...
Definition: IsLower.h:175
Header file for the extended initializer_list functionality.
Header file for the IsUniLower type trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
constexpr bool IsStrictlyLower_v
Auxiliary variable template for the IsStrictlyLower type trait.The IsStrictlyLower_v variable templat...
Definition: IsStrictlyLower.h:173
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
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:220
Header file for the band trait.
Constraint on the data type.
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:253
Constraint on the data type.
Header file for the IsStrictlyUpper type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
constexpr bool IsStrictlyUpper_v
Auxiliary variable template for the IsStrictlyUpper type trait.The IsStrictlyUpper_v variable templat...
Definition: IsStrictlyUpper.h:173
Header file for the If class template.
Header file for the implementation of a vector representation of an initializer list.
constexpr bool IsExpression_v
Auxiliary variable template for the IsExpression type trait.The IsExpression_v variable template prov...
Definition: IsExpression.h:130
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:9091
#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
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:1162
#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
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 > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:446
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.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 Contains_v
Auxiliary variable template for the Contains type trait.The Contains_v variable template provides a c...
Definition: Contains.h:138
Header file for the IsLower type trait.
Constraint on the data type.
Constraint on the data type.
Header file for the IsTriangular type trait.
Constraint on the data type.
Header file for the exception macros of the math module.
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
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.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:137
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
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:558
Header file for the IsSparseVector type trait.
Header file for the IsConst type trait.
Header file for run time assertion macros.
Header file for the cross product trait.
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
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
constexpr bool IsUniLower_v
Auxiliary variable template for the IsUniLower type trait.The IsUniLower_v variable template provides...
Definition: IsUniLower.h:173
#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,...
Definition: Reference.h:79
Header file for the isDefault shim.
constexpr bool IsUpper_v
Auxiliary variable template for the IsUpper type trait.The IsUpper_v variable template provides a con...
Definition: IsUpper.h:175
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
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
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
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
Header file for the HasMutableDataAccess type trait.
#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
Header file for the IsReference type trait.
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
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:718
Header file for the RemoveReference type trait.
#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.
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
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
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:494
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
Header file for the IsUpper type trait.
Constraint on the data type.
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
Header file for the IsRestricted type trait.
#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
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101
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:191
Header file for the clear shim.
Header file for the IsExpression type trait class.
Header file for the implementation of the BandData class template.