35 #ifndef _BLAZE_MATH_VIEWS_BAND_DENSE_H_ 36 #define _BLAZE_MATH_VIEWS_BAND_DENSE_H_ 112 template<
typename MT
114 , ptrdiff_t... CBAs >
115 class 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_<MT>;
122 using DataType = BandData<CBAs...>;
123 using Operand = If_< IsExpression<MT>, MT, MT& >;
129 using This = Band<MT,TF,
true,
false,CBAs...>;
131 using BaseType = DenseVector<This,TF>;
132 using ViewedType = MT;
148 using ConstPointer = ConstPointer_<MT>;
151 using Pointer = If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, Pointer_<MT> >;
157 template<
typename MatrixType
158 ,
typename IteratorType >
164 using IteratorCategory =
typename std::iterator_traits<IteratorType>::iterator_category;
167 using ValueType =
typename std::iterator_traits<IteratorType>::value_type;
170 using PointerType =
typename std::iterator_traits<IteratorType>::pointer;
173 using ReferenceType =
typename std::iterator_traits<IteratorType>::reference;
176 using DifferenceType =
typename std::iterator_traits<IteratorType>::difference_type;
179 using iterator_category = IteratorCategory;
180 using value_type = ValueType;
181 using pointer = PointerType;
182 using reference = ReferenceType;
183 using difference_type = DifferenceType;
189 inline BandIterator() noexcept
204 inline BandIterator( MatrixType& matrix,
size_t rowIndex,
size_t columnIndex ) noexcept
207 , column_( columnIndex )
210 if( IsRowMajorMatrix<MatrixType>::value && row_ != matrix_->rows() )
211 pos_ = matrix_->begin( row_ ) + column_;
212 else if( IsColumnMajorMatrix<MatrixType>::value && column_ != matrix_->columns() )
213 pos_ = matrix_->begin( column_ ) + row_;
222 template<
typename MatrixType2,
typename IteratorType2 >
223 inline BandIterator(
const BandIterator<MatrixType2,IteratorType2>& it ) noexcept
224 : matrix_( it.matrix_ )
226 , column_( it.column_ )
237 inline BandIterator&
operator+=(
size_t inc ) noexcept {
243 if( IsRowMajorMatrix<MatrixType>::value && row_ != matrix_->rows() )
244 pos_ = matrix_->begin( row_ ) + column_;
245 else if( IsColumnMajorMatrix<MatrixType>::value && column_ != matrix_->columns() )
246 pos_ = matrix_->begin( column_ ) + row_;
259 inline BandIterator&
operator-=(
size_t dec ) noexcept {
265 if( IsRowMajorMatrix<MatrixType>::value && row_ != matrix_->rows() )
266 pos_ = matrix_->begin( row_ ) + column_;
267 else if( IsColumnMajorMatrix<MatrixType>::value && column_ != matrix_->columns() )
268 pos_ = matrix_->begin( column_ ) + row_;
280 inline BandIterator& operator++() noexcept {
286 if( IsRowMajorMatrix<MatrixType>::value && row_ != matrix_->rows() )
287 pos_ = matrix_->begin( row_ ) + column_;
288 else if( IsColumnMajorMatrix<MatrixType>::value && column_ != matrix_->columns() )
289 pos_ = matrix_->begin( column_ ) + row_;
301 inline const BandIterator operator++(
int ) noexcept {
302 const BandIterator tmp( *
this );
313 inline BandIterator& operator--() noexcept {
319 if( IsRowMajorMatrix<MatrixType>::value && row_ != matrix_->rows() )
320 pos_ = matrix_->begin( row_ ) + column_;
321 else if( IsColumnMajorMatrix<MatrixType>::value && column_ != matrix_->columns() )
322 pos_ = matrix_->begin( column_ ) + row_;
334 inline const BandIterator operator--(
int ) noexcept {
335 const BandIterator tmp( *
this );
347 inline ReferenceType operator[](
size_t index )
const {
350 const IteratorType pos( IsRowMajorMatrix<MatrixType>::value
351 ? matrix_->begin( row_+index ) + column_ + index
352 : matrix_->begin( column_+index ) + row_ + index );
372 inline PointerType operator->()
const {
383 template<
typename MatrixType2,
typename IteratorType2 >
384 inline bool operator==(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
385 return row_ == rhs.row_;
395 template<
typename MatrixType2,
typename IteratorType2 >
396 inline bool operator!=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
397 return !( *
this == rhs );
407 template<
typename MatrixType2,
typename IteratorType2 >
408 inline bool operator<( const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
409 return row_ < rhs.row_;
419 template<
typename MatrixType2,
typename IteratorType2 >
420 inline bool operator>(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
421 return row_ > rhs.row_;
431 template<
typename MatrixType2,
typename IteratorType2 >
432 inline bool operator<=( const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
433 return row_ <= rhs.row_;
443 template<
typename MatrixType2,
typename IteratorType2 >
444 inline bool operator>=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
445 return row_ >= rhs.row_;
455 inline DifferenceType
operator-(
const BandIterator& rhs )
const noexcept {
456 return row_ - rhs.row_;
467 friend inline const BandIterator
operator+(
const BandIterator& it,
size_t inc ) noexcept {
468 return BandIterator( *it.matrix_, it.row_+inc, it.column_+inc );
479 friend inline const BandIterator
operator+(
size_t inc,
const BandIterator& it ) noexcept {
480 return BandIterator( *it.matrix_, it.row_+inc, it.column_+inc );
491 friend inline const BandIterator
operator-(
const BandIterator& it,
size_t dec ) noexcept {
492 return BandIterator( *it.matrix_, it.row_-dec, it.column_-dec );
505 template<
typename MatrixType2,
typename IteratorType2 >
friend class BandIterator;
512 using ConstIterator = BandIterator< const MT, ConstIterator_<MT> >;
520 enum :
bool { simdEnabled =
false };
523 enum :
bool { smpAssignable = MT::smpAssignable };
529 template<
typename... RBAs >
530 explicit inline Band( MT& matrix, RBAs... args );
542 inline Reference operator[](
size_t index );
543 inline ConstReference operator[](
size_t index )
const;
545 inline ConstReference at(
size_t index )
const;
546 inline Pointer
data () noexcept;
547 inline ConstPointer
data () const noexcept;
549 inline ConstIterator begin () const;
550 inline ConstIterator
cbegin() const;
552 inline ConstIterator end () const;
553 inline ConstIterator
cend () const;
561 inline Band& operator=( initializer_list<
ElementType> list );
562 inline Band& operator=( const Band& rhs );
564 template< typename VT > inline Band& operator= ( const Vector<VT,TF>& rhs );
565 template< typename VT > inline Band& operator+=( const Vector<VT,TF>& rhs );
566 template< typename VT > inline Band& operator-=( const Vector<VT,TF>& rhs );
567 template< typename VT > inline Band& operator*=( const Vector<VT,TF>& rhs );
568 template< typename VT > inline Band& operator/=( const DenseVector<VT,TF>& rhs );
569 template< typename VT > inline Band& operator%=( const Vector<VT,TF>& rhs );
576 using DataType::
band;
580 inline MT& operand() noexcept;
581 inline const MT& operand() const noexcept;
583 inline
size_t size() const noexcept;
584 inline
size_t spacing() const noexcept;
585 inline
size_t capacity() const noexcept;
594 template< typename Other > inline Band& scale( const Other& scalar );
601 template< typename Other >
602 inline
bool canAlias( const Other* alias ) const noexcept;
604 template< typename MT2, ptrdiff_t... CBAs2 >
605 inline
bool canAlias( const Band<MT2,TF,true,false,CBAs2...>* alias ) const noexcept;
607 template< typename Other >
608 inline
bool isAliased( const Other* alias ) const noexcept;
610 template< typename MT2, ptrdiff_t... CBAs2 >
611 inline
bool isAliased( const Band<MT2,TF,true,false,CBAs2...>* alias ) const noexcept;
613 inline
bool isAligned () const noexcept;
614 inline
bool canSMPAssign() const noexcept;
616 template< typename VT > inline
void assign ( const DenseVector <VT,TF>& rhs );
617 template< typename VT > inline
void assign ( const SparseVector<VT,TF>& rhs );
618 template< typename VT > inline
void addAssign ( const DenseVector <VT,TF>& rhs );
619 template< typename VT > inline
void addAssign ( const SparseVector<VT,TF>& rhs );
620 template< typename VT > inline
void subAssign ( const DenseVector <VT,TF>& rhs );
621 template< typename VT > inline
void subAssign ( const SparseVector<VT,TF>& rhs );
622 template< typename VT > inline
void multAssign( const DenseVector <VT,TF>& rhs );
623 template< typename VT > inline
void multAssign( const SparseVector<VT,TF>& rhs );
624 template< typename VT > inline
void divAssign ( const DenseVector <VT,TF>& rhs );
637 template< typename MT2,
bool TF2,
bool DF2,
bool MF2, ptrdiff_t... CBAs2 > friend class Band;
673 template< typename MT
675 , ptrdiff_t... CBAs >
676 template< typename... RBAs >
677 inline Band<MT,TF,true,false,CBAs...>::Band( MT& matrix, RBAs... args )
678 : DataType( args... )
681 if( !Contains< TypeList<RBAs...>,
Unchecked >::value ) {
682 if( (
band() > 0L &&
column() >= matrix.columns() ) ||
683 (
band() < 0L &&
row() >= matrix.rows() ) ) {
714 template<
typename MT
716 , ptrdiff_t... CBAs >
717 inline typename Band<MT,TF,
true,
false,CBAs...>
::Reference 718 Band<MT,TF,true,false,CBAs...>::operator[](
size_t index )
721 return matrix_(
row()+index,
column()+index);
737 template<
typename MT
739 , ptrdiff_t... CBAs >
741 Band<MT,TF,true,false,CBAs...>::operator[](
size_t index )
const 744 return const_cast<const MT&
>( matrix_ )(
row()+index,
column()+index);
761 template<
typename MT
763 , ptrdiff_t... CBAs >
764 inline typename Band<MT,TF,
true,
false,CBAs...>
::Reference 765 Band<MT,TF,true,false,CBAs...>::at(
size_t index )
767 if( index >=
size() ) {
770 return (*
this)[index];
787 template<
typename MT
789 , ptrdiff_t... CBAs >
791 Band<MT,TF,true,false,CBAs...>::at(
size_t index )
const 793 if( index >=
size() ) {
796 return (*
this)[index];
811 template<
typename MT
813 , ptrdiff_t... CBAs >
814 inline typename Band<MT,TF,
true,
false,CBAs...>::Pointer
817 if( IsRowMajorMatrix<MT>::value )
818 return matrix_.data() +
row() * matrix_.spacing() +
column();
820 return matrix_.data() +
row() +
column() * matrix_.spacing();
835 template<
typename MT
837 , ptrdiff_t... CBAs >
838 inline typename Band<MT,TF,
true,
false,CBAs...>::ConstPointer
841 if( IsRowMajorMatrix<MT>::value )
842 return matrix_.data() +
row() * matrix_.spacing() +
column();
844 return matrix_.data() +
row() +
column() * matrix_.spacing();
858 template<
typename MT
860 , ptrdiff_t... CBAs >
861 inline typename Band<MT,TF,
true,
false,CBAs...>
::Iterator 878 template<
typename MT
880 , ptrdiff_t... CBAs >
898 template<
typename MT
900 , ptrdiff_t... CBAs >
918 template<
typename MT
920 , ptrdiff_t... CBAs >
921 inline typename Band<MT,TF,
true,
false,CBAs...>
::Iterator 924 const size_t n(
size() );
939 template<
typename MT
941 , ptrdiff_t... CBAs >
945 const size_t n(
size() );
960 template<
typename MT
962 , ptrdiff_t... CBAs >
966 const size_t n(
size() );
992 template<
typename MT
994 , ptrdiff_t... CBAs >
995 inline Band<MT,TF,
true,
false,CBAs...>&
996 Band<MT,TF,true,false,CBAs...>::operator=(
const ElementType& rhs )
998 decltype(
auto) left( derestrict( matrix_ ) );
1000 if( ( IsLower<MT>::value && column() > 0UL ) ||
1001 ( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value ) && row() == 0UL ) ||
1002 ( IsUpper<MT>::value && row() > 0UL ) ||
1003 ( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value ) && column() == 0UL ) )
1006 const
size_t n(
size() );
1007 for(
size_t i=0UL; i<n; ++i ) {
1008 if( !IsRestricted<MT>::value || IsTriangular<MT>::value || trySet( matrix_,
row()+i,
column()+i, rhs ) )
1033 template<
typename MT
1035 , ptrdiff_t... CBAs >
1036 inline Band<MT,TF,
true,
false,CBAs...>&
1037 Band<MT,TF,true,false,CBAs...>::operator=( initializer_list<ElementType> list )
1039 if( list.size() >
size() ) {
1043 if( IsRestricted<MT>::value ) {
1044 const InitializerVector<ElementType,false> tmp( list,
size() );
1050 decltype(
auto) left( derestrict( *this ) );
1052 std::fill(
std::copy( list.begin(), list.end(), left.begin() ), left.end(),
ElementType() );
1076 template< typename MT
1078 , ptrdiff_t... CBAs >
1079 inline Band<MT,TF,true,false,CBAs...>&
1080 Band<MT,TF,true,false,CBAs...>::operator=( const Band& rhs )
1082 if( &rhs ==
this )
return *
this;
1084 if(
size() != rhs.size() ) {
1092 decltype(
auto) left( derestrict( *this ) );
1094 if( IsExpression<MT>::value && rhs.canAlias( &matrix_ ) ) {
1095 const ResultType tmp( rhs );
1124 template<
typename MT
1126 , ptrdiff_t... CBAs >
1127 template<
typename VT >
1128 inline Band<MT,TF,
true,
false,CBAs...>&
1129 Band<MT,TF,true,false,CBAs...>::operator=(
const Vector<VT,TF>& rhs )
1138 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
1139 Right right( ~rhs );
1141 if( !tryAssign( matrix_, right,
band(),
row(),
column() ) ) {
1145 decltype(
auto) left( derestrict( *this ) );
1147 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1148 const ResultType_<VT> tmp( right );
1152 if( IsSparseVector<VT>::value )
1179 template<
typename MT
1181 , ptrdiff_t... CBAs >
1182 template<
typename VT >
1183 inline Band<MT,TF,
true,
false,CBAs...>&
1193 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
1194 Right right( ~rhs );
1196 if( !tryAddAssign( matrix_, right,
band(),
row(),
column() ) ) {
1200 decltype(
auto) left( derestrict( *this ) );
1202 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1203 const ResultType_<VT> tmp( right );
1232 template<
typename MT
1234 , ptrdiff_t... CBAs >
1235 template<
typename VT >
1236 inline Band<MT,TF,
true,
false,CBAs...>&
1246 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
1247 Right right( ~rhs );
1249 if( !trySubAssign( matrix_, right,
band(),
row(),
column() ) ) {
1253 decltype(
auto) left( derestrict( *this ) );
1255 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1256 const ResultType_<VT> tmp( right );
1284 template<
typename MT
1286 , ptrdiff_t... CBAs >
1287 template<
typename VT >
1288 inline Band<MT,TF,
true,
false,CBAs...>&
1301 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
1302 Right right( ~rhs );
1304 if( !tryMultAssign( matrix_, right,
band(),
row(),
column() ) ) {
1308 decltype(
auto) left( derestrict( *this ) );
1310 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1311 const ResultType_<VT> tmp( right );
1338 template<
typename MT
1340 , ptrdiff_t... CBAs >
1341 template<
typename VT >
1342 inline Band<MT,TF,
true,
false,CBAs...>&
1352 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
1353 Right right( ~rhs );
1355 if( !tryDivAssign( matrix_, right,
band(),
row(),
column() ) ) {
1359 decltype(
auto) left( derestrict( *this ) );
1361 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1362 const ResultType_<VT> tmp( right );
1390 template<
typename MT
1392 , ptrdiff_t... CBAs >
1393 template<
typename VT >
1394 inline Band<MT,TF,
true,
false,CBAs...>&
1395 Band<MT,TF,true,false,CBAs...>::operator%=(
const Vector<VT,TF>& rhs )
1397 using blaze::assign;
1402 using CrossType = CrossTrait_< ResultType, ResultType_<VT> >;
1408 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
1412 const CrossType right( *
this % (~rhs) );
1414 if( !tryAssign( matrix_, right,
band(),
row(),
column() ) ) {
1418 decltype(
auto) left( derestrict( *this ) );
1420 assign( left, right );
1444 template< typename MT
1446 , ptrdiff_t... CBAs >
1447 inline MT& Band<MT,TF,true,false,CBAs...>::operand() noexcept
1461 template<
typename MT
1463 , ptrdiff_t... CBAs >
1464 inline const MT& Band<MT,TF,true,false,CBAs...>::operand() const noexcept
1478 template<
typename MT
1480 , ptrdiff_t... CBAs >
1483 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
1498 template<
typename MT
1500 , ptrdiff_t... CBAs >
1515 template<
typename MT
1517 , ptrdiff_t... CBAs >
1535 template<
typename MT
1537 , ptrdiff_t... CBAs >
1540 const size_t n(
size() );
1541 size_t nonzeros( 0UL );
1543 for(
size_t i=0UL; i<n; ++i )
1559 template<
typename MT
1561 , ptrdiff_t... CBAs >
1566 if( ( IsLower<MT>::value &&
column() > 0UL ) ||
1567 ( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value ) &&
row() == 0UL ) ||
1568 ( IsUpper<MT>::value &&
row() > 0UL ) ||
1569 ( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value ) &&
column() == 0UL ) )
1572 const size_t n(
size() );
1573 for(
size_t i=0UL; i<n; ++i )
1601 template<
typename MT
1603 , ptrdiff_t... CBAs >
1604 template<
typename Other >
1605 inline Band<MT,TF,
true,
false,CBAs...>&
1606 Band<MT,TF,true,false,CBAs...>::scale(
const Other& scalar )
1610 if( ( IsLower<MT>::value &&
column() > 0UL ) ||
1611 ( IsStrictlyLower<MT>::value &&
row() == 0UL ) ||
1612 ( IsUpper<MT>::value &&
row() > 0UL ) ||
1613 ( IsStrictlyUpper<MT>::value &&
column() == 0UL ) )
1616 const size_t n(
size() );
1617 for(
size_t i=0UL; i<n; ++i ) {
1646 template<
typename MT
1648 , ptrdiff_t... CBAs >
1649 template<
typename Other >
1650 inline bool Band<MT,TF,true,false,CBAs...>::canAlias(
const Other* alias )
const noexcept
1652 return matrix_.isAliased( alias );
1669 template<
typename MT
1671 , ptrdiff_t... CBAs >
1672 template<
typename MT2
1673 , ptrdiff_t... CBAs2 >
1675 Band<MT,TF,true,false,CBAs...>::canAlias(
const Band<MT2,TF,true,false,CBAs2...>* alias )
const noexcept
1677 return matrix_.isAliased( &alias->matrix_ ) && (
band() == alias->band() );
1694 template<
typename MT
1696 , ptrdiff_t... CBAs >
1697 template<
typename Other >
1698 inline bool Band<MT,TF,true,false,CBAs...>::isAliased(
const Other* alias )
const noexcept
1700 return matrix_.isAliased( alias );
1717 template<
typename MT
1719 , ptrdiff_t... CBAs >
1720 template<
typename MT2
1721 , ptrdiff_t... CBAs2 >
1723 Band<MT,TF,true,false,CBAs...>::isAliased(
const Band<MT2,TF,true,false,CBAs2...>* alias )
const noexcept
1725 return matrix_.isAliased( &alias->matrix_ ) && (
band() == alias->band() );
1741 template<
typename MT
1743 , ptrdiff_t... CBAs >
1744 inline bool Band<MT,TF,true,false,CBAs...>::isAligned() const noexcept
1763 template<
typename MT
1765 , ptrdiff_t... CBAs >
1766 inline bool Band<MT,TF,true,false,CBAs...>::canSMPAssign() const noexcept
1768 return (
size() > SMP_DVECASSIGN_THRESHOLD );
1786 template<
typename MT
1788 , ptrdiff_t... CBAs >
1789 template<
typename VT >
1790 inline void Band<MT,TF,true,false,CBAs...>::assign(
const DenseVector<VT,TF>& rhs )
1794 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1795 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1796 matrix_(
row()+i ,
column()+i ) = (~rhs)[i ];
1797 matrix_(
row()+i+1UL,
column()+i+1UL) = (~rhs)[i+1UL];
1799 if( ipos < (~rhs).size() ) {
1800 matrix_(
row()+ipos,
column()+ipos) = (~rhs)[ipos];
1819 template<
typename MT
1821 , ptrdiff_t... CBAs >
1822 template<
typename VT >
1823 inline void Band<MT,TF,true,false,CBAs...>::assign(
const SparseVector<VT,TF>& rhs )
1827 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1828 const size_t index( element->index() );
1829 matrix_(
row()+index,
column()+index) = element->value();
1848 template<
typename MT
1850 , ptrdiff_t... CBAs >
1851 template<
typename VT >
1852 inline void Band<MT,TF,true,false,CBAs...>::addAssign(
const DenseVector<VT,TF>& rhs )
1856 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1857 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1858 matrix_(
row()+i ,
column()+i ) += (~rhs)[i ];
1859 matrix_(
row()+i+1UL,
column()+i+1UL) += (~rhs)[i+1UL];
1861 if( ipos < (~rhs).size() ) {
1862 matrix_(
row()+ipos,
column()+ipos) += (~rhs)[ipos];
1881 template<
typename MT
1883 , ptrdiff_t... CBAs >
1884 template<
typename VT >
1885 inline void Band<MT,TF,true,false,CBAs...>::addAssign(
const SparseVector<VT,TF>& rhs )
1889 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1890 const size_t index( element->index() );
1891 matrix_(
row()+index,
column()+index) += element->value();
1910 template<
typename MT
1912 , ptrdiff_t... CBAs >
1913 template<
typename VT >
1914 inline void Band<MT,TF,true,false,CBAs...>::subAssign(
const DenseVector<VT,TF>& rhs )
1918 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1919 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1920 matrix_(
row()+i ,
column()+i ) -= (~rhs)[i ];
1921 matrix_(
row()+i+1UL,
column()+i+1UL) -= (~rhs)[i+1UL];
1923 if( ipos < (~rhs).size() ) {
1924 matrix_(
row()+ipos,
column()+ipos) -= (~rhs)[ipos];
1943 template<
typename MT
1945 , ptrdiff_t... CBAs >
1946 template<
typename VT >
1947 inline void Band<MT,TF,true,false,CBAs...>::subAssign(
const SparseVector<VT,TF>& rhs )
1951 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1952 const size_t index( element->index() );
1953 matrix_(
row()+index,
column()+index) -= element->value();
1972 template<
typename MT
1974 , ptrdiff_t... CBAs >
1975 template<
typename VT >
1976 inline void Band<MT,TF,true,false,CBAs...>::multAssign(
const DenseVector<VT,TF>& rhs )
1980 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1981 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1982 matrix_(
row()+i ,
column()+i ) *= (~rhs)[i ];
1983 matrix_(
row()+i+1UL,
column()+i+1UL) *= (~rhs)[i+1UL];
1985 if( ipos < (~rhs).size() ) {
1986 matrix_(
row()+ipos,
column()+ipos) *= (~rhs)[ipos];
2005 template<
typename MT
2007 , ptrdiff_t... CBAs >
2008 template<
typename VT >
2009 inline void Band<MT,TF,true,false,CBAs...>::multAssign(
const SparseVector<VT,TF>& rhs )
2017 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
2018 const size_t index( element->index() );
2019 for( ; i<index; ++i )
2021 matrix_(
row()+index,
column()+index) *= element->value();
2025 for( ; i<
size(); ++i ) {
2045 template<
typename MT
2047 , ptrdiff_t... CBAs >
2048 template<
typename VT >
2049 inline void Band<MT,TF,true,false,CBAs...>::divAssign(
const DenseVector<VT,TF>& rhs )
2053 const size_t ipos( (~rhs).
size() &
size_t(-2) );
2054 for(
size_t i=0UL; i<ipos; i+=2UL ) {
2055 matrix_(
row()+i ,
column()+i ) /= (~rhs)[i ];
2056 matrix_(
row()+i+1UL,
column()+i+1UL) /= (~rhs)[i+1UL];
2058 if( ipos < (~rhs).size() ) {
2059 matrix_(
row()+ipos,
column()+ipos) /= (~rhs)[ipos];
2082 template<
typename MT
2084 , ptrdiff_t... CBAs >
2085 class Band<MT,TF,true,true,CBAs...>
2086 :
public View< DenseVector< Band<MT,TF,true,true,CBAs...>, TF > >
2087 ,
private BandData<CBAs...>
2088 ,
private Computation
2093 using DataType = BandData<CBAs...>;
2096 using LeftOperand = RemoveReference_< LeftOperand_<MT> >;
2099 using RightOperand = RemoveReference_< RightOperand_<MT> >;
2105 using This = Band<MT,TF,
true,
true,CBAs...>;
2108 using BaseType = DenseVector<This,TF>;
2111 using ViewedType = MT;
2114 using ResultType = BandTrait_<ResultType_<MT>,CBAs...>;
2117 using ElementType = ElementType_<ResultType>;
2121 using CompositeType = If_< Or< RequiresEvaluation<LeftOperand>
2122 , RequiresEvaluation<RightOperand> >
2126 using LT = If_< And< IsSparseMatrix<LeftOperand>, IsColumnMajorMatrix<LeftOperand> >
2127 , ResultType_<LeftOperand>
2128 , CompositeType_<LeftOperand> >;
2131 using RT = If_< And< IsSparseMatrix<RightOperand>, IsRowMajorMatrix<RightOperand> >
2132 , ResultType_<RightOperand>
2133 , CompositeType_<RightOperand> >;
2138 enum :
bool { simdEnabled =
false };
2141 enum :
bool { smpAssignable =
false };
2151 template<
typename... RBAs >
2152 explicit inline Band(
const MT& mmm, RBAs... args )
2153 : DataType( args... )
2156 if( !Contains< TypeList<RBAs...>,
Unchecked >::value ) {
2157 if( (
band() > 0L &&
column() >= mmm.columns() ) ||
2158 (
band() < 0L &&
row() >= mmm.rows() ) ) {
2175 inline ReturnType operator[](
size_t index )
const {
2177 return matrix_(
row()+index,
column()+index);
2189 if( index >=
size() ) {
2192 return (*
this)[index];
2201 inline size_t size() const noexcept {
2202 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
2217 inline const MT& operand() const noexcept {
2228 template<
typename T >
2229 inline bool canAlias(
const T* alias )
const noexcept {
2230 return matrix_.isAliased( alias );
2240 template<
typename T >
2241 inline bool isAliased(
const T* alias )
const noexcept {
2242 return matrix_.isAliased( alias );
2251 inline constexpr
bool isAligned() const noexcept {
2273 template<
typename VT >
2274 friend inline void assign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2283 LT A(
serial( rhs.operand().leftOperand() ) );
2284 RT B(
serial( rhs.operand().rightOperand() ) );
2286 const size_t n( rhs.size() );
2287 for(
size_t i=0UL; i<n; ++i ) {
2306 template<
typename VT >
2307 friend inline void assign( SparseVector<VT,TF>& lhs,
const Band& rhs )
2317 const ResultType tmp(
serial( rhs ) );
2318 assign( ~lhs, tmp );
2335 template<
typename VT >
2336 friend inline void addAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2345 LT A(
serial( rhs.operand().leftOperand() ) );
2346 RT B(
serial( rhs.operand().rightOperand() ) );
2348 const size_t n( rhs.size() );
2349 for(
size_t i=0UL; i<n; ++i ) {
2372 template<
typename VT >
2373 friend inline void subAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2382 LT A(
serial( rhs.operand().leftOperand() ) );
2383 RT B(
serial( rhs.operand().rightOperand() ) );
2385 const size_t n( rhs.size() );
2386 for(
size_t i=0UL; i<n; ++i ) {
2410 template<
typename VT >
2411 friend inline void multAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2420 LT A(
serial( rhs.operand().leftOperand() ) );
2421 RT B(
serial( rhs.operand().rightOperand() ) );
2423 const size_t n( rhs.size() );
2424 for(
size_t i=0UL; i<n; ++i ) {
2447 template<
typename VT >
2448 friend inline void divAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2457 LT A(
serial( rhs.operand().leftOperand() ) );
2458 RT B(
serial( rhs.operand().rightOperand() ) );
2460 const size_t n( rhs.size() );
2461 for(
size_t i=0UL; i<n; ++i ) {
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:131
Header file for the blaze::checked and blaze::unchecked instances.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the IsUniUpper type trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:522
Header file for basic type definitions.
Header file for the SparseVector base class.
Header file for the View base class.
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:164
Header file for the IsSparseMatrix type trait.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:265
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
#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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3076
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:364
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3074
Header file for the IsColumnMajorMatrix type trait.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
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:701
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
EnableIf_< IsDenseVector< VT1 > > smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:193
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3078
Header file for the And class template.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1903
Header file for the DenseVector base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3083
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:560
Header file for the implementation of the Band base template.
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:733
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3084
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
Header file for the RequiresEvaluation type trait.
Header file for the extended initializer_list functionality.
Header file for the IsUniLower type trait.
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:133
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:474
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:408
Header file for the band trait.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:252
Constraint on the data type.
Header file for the IsStrictlyUpper type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3082
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
Header file for the implementation of a vector representation of an initializer list.
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
EnableIf_< IsDenseMatrix< MT1 > > smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:102
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3079
Header file for the Or class template.
#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:367
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:443
Header file for the Not class template.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Header file for the IsLower type trait.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:506
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.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:430
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8893
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Constraint on the data type.
typename BandTrait< MT, CBAs... >::Type BandTrait_
Auxiliary alias declaration for the BandTrait type trait.The BandTrait_ alias declaration provides a ...
Definition: BandTrait.h:145
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:608
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:134
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_MATMATMULTEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is not a matrix/matrix multiplication expre...
Definition: MatMatMultExpr.h:67
Header file for the IsSparseVector type trait.
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Header file for run time assertion macros.
Header file for the cross product trait.
Header file for the Unique class template.
Check< false > Unchecked
Type of the blaze::unchecked instance.blaze::Unchecked is the type of the blaze::unchecked instance...
Definition: Check.h:96
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:131
EnableIf_< IsDenseVector< VT1 > > smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:222
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Header file for the isDefault shim.
Constraint on the data type.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:816
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.
Header file for the RemoveReference type trait.
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
BLAZE_ALWAYS_INLINE MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:169
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
Header file for the IsRowMajorMatrix type trait.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3081
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:254
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
Header file for the IsUpper type trait.
Constraint on the data type.
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
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, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the IsExpression type trait class.
Header file for the implementation of the BandData class template.