35 #ifndef _BLAZE_MATH_VIEWS_BAND_DENSE_H_ 36 #define _BLAZE_MATH_VIEWS_BAND_DENSE_H_ 109 template<
typename MT
111 , ptrdiff_t... CBAs >
112 class Band<MT,TF,true,false,CBAs...>
113 :
public View< DenseVector< Band<MT,TF,true,false,CBAs...>, TF > >
114 ,
private BandData<CBAs...>
118 using RT = ResultType_t<MT>;
119 using DataType = BandData<CBAs...>;
120 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
126 using This = Band<MT,TF,
true,
false,CBAs...>;
128 using BaseType = DenseVector<This,TF>;
129 using ViewedType = MT;
145 using ConstPointer = ConstPointer_t<MT>;
148 using Pointer = If_t< IsConst_v<MT> || !HasMutableDataAccess_v<MT>, ConstPointer, Pointer_t<MT> >;
154 template<
typename MatrixType
155 ,
typename IteratorType >
161 using IteratorCategory =
typename std::iterator_traits<IteratorType>::iterator_category;
164 using ValueType =
typename std::iterator_traits<IteratorType>::value_type;
167 using PointerType =
typename std::iterator_traits<IteratorType>::pointer;
170 using ReferenceType =
typename std::iterator_traits<IteratorType>::reference;
173 using DifferenceType =
typename std::iterator_traits<IteratorType>::difference_type;
176 using iterator_category = IteratorCategory;
177 using value_type = ValueType;
178 using pointer = PointerType;
179 using reference = ReferenceType;
180 using difference_type = DifferenceType;
186 inline BandIterator() noexcept
201 inline BandIterator( MatrixType& matrix,
size_t rowIndex,
size_t columnIndex ) noexcept
204 , column_( columnIndex )
207 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
208 pos_ = matrix_->begin( row_ ) + column_;
209 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
210 pos_ = matrix_->begin( column_ ) + row_;
219 template<
typename MatrixType2,
typename IteratorType2 >
220 inline BandIterator(
const BandIterator<MatrixType2,IteratorType2>& it ) noexcept
221 : matrix_( it.matrix_ )
223 , column_( it.column_ )
234 inline BandIterator&
operator+=(
size_t inc ) noexcept {
240 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
241 pos_ = matrix_->begin( row_ ) + column_;
242 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
243 pos_ = matrix_->begin( column_ ) + row_;
256 inline BandIterator&
operator-=(
size_t dec ) noexcept {
262 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
263 pos_ = matrix_->begin( row_ ) + column_;
264 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
265 pos_ = matrix_->begin( column_ ) + row_;
277 inline BandIterator& operator++() noexcept {
283 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
284 pos_ = matrix_->begin( row_ ) + column_;
285 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
286 pos_ = matrix_->begin( column_ ) + row_;
298 inline const BandIterator operator++(
int ) noexcept {
299 const BandIterator tmp( *
this );
310 inline BandIterator& operator--() noexcept {
316 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
317 pos_ = matrix_->begin( row_ ) + column_;
318 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
319 pos_ = matrix_->begin( column_ ) + row_;
331 inline const BandIterator operator--(
int ) noexcept {
332 const BandIterator tmp( *
this );
344 inline ReferenceType operator[](
size_t index )
const {
347 const IteratorType pos( IsRowMajorMatrix_v<MatrixType>
348 ? matrix_->begin( row_+index ) + column_ + index
349 : matrix_->begin( column_+index ) + row_ + index );
369 inline PointerType operator->()
const {
380 template<
typename MatrixType2,
typename IteratorType2 >
381 inline bool operator==(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
382 return row_ == rhs.row_;
392 template<
typename MatrixType2,
typename IteratorType2 >
393 inline bool operator!=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
394 return !( *
this == rhs );
404 template<
typename MatrixType2,
typename IteratorType2 >
405 inline bool operator<( const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
406 return row_ < rhs.row_;
416 template<
typename MatrixType2,
typename IteratorType2 >
417 inline bool operator>(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
418 return row_ > rhs.row_;
428 template<
typename MatrixType2,
typename IteratorType2 >
429 inline bool operator<=( const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
430 return row_ <= rhs.row_;
440 template<
typename MatrixType2,
typename IteratorType2 >
441 inline bool operator>=(
const BandIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
442 return row_ >= rhs.row_;
452 inline DifferenceType
operator-(
const BandIterator& rhs )
const noexcept {
453 return row_ - rhs.row_;
464 friend inline const BandIterator
operator+(
const BandIterator& it,
size_t inc ) noexcept {
465 return BandIterator( *it.matrix_, it.row_+inc, it.column_+inc );
476 friend inline const BandIterator
operator+(
size_t inc,
const BandIterator& it ) noexcept {
477 return BandIterator( *it.matrix_, it.row_+inc, it.column_+inc );
488 friend inline const BandIterator
operator-(
const BandIterator& it,
size_t dec ) noexcept {
489 return BandIterator( *it.matrix_, it.row_-dec, it.column_-dec );
502 template<
typename MatrixType2,
typename IteratorType2 >
friend class BandIterator;
509 using ConstIterator = BandIterator< const MT, ConstIterator_t<MT> >;
517 static constexpr
bool simdEnabled =
false;
526 template<
typename... RBAs >
527 explicit inline Band( MT& matrix, RBAs... args );
529 Band(
const Band& ) =
default;
543 inline Reference operator[](
size_t index );
547 inline Pointer
data () noexcept;
548 inline ConstPointer
data () const noexcept;
562 inline Band& operator=( initializer_list<
ElementType> list );
563 inline Band& operator=( const Band& 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 Vector<VT,TF>& rhs );
569 template< typename VT > inline Band& operator/=( const DenseVector<VT,TF>& rhs );
570 template< typename VT > inline Band& operator%=( const Vector<VT,TF>& rhs );
577 using DataType::
band;
581 inline MT& operand() noexcept;
582 inline const MT& operand() const noexcept;
584 inline
size_t size() const noexcept;
585 inline
size_t spacing() const noexcept;
586 inline
size_t capacity() const noexcept;
595 template< typename Other > inline Band& scale( const Other& scalar );
602 template< typename Other >
603 inline
bool canAlias( const Other* alias ) const noexcept;
605 template< typename MT2, ptrdiff_t... CBAs2 >
606 inline
bool canAlias( const Band<MT2,TF,true,false,CBAs2...>* alias ) const noexcept;
608 template< typename Other >
609 inline
bool isAliased( const Other* alias ) const noexcept;
611 template< typename MT2, ptrdiff_t... CBAs2 >
612 inline
bool isAliased( const Band<MT2,TF,true,false,CBAs2...>* alias ) const noexcept;
614 inline
bool isAligned () const noexcept;
615 inline
bool canSMPAssign() const noexcept;
617 template< typename VT > inline
void assign ( const DenseVector <VT,TF>& rhs );
618 template< typename VT > inline
void assign ( const SparseVector<VT,TF>& rhs );
619 template< typename VT > inline
void addAssign ( const DenseVector <VT,TF>& rhs );
620 template< typename VT > inline
void addAssign ( const SparseVector<VT,TF>& rhs );
621 template< typename VT > inline
void subAssign ( const DenseVector <VT,TF>& rhs );
622 template< typename VT > inline
void subAssign ( const SparseVector<VT,TF>& rhs );
623 template< typename VT > inline
void multAssign( const DenseVector <VT,TF>& rhs );
624 template< typename VT > inline
void multAssign( const SparseVector<VT,TF>& rhs );
625 template< typename VT > inline
void divAssign ( const DenseVector <VT,TF>& rhs );
638 template< typename MT2,
bool TF2,
bool DF2,
bool MF2, ptrdiff_t... CBAs2 > friend class Band;
674 template< typename MT
676 , ptrdiff_t... CBAs >
677 template< typename... RBAs >
678 inline Band<MT,TF,true,false,CBAs...>::Band( MT& matrix, RBAs... args )
679 : DataType( args... )
683 if( (
band() > 0L &&
column() >= matrix.columns() ) ||
684 (
band() < 0L &&
row() >= matrix.rows() ) ) {
715 template<
typename MT
717 , ptrdiff_t... CBAs >
718 inline typename Band<MT,TF,
true,
false,CBAs...>
::Reference 719 Band<MT,TF,true,false,CBAs...>::operator[](
size_t index )
722 return matrix_(
row()+index,
column()+index);
738 template<
typename MT
740 , ptrdiff_t... CBAs >
742 Band<MT,TF,true,false,CBAs...>::operator[](
size_t index )
const 745 return const_cast<const MT&
>( matrix_ )(
row()+index,
column()+index);
762 template<
typename MT
764 , ptrdiff_t... CBAs >
765 inline typename Band<MT,TF,
true,
false,CBAs...>
::Reference 766 Band<MT,TF,true,false,CBAs...>::at(
size_t index )
768 if( index >=
size() ) {
771 return (*
this)[index];
788 template<
typename MT
790 , ptrdiff_t... CBAs >
792 Band<MT,TF,true,false,CBAs...>::at(
size_t index )
const 794 if( index >=
size() ) {
797 return (*
this)[index];
812 template<
typename MT
814 , ptrdiff_t... CBAs >
815 inline typename Band<MT,TF,
true,
false,CBAs...>::Pointer
818 if( IsRowMajorMatrix_v<MT> )
819 return matrix_.data() +
row() * matrix_.spacing() +
column();
821 return matrix_.data() +
row() +
column() * matrix_.spacing();
836 template<
typename MT
838 , ptrdiff_t... CBAs >
839 inline typename Band<MT,TF,
true,
false,CBAs...>::ConstPointer
842 if( IsRowMajorMatrix_v<MT> )
843 return matrix_.data() +
row() * matrix_.spacing() +
column();
845 return matrix_.data() +
row() +
column() * matrix_.spacing();
859 template<
typename MT
861 , ptrdiff_t... CBAs >
862 inline typename Band<MT,TF,
true,
false,CBAs...>
::Iterator 879 template<
typename MT
881 , ptrdiff_t... CBAs >
899 template<
typename MT
901 , ptrdiff_t... CBAs >
919 template<
typename MT
921 , ptrdiff_t... CBAs >
922 inline typename Band<MT,TF,
true,
false,CBAs...>
::Iterator 925 const size_t n(
size() );
940 template<
typename MT
942 , ptrdiff_t... CBAs >
946 const size_t n(
size() );
961 template<
typename MT
963 , ptrdiff_t... CBAs >
967 const size_t n(
size() );
993 template<
typename MT
995 , ptrdiff_t... CBAs >
996 inline Band<MT,TF,
true,
false,CBAs...>&
997 Band<MT,TF,true,false,CBAs...>::operator=(
const ElementType& rhs )
999 decltype(
auto) left( derestrict( matrix_ ) );
1007 const
size_t n(
size() );
1008 for(
size_t i=0UL; i<n; ++i ) {
1009 if( !IsRestricted_v<MT> || IsTriangular_v<MT> || trySet( matrix_,
row()+i,
column()+i, rhs ) )
1034 template<
typename MT
1036 , ptrdiff_t... CBAs >
1037 inline Band<MT,TF,
true,
false,CBAs...>&
1038 Band<MT,TF,true,false,CBAs...>::operator=( initializer_list<ElementType> list )
1040 if( list.size() >
size() ) {
1044 if( IsRestricted_v<MT> ) {
1045 const InitializerVector<ElementType,false> tmp( list,
size() );
1051 decltype(
auto) left( derestrict( *this ) );
1077 template< typename MT
1079 , ptrdiff_t... CBAs >
1080 inline Band<MT,TF,true,false,CBAs...>&
1081 Band<MT,TF,true,false,CBAs...>::operator=( const Band& rhs )
1083 if( &rhs ==
this )
return *
this;
1085 if(
size() != rhs.size() ) {
1093 decltype(
auto) left( derestrict( *this ) );
1125 template<
typename MT
1127 , ptrdiff_t... CBAs >
1128 template<
typename VT >
1129 inline Band<MT,TF,
true,
false,CBAs...>&
1130 Band<MT,TF,true,false,CBAs...>::operator=(
const Vector<VT,TF>& rhs )
1139 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1140 Right right( ~rhs );
1142 if( !tryAssign( matrix_, right,
band(),
row(),
column() ) ) {
1146 decltype(
auto) left( derestrict( *this ) );
1149 const ResultType_t<VT> tmp( right );
1153 if( IsSparseVector_v<VT> )
1180 template<
typename MT
1182 , ptrdiff_t... CBAs >
1183 template<
typename VT >
1184 inline Band<MT,TF,
true,
false,CBAs...>&
1194 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1195 Right right( ~rhs );
1197 if( !tryAddAssign( matrix_, right,
band(),
row(),
column() ) ) {
1201 decltype(
auto) left( derestrict( *this ) );
1204 const ResultType_t<VT> tmp( right );
1233 template<
typename MT
1235 , ptrdiff_t... CBAs >
1236 template<
typename VT >
1237 inline Band<MT,TF,
true,
false,CBAs...>&
1247 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1248 Right right( ~rhs );
1250 if( !trySubAssign( matrix_, right,
band(),
row(),
column() ) ) {
1254 decltype(
auto) left( derestrict( *this ) );
1257 const ResultType_t<VT> tmp( right );
1285 template<
typename MT
1287 , ptrdiff_t... CBAs >
1288 template<
typename VT >
1289 inline Band<MT,TF,
true,
false,CBAs...>&
1302 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1303 Right right( ~rhs );
1305 if( !tryMultAssign( matrix_, right,
band(),
row(),
column() ) ) {
1309 decltype(
auto) left( derestrict( *this ) );
1312 const ResultType_t<VT> tmp( right );
1339 template<
typename MT
1341 , ptrdiff_t... CBAs >
1342 template<
typename VT >
1343 inline Band<MT,TF,
true,
false,CBAs...>&
1353 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>,
const VT& >;
1354 Right right( ~rhs );
1356 if( !tryDivAssign( matrix_, right,
band(),
row(),
column() ) ) {
1360 decltype(
auto) left( derestrict( *this ) );
1363 const ResultType_t<VT> tmp( right );
1391 template<
typename MT
1393 , ptrdiff_t... CBAs >
1394 template<
typename VT >
1395 inline Band<MT,TF,
true,
false,CBAs...>&
1396 Band<MT,TF,true,false,CBAs...>::operator%=(
const Vector<VT,TF>& rhs )
1398 using blaze::assign;
1403 using CrossType = CrossTrait_t< ResultType, ResultType_t<VT> >;
1409 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
1413 const CrossType right( *
this % (~rhs) );
1415 if( !tryAssign( matrix_, right,
band(),
row(),
column() ) ) {
1419 decltype(
auto) left( derestrict( *this ) );
1421 assign( left, right );
1445 template< typename MT
1447 , ptrdiff_t... CBAs >
1448 inline MT& Band<MT,TF,true,false,CBAs...>::operand() noexcept
1462 template<
typename MT
1464 , ptrdiff_t... CBAs >
1465 inline const MT& Band<MT,TF,true,false,CBAs...>::operand() const noexcept
1479 template<
typename MT
1481 , ptrdiff_t... CBAs >
1484 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
1499 template<
typename MT
1501 , ptrdiff_t... CBAs >
1516 template<
typename MT
1518 , ptrdiff_t... CBAs >
1536 template<
typename MT
1538 , ptrdiff_t... CBAs >
1541 const size_t n(
size() );
1542 size_t nonzeros( 0UL );
1544 for(
size_t i=0UL; i<n; ++i )
1560 template<
typename MT
1562 , ptrdiff_t... CBAs >
1567 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1568 ( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> ) &&
row() == 0UL ) ||
1569 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1570 ( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> ) &&
column() == 0UL ) )
1573 const size_t n(
size() );
1574 for(
size_t i=0UL; i<n; ++i )
1602 template<
typename MT
1604 , ptrdiff_t... CBAs >
1605 template<
typename Other >
1606 inline Band<MT,TF,
true,
false,CBAs...>&
1607 Band<MT,TF,true,false,CBAs...>::scale(
const Other& scalar )
1611 if( ( IsLower_v<MT> &&
column() > 0UL ) ||
1612 ( IsStrictlyLower_v<MT> &&
row() == 0UL ) ||
1613 ( IsUpper_v<MT> &&
row() > 0UL ) ||
1614 ( IsStrictlyUpper_v<MT> &&
column() == 0UL ) )
1617 const size_t n(
size() );
1618 for(
size_t i=0UL; i<n; ++i ) {
1647 template<
typename MT
1649 , ptrdiff_t... CBAs >
1650 template<
typename Other >
1651 inline bool Band<MT,TF,true,false,CBAs...>::canAlias(
const Other* alias )
const noexcept
1653 return matrix_.isAliased( alias );
1670 template<
typename MT
1672 , ptrdiff_t... CBAs >
1673 template<
typename MT2
1674 , ptrdiff_t... CBAs2 >
1676 Band<MT,TF,true,false,CBAs...>::canAlias(
const Band<MT2,TF,true,false,CBAs2...>* alias )
const noexcept
1678 return matrix_.isAliased( &alias->matrix_ ) && (
band() == alias->band() );
1695 template<
typename MT
1697 , ptrdiff_t... CBAs >
1698 template<
typename Other >
1699 inline bool Band<MT,TF,true,false,CBAs...>::isAliased(
const Other* alias )
const noexcept
1701 return matrix_.isAliased( alias );
1718 template<
typename MT
1720 , ptrdiff_t... CBAs >
1721 template<
typename MT2
1722 , ptrdiff_t... CBAs2 >
1724 Band<MT,TF,true,false,CBAs...>::isAliased(
const Band<MT2,TF,true,false,CBAs2...>* alias )
const noexcept
1726 return matrix_.isAliased( &alias->matrix_ ) && (
band() == alias->band() );
1742 template<
typename MT
1744 , ptrdiff_t... CBAs >
1745 inline bool Band<MT,TF,true,false,CBAs...>::isAligned() const noexcept
1764 template<
typename MT
1766 , ptrdiff_t... CBAs >
1767 inline bool Band<MT,TF,true,false,CBAs...>::canSMPAssign() const noexcept
1769 return (
size() > SMP_DVECASSIGN_THRESHOLD );
1787 template<
typename MT
1789 , ptrdiff_t... CBAs >
1790 template<
typename VT >
1791 inline void Band<MT,TF,true,false,CBAs...>::assign(
const DenseVector<VT,TF>& rhs )
1795 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1796 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1797 matrix_(
row()+i ,
column()+i ) = (~rhs)[i ];
1798 matrix_(
row()+i+1UL,
column()+i+1UL) = (~rhs)[i+1UL];
1800 if( ipos < (~rhs).size() ) {
1801 matrix_(
row()+ipos,
column()+ipos) = (~rhs)[ipos];
1820 template<
typename MT
1822 , ptrdiff_t... CBAs >
1823 template<
typename VT >
1824 inline void Band<MT,TF,true,false,CBAs...>::assign(
const SparseVector<VT,TF>& rhs )
1828 for( ConstIterator_t<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1829 const size_t index( element->index() );
1830 matrix_(
row()+index,
column()+index) = element->value();
1849 template<
typename MT
1851 , ptrdiff_t... CBAs >
1852 template<
typename VT >
1853 inline void Band<MT,TF,true,false,CBAs...>::addAssign(
const DenseVector<VT,TF>& rhs )
1857 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1858 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1859 matrix_(
row()+i ,
column()+i ) += (~rhs)[i ];
1860 matrix_(
row()+i+1UL,
column()+i+1UL) += (~rhs)[i+1UL];
1862 if( ipos < (~rhs).size() ) {
1863 matrix_(
row()+ipos,
column()+ipos) += (~rhs)[ipos];
1882 template<
typename MT
1884 , ptrdiff_t... CBAs >
1885 template<
typename VT >
1886 inline void Band<MT,TF,true,false,CBAs...>::addAssign(
const SparseVector<VT,TF>& rhs )
1890 for( ConstIterator_t<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1891 const size_t index( element->index() );
1892 matrix_(
row()+index,
column()+index) += element->value();
1911 template<
typename MT
1913 , ptrdiff_t... CBAs >
1914 template<
typename VT >
1915 inline void Band<MT,TF,true,false,CBAs...>::subAssign(
const DenseVector<VT,TF>& rhs )
1919 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1920 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1921 matrix_(
row()+i ,
column()+i ) -= (~rhs)[i ];
1922 matrix_(
row()+i+1UL,
column()+i+1UL) -= (~rhs)[i+1UL];
1924 if( ipos < (~rhs).size() ) {
1925 matrix_(
row()+ipos,
column()+ipos) -= (~rhs)[ipos];
1944 template<
typename MT
1946 , ptrdiff_t... CBAs >
1947 template<
typename VT >
1948 inline void Band<MT,TF,true,false,CBAs...>::subAssign(
const SparseVector<VT,TF>& rhs )
1952 for( ConstIterator_t<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1953 const size_t index( element->index() );
1954 matrix_(
row()+index,
column()+index) -= element->value();
1973 template<
typename MT
1975 , ptrdiff_t... CBAs >
1976 template<
typename VT >
1977 inline void Band<MT,TF,true,false,CBAs...>::multAssign(
const DenseVector<VT,TF>& rhs )
1981 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1982 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1983 matrix_(
row()+i ,
column()+i ) *= (~rhs)[i ];
1984 matrix_(
row()+i+1UL,
column()+i+1UL) *= (~rhs)[i+1UL];
1986 if( ipos < (~rhs).size() ) {
1987 matrix_(
row()+ipos,
column()+ipos) *= (~rhs)[ipos];
2006 template<
typename MT
2008 , ptrdiff_t... CBAs >
2009 template<
typename VT >
2010 inline void Band<MT,TF,true,false,CBAs...>::multAssign(
const SparseVector<VT,TF>& rhs )
2018 for( ConstIterator_t<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
2019 const size_t index( element->index() );
2020 for( ; i<index; ++i )
2022 matrix_(
row()+index,
column()+index) *= element->value();
2026 for( ; i<
size(); ++i ) {
2046 template<
typename MT
2048 , ptrdiff_t... CBAs >
2049 template<
typename VT >
2050 inline void Band<MT,TF,true,false,CBAs...>::divAssign(
const DenseVector<VT,TF>& rhs )
2054 const size_t ipos( (~rhs).
size() &
size_t(-2) );
2055 for(
size_t i=0UL; i<ipos; i+=2UL ) {
2056 matrix_(
row()+i ,
column()+i ) /= (~rhs)[i ];
2057 matrix_(
row()+i+1UL,
column()+i+1UL) /= (~rhs)[i+1UL];
2059 if( ipos < (~rhs).size() ) {
2060 matrix_(
row()+ipos,
column()+ipos) /= (~rhs)[ipos];
2083 template<
typename MT
2085 , ptrdiff_t... CBAs >
2086 class Band<MT,TF,true,true,CBAs...>
2087 :
public View< DenseVector< Band<MT,TF,true,true,CBAs...>, TF > >
2088 ,
private BandData<CBAs...>
2089 ,
private Computation
2094 using DataType = BandData<CBAs...>;
2097 using LeftOperand = RemoveReference_t< LeftOperand_t<MT> >;
2100 using RightOperand = RemoveReference_t< RightOperand_t<MT> >;
2106 using This = Band<MT,TF,
true,
true,CBAs...>;
2109 using BaseType = DenseVector<This,TF>;
2112 using ViewedType = MT;
2115 using ResultType = BandTrait_t<ResultType_t<MT>,CBAs...>;
2122 using CompositeType = If_t< RequiresEvaluation_v<LeftOperand> ||
2123 RequiresEvaluation_v<RightOperand>
2127 using LT = If_t< IsSparseMatrix_v<LeftOperand> && IsColumnMajorMatrix_v<LeftOperand>
2128 , ResultType_t<LeftOperand>
2129 , CompositeType_t<LeftOperand> >;
2132 using RT = If_t< IsSparseMatrix_v<RightOperand> && IsRowMajorMatrix_v<RightOperand>
2133 , ResultType_t<RightOperand>
2134 , CompositeType_t<RightOperand> >;
2139 static constexpr
bool simdEnabled =
false;
2152 template<
typename... RBAs >
2153 explicit inline Band(
const MT& mmm, RBAs... args )
2154 : DataType( args... )
2158 if( (
band() > 0L &&
column() >= mmm.columns() ) ||
2159 (
band() < 0L &&
row() >= mmm.rows() ) ) {
2176 inline ReturnType operator[](
size_t index )
const {
2178 return matrix_(
row()+index,
column()+index);
2190 if( index >=
size() ) {
2193 return (*
this)[index];
2202 inline size_t size() const noexcept {
2203 return min( matrix_.rows() -
row(), matrix_.columns() -
column() );
2218 inline const MT& operand() const noexcept {
2229 template<
typename T >
2230 inline bool canAlias(
const T* alias )
const noexcept {
2231 return matrix_.isAliased( alias );
2241 template<
typename T >
2242 inline bool isAliased(
const T* alias )
const noexcept {
2243 return matrix_.isAliased( alias );
2252 inline constexpr
bool isAligned() const noexcept {
2274 template<
typename VT >
2275 friend inline void assign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2284 LT A(
serial( rhs.operand().leftOperand() ) );
2285 RT B(
serial( rhs.operand().rightOperand() ) );
2287 const size_t n( rhs.size() );
2288 for(
size_t i=0UL; i<n; ++i ) {
2307 template<
typename VT >
2308 friend inline void assign( SparseVector<VT,TF>& lhs,
const Band& rhs )
2319 assign( ~lhs, tmp );
2336 template<
typename VT >
2337 friend inline void addAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2346 LT A(
serial( rhs.operand().leftOperand() ) );
2347 RT B(
serial( rhs.operand().rightOperand() ) );
2349 const size_t n( rhs.size() );
2350 for(
size_t i=0UL; i<n; ++i ) {
2373 template<
typename VT >
2374 friend inline void subAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2383 LT A(
serial( rhs.operand().leftOperand() ) );
2384 RT B(
serial( rhs.operand().rightOperand() ) );
2386 const size_t n( rhs.size() );
2387 for(
size_t i=0UL; i<n; ++i ) {
2411 template<
typename VT >
2412 friend inline void multAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2421 LT A(
serial( rhs.operand().leftOperand() ) );
2422 RT B(
serial( rhs.operand().rightOperand() ) );
2424 const size_t n( rhs.size() );
2425 for(
size_t i=0UL; i<n; ++i ) {
2448 template<
typename VT >
2449 friend inline void divAssign( DenseVector<VT,TF>& lhs,
const Band& rhs )
2458 LT A(
serial( rhs.operand().leftOperand() ) );
2459 RT B(
serial( rhs.operand().rightOperand() ) );
2461 const size_t n( rhs.size() );
2462 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
Header file for the blaze::checked and blaze::unchecked instances.
constexpr bool IsUniUpper_v
Auxiliary variable template for the IsUniUpper type trait.The IsUniUpper_v variable template provides...
Definition: IsUniUpper.h:172
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:354
Header file for the 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:169
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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
Header file for the IsColumnMajorMatrix type trait.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3079
Header file for the DenseVector base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
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.
constexpr bool IsUpper_v
Auxiliary variable template for the IsUpper type trait.The IsUpper_v variable template provides a con...
Definition: IsUpper.h:174
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
Header file for the RequiresEvaluation type trait.
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
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: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:3083
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
Header file for the implementation of a vector representation of an initializer list.
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3080
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:253
constexpr bool Contains_v
Auxiliary variable template for the Contains type trait.The Contains_v variable template provides a c...
Definition: Contains.h:139
Header file for the IsLower type trait.
Constraint on the data type.
Constraint on the data type.
Header file for the IsTriangular type trait.
Constraint on the data type.
constexpr bool IsStrictlyLower_v
Auxiliary variable template for the IsStrictlyLower type trait.The IsStrictlyLower_v variable templat...
Definition: IsStrictlyLower.h:172
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
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8908
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
Constraint on the data type.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:135
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_MATMATMULTEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is not a matrix/matrix multiplication expre...
Definition: MatMatMultExpr.h:63
Header file for the 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.
constexpr bool IsUniLower_v
Auxiliary variable template for the IsUniLower type trait.The IsUniLower_v variable template provides...
Definition: IsUniLower.h:172
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 IsStrictlyUpper_v
Auxiliary variable template for the IsStrictlyUpper type trait.The IsStrictlyUpper_v variable templat...
Definition: IsStrictlyUpper.h:172
constexpr bool IsLower_v
Auxiliary variable template for the IsLower type trait.The IsLower_v variable template provides a con...
Definition: IsLower.h:174
#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.
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
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.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
constexpr bool IsExpression_v
Auxiliary variable template for the IsExpression type trait.The IsExpression_v variable template prov...
Definition: IsExpression.h:131
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
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3082
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:290
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
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.
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, 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
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.