35 #ifndef _BLAZE_MATH_VIEWS_SUBMATRIX_DENSE_H_
36 #define _BLAZE_MATH_VIEWS_SUBMATRIX_DENSE_H_
127 template<
typename MT >
129 :
public DenseMatrix< Submatrix<MT,unaligned,false,true>, false >
135 typedef If_< IsExpression<MT>, MT, MT& > Operand;
140 typedef Submatrix<MT,unaligned,false,true>
This;
141 typedef DenseMatrix<This,false>
BaseType;
146 typedef SIMDTrait_<ElementType> SIMDType;
157 typedef const ElementType* ConstPointer;
160 typedef If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, ElementType* > Pointer;
166 template<
typename IteratorType >
167 class SubmatrixIterator
172 typedef typename std::iterator_traits<IteratorType>::iterator_category IteratorCategory;
175 typedef typename std::iterator_traits<IteratorType>::value_type ValueType;
178 typedef typename std::iterator_traits<IteratorType>::pointer PointerType;
181 typedef typename std::iterator_traits<IteratorType>::reference ReferenceType;
184 typedef typename std::iterator_traits<IteratorType>::difference_type DifferenceType;
187 typedef IteratorCategory iterator_category;
188 typedef ValueType value_type;
189 typedef PointerType pointer;
190 typedef ReferenceType reference;
191 typedef DifferenceType difference_type;
197 inline SubmatrixIterator()
199 , isAligned_( false )
209 inline SubmatrixIterator( IteratorType iterator,
bool isMemoryAligned )
210 : iterator_ ( iterator )
211 , isAligned_( isMemoryAligned )
220 template<
typename IteratorType2 >
221 inline SubmatrixIterator(
const SubmatrixIterator<IteratorType2>& it )
222 : iterator_ ( it.base() )
223 , isAligned_( it.isAligned() )
233 inline SubmatrixIterator&
operator+=(
size_t inc ) {
245 inline SubmatrixIterator&
operator-=(
size_t dec ) {
256 inline SubmatrixIterator& operator++() {
267 inline const SubmatrixIterator operator++(
int ) {
268 return SubmatrixIterator( iterator_++, isAligned_ );
277 inline SubmatrixIterator& operator--() {
288 inline const SubmatrixIterator operator--(
int ) {
289 return SubmatrixIterator( iterator_--, isAligned_ );
313 inline SIMDType load() const noexcept {
331 inline SIMDType
loada() const noexcept {
332 return iterator_.loada();
346 inline SIMDType
loadu() const noexcept {
347 return iterator_.loadu();
362 inline void store(
const SIMDType& value )
const {
378 inline void storea(
const SIMDType& value )
const {
379 iterator_.storea( value );
394 inline void storeu(
const SIMDType& value )
const {
396 iterator_.storea( value );
399 iterator_.storeu( value );
415 inline void stream(
const SIMDType& value )
const {
416 iterator_.stream( value );
426 inline bool operator==(
const SubmatrixIterator& rhs )
const {
427 return iterator_ == rhs.iterator_;
437 inline bool operator!=(
const SubmatrixIterator& rhs )
const {
438 return iterator_ != rhs.iterator_;
448 inline bool operator<(
const SubmatrixIterator& rhs )
const {
449 return iterator_ < rhs.iterator_;
459 inline bool operator>(
const SubmatrixIterator& rhs )
const {
460 return iterator_ > rhs.iterator_;
470 inline bool operator<=(
const SubmatrixIterator& rhs )
const {
471 return iterator_ <= rhs.iterator_;
481 inline bool operator>=(
const SubmatrixIterator& rhs )
const {
482 return iterator_ >= rhs.iterator_;
492 inline DifferenceType
operator-(
const SubmatrixIterator& rhs )
const {
493 return iterator_ - rhs.iterator_;
504 friend inline const SubmatrixIterator
operator+(
const SubmatrixIterator& it,
size_t inc ) {
505 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
516 friend inline const SubmatrixIterator
operator+(
size_t inc,
const SubmatrixIterator& it ) {
517 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
528 friend inline const SubmatrixIterator
operator-(
const SubmatrixIterator& it,
size_t dec ) {
529 return SubmatrixIterator( it.iterator_ - dec, it.isAligned_ );
538 inline IteratorType base()
const {
548 inline bool isAligned() const noexcept {
555 IteratorType iterator_;
563 typedef SubmatrixIterator< ConstIterator_<MT> >
ConstIterator;
571 enum :
bool { simdEnabled = MT::simdEnabled };
574 enum :
bool { smpAssignable = MT::smpAssignable };
580 explicit inline Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n );
592 inline Reference operator()(
size_t i,
size_t j );
593 inline ConstReference operator()(
size_t i,
size_t j )
const;
594 inline Reference at(
size_t i,
size_t j );
595 inline ConstReference at(
size_t i,
size_t j )
const;
596 inline Pointer data () noexcept;
597 inline ConstPointer data () const noexcept;
598 inline Pointer data (
size_t i ) noexcept;
599 inline ConstPointer data (
size_t i ) const noexcept;
600 inline Iterator
begin (
size_t i );
601 inline ConstIterator
begin (
size_t i ) const;
602 inline ConstIterator
cbegin(
size_t i ) const;
603 inline Iterator
end (
size_t i );
604 inline ConstIterator
end (
size_t i ) const;
605 inline ConstIterator
cend (
size_t i ) const;
612 inline Submatrix& operator=( const ElementType& rhs );
613 inline Submatrix& operator=( initializer_list< initializer_list<ElementType> > list );
614 inline Submatrix& operator=( const Submatrix& rhs );
616 template< typename MT2,
bool SO2 >
617 inline Submatrix& operator=( const Matrix<MT2,SO2>& rhs );
619 template< typename MT2,
bool SO2 >
620 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
621 operator+=( const Matrix<MT2,SO2>& rhs );
623 template< typename MT2,
bool SO2 >
624 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
625 operator+=( const Matrix<MT2,SO2>& rhs );
627 template< typename MT2,
bool SO2 >
628 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
629 operator-=( const Matrix<MT2,SO2>& rhs );
631 template< typename MT2,
bool SO2 >
632 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
633 operator-=( const Matrix<MT2,SO2>& rhs );
635 template< typename MT2,
bool SO2 >
636 inline Submatrix& operator*=( const Matrix<MT2,SO2>& rhs );
638 template< typename Other >
639 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator*=( Other rhs );
641 template< typename Other >
642 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator/=( Other rhs );
649 inline
size_t row() const noexcept;
650 inline
size_t rows() const noexcept;
651 inline
size_t column() const noexcept;
652 inline
size_t columns() const noexcept;
653 inline
size_t spacing() const noexcept;
654 inline
size_t capacity() const noexcept;
655 inline
size_t capacity(
size_t i ) const noexcept;
657 inline
size_t nonZeros(
size_t i ) const;
659 inline
void reset(
size_t i );
662 template< typename Other > inline Submatrix& scale( const Other& scalar );
669 template< typename MT2 >
670 struct VectorizedAssign {
672 simdEnabled && MT2::simdEnabled &&
673 AreSIMDCombinable< ElementType, ElementType_<MT2> >::value };
679 template<
typename MT2 >
680 struct VectorizedAddAssign {
682 simdEnabled && MT2::simdEnabled &&
683 AreSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
684 HasSIMDAdd< ElementType, ElementType_<MT2> >::value &&
685 !IsDiagonal<MT2>::value };
691 template<
typename MT2 >
692 struct VectorizedSubAssign {
694 simdEnabled && MT2::simdEnabled &&
695 AreSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
696 HasSIMDSub< ElementType, ElementType_<MT2> >::value &&
697 !IsDiagonal<MT2>::value };
710 template<
typename Other >
711 inline bool canAlias(
const Other* alias )
const noexcept;
713 template<
typename MT2,
bool AF2,
bool SO2 >
714 inline bool canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
716 template<
typename Other >
717 inline bool isAliased(
const Other* alias )
const noexcept;
719 template<
typename MT2,
bool AF2,
bool SO2 >
720 inline bool isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
722 inline bool isAligned () const noexcept;
723 inline
bool canSMPAssign() const noexcept;
734 template< typename MT2 >
735 inline
DisableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,false>& rhs );
737 template< typename MT2 >
738 inline
EnableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,false>& rhs );
740 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,true>& rhs );
741 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
742 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
744 template< typename MT2 >
745 inline
DisableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,false>& rhs );
747 template< typename MT2 >
748 inline
EnableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,false>& rhs );
750 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,true>& rhs );
751 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
752 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
754 template< typename MT2 >
755 inline
DisableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,false>& rhs );
757 template< typename MT2 >
758 inline
EnableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,false>& rhs );
760 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,true>& rhs );
761 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
762 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
770 inline
bool hasOverlap() const noexcept;
779 const
size_t column_;
782 const
bool isAligned_;
793 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 > friend class Submatrix;
795 template<
bool AF1, typename MT2,
bool AF2,
bool SO2,
bool DF2 >
796 friend const Submatrix<MT2,AF1,SO2,DF2>
797 submatrix( const Submatrix<MT2,AF2,SO2,DF2>& sm,
size_t row,
size_t column,
size_t m,
size_t n );
799 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
800 friend
bool isIntact( const Submatrix<MT2,AF2,SO2,DF2>& sm ) noexcept;
802 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
803 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Matrix<MT2,SO2>& b ) noexcept;
805 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
806 friend
bool isSame( const Matrix<MT2,SO2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
808 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
809 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
811 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
812 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
813 size_t row,
size_t column );
815 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
816 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
817 size_t row,
size_t column );
819 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
820 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
821 size_t row,
size_t column );
823 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
824 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
825 size_t row,
size_t column );
827 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
828 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
829 size_t row,
size_t column );
831 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
832 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
833 size_t row,
size_t column );
835 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
836 friend
bool tryMultAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
837 size_t row,
size_t column );
839 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
840 friend
DerestrictTrait_< Submatrix<MT2,AF2,SO2,DF2> > derestrict( Submatrix<MT2,AF2,SO2,DF2>& sm );
879 template< typename MT >
880 inline Submatrix<MT,
unaligned,false,true>::Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n )
886 , isAligned_( simdEnabled && matrix.data() !=
nullptr &&
checkAlignment( data() ) &&
887 ( m < 2UL || ( matrix.
spacing() &
size_t(-SIMDSIZE) ) == 0UL ) )
889 if( ( row_ + m_ > matrix_.rows() ) || ( column_ + n_ > matrix_.columns() ) ) {
916 template<
typename MT >
918 Submatrix<MT,unaligned,false,true>::operator()(
size_t i,
size_t j )
923 return matrix_(row_+i,column_+j);
940 template<
typename MT >
942 Submatrix<MT,unaligned,false,true>::operator()(
size_t i,
size_t j )
const
947 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
965 template<
typename MT >
967 Submatrix<MT,unaligned,false,true>::at(
size_t i,
size_t j )
993 template<
typename MT >
995 Submatrix<MT,unaligned,false,true>::at(
size_t i,
size_t j )
const
1003 return (*
this)(i,j);
1019 template<
typename MT >
1020 inline typename Submatrix<MT,unaligned,false,true>::Pointer
1021 Submatrix<MT,unaligned,false,true>::data() noexcept
1023 return matrix_.data() + row_*
spacing() + column_;
1039 template<
typename MT >
1040 inline typename Submatrix<MT,unaligned,false,true>::ConstPointer
1041 Submatrix<MT,unaligned,false,true>::data() const noexcept
1043 return matrix_.data() + row_*
spacing() + column_;
1058 template<
typename MT >
1059 inline typename Submatrix<MT,unaligned,false,true>::Pointer
1060 Submatrix<MT,unaligned,false,true>::data(
size_t i ) noexcept
1062 return matrix_.data() + (row_+i)*
spacing() + column_;
1077 template<
typename MT >
1078 inline typename Submatrix<MT,unaligned,false,true>::ConstPointer
1079 Submatrix<MT,unaligned,false,true>::data(
size_t i )
const noexcept
1081 return matrix_.data() + (row_+i)*
spacing() + column_;
1099 template<
typename MT >
1104 return Iterator( matrix_.begin( row_ + i ) + column_, isAligned_ );
1122 template<
typename MT >
1127 return ConstIterator( matrix_.cbegin( row_ + i ) + column_, isAligned_ );
1145 template<
typename MT >
1150 return ConstIterator( matrix_.cbegin( row_ + i ) + column_, isAligned_ );
1168 template<
typename MT >
1173 return Iterator( matrix_.begin( row_ + i ) + column_ +
n_, isAligned_ );
1191 template<
typename MT >
1196 return ConstIterator( matrix_.cbegin( row_ + i ) + column_ +
n_, isAligned_ );
1214 template<
typename MT >
1219 return ConstIterator( matrix_.cbegin( row_ + i ) + column_ +
n_, isAligned_ );
1244 template<
typename MT >
1245 inline Submatrix<MT,unaligned,false,true>&
1246 Submatrix<MT,unaligned,false,true>::operator=(
const ElementType& rhs )
1248 const size_t iend( row_ + m_ );
1250 for(
size_t i=row_; i<iend; ++i )
1252 const size_t jbegin( ( IsUpper<MT>::value )
1253 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
1254 ?(
max( i+1UL, column_ ) )
1255 :(
max( i, column_ ) ) )
1257 const size_t jend ( ( IsLower<MT>::value )
1258 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
1259 ?(
min( i, column_+n_ ) )
1260 :(
min( i+1UL, column_+n_ ) ) )
1263 for(
size_t j=jbegin; j<jend; ++j )
1286 template<
typename MT >
1287 inline Submatrix<MT,unaligned,false,true>&
1288 Submatrix<MT,unaligned,false,true>::operator=( initializer_list< initializer_list<ElementType> > list )
1296 for(
const auto& rowList : list ) {
1297 std::fill( std::copy( rowList.begin(), rowList.end(),
begin(i) ),
end(i),
ElementType() );
1322 template<
typename MT >
1323 inline Submatrix<MT,unaligned,false,true>&
1324 Submatrix<MT,unaligned,false,true>::operator=(
const Submatrix& rhs )
1329 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
1332 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
1336 if( !tryAssign( matrix_, rhs, row_, column_ ) ) {
1340 DerestrictTrait_<This> left( derestrict( *
this ) );
1342 if( rhs.canAlias( &matrix_ ) ) {
1343 const ResultType tmp( rhs );
1373 template<
typename MT >
1374 template<
typename MT2
1376 inline Submatrix<MT,unaligned,false,true>&
1377 Submatrix<MT,unaligned,false,true>::operator=(
const Matrix<MT2,SO2>& rhs )
1385 typedef If_< IsRestricted<MT>, CompositeType_<MT2>,
const MT2& > Right;
1386 Right right( ~rhs );
1388 if( !tryAssign( matrix_, right, row_, column_ ) ) {
1392 if( IsSparseMatrix<MT2>::value )
1395 DerestrictTrait_<This> left( derestrict( *
this ) );
1397 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1398 const ResultType_<MT2> tmp( right );
1427 template<
typename MT >
1428 template<
typename MT2
1430 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,false,true>& >
1437 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
1446 if( !tryAddAssign( matrix_, ~rhs, row_, column_ ) ) {
1450 DerestrictTrait_<This> left( derestrict( *
this ) );
1452 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
1453 (~rhs).canAlias( &matrix_ ) ) {
1454 const AddType tmp( *
this + (~rhs) );
1483 template<
typename MT >
1484 template<
typename MT2
1486 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,false,true>& >
1493 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
1502 const AddType tmp( *
this + (~rhs) );
1504 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
1508 DerestrictTrait_<This> left( derestrict( *
this ) );
1534 template<
typename MT >
1535 template<
typename MT2
1537 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,false,true>& >
1544 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
1553 if( !trySubAssign( matrix_, ~rhs, row_, column_ ) ) {
1557 DerestrictTrait_<This> left( derestrict( *
this ) );
1559 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
1560 (~rhs).canAlias( &matrix_ ) ) {
1561 const SubType tmp( *
this - (~rhs ) );
1590 template<
typename MT >
1591 template<
typename MT2
1593 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,false,true>& >
1600 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
1609 const SubType tmp( *
this - (~rhs) );
1611 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
1615 DerestrictTrait_<This> left( derestrict( *
this ) );
1641 template<
typename MT >
1642 template<
typename MT2
1644 inline Submatrix<MT,unaligned,false,true>&
1651 typedef MultTrait_< ResultType, ResultType_<MT2> > MultType;
1660 const MultType tmp( *
this * (~rhs) );
1662 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
1666 DerestrictTrait_<This> left( derestrict( *
this ) );
1689 template<
typename MT >
1690 template<
typename Other >
1691 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,unaligned,false,true> >&
1696 DerestrictTrait_<This> left( derestrict( *
this ) );
1718 template<
typename MT >
1719 template<
typename Other >
1720 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,unaligned,false,true> >&
1727 DerestrictTrait_<This> left( derestrict( *
this ) );
1750 template<
typename MT >
1765 template<
typename MT >
1780 template<
typename MT >
1794 template<
typename MT >
1814 template<
typename MT >
1817 return matrix_.spacing();
1828 template<
typename MT >
1849 template<
typename MT >
1868 template<
typename MT >
1871 const size_t iend( row_ + m_ );
1872 const size_t jend( column_ + n_ );
1873 size_t nonzeros( 0UL );
1875 for(
size_t i=row_; i<iend; ++i )
1876 for(
size_t j=column_; j<jend; ++j )
1898 template<
typename MT >
1903 const size_t jend( column_ + n_ );
1904 size_t nonzeros( 0UL );
1906 for(
size_t j=column_; j<jend; ++j )
1922 template<
typename MT >
1927 for(
size_t i=row_; i<row_+
m_; ++i )
1929 const size_t jbegin( ( IsUpper<MT>::value )
1930 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
1931 ?(
max( i+1UL, column_ ) )
1932 :(
max( i, column_ ) ) )
1934 const size_t jend ( ( IsLower<MT>::value )
1935 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
1936 ?(
min( i, column_+n_ ) )
1937 :(
min( i+1UL, column_+n_ ) ) )
1940 for(
size_t j=jbegin; j<jend; ++j )
1941 clear( matrix_(i,j) );
1960 template<
typename MT >
1967 const size_t jbegin( ( IsUpper<MT>::value )
1968 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
1969 ?(
max( i+1UL, column_ ) )
1970 :(
max( i, column_ ) ) )
1972 const size_t jend ( ( IsLower<MT>::value )
1973 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
1974 ?(
min( i, column_+n_ ) )
1975 :(
min( i+1UL, column_+n_ ) ) )
1978 for(
size_t j=jbegin; j<jend; ++j )
1979 clear( matrix_(row_+i,j) );
2003 template<
typename MT >
2010 if( !tryAssign( matrix_,
trans( *
this ), row_, column_ ) ) {
2014 DerestrictTrait_<This> left( derestrict( *
this ) );
2015 const ResultType tmp(
trans( *
this ) );
2042 template<
typename MT >
2049 if( !tryAssign( matrix_,
ctrans( *
this ), row_, column_ ) ) {
2053 DerestrictTrait_<This> left( derestrict( *
this ) );
2054 const ResultType tmp(
ctrans( *
this ) );
2074 template<
typename MT >
2075 template<
typename Other >
2076 inline Submatrix<MT,unaligned,false,true>&
2077 Submatrix<MT,unaligned,false,true>::scale(
const Other& scalar )
2081 const size_t iend( row_ + m_ );
2083 for(
size_t i=row_; i<iend; ++i )
2085 const size_t jbegin( ( IsUpper<MT>::value )
2086 ?( ( IsStrictlyUpper<MT>::value )
2087 ?(
max( i+1UL, column_ ) )
2088 :(
max( i, column_ ) ) )
2090 const size_t jend ( ( IsLower<MT>::value )
2091 ?( ( IsStrictlyLower<MT>::value )
2092 ?(
min( i, column_+n_ ) )
2093 :(
min( i+1UL, column_+n_ ) ) )
2096 for(
size_t j=jbegin; j<jend; ++j )
2097 matrix_(i,j) *= scalar;
2116 template<
typename MT >
2117 inline bool Submatrix<MT,unaligned,false,true>::hasOverlap() const noexcept
2119 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
2121 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
2148 template<
typename MT >
2149 template<
typename Other >
2150 inline bool Submatrix<MT,unaligned,false,true>::canAlias(
const Other* alias )
const noexcept
2152 return matrix_.isAliased( alias );
2169 template<
typename MT >
2170 template<
typename MT2
2173 inline bool Submatrix<MT,unaligned,false,true>::canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
2175 return ( matrix_.isAliased( &alias->matrix_ ) &&
2176 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
2177 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
2194 template<
typename MT >
2195 template<
typename Other >
2196 inline bool Submatrix<MT,unaligned,false,true>::isAliased(
const Other* alias )
const noexcept
2198 return matrix_.isAliased( alias );
2215 template<
typename MT >
2216 template<
typename MT2
2219 inline bool Submatrix<MT,unaligned,false,true>::isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
2221 return ( matrix_.isAliased( &alias->matrix_ ) &&
2222 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
2223 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
2239 template<
typename MT >
2240 inline bool Submatrix<MT,unaligned,false,true>::isAligned() const noexcept
2259 template<
typename MT >
2260 inline bool Submatrix<MT,unaligned,false,true>::canSMPAssign() const noexcept
2262 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
2284 template<
typename MT >
2286 Submatrix<MT,unaligned,false,true>::load(
size_t i,
size_t j )
const noexcept
2289 return loada( i, j );
2291 return loadu( i, j );
2313 template<
typename MT >
2324 return matrix_.loada( row_+i, column_+j );
2346 template<
typename MT >
2357 return matrix_.loadu( row_+i, column_+j );
2380 template<
typename MT >
2382 Submatrix<MT,unaligned,false,true>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
2410 template<
typename MT >
2421 matrix_.storea( row_+i, column_+j, value );
2444 template<
typename MT >
2455 matrix_.storeu( row_+i, column_+j, value );
2478 template<
typename MT >
2490 matrix_.stream( row_+i, column_+j, value );
2492 matrix_.storeu( row_+i, column_+j, value );
2510 template<
typename MT >
2511 template<
typename MT2 >
2512 inline DisableIf_< typename Submatrix<MT,unaligned,false,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
2513 Submatrix<MT,unaligned,false,true>::assign(
const DenseMatrix<MT2,false>& rhs )
2518 const size_t jpos( n_ &
size_t(-2) );
2521 for(
size_t i=0UL; i<
m_; ++i ) {
2522 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2523 matrix_(row_+i,column_+j ) = (~rhs)(i,j );
2524 matrix_(row_+i,column_+j+1UL) = (~rhs)(i,j+1UL);
2527 matrix_(row_+i,column_+jpos) = (~rhs)(i,jpos);
2547 template<
typename MT >
2548 template<
typename MT2 >
2549 inline EnableIf_< typename Submatrix<MT,unaligned,false,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
2550 Submatrix<MT,unaligned,false,true>::assign(
const DenseMatrix<MT2,false>& rhs )
2557 const size_t jpos( n_ &
size_t(-SIMDSIZE) );
2561 m_*n_ > (
cacheSize / (
sizeof(ElementType) * 3UL ) ) &&
2562 !(~rhs).isAliased( &matrix_ ) )
2564 for(
size_t i=0UL; i<
m_; ++i )
2567 Iterator left(
begin(i) );
2568 ConstIterator_<MT2> right( (~rhs).
begin(i) );
2570 for( ; j<jpos; j+=SIMDSIZE ) {
2571 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2573 for( ; j<
n_; ++j ) {
2580 for(
size_t i=0UL; i<
m_; ++i )
2583 Iterator left(
begin(i) );
2584 ConstIterator_<MT2> right( (~rhs).
begin(i) );
2586 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2587 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2588 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2589 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2590 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2592 for( ; j<jpos; j+=SIMDSIZE ) {
2593 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2595 for( ; j<
n_; ++j ) {
2596 *left = *right; ++left; ++right;
2617 template<
typename MT >
2618 template<
typename MT2 >
2619 inline void Submatrix<MT,unaligned,false,true>::assign(
const DenseMatrix<MT2,true>& rhs )
2626 const size_t block( BLOCK_SIZE );
2628 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2629 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2630 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2631 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2632 for(
size_t i=ii; i<iend; ++i ) {
2633 for(
size_t j=jj; j<jend; ++j ) {
2634 matrix_(row_+i,column_+j) = (~rhs)(i,j);
2656 template<
typename MT >
2657 template<
typename MT2 >
2658 inline void Submatrix<MT,unaligned,false,true>::assign(
const SparseMatrix<MT2,false>& rhs )
2663 for(
size_t i=0UL; i<
m_; ++i )
2664 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
2665 matrix_(row_+i,column_+element->index()) = element->value();
2683 template<
typename MT >
2684 template<
typename MT2 >
2685 inline void Submatrix<MT,unaligned,false,true>::assign(
const SparseMatrix<MT2,true>& rhs )
2692 for(
size_t j=0UL; j<
n_; ++j )
2693 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2694 matrix_(row_+element->index(),column_+j) = element->value();
2712 template<
typename MT >
2713 template<
typename MT2 >
2714 inline DisableIf_< typename Submatrix<MT,unaligned,false,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
2715 Submatrix<MT,unaligned,false,true>::addAssign(
const DenseMatrix<MT2,false>& rhs )
2720 const size_t jpos( n_ &
size_t(-2) );
2723 for(
size_t i=0UL; i<
m_; ++i )
2725 if( IsDiagonal<MT2>::value ) {
2726 matrix_(row_+i,column_+i) += (~rhs)(i,i);
2729 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2730 matrix_(row_+i,column_+j ) += (~rhs)(i,j );
2731 matrix_(row_+i,column_+j+1UL) += (~rhs)(i,j+1UL);
2734 matrix_(row_+i,column_+jpos) += (~rhs)(i,jpos);
2755 template<
typename MT >
2756 template<
typename MT2 >
2757 inline EnableIf_< typename Submatrix<MT,unaligned,false,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
2758 Submatrix<MT,unaligned,false,true>::addAssign(
const DenseMatrix<MT2,false>& rhs )
2765 for(
size_t i=0UL; i<
m_; ++i )
2767 const size_t jbegin( ( IsUpper<MT2>::value )
2768 ?( ( IsStrictlyUpper<MT2>::value ? i+1UL : i ) &
size_t(-SIMDSIZE) )
2770 const size_t jend ( ( IsLower<MT2>::value )
2771 ?( IsStrictlyLower<MT2>::value ? i : i+1UL )
2775 const size_t jpos( jend &
size_t(-SIMDSIZE) );
2779 Iterator left(
begin(i) + jbegin );
2780 ConstIterator_<MT2> right( (~rhs).
begin(i) + jbegin );
2782 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2783 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2784 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2785 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2786 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2788 for( ; j<jpos; j+=SIMDSIZE ) {
2789 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2791 for( ; j<jend; ++j ) {
2792 *left += *right; ++left; ++right;
2812 template<
typename MT >
2813 template<
typename MT2 >
2814 inline void Submatrix<MT,unaligned,false,true>::addAssign(
const DenseMatrix<MT2,true>& rhs )
2821 const size_t block( BLOCK_SIZE );
2823 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2824 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2825 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2826 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2827 for(
size_t i=ii; i<iend; ++i ) {
2828 for(
size_t j=jj; j<jend; ++j ) {
2829 matrix_(row_+i,column_+j) += (~rhs)(i,j);
2851 template<
typename MT >
2852 template<
typename MT2 >
2853 inline void Submatrix<MT,unaligned,false,true>::addAssign(
const SparseMatrix<MT2,false>& rhs )
2858 for(
size_t i=0UL; i<
m_; ++i )
2859 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
2860 matrix_(row_+i,column_+element->index()) += element->value();
2878 template<
typename MT >
2879 template<
typename MT2 >
2880 inline void Submatrix<MT,unaligned,false,true>::addAssign(
const SparseMatrix<MT2,true>& rhs )
2887 for(
size_t j=0UL; j<
n_; ++j )
2888 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2889 matrix_(row_+element->index(),column_+j) += element->value();
2907 template<
typename MT >
2908 template<
typename MT2 >
2909 inline DisableIf_< typename Submatrix<MT,unaligned,false,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
2910 Submatrix<MT,unaligned,false,true>::subAssign(
const DenseMatrix<MT2,false>& rhs )
2915 const size_t jpos( n_ &
size_t(-2) );
2918 for(
size_t i=0UL; i<
m_; ++i )
2920 if( IsDiagonal<MT2>::value ) {
2921 matrix_(row_+i,column_+i) -= (~rhs)(i,i);
2924 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2925 matrix_(row_+i,column_+j ) -= (~rhs)(i,j );
2926 matrix_(row_+i,column_+j+1UL) -= (~rhs)(i,j+1UL);
2929 matrix_(row_+i,column_+jpos) -= (~rhs)(i,jpos);
2950 template<
typename MT >
2951 template<
typename MT2 >
2952 inline EnableIf_< typename Submatrix<MT,unaligned,false,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
2953 Submatrix<MT,unaligned,false,true>::subAssign(
const DenseMatrix<MT2,false>& rhs )
2960 for(
size_t i=0UL; i<
m_; ++i )
2962 const size_t jbegin( ( IsUpper<MT2>::value )
2963 ?( ( IsStrictlyUpper<MT2>::value ? i+1UL : i ) &
size_t(-SIMDSIZE) )
2965 const size_t jend ( ( IsLower<MT2>::value )
2966 ?( IsStrictlyLower<MT2>::value ? i : i+1UL )
2970 const size_t jpos( jend &
size_t(-SIMDSIZE) );
2974 Iterator left(
begin(i) + jbegin );
2975 ConstIterator_<MT2> right( (~rhs).
begin(i) + jbegin );
2977 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2978 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2979 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2980 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2981 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2983 for( ; j<jpos; j+=SIMDSIZE ) {
2984 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2986 for( ; j<jend; ++j ) {
2987 *left -= *right; ++left; ++right;
3007 template<
typename MT >
3008 template<
typename MT2 >
3009 inline void Submatrix<MT,unaligned,false,true>::subAssign(
const DenseMatrix<MT2,true>& rhs )
3016 const size_t block( BLOCK_SIZE );
3018 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
3019 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
3020 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
3021 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
3022 for(
size_t i=ii; i<iend; ++i ) {
3023 for(
size_t j=jj; j<jend; ++j ) {
3024 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
3046 template<
typename MT >
3047 template<
typename MT2 >
3048 inline void Submatrix<MT,unaligned,false,true>::subAssign(
const SparseMatrix<MT2,false>& rhs )
3053 for(
size_t i=0UL; i<
m_; ++i )
3054 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
3055 matrix_(row_+i,column_+element->index()) -= element->value();
3073 template<
typename MT >
3074 template<
typename MT2 >
3075 inline void Submatrix<MT,unaligned,false,true>::subAssign(
const SparseMatrix<MT2,true>& rhs )
3082 for(
size_t j=0UL; j<
n_; ++j )
3083 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
3084 matrix_(row_+element->index(),column_+j) -= element->value();
3110 template<
typename MT >
3111 class Submatrix<MT,unaligned,true,true>
3112 :
public DenseMatrix< Submatrix<MT,unaligned,true,true>, true >
3118 typedef If_< IsExpression<MT>, MT, MT& > Operand;
3123 typedef Submatrix<MT,unaligned,true,true>
This;
3124 typedef DenseMatrix<This,true>
BaseType;
3129 typedef SIMDTrait_<ElementType> SIMDType;
3140 typedef const ElementType* ConstPointer;
3143 typedef If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, ElementType* > Pointer;
3149 template<
typename IteratorType >
3150 class SubmatrixIterator
3155 typedef typename std::iterator_traits<IteratorType>::iterator_category IteratorCategory;
3158 typedef typename std::iterator_traits<IteratorType>::value_type ValueType;
3161 typedef typename std::iterator_traits<IteratorType>::pointer PointerType;
3164 typedef typename std::iterator_traits<IteratorType>::reference ReferenceType;
3167 typedef typename std::iterator_traits<IteratorType>::difference_type DifferenceType;
3170 typedef IteratorCategory iterator_category;
3171 typedef ValueType value_type;
3172 typedef PointerType pointer;
3173 typedef ReferenceType reference;
3174 typedef DifferenceType difference_type;
3180 inline SubmatrixIterator()
3182 , isAligned_( false )
3194 inline SubmatrixIterator( IteratorType iterator,
bool isMemoryAligned )
3195 : iterator_ ( iterator )
3196 , isAligned_( isMemoryAligned )
3205 template<
typename IteratorType2 >
3206 inline SubmatrixIterator(
const SubmatrixIterator<IteratorType2>& it )
3207 : iterator_ ( it.base() )
3208 , isAligned_( it.isAligned() )
3218 inline SubmatrixIterator&
operator+=(
size_t inc ) {
3230 inline SubmatrixIterator&
operator-=(
size_t dec ) {
3241 inline SubmatrixIterator& operator++() {
3252 inline const SubmatrixIterator operator++(
int ) {
3253 return SubmatrixIterator( iterator_++, isAligned_ );
3262 inline SubmatrixIterator& operator--() {
3273 inline const SubmatrixIterator operator--(
int ) {
3274 return SubmatrixIterator( iterator_--, isAligned_ );
3283 inline ReferenceType
operator*()
const {
3298 inline SIMDType load() const noexcept {
3316 inline SIMDType
loada() const noexcept {
3317 return iterator_.loada();
3331 inline SIMDType
loadu() const noexcept {
3332 return iterator_.loadu();
3347 inline void store(
const SIMDType& value )
const {
3363 inline void storea(
const SIMDType& value )
const {
3364 iterator_.storea( value );
3379 inline void storeu(
const SIMDType& value )
const {
3381 iterator_.storea( value );
3384 iterator_.storeu( value );
3400 inline void stream(
const SIMDType& value )
const {
3401 iterator_.stream( value );
3411 inline bool operator==(
const SubmatrixIterator& rhs )
const {
3412 return iterator_ == rhs.iterator_;
3422 inline bool operator!=(
const SubmatrixIterator& rhs )
const {
3423 return iterator_ != rhs.iterator_;
3433 inline bool operator<(
const SubmatrixIterator& rhs )
const {
3434 return iterator_ < rhs.iterator_;
3444 inline bool operator>(
const SubmatrixIterator& rhs )
const {
3445 return iterator_ > rhs.iterator_;
3455 inline bool operator<=(
const SubmatrixIterator& rhs )
const {
3456 return iterator_ <= rhs.iterator_;
3466 inline bool operator>=(
const SubmatrixIterator& rhs )
const {
3467 return iterator_ >= rhs.iterator_;
3477 inline DifferenceType
operator-(
const SubmatrixIterator& rhs )
const {
3478 return iterator_ - rhs.iterator_;
3489 friend inline const SubmatrixIterator
operator+(
const SubmatrixIterator& it,
size_t inc ) {
3490 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
3501 friend inline const SubmatrixIterator
operator+(
size_t inc,
const SubmatrixIterator& it ) {
3502 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
3513 friend inline const SubmatrixIterator
operator-(
const SubmatrixIterator& it,
size_t dec ) {
3514 return SubmatrixIterator( it.iterator_ - dec, it.isAligned_ );
3523 inline IteratorType base()
const {
3533 inline bool isAligned() const noexcept {
3540 IteratorType iterator_;
3548 typedef SubmatrixIterator< ConstIterator_<MT> >
ConstIterator;
3556 enum :
bool { simdEnabled = MT::simdEnabled };
3559 enum :
bool { smpAssignable = MT::smpAssignable };
3565 explicit inline Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n );
3577 inline Reference operator()(
size_t i,
size_t j );
3578 inline ConstReference operator()(
size_t i,
size_t j )
const;
3579 inline Reference at(
size_t i,
size_t j );
3580 inline ConstReference at(
size_t i,
size_t j )
const;
3581 inline Pointer data () noexcept;
3582 inline ConstPointer data () const noexcept;
3583 inline Pointer data (
size_t j ) noexcept;
3584 inline ConstPointer data (
size_t j ) const noexcept;
3585 inline Iterator
begin (
size_t j );
3586 inline ConstIterator
begin (
size_t j ) const;
3587 inline ConstIterator
cbegin(
size_t j ) const;
3588 inline Iterator
end (
size_t j );
3589 inline ConstIterator
end (
size_t j ) const;
3590 inline ConstIterator
cend (
size_t j ) const;
3597 inline Submatrix& operator=( const ElementType& rhs );
3598 inline Submatrix& operator=( initializer_list< initializer_list<ElementType> > list );
3599 inline Submatrix& operator=( const Submatrix& rhs );
3601 template< typename MT2,
bool SO >
3602 inline Submatrix& operator=( const Matrix<MT2,SO>& rhs );
3604 template< typename MT2,
bool SO >
3605 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3606 operator+=( const Matrix<MT2,SO>& rhs );
3608 template< typename MT2,
bool SO >
3609 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3610 operator+=( const Matrix<MT2,SO>& rhs );
3612 template< typename MT2,
bool SO >
3613 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3614 operator-=( const Matrix<MT2,SO>& rhs );
3616 template< typename MT2,
bool SO >
3617 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3618 operator-=( const Matrix<MT2,SO>& rhs );
3620 template< typename MT2,
bool SO >
3621 inline Submatrix& operator*=( const Matrix<MT2,SO>& rhs );
3623 template< typename Other >
3624 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator*=( Other rhs );
3626 template< typename Other >
3627 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator/=( Other rhs );
3634 inline
size_t row() const noexcept;
3635 inline
size_t rows() const noexcept;
3636 inline
size_t column() const noexcept;
3637 inline
size_t columns() const noexcept;
3638 inline
size_t spacing() const noexcept;
3639 inline
size_t capacity() const noexcept;
3640 inline
size_t capacity(
size_t i ) const noexcept;
3642 inline
size_t nonZeros(
size_t i ) const;
3643 inline
void reset();
3644 inline
void reset(
size_t i );
3647 template< typename Other > inline Submatrix& scale( const Other& scalar );
3654 template< typename MT2 >
3655 struct VectorizedAssign {
3657 simdEnabled && MT2::simdEnabled &&
3658 AreSIMDCombinable< ElementType, ElementType_<MT2> >::value };
3664 template<
typename MT2 >
3665 struct VectorizedAddAssign {
3667 simdEnabled && MT2::simdEnabled &&
3668 AreSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
3669 HasSIMDAdd< ElementType, ElementType_<MT2> >::value &&
3670 !IsDiagonal<MT2>::value };
3676 template<
typename MT2 >
3677 struct VectorizedSubAssign {
3679 simdEnabled && MT2::simdEnabled &&
3680 AreSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
3681 HasSIMDSub< ElementType, ElementType_<MT2> >::value &&
3682 !IsDiagonal<MT2>::value };
3695 template<
typename Other >
3696 inline bool canAlias(
const Other* alias )
const noexcept;
3698 template<
typename MT2,
bool AF2,
bool SO2 >
3699 inline bool canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
3701 template<
typename Other >
3702 inline bool isAliased(
const Other* alias )
const noexcept;
3704 template<
typename MT2,
bool AF2,
bool SO2 >
3705 inline bool isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
3707 inline bool isAligned () const noexcept;
3708 inline
bool canSMPAssign() const noexcept;
3719 template< typename MT2 >
3720 inline
DisableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,true>& rhs );
3722 template< typename MT2 >
3723 inline
EnableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,true>& rhs );
3725 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,false>& rhs );
3726 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
3727 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
3729 template< typename MT2 >
3730 inline
DisableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,true>& rhs );
3732 template< typename MT2 >
3733 inline
EnableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,true>& rhs );
3735 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,false>& rhs );
3736 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
3737 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
3739 template< typename MT2 >
3740 inline
DisableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,true>& rhs );
3742 template< typename MT2 >
3743 inline
EnableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,true>& rhs );
3745 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,false>& rhs );
3746 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
3747 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
3755 inline
bool hasOverlap() const noexcept;
3764 const
size_t column_;
3767 const
bool isAligned_;
3778 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 > friend class Submatrix;
3780 template<
bool AF1, typename MT2,
bool AF2,
bool SO2,
bool DF2 >
3781 friend const Submatrix<MT2,AF1,SO2,DF2>
3782 submatrix( const Submatrix<MT2,AF2,SO2,DF2>& sm,
size_t row,
size_t column,
size_t m,
size_t n );
3784 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
3785 friend
bool isIntact( const Submatrix<MT2,AF2,SO2,DF2>& sm ) noexcept;
3787 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
3788 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Matrix<MT2,SO2>& b ) noexcept;
3790 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
3791 friend
bool isSame( const Matrix<MT2,SO2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
3793 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
3794 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
3796 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
3797 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
3798 size_t row,
size_t column );
3800 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
3801 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
3802 size_t row,
size_t column );
3804 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
3805 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
3806 size_t row,
size_t column );
3808 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
3809 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
3810 size_t row,
size_t column );
3812 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
3813 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
3814 size_t row,
size_t column );
3816 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
3817 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
3818 size_t row,
size_t column );
3820 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
3821 friend
bool tryMultAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
3822 size_t row,
size_t column );
3824 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
3825 friend
DerestrictTrait_< Submatrix<MT2,AF2,SO2,DF2> > derestrict( Submatrix<MT2,AF2,SO2,DF2>& sm );
3864 template< typename MT >
3865 inline Submatrix<MT,unaligned,true,true>::Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n )
3866 : matrix_ ( matrix )
3868 , column_ ( cindex )
3871 , isAligned_( simdEnabled && matrix.data() !=
nullptr &&
checkAlignment( data() ) &&
3872 ( n < 2UL || ( matrix.
spacing() &
size_t(-SIMDSIZE) ) == 0UL ) )
3874 if( ( row_ + m_ > matrix_.rows() ) || ( column_ + n_ > matrix_.columns() ) ) {
3901 template<
typename MT >
3903 Submatrix<MT,unaligned,true,true>::operator()(
size_t i,
size_t j )
3908 return matrix_(row_+i,column_+j);
3925 template<
typename MT >
3927 Submatrix<MT,unaligned,true,true>::operator()(
size_t i,
size_t j )
const
3932 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
3950 template<
typename MT >
3952 Submatrix<MT,unaligned,true,true>::at(
size_t i,
size_t j )
3960 return (*
this)(i,j);
3978 template<
typename MT >
3980 Submatrix<MT,unaligned,true,true>::at(
size_t i,
size_t j )
const
3988 return (*
this)(i,j);
4004 template<
typename MT >
4005 inline typename Submatrix<MT,unaligned,true,true>::Pointer
4006 Submatrix<MT,unaligned,true,true>::data() noexcept
4008 return matrix_.data() + row_ + column_*
spacing();
4024 template<
typename MT >
4025 inline typename Submatrix<MT,unaligned,true,true>::ConstPointer
4026 Submatrix<MT,unaligned,true,true>::data() const noexcept
4028 return matrix_.data() + row_ + column_*
spacing();
4043 template<
typename MT >
4044 inline typename Submatrix<MT,unaligned,true,true>::Pointer
4045 Submatrix<MT,unaligned,true,true>::data(
size_t j ) noexcept
4047 return matrix_.data() + row_ + (column_+j)*
spacing();
4062 template<
typename MT >
4063 inline typename Submatrix<MT,unaligned,true,true>::ConstPointer
4064 Submatrix<MT,unaligned,true,true>::data(
size_t j )
const noexcept
4066 return matrix_.data() + row_ + (column_+j)*
spacing();
4079 template<
typename MT >
4084 return Iterator( matrix_.begin( column_ + j ) + row_, isAligned_ );
4097 template<
typename MT >
4102 return ConstIterator( matrix_.cbegin( column_ + j ) + row_, isAligned_ );
4115 template<
typename MT >
4120 return ConstIterator( matrix_.cbegin( column_ + j ) + row_, isAligned_ );
4133 template<
typename MT >
4138 return Iterator( matrix_.begin( column_ + j ) + row_ +
m_, isAligned_ );
4151 template<
typename MT >
4156 return ConstIterator( matrix_.cbegin( column_ + j ) + row_ +
m_, isAligned_ );
4169 template<
typename MT >
4174 return ConstIterator( matrix_.cbegin( column_ + j ) + row_ +
m_, isAligned_ );
4199 template<
typename MT >
4200 inline Submatrix<MT,unaligned,true,true>&
4201 Submatrix<MT,unaligned,true,true>::operator=(
const ElementType& rhs )
4203 const size_t jend( column_ + n_ );
4205 for(
size_t j=column_; j<jend; ++j )
4207 const size_t ibegin( ( IsLower<MT>::value )
4208 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4209 ?(
max( j+1UL, row_ ) )
4210 :(
max( j, row_ ) ) )
4212 const size_t iend ( ( IsUpper<MT>::value )
4213 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4214 ?(
min( j, row_+m_ ) )
4215 :(
min( j+1UL, row_+m_ ) ) )
4218 for(
size_t i=ibegin; i<iend; ++i )
4241 template<
typename MT >
4242 inline Submatrix<MT,unaligned,true,true>&
4243 Submatrix<MT,unaligned,true,true>::operator=( initializer_list< initializer_list<ElementType> > list )
4251 for(
const auto& rowList : list ) {
4253 for(
const auto& element : rowList ) {
4254 matrix_(row_+i,column_+j) = element;
4257 for( ; j<
n_; ++j ) {
4284 template<
typename MT >
4285 inline Submatrix<MT,unaligned,true,true>&
4286 Submatrix<MT,unaligned,true,true>::operator=(
const Submatrix& rhs )
4291 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
4294 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
4298 if( !tryAssign( matrix_, rhs, row_, column_ ) ) {
4302 DerestrictTrait_<This> left( derestrict( *
this ) );
4304 if( rhs.canAlias( &matrix_ ) ) {
4305 const ResultType tmp( rhs );
4335 template<
typename MT >
4336 template<
typename MT2
4338 inline Submatrix<MT,unaligned,true,true>&
4339 Submatrix<MT,unaligned,true,true>::operator=(
const Matrix<MT2,SO>& rhs )
4347 typedef If_< IsRestricted<MT>, CompositeType_<MT2>,
const MT2& > Right;
4348 Right right( ~rhs );
4350 if( !tryAssign( matrix_, right, row_, column_ ) ) {
4354 if( IsSparseMatrix<MT2>::value )
4357 DerestrictTrait_<This> left( derestrict( *
this ) );
4359 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4360 const ResultType_<MT2> tmp( right );
4389 template<
typename MT >
4390 template<
typename MT2
4392 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,true,true>& >
4399 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
4408 if( !tryAddAssign( matrix_, ~rhs, row_, column_ ) ) {
4412 DerestrictTrait_<This> left( derestrict( *
this ) );
4414 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
4415 (~rhs).canAlias( &matrix_ ) ) {
4416 const AddType tmp( *
this + (~rhs) );
4445 template<
typename MT >
4446 template<
typename MT2
4448 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,true,true>& >
4455 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
4464 const AddType tmp( *
this + (~rhs) );
4466 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
4470 DerestrictTrait_<This> left( derestrict( *
this ) );
4496 template<
typename MT >
4497 template<
typename MT2
4499 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,true,true>& >
4506 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
4515 if( !trySubAssign( matrix_, ~rhs, row_, column_ ) ) {
4519 DerestrictTrait_<This> left( derestrict( *
this ) );
4521 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
4522 (~rhs).canAlias( &matrix_ ) ) {
4523 const SubType tmp( *
this - (~rhs ) );
4552 template<
typename MT >
4553 template<
typename MT2
4555 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,true,true>& >
4562 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
4571 const SubType tmp( *
this - (~rhs) );
4573 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
4577 DerestrictTrait_<This> left( derestrict( *
this ) );
4603 template<
typename MT >
4604 template<
typename MT2
4606 inline Submatrix<MT,unaligned,true,true>&
4613 typedef MultTrait_< ResultType, ResultType_<MT2> > MultType;
4622 const MultType tmp( *
this * (~rhs) );
4624 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
4628 DerestrictTrait_<This> left( derestrict( *
this ) );
4651 template<
typename MT >
4652 template<
typename Other >
4653 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,unaligned,true,true> >&
4658 DerestrictTrait_<This> left( derestrict( *
this ) );
4680 template<
typename MT >
4681 template<
typename Other >
4682 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,unaligned,true,true> >&
4689 DerestrictTrait_<This> left( derestrict( *
this ) );
4712 template<
typename MT >
4727 template<
typename MT >
4742 template<
typename MT >
4757 template<
typename MT >
4775 template<
typename MT >
4778 return matrix_.spacing();
4790 template<
typename MT >
4806 template<
typename MT >
4825 template<
typename MT >
4828 const size_t iend( row_ + m_ );
4829 const size_t jend( column_ + n_ );
4830 size_t nonzeros( 0UL );
4832 for(
size_t j=column_; j<jend; ++j )
4833 for(
size_t i=row_; i<iend; ++i )
4850 template<
typename MT >
4855 const size_t iend( row_ + m_ );
4856 size_t nonzeros( 0UL );
4858 for(
size_t i=row_; i<iend; ++i )
4859 if( !
isDefault( matrix_(i,column_+j) ) )
4874 template<
typename MT >
4879 for(
size_t j=column_; j<column_+
n_; ++j )
4881 const size_t ibegin( ( IsLower<MT>::value )
4882 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4883 ?(
max( j+1UL, row_ ) )
4884 :(
max( j, row_ ) ) )
4886 const size_t iend ( ( IsUpper<MT>::value )
4887 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4888 ?(
min( j, row_+m_ ) )
4889 :(
min( j+1UL, row_+m_ ) ) )
4892 for(
size_t i=ibegin; i<iend; ++i )
4893 clear( matrix_(i,j) );
4907 template<
typename MT >
4914 const size_t ibegin( ( IsLower<MT>::value )
4915 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4916 ?(
max( j+1UL, row_ ) )
4917 :(
max( j, row_ ) ) )
4919 const size_t iend ( ( IsUpper<MT>::value )
4920 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4921 ?(
min( j, row_+m_ ) )
4922 :(
min( j+1UL, row_+m_ ) ) )
4925 for(
size_t i=ibegin; i<iend; ++i )
4926 clear( matrix_(i,column_+j) );
4950 template<
typename MT >
4957 if( !tryAssign( matrix_,
trans( *
this ), row_, column_ ) ) {
4961 DerestrictTrait_<This> left( derestrict( *
this ) );
4962 const ResultType tmp(
trans( *
this ) );
4989 template<
typename MT >
4996 if( !tryAssign( matrix_,
ctrans( *
this ), row_, column_ ) ) {
5000 DerestrictTrait_<This> left( derestrict( *
this ) );
5001 const ResultType tmp(
ctrans( *
this ) );
5021 template<
typename MT >
5022 template<
typename Other >
5023 inline Submatrix<MT,unaligned,true,true>& Submatrix<MT,unaligned,true,true>::scale(
const Other& scalar )
5027 const size_t jend( column_ + n_ );
5029 for(
size_t j=column_; j<jend; ++j )
5031 const size_t ibegin( ( IsLower<MT>::value )
5032 ?( ( IsStrictlyLower<MT>::value )
5033 ?(
max( j+1UL, row_ ) )
5034 :(
max( j, row_ ) ) )
5036 const size_t iend ( ( IsUpper<MT>::value )
5037 ?( ( IsStrictlyUpper<MT>::value )
5038 ?(
min( j, row_+m_ ) )
5039 :(
min( j+1UL, row_+m_ ) ) )
5042 for(
size_t i=ibegin; i<iend; ++i )
5043 matrix_(i,j) *= scalar;
5062 template<
typename MT >
5063 inline bool Submatrix<MT,unaligned,true,true>::hasOverlap() const noexcept
5065 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
5067 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
5094 template<
typename MT >
5095 template<
typename Other >
5096 inline bool Submatrix<MT,unaligned,true,true>::canAlias(
const Other* alias )
const noexcept
5098 return matrix_.isAliased( alias );
5115 template<
typename MT >
5116 template<
typename MT2
5119 inline bool Submatrix<MT,unaligned,true,true>::canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
5121 return ( matrix_.isAliased( &alias->matrix_ ) &&
5122 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
5123 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
5140 template<
typename MT >
5141 template<
typename Other >
5142 inline bool Submatrix<MT,unaligned,true,true>::isAliased(
const Other* alias )
const noexcept
5144 return matrix_.isAliased( alias );
5161 template<
typename MT >
5162 template<
typename MT2
5165 inline bool Submatrix<MT,unaligned,true,true>::isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
5167 return ( matrix_.isAliased( &alias->matrix_ ) &&
5168 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
5169 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
5185 template<
typename MT >
5186 inline bool Submatrix<MT,unaligned,true,true>::isAligned() const noexcept
5205 template<
typename MT >
5206 inline bool Submatrix<MT,unaligned,true,true>::canSMPAssign() const noexcept
5208 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
5229 template<
typename MT >
5231 Submatrix<MT,unaligned,true,true>::load(
size_t i,
size_t j )
const noexcept
5234 return loada( i, j );
5236 return loadu( i, j );
5257 template<
typename MT >
5268 return matrix_.loada( row_+i, column_+j );
5289 template<
typename MT >
5300 return matrix_.loadu( row_+i, column_+j );
5322 template<
typename MT >
5324 Submatrix<MT,unaligned,true,true>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
5351 template<
typename MT >
5362 matrix_.storea( row_+i, column_+j, value );
5384 template<
typename MT >
5395 matrix_.storeu( row_+i, column_+j, value );
5418 template<
typename MT >
5430 matrix_.stream( row_+i, column_+j, value );
5432 matrix_.storeu( row_+i, column_+j, value );
5450 template<
typename MT >
5451 template<
typename MT2 >
5452 inline DisableIf_< typename Submatrix<MT,unaligned,true,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
5453 Submatrix<MT,unaligned,true,true>::assign(
const DenseMatrix<MT2,true>& rhs )
5458 const size_t ipos( m_ &
size_t(-2) );
5461 for(
size_t j=0UL; j<
n_; ++j ) {
5462 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5463 matrix_(row_+i ,column_+j) = (~rhs)(i ,j);
5464 matrix_(row_+i+1UL,column_+j) = (~rhs)(i+1UL,j);
5467 matrix_(row_+ipos,column_+j) = (~rhs)(ipos,j);
5487 template<
typename MT >
5488 template<
typename MT2 >
5489 inline EnableIf_< typename Submatrix<MT,unaligned,true,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
5490 Submatrix<MT,unaligned,true,true>::assign(
const DenseMatrix<MT2,true>& rhs )
5497 const size_t ipos( m_ &
size_t(-SIMDSIZE) );
5501 m_*n_ > (
cacheSize / (
sizeof(ElementType) * 3UL ) ) &&
5502 !(~rhs).isAliased( &matrix_ ) )
5504 for(
size_t j=0UL; j<
n_; ++j )
5507 Iterator left(
begin(j) );
5508 ConstIterator_<MT2> right( (~rhs).
begin(j) );
5510 for( ; i<ipos; i+=SIMDSIZE ) {
5511 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5513 for( ; i<
m_; ++i ) {
5514 *left = *right; ++left; ++right;
5520 for(
size_t j=0UL; j<
n_; ++j )
5523 Iterator left(
begin(j) );
5524 ConstIterator_<MT2> right( (~rhs).
begin(j) );
5526 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5527 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5528 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5529 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5530 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5532 for( ; i<ipos; i+=SIMDSIZE ) {
5533 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5535 for( ; i<
m_; ++i ) {
5536 *left = *right; ++left; ++right;
5557 template<
typename MT >
5558 template<
typename MT2 >
5559 inline void Submatrix<MT,unaligned,true,true>::assign(
const DenseMatrix<MT2,false>& rhs )
5566 const size_t block( BLOCK_SIZE );
5568 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
5569 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
5570 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
5571 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
5572 for(
size_t j=jj; j<jend; ++j ) {
5573 for(
size_t i=ii; i<iend; ++i ) {
5574 matrix_(row_+i,column_+j) = (~rhs)(i,j);
5596 template<
typename MT >
5597 template<
typename MT2 >
5598 inline void Submatrix<MT,unaligned,true,true>::assign(
const SparseMatrix<MT2,true>& rhs )
5603 for(
size_t j=0UL; j<
n_; ++j )
5604 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
5605 matrix_(row_+element->index(),column_+j) = element->value();
5623 template<
typename MT >
5624 template<
typename MT2 >
5625 inline void Submatrix<MT,unaligned,true,true>::assign(
const SparseMatrix<MT2,false>& rhs )
5632 for(
size_t i=0UL; i<
m_; ++i )
5633 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
5634 matrix_(row_+i,column_+element->index()) = element->value();
5652 template<
typename MT >
5653 template<
typename MT2 >
5654 inline DisableIf_< typename Submatrix<MT,unaligned,true,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
5655 Submatrix<MT,unaligned,true,true>::addAssign(
const DenseMatrix<MT2,true>& rhs )
5660 const size_t ipos( m_ &
size_t(-2) );
5663 for(
size_t j=0UL; j<
n_; ++j )
5665 if( IsDiagonal<MT2>::value ) {
5666 matrix_(row_+j,column_+j) += (~rhs)(j,j);
5669 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5670 matrix_(row_+i ,column_+j) += (~rhs)(i ,j);
5671 matrix_(row_+i+1UL,column_+j) += (~rhs)(i+1UL,j);
5674 matrix_(row_+ipos,column_+j) += (~rhs)(ipos,j);
5695 template<
typename MT >
5696 template<
typename MT2 >
5697 inline EnableIf_< typename Submatrix<MT,unaligned,true,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
5698 Submatrix<MT,unaligned,true,true>::addAssign(
const DenseMatrix<MT2,true>& rhs )
5705 for(
size_t j=0UL; j<
n_; ++j )
5707 const size_t ibegin( ( IsLower<MT>::value )
5708 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-SIMDSIZE) )
5710 const size_t iend ( ( IsUpper<MT>::value )
5711 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
5715 const size_t ipos( iend &
size_t(-SIMDSIZE) );
5719 Iterator left(
begin(j) + ibegin );
5720 ConstIterator_<MT2> right( (~rhs).
begin(j) + ibegin );
5722 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5723 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5724 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5725 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5726 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5728 for( ; i<ipos; i+=SIMDSIZE ) {
5729 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5731 for( ; i<iend; ++i ) {
5732 *left += *right; ++left; ++right;
5752 template<
typename MT >
5753 template<
typename MT2 >
5754 inline void Submatrix<MT,unaligned,true,true>::addAssign(
const DenseMatrix<MT2,false>& rhs )
5761 const size_t block( BLOCK_SIZE );
5763 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
5764 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
5765 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
5766 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
5767 for(
size_t j=jj; j<jend; ++j ) {
5768 for(
size_t i=ii; i<iend; ++i ) {
5769 matrix_(row_+i,column_+j) += (~rhs)(i,j);
5791 template<
typename MT >
5792 template<
typename MT2 >
5793 inline void Submatrix<MT,unaligned,true,true>::addAssign(
const SparseMatrix<MT2,true>& rhs )
5798 for(
size_t j=0UL; j<
n_; ++j )
5799 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
5800 matrix_(row_+element->index(),column_+j) += element->value();
5818 template<
typename MT >
5819 template<
typename MT2 >
5820 inline void Submatrix<MT,unaligned,true,true>::addAssign(
const SparseMatrix<MT2,false>& rhs )
5827 for(
size_t i=0UL; i<
m_; ++i )
5828 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
5829 matrix_(row_+i,column_+element->index()) += element->value();
5847 template<
typename MT >
5848 template<
typename MT2 >
5849 inline DisableIf_< typename Submatrix<MT,unaligned,true,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
5850 Submatrix<MT,unaligned,true,true>::subAssign(
const DenseMatrix<MT2,true>& rhs )
5855 const size_t ipos( m_ &
size_t(-2) );
5858 for(
size_t j=0UL; j<
n_; ++j )
5860 if( IsDiagonal<MT2>::value ) {
5861 matrix_(row_+j,column_+j) -= (~rhs)(j,j);
5864 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5865 matrix_(row_+i ,column_+j) -= (~rhs)(i ,j);
5866 matrix_(row_+i+1UL,column_+j) -= (~rhs)(i+1UL,j);
5869 matrix_(row_+ipos,column_+j) -= (~rhs)(ipos,j);
5890 template<
typename MT >
5891 template<
typename MT2 >
5892 inline EnableIf_< typename Submatrix<MT,unaligned,true,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
5893 Submatrix<MT,unaligned,true,true>::subAssign(
const DenseMatrix<MT2,true>& rhs )
5900 for(
size_t j=0UL; j<
n_; ++j )
5902 const size_t ibegin( ( IsLower<MT>::value )
5903 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-SIMDSIZE) )
5905 const size_t iend ( ( IsUpper<MT>::value )
5906 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
5910 const size_t ipos( iend &
size_t(-SIMDSIZE) );
5914 Iterator left(
begin(j) + ibegin );
5915 ConstIterator_<MT2> right( (~rhs).
begin(j) + ibegin );
5917 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5918 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5919 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5920 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5921 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5923 for( ; i<ipos; i+=SIMDSIZE ) {
5924 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5926 for( ; i<iend; ++i ) {
5927 *left -= *right; ++left; ++right;
5947 template<
typename MT >
5948 template<
typename MT2 >
5949 inline void Submatrix<MT,unaligned,true,true>::subAssign(
const DenseMatrix<MT2,false>& rhs )
5956 const size_t block( BLOCK_SIZE );
5958 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
5959 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
5960 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
5961 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
5962 for(
size_t j=jj; j<jend; ++j ) {
5963 for(
size_t i=ii; i<iend; ++i ) {
5964 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
5986 template<
typename MT >
5987 template<
typename MT2 >
5988 inline void Submatrix<MT,unaligned,true,true>::subAssign(
const SparseMatrix<MT2,true>& rhs )
5993 for(
size_t j=0UL; j<
n_; ++j )
5994 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
5995 matrix_(row_+element->index(),column_+j) -= element->value();
6013 template<
typename MT >
6014 template<
typename MT2 >
6015 inline void Submatrix<MT,unaligned,true,true>::subAssign(
const SparseMatrix<MT2,false>& rhs )
6022 for(
size_t i=0UL; i<
m_; ++i )
6023 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
6024 matrix_(row_+i,column_+element->index()) -= element->value();
6050 template<
typename MT >
6051 class Submatrix<MT,
aligned,false,true>
6052 :
public DenseMatrix< Submatrix<MT,aligned,false,true>, false >
6058 typedef If_< IsExpression<MT>, MT, MT& > Operand;
6063 typedef Submatrix<MT,aligned,false,true>
This;
6064 typedef DenseMatrix<This,false>
BaseType;
6069 typedef SIMDTrait_<ElementType> SIMDType;
6080 typedef const ElementType* ConstPointer;
6083 typedef If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, ElementType* > Pointer;
6094 enum :
bool { simdEnabled = MT::simdEnabled };
6097 enum :
bool { smpAssignable = MT::smpAssignable };
6103 explicit inline Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n );
6115 inline Reference operator()(
size_t i,
size_t j );
6116 inline ConstReference operator()(
size_t i,
size_t j )
const;
6117 inline Reference at(
size_t i,
size_t j );
6118 inline ConstReference at(
size_t i,
size_t j )
const;
6119 inline Pointer data () noexcept;
6120 inline ConstPointer data () const noexcept;
6121 inline Pointer data (
size_t i ) noexcept;
6122 inline ConstPointer data (
size_t i ) const noexcept;
6123 inline Iterator
begin (
size_t i );
6124 inline ConstIterator
begin (
size_t i ) const;
6125 inline ConstIterator
cbegin(
size_t i ) const;
6126 inline Iterator
end (
size_t i );
6127 inline ConstIterator
end (
size_t i ) const;
6128 inline ConstIterator
cend (
size_t i ) const;
6135 inline Submatrix& operator=( const ElementType& rhs );
6136 inline Submatrix& operator=( initializer_list< initializer_list<ElementType> > list );
6137 inline Submatrix& operator=( const Submatrix& rhs );
6139 template< typename MT2,
bool SO >
6140 inline Submatrix& operator=( const Matrix<MT2,SO>& rhs );
6142 template< typename MT2,
bool SO >
6143 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6144 operator+=( const Matrix<MT2,SO>& rhs );
6146 template< typename MT2,
bool SO >
6147 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6148 operator+=( const Matrix<MT2,SO>& rhs );
6150 template< typename MT2,
bool SO >
6151 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6152 operator-=( const Matrix<MT2,SO>& rhs );
6154 template< typename MT2,
bool SO >
6155 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6156 operator-=( const Matrix<MT2,SO>& rhs );
6158 template< typename MT2,
bool SO >
6159 inline Submatrix& operator*=( const Matrix<MT2,SO>& rhs );
6161 template< typename Other >
6162 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator*=( Other rhs );
6164 template< typename Other >
6165 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator/=( Other rhs );
6172 inline
size_t row() const noexcept;
6173 inline
size_t rows() const noexcept;
6174 inline
size_t column() const noexcept;
6175 inline
size_t columns() const noexcept;
6176 inline
size_t spacing() const noexcept;
6177 inline
size_t capacity() const noexcept;
6178 inline
size_t capacity(
size_t i ) const noexcept;
6180 inline
size_t nonZeros(
size_t i ) const;
6181 inline
void reset();
6182 inline
void reset(
size_t i );
6185 template< typename Other > inline Submatrix& scale( const Other& scalar );
6192 template< typename MT2 >
6193 struct VectorizedAssign {
6195 simdEnabled && MT2::simdEnabled &&
6196 AreSIMDCombinable< ElementType, ElementType_<MT2> >::value };
6202 template<
typename MT2 >
6203 struct VectorizedAddAssign {
6205 simdEnabled && MT2::simdEnabled &&
6206 AreSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
6207 HasSIMDAdd< ElementType, ElementType_<MT2> >::value &&
6208 !IsDiagonal<MT2>::value };
6214 template<
typename MT2 >
6215 struct VectorizedSubAssign {
6217 simdEnabled && MT2::simdEnabled &&
6218 AreSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
6219 HasSIMDSub< ElementType, ElementType_<MT2> >::value &&
6220 !IsDiagonal<MT2>::value };
6233 template<
typename Other >
6234 inline bool canAlias(
const Other* alias )
const noexcept;
6236 template<
typename MT2,
bool AF2,
bool SO2 >
6237 inline bool canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
6239 template<
typename Other >
6240 inline bool isAliased(
const Other* alias )
const noexcept;
6242 template<
typename MT2,
bool AF2,
bool SO2 >
6243 inline bool isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
6245 inline bool isAligned () const noexcept;
6246 inline
bool canSMPAssign() const noexcept;
6257 template< typename MT2 >
6258 inline
DisableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,false>& rhs );
6260 template< typename MT2 >
6261 inline
EnableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,false>& rhs );
6263 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,true>& rhs );
6264 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
6265 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
6267 template< typename MT2 >
6268 inline
DisableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,false>& rhs );
6270 template< typename MT2 >
6271 inline
EnableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,false>& rhs );
6273 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,true>& rhs );
6274 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
6275 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
6277 template< typename MT2 >
6278 inline
DisableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,false>& rhs );
6280 template< typename MT2 >
6281 inline
EnableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,false>& rhs );
6283 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,true>& rhs );
6284 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
6285 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
6293 inline
bool hasOverlap() const noexcept;
6302 const
size_t column_;
6309 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 > friend class Submatrix;
6311 template<
bool AF1, typename MT2,
bool AF2,
bool SO2,
bool DF2 >
6312 friend const Submatrix<MT2,AF1,SO2,DF2>
6313 submatrix( const Submatrix<MT2,AF2,SO2,DF2>& sm,
size_t row,
size_t column,
size_t m,
size_t n );
6315 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
6316 friend
bool isIntact( const Submatrix<MT2,AF2,SO2,DF2>& sm ) noexcept;
6318 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
6319 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Matrix<MT2,SO2>& b ) noexcept;
6321 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
6322 friend
bool isSame( const Matrix<MT2,SO2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
6324 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
6325 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
6327 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
6328 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
6329 size_t row,
size_t column );
6331 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
6332 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
6333 size_t row,
size_t column );
6335 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
6336 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
6337 size_t row,
size_t column );
6339 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
6340 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
6341 size_t row,
size_t column );
6343 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
6344 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
6345 size_t row,
size_t column );
6347 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
6348 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
6349 size_t row,
size_t column );
6351 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
6352 friend
bool tryMultAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
6353 size_t row,
size_t column );
6355 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
6356 friend
DerestrictTrait_< Submatrix<MT2,AF2,SO2,DF2> > derestrict( Submatrix<MT2,AF2,SO2,DF2>& sm );
6395 template< typename MT >
6396 inline Submatrix<MT,
aligned,false,true>::Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n )
6403 if( ( row_ + m_ > matrix_.rows() ) || ( column_ + n_ > matrix_.columns() ) ) {
6407 if( ( simdEnabled && matrix_.data() !=
nullptr && !
checkAlignment( data() ) ) ||
6408 ( m_ > 1UL && matrix_.spacing() % SIMDSIZE != 0UL ) ) {
6435 template<
typename MT >
6437 Submatrix<MT,aligned,false,true>::operator()(
size_t i,
size_t j )
6442 return matrix_(row_+i,column_+j);
6459 template<
typename MT >
6461 Submatrix<MT,aligned,false,true>::operator()(
size_t i,
size_t j )
const
6466 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
6484 template<
typename MT >
6486 Submatrix<MT,aligned,false,true>::at(
size_t i,
size_t j )
6494 return (*
this)(i,j);
6512 template<
typename MT >
6514 Submatrix<MT,aligned,false,true>::at(
size_t i,
size_t j )
const
6522 return (*
this)(i,j);
6538 template<
typename MT >
6539 inline typename Submatrix<MT,aligned,false,true>::Pointer
6540 Submatrix<MT,aligned,false,true>::data() noexcept
6542 return matrix_.data() + row_*
spacing() + column_;
6558 template<
typename MT >
6559 inline typename Submatrix<MT,aligned,false,true>::ConstPointer
6560 Submatrix<MT,aligned,false,true>::data() const noexcept
6562 return matrix_.data() + row_*
spacing() + column_;
6577 template<
typename MT >
6578 inline typename Submatrix<MT,aligned,false,true>::Pointer
6579 Submatrix<MT,aligned,false,true>::data(
size_t i ) noexcept
6581 return matrix_.data() + (row_+i)*
spacing() + column_;
6596 template<
typename MT >
6597 inline typename Submatrix<MT,aligned,false,true>::ConstPointer
6598 Submatrix<MT,aligned,false,true>::data(
size_t i )
const noexcept
6600 return matrix_.data() + (row_+i)*
spacing() + column_;
6618 template<
typename MT >
6623 return ( matrix_.begin( row_ + i ) + column_ );
6641 template<
typename MT >
6646 return ( matrix_.cbegin( row_ + i ) + column_ );
6664 template<
typename MT >
6669 return ( matrix_.cbegin( row_ + i ) + column_ );
6687 template<
typename MT >
6692 return ( matrix_.begin( row_ + i ) + column_ +
n_ );
6710 template<
typename MT >
6715 return ( matrix_.cbegin( row_ + i ) + column_ +
n_ );
6733 template<
typename MT >
6738 return ( matrix_.cbegin( row_ + i ) + column_ +
n_ );
6763 template<
typename MT >
6764 inline Submatrix<MT,aligned,false,true>&
6765 Submatrix<MT,aligned,false,true>::operator=(
const ElementType& rhs )
6767 const size_t iend( row_ + m_ );
6769 for(
size_t i=row_; i<iend; ++i )
6771 const size_t jbegin( ( IsUpper<MT>::value )
6772 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
6773 ?(
max( i+1UL, column_ ) )
6774 :(
max( i, column_ ) ) )
6776 const size_t jend ( ( IsLower<MT>::value )
6777 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
6778 ?(
min( i, column_+n_ ) )
6779 :(
min( i+1UL, column_+n_ ) ) )
6782 for(
size_t j=jbegin; j<jend; ++j )
6805 template<
typename MT >
6806 inline Submatrix<MT,aligned,false,true>&
6807 Submatrix<MT,aligned,false,true>::operator=( initializer_list< initializer_list<ElementType> > list )
6815 for(
const auto& rowList : list ) {
6816 std::fill( std::copy( rowList.begin(), rowList.end(),
begin(i) ),
end(i),
ElementType() );
6841 template<
typename MT >
6842 inline Submatrix<MT,aligned,false,true>&
6843 Submatrix<MT,aligned,false,true>::operator=(
const Submatrix& rhs )
6848 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
6851 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
6855 if( !tryAssign( matrix_, rhs, row_, column_ ) ) {
6859 DerestrictTrait_<This> left( derestrict( *
this ) );
6861 if( rhs.canAlias( &matrix_ ) ) {
6862 const ResultType tmp( rhs );
6892 template<
typename MT >
6893 template<
typename MT2
6895 inline Submatrix<MT,aligned,false,true>&
6896 Submatrix<MT,aligned,false,true>::operator=(
const Matrix<MT2,SO>& rhs )
6904 typedef If_< IsRestricted<MT>, CompositeType_<MT2>,
const MT2& > Right;
6905 Right right( ~rhs );
6907 if( !tryAssign( matrix_, right, row_, column_ ) ) {
6911 if( IsSparseMatrix<MT2>::value )
6914 DerestrictTrait_<This> left( derestrict( *
this ) );
6916 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
6917 const ResultType_<MT2> tmp( right );
6946 template<
typename MT >
6947 template<
typename MT2
6949 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,false,true>& >
6956 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
6965 if( !tryAddAssign( matrix_, ~rhs, row_, column_ ) ) {
6969 DerestrictTrait_<This> left( derestrict( *
this ) );
6971 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
6972 (~rhs).canAlias( &matrix_ ) ) {
6973 const AddType tmp( *
this + (~rhs) );
7002 template<
typename MT >
7003 template<
typename MT2
7005 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,false,true>& >
7012 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
7021 const AddType tmp( *
this + (~rhs) );
7023 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
7027 DerestrictTrait_<This> left( derestrict( *
this ) );
7053 template<
typename MT >
7054 template<
typename MT2
7056 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,false,true>& >
7063 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
7072 if( !trySubAssign( matrix_, ~rhs, row_, column_ ) ) {
7076 DerestrictTrait_<This> left( derestrict( *
this ) );
7078 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
7079 (~rhs).canAlias( &matrix_ ) ) {
7080 const SubType tmp( *
this - (~rhs ) );
7109 template<
typename MT >
7110 template<
typename MT2
7112 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,false,true>& >
7119 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
7128 const SubType tmp( *
this - (~rhs) );
7130 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
7134 DerestrictTrait_<This> left( derestrict( *
this ) );
7160 template<
typename MT >
7161 template<
typename MT2
7163 inline Submatrix<MT,aligned,false,true>&
7170 typedef MultTrait_< ResultType, ResultType_<MT2> > MultType;
7179 const MultType tmp( *
this * (~rhs) );
7181 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
7185 DerestrictTrait_<This> left( derestrict( *
this ) );
7208 template<
typename MT >
7209 template<
typename Other >
7210 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,aligned,false,true> >&
7215 DerestrictTrait_<This> left( derestrict( *
this ) );
7237 template<
typename MT >
7238 template<
typename Other >
7239 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,aligned,false,true> >&
7246 DerestrictTrait_<This> left( derestrict( *
this ) );
7269 template<
typename MT >
7284 template<
typename MT >
7299 template<
typename MT >
7314 template<
typename MT >
7334 template<
typename MT >
7337 return matrix_.spacing();
7349 template<
typename MT >
7370 template<
typename MT >
7389 template<
typename MT >
7392 const size_t iend( row_ + m_ );
7393 const size_t jend( column_ + n_ );
7394 size_t nonzeros( 0UL );
7396 for(
size_t i=row_; i<iend; ++i )
7397 for(
size_t j=column_; j<jend; ++j )
7419 template<
typename MT >
7424 const size_t jend( column_ + n_ );
7425 size_t nonzeros( 0UL );
7427 for(
size_t j=column_; j<jend; ++j )
7443 template<
typename MT >
7448 for(
size_t i=row_; i<row_+
m_; ++i )
7450 const size_t jbegin( ( IsUpper<MT>::value )
7451 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
7452 ?(
max( i+1UL, column_ ) )
7453 :(
max( i, column_ ) ) )
7455 const size_t jend ( ( IsLower<MT>::value )
7456 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
7457 ?(
min( i, column_+n_ ) )
7458 :(
min( i+1UL, column_+n_ ) ) )
7461 for(
size_t j=jbegin; j<jend; ++j )
7462 clear( matrix_(i,j) );
7481 template<
typename MT >
7488 const size_t jbegin( ( IsUpper<MT>::value )
7489 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
7490 ?(
max( i+1UL, column_ ) )
7491 :(
max( i, column_ ) ) )
7493 const size_t jend ( ( IsLower<MT>::value )
7494 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
7495 ?(
min( i, column_+n_ ) )
7496 :(
min( i+1UL, column_+n_ ) ) )
7499 for(
size_t j=jbegin; j<jend; ++j )
7500 clear( matrix_(row_+i,j) );
7524 template<
typename MT >
7531 if( !tryAssign( matrix_,
trans( *
this ), row_, column_ ) ) {
7535 DerestrictTrait_<This> left( derestrict( *
this ) );
7536 const ResultType tmp(
trans( *
this ) );
7563 template<
typename MT >
7570 if( !tryAssign( matrix_,
ctrans( *
this ), row_, column_ ) ) {
7574 DerestrictTrait_<This> left( derestrict( *
this ) );
7575 const ResultType tmp(
ctrans( *
this ) );
7595 template<
typename MT >
7596 template<
typename Other >
7597 inline Submatrix<MT,aligned,false,true>& Submatrix<MT,aligned,false,true>::scale(
const Other& scalar )
7601 const size_t iend( row_ + m_ );
7603 for(
size_t i=row_; i<iend; ++i )
7605 const size_t jbegin( ( IsUpper<MT>::value )
7606 ?( ( IsStrictlyUpper<MT>::value )
7607 ?(
max( i+1UL, column_ ) )
7608 :(
max( i, column_ ) ) )
7610 const size_t jend ( ( IsLower<MT>::value )
7611 ?( ( IsStrictlyLower<MT>::value )
7612 ?(
min( i, column_+n_ ) )
7613 :(
min( i+1UL, column_+n_ ) ) )
7616 for(
size_t j=jbegin; j<jend; ++j )
7617 matrix_(i,j) *= scalar;
7636 template<
typename MT >
7637 inline bool Submatrix<MT,aligned,false,true>::hasOverlap() const noexcept
7639 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
7641 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
7668 template<
typename MT >
7669 template<
typename Other >
7670 inline bool Submatrix<MT,aligned,false,true>::canAlias(
const Other* alias )
const noexcept
7672 return matrix_.isAliased( alias );
7689 template<
typename MT >
7690 template<
typename MT2
7693 inline bool Submatrix<MT,aligned,false,true>::canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
7695 return ( matrix_.isAliased( &alias->matrix_ ) &&
7696 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
7697 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
7714 template<
typename MT >
7715 template<
typename Other >
7716 inline bool Submatrix<MT,aligned,false,true>::isAliased(
const Other* alias )
const noexcept
7718 return matrix_.isAliased( alias );
7735 template<
typename MT >
7736 template<
typename MT2
7739 inline bool Submatrix<MT,aligned,false,true>::isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
7741 return ( matrix_.isAliased( &alias->matrix_ ) &&
7742 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
7743 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
7759 template<
typename MT >
7760 inline bool Submatrix<MT,aligned,false,true>::isAligned() const noexcept
7779 template<
typename MT >
7780 inline bool Submatrix<MT,aligned,false,true>::canSMPAssign() const noexcept
7782 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
7804 template<
typename MT >
7806 Submatrix<MT,aligned,false,true>::load(
size_t i,
size_t j )
const noexcept
7808 return loada( i, j );
7830 template<
typename MT >
7841 return matrix_.loada( row_+i, column_+j );
7863 template<
typename MT >
7874 return matrix_.loadu( row_+i, column_+j );
7897 template<
typename MT >
7899 Submatrix<MT,aligned,false,true>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
7901 return storea( i, j, value );
7924 template<
typename MT >
7935 return matrix_.storea( row_+i, column_+j, value );
7958 template<
typename MT >
7969 matrix_.storeu( row_+i, column_+j, value );
7993 template<
typename MT >
8004 matrix_.stream( row_+i, column_+j, value );
8022 template<
typename MT >
8023 template<
typename MT2 >
8024 inline DisableIf_< typename Submatrix<MT,aligned,false,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
8025 Submatrix<MT,aligned,false,true>::assign(
const DenseMatrix<MT2,false>& rhs )
8030 const size_t jpos( n_ &
size_t(-2) );
8033 for(
size_t i=0UL; i<
m_; ++i ) {
8034 for(
size_t j=0UL; j<jpos; j+=2UL ) {
8035 matrix_(row_+i,column_+j ) = (~rhs)(i,j );
8036 matrix_(row_+i,column_+j+1UL) = (~rhs)(i,j+1UL);
8039 matrix_(row_+i,column_+jpos) = (~rhs)(i,jpos);
8059 template<
typename MT >
8060 template<
typename MT2 >
8061 inline EnableIf_< typename Submatrix<MT,aligned,false,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
8062 Submatrix<MT,aligned,false,true>::assign(
const DenseMatrix<MT2,false>& rhs )
8069 const size_t jpos( n_ &
size_t(-SIMDSIZE) );
8073 m_*n_ > (
cacheSize / (
sizeof(ElementType) * 3UL ) ) &&
8074 !(~rhs).isAliased( &matrix_ ) )
8076 for(
size_t i=0UL; i<
m_; ++i )
8079 Iterator left(
begin(i) );
8080 ConstIterator_<MT2> right( (~rhs).
begin(i) );
8082 for( ; j<jpos; j+=SIMDSIZE ) {
8083 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8085 for( ; j<
n_; ++j ) {
8086 *left = *right; ++left; ++right;
8092 for(
size_t i=0UL; i<
m_; ++i )
8095 Iterator left(
begin(i) );
8096 ConstIterator_<MT2> right( (~rhs).
begin(i) );
8098 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
8099 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8100 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8101 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8102 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8104 for( ; j<jpos; j+=SIMDSIZE ) {
8105 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8107 for( ; j<
n_; ++j ) {
8108 *left = *right; ++left; ++right;
8129 template<
typename MT >
8130 template<
typename MT2 >
8131 inline void Submatrix<MT,aligned,false,true>::assign(
const DenseMatrix<MT2,true>& rhs )
8138 const size_t block( BLOCK_SIZE );
8140 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
8141 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
8142 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
8143 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
8144 for(
size_t i=ii; i<iend; ++i ) {
8145 for(
size_t j=jj; j<jend; ++j ) {
8146 matrix_(row_+i,column_+j) = (~rhs)(i,j);
8168 template<
typename MT >
8169 template<
typename MT2 >
8170 inline void Submatrix<MT,aligned,false,true>::assign(
const SparseMatrix<MT2,false>& rhs )
8175 for(
size_t i=0UL; i<
m_; ++i )
8176 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
8177 matrix_(row_+i,column_+element->index()) = element->value();
8195 template<
typename MT >
8196 template<
typename MT2 >
8197 inline void Submatrix<MT,aligned,false,true>::assign(
const SparseMatrix<MT2,true>& rhs )
8204 for(
size_t j=0UL; j<
n_; ++j )
8205 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
8206 matrix_(row_+element->index(),column_+j) = element->value();
8224 template<
typename MT >
8225 template<
typename MT2 >
8226 inline DisableIf_< typename Submatrix<MT,aligned,false,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
8227 Submatrix<MT,aligned,false,true>::addAssign(
const DenseMatrix<MT2,false>& rhs )
8232 const size_t jpos( n_ &
size_t(-2) );
8235 for(
size_t i=0UL; i<
m_; ++i )
8237 if( IsDiagonal<MT2>::value ) {
8238 matrix_(row_+i,column_+i) += (~rhs)(i,i);
8241 for(
size_t j=0UL; j<jpos; j+=2UL ) {
8242 matrix_(row_+i,column_+j ) += (~rhs)(i,j );
8243 matrix_(row_+i,column_+j+1UL) += (~rhs)(i,j+1UL);
8246 matrix_(row_+i,column_+jpos) += (~rhs)(i,jpos);
8267 template<
typename MT >
8268 template<
typename MT2 >
8269 inline EnableIf_< typename Submatrix<MT,aligned,false,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
8270 Submatrix<MT,aligned,false,true>::addAssign(
const DenseMatrix<MT2,false>& rhs )
8277 for(
size_t i=0UL; i<
m_; ++i )
8279 const size_t jbegin( ( IsUpper<MT2>::value )
8280 ?( ( IsStrictlyUpper<MT2>::value ? i+1UL : i ) &
size_t(-SIMDSIZE) )
8282 const size_t jend ( ( IsLower<MT2>::value )
8283 ?( IsStrictlyLower<MT2>::value ? i : i+1UL )
8287 const size_t jpos( jend &
size_t(-SIMDSIZE) );
8291 Iterator left(
begin(i) + jbegin );
8292 ConstIterator_<MT2> right( (~rhs).
begin(i) + jbegin );
8294 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
8295 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8296 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8297 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8298 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8300 for( ; j<jpos; j+=SIMDSIZE ) {
8301 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8303 for( ; j<jend; ++j ) {
8304 *left += *right; ++left; ++right;
8324 template<
typename MT >
8325 template<
typename MT2 >
8326 inline void Submatrix<MT,aligned,false,true>::addAssign(
const DenseMatrix<MT2,true>& rhs )
8333 const size_t block( BLOCK_SIZE );
8335 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
8336 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
8337 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
8338 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
8339 for(
size_t i=ii; i<iend; ++i ) {
8340 for(
size_t j=jj; j<jend; ++j ) {
8341 matrix_(row_+i,column_+j) += (~rhs)(i,j);
8363 template<
typename MT >
8364 template<
typename MT2 >
8365 inline void Submatrix<MT,aligned,false,true>::addAssign(
const SparseMatrix<MT2,false>& rhs )
8370 for(
size_t i=0UL; i<
m_; ++i )
8371 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
8372 matrix_(row_+i,column_+element->index()) += element->value();
8390 template<
typename MT >
8391 template<
typename MT2 >
8392 inline void Submatrix<MT,aligned,false,true>::addAssign(
const SparseMatrix<MT2,true>& rhs )
8399 for(
size_t j=0UL; j<
n_; ++j )
8400 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
8401 matrix_(row_+element->index(),column_+j) += element->value();
8419 template<
typename MT >
8420 template<
typename MT2 >
8421 inline DisableIf_< typename Submatrix<MT,aligned,false,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
8422 Submatrix<MT,aligned,false,true>::subAssign(
const DenseMatrix<MT2,false>& rhs )
8427 const size_t jpos( n_ &
size_t(-2) );
8430 for(
size_t i=0UL; i<
m_; ++i )
8432 if( IsDiagonal<MT2>::value ) {
8433 matrix_(row_+i,column_+i) -= (~rhs)(i,i);
8436 for(
size_t j=0UL; j<jpos; j+=2UL ) {
8437 matrix_(row_+i,column_+j ) -= (~rhs)(i,j );
8438 matrix_(row_+i,column_+j+1UL) -= (~rhs)(i,j+1UL);
8441 matrix_(row_+i,column_+jpos) -= (~rhs)(i,jpos);
8462 template<
typename MT >
8463 template<
typename MT2 >
8464 inline EnableIf_< typename Submatrix<MT,aligned,false,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
8465 Submatrix<MT,aligned,false,true>::subAssign(
const DenseMatrix<MT2,false>& rhs )
8472 for(
size_t i=0UL; i<
m_; ++i )
8474 const size_t jbegin( ( IsUpper<MT2>::value )
8475 ?( ( IsStrictlyUpper<MT2>::value ? i+1UL : i ) &
size_t(-SIMDSIZE) )
8477 const size_t jend ( ( IsLower<MT2>::value )
8478 ?( IsStrictlyLower<MT2>::value ? i : i+1UL )
8482 const size_t jpos( jend &
size_t(-SIMDSIZE) );
8486 Iterator left(
begin(i) + jbegin );
8487 ConstIterator_<MT2> right( (~rhs).
begin(i) + jbegin );
8489 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
8490 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8491 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8492 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8493 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8495 for( ; j<jpos; j+=SIMDSIZE ) {
8496 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8498 for( ; j<jend; ++j ) {
8499 *left -= *right; ++left; ++right;
8519 template<
typename MT >
8520 template<
typename MT2 >
8521 inline void Submatrix<MT,aligned,false,true>::subAssign(
const DenseMatrix<MT2,true>& rhs )
8528 const size_t block( BLOCK_SIZE );
8530 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
8531 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
8532 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
8533 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
8534 for(
size_t i=ii; i<iend; ++i ) {
8535 for(
size_t j=jj; j<jend; ++j ) {
8536 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
8558 template<
typename MT >
8559 template<
typename MT2 >
8560 inline void Submatrix<MT,aligned,false,true>::subAssign(
const SparseMatrix<MT2,false>& rhs )
8565 for(
size_t i=0UL; i<
m_; ++i )
8566 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
8567 matrix_(row_+i,column_+element->index()) -= element->value();
8585 template<
typename MT >
8586 template<
typename MT2 >
8587 inline void Submatrix<MT,aligned,false,true>::subAssign(
const SparseMatrix<MT2,true>& rhs )
8594 for(
size_t j=0UL; j<
n_; ++j )
8595 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
8596 matrix_(row_+element->index(),column_+j) -= element->value();
8622 template<
typename MT >
8623 class Submatrix<MT,aligned,true,true>
8624 :
public DenseMatrix< Submatrix<MT,aligned,true,true>, true >
8630 typedef If_< IsExpression<MT>, MT, MT& > Operand;
8635 typedef Submatrix<MT,aligned,true,true>
This;
8636 typedef DenseMatrix<This,true>
BaseType;
8641 typedef SIMDTrait_<ElementType> SIMDType;
8652 typedef const ElementType* ConstPointer;
8655 typedef If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, ElementType* > Pointer;
8666 enum :
bool { simdEnabled = MT::simdEnabled };
8669 enum :
bool { smpAssignable = MT::smpAssignable };
8675 explicit inline Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n );
8687 inline Reference operator()(
size_t i,
size_t j );
8688 inline ConstReference operator()(
size_t i,
size_t j )
const;
8689 inline Reference at(
size_t i,
size_t j );
8690 inline ConstReference at(
size_t i,
size_t j )
const;
8691 inline Pointer data () noexcept;
8692 inline ConstPointer data () const noexcept;
8693 inline Pointer data (
size_t j ) noexcept;
8694 inline ConstPointer data (
size_t j ) const noexcept;
8695 inline Iterator
begin (
size_t j );
8696 inline ConstIterator
begin (
size_t j ) const;
8697 inline ConstIterator
cbegin(
size_t j ) const;
8698 inline Iterator
end (
size_t j );
8699 inline ConstIterator
end (
size_t j ) const;
8700 inline ConstIterator
cend (
size_t j ) const;
8707 inline Submatrix& operator=( const ElementType& rhs );
8708 inline Submatrix& operator=( initializer_list< initializer_list<ElementType> > list );
8709 inline Submatrix& operator=( const Submatrix& rhs );
8711 template< typename MT2,
bool SO >
8712 inline Submatrix& operator=( const Matrix<MT2,SO>& rhs );
8714 template< typename MT2,
bool SO >
8715 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
8716 operator+=( const Matrix<MT2,SO>& rhs );
8718 template< typename MT2,
bool SO >
8719 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
8720 operator+=( const Matrix<MT2,SO>& rhs );
8722 template< typename MT2,
bool SO >
8723 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
8724 operator-=( const Matrix<MT2,SO>& rhs );
8726 template< typename MT2,
bool SO >
8727 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
8728 operator-=( const Matrix<MT2,SO>& rhs );
8730 template< typename MT2,
bool SO >
8731 inline Submatrix& operator*=( const Matrix<MT2,SO>& rhs );
8733 template< typename Other >
8734 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator*=( Other rhs );
8736 template< typename Other >
8737 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator/=( Other rhs );
8744 inline
size_t row() const noexcept;
8745 inline
size_t rows() const noexcept;
8746 inline
size_t column() const noexcept;
8747 inline
size_t columns() const noexcept;
8748 inline
size_t spacing() const noexcept;
8749 inline
size_t capacity() const noexcept;
8750 inline
size_t capacity(
size_t i ) const noexcept;
8752 inline
size_t nonZeros(
size_t i ) const;
8753 inline
void reset();
8754 inline
void reset(
size_t i );
8757 template< typename Other > inline Submatrix& scale( const Other& scalar );
8764 template< typename MT2 >
8765 struct VectorizedAssign {
8767 simdEnabled && MT2::simdEnabled &&
8768 AreSIMDCombinable< ElementType, ElementType_<MT2> >::value };
8774 template<
typename MT2 >
8775 struct VectorizedAddAssign {
8777 simdEnabled && MT2::simdEnabled &&
8778 AreSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
8779 HasSIMDAdd< ElementType, ElementType_<MT2> >::value &&
8780 !IsDiagonal<MT2>::value };
8786 template<
typename MT2 >
8787 struct VectorizedSubAssign {
8789 simdEnabled && MT2::simdEnabled &&
8790 AreSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
8791 HasSIMDSub< ElementType, ElementType_<MT2> >::value &&
8792 !IsDiagonal<MT2>::value };
8805 template<
typename Other >
8806 inline bool canAlias(
const Other* alias )
const noexcept;
8808 template<
typename MT2,
bool AF2,
bool SO2 >
8809 inline bool canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
8811 template<
typename Other >
8812 inline bool isAliased(
const Other* alias )
const noexcept;
8814 template<
typename MT2,
bool AF2,
bool SO2 >
8815 inline bool isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
8817 inline bool isAligned () const noexcept;
8818 inline
bool canSMPAssign() const noexcept;
8829 template< typename MT2 >
8830 inline
DisableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,true>& rhs );
8832 template< typename MT2 >
8833 inline
EnableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,true>& rhs );
8835 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,false>& rhs );
8836 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
8837 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
8839 template< typename MT2 >
8840 inline
DisableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,true>& rhs );
8842 template< typename MT2 >
8843 inline
EnableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,true>& rhs );
8845 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,false>& rhs );
8846 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
8847 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
8849 template< typename MT2 >
8850 inline
DisableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,true>& rhs );
8852 template< typename MT2 >
8853 inline
EnableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,true>& rhs );
8855 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,false>& rhs );
8856 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
8857 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
8865 inline
bool hasOverlap() const noexcept;
8874 const
size_t column_;
8881 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 > friend class Submatrix;
8883 template<
bool AF1, typename MT2,
bool AF2,
bool SO2,
bool DF2 >
8884 friend const Submatrix<MT2,AF1,SO2,DF2>
8885 submatrix( const Submatrix<MT2,AF2,SO2,DF2>& sm,
size_t row,
size_t column,
size_t m,
size_t n );
8887 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
8888 friend
bool isIntact( const Submatrix<MT2,AF2,SO2,DF2>& sm ) noexcept;
8890 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
8891 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Matrix<MT2,SO2>& b ) noexcept;
8893 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
8894 friend
bool isSame( const Matrix<MT2,SO2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
8896 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
8897 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
8899 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
8900 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
8901 size_t row,
size_t column );
8903 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
8904 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
8905 size_t row,
size_t column );
8907 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
8908 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
8909 size_t row,
size_t column );
8911 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
8912 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
8913 size_t row,
size_t column );
8915 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
8916 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
8917 size_t row,
size_t column );
8919 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
8920 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
8921 size_t row,
size_t column );
8923 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
8924 friend
bool tryMultAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
8925 size_t row,
size_t column );
8927 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
8928 friend
DerestrictTrait_< Submatrix<MT2,AF2,SO2,DF2> > derestrict( Submatrix<MT2,AF2,SO2,DF2>& sm );
8967 template< typename MT >
8968 inline Submatrix<MT,aligned,true,true>::Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n )
8975 if( ( row_ + m_ > matrix_.rows() ) || ( column_ + n_ > matrix_.columns() ) ) {
8979 if( ( simdEnabled && matrix_.data() !=
nullptr && !
checkAlignment( data() ) ) ||
8980 ( n_ > 1UL && matrix_.spacing() % SIMDSIZE != 0UL ) ) {
9007 template<
typename MT >
9009 Submatrix<MT,aligned,true,true>::operator()(
size_t i,
size_t j )
9014 return matrix_(row_+i,column_+j);
9031 template<
typename MT >
9033 Submatrix<MT,aligned,true,true>::operator()(
size_t i,
size_t j )
const
9038 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
9056 template<
typename MT >
9058 Submatrix<MT,aligned,true,true>::at(
size_t i,
size_t j )
9066 return (*
this)(i,j);
9084 template<
typename MT >
9086 Submatrix<MT,aligned,true,true>::at(
size_t i,
size_t j )
const
9094 return (*
this)(i,j);
9110 template<
typename MT >
9111 inline typename Submatrix<MT,aligned,true,true>::Pointer
9112 Submatrix<MT,aligned,true,true>::data() noexcept
9114 return matrix_.data() + row_ + column_*
spacing();
9130 template<
typename MT >
9131 inline typename Submatrix<MT,aligned,true,true>::ConstPointer
9132 Submatrix<MT,aligned,true,true>::data() const noexcept
9134 return matrix_.data() + row_ + column_*
spacing();
9149 template<
typename MT >
9150 inline typename Submatrix<MT,aligned,true,true>::Pointer
9151 Submatrix<MT,aligned,true,true>::data(
size_t j ) noexcept
9153 return matrix_.data() + row_ + (column_+j)*
spacing();
9168 template<
typename MT >
9169 inline typename Submatrix<MT,aligned,true,true>::ConstPointer
9170 Submatrix<MT,aligned,true,true>::data(
size_t j )
const noexcept
9172 return matrix_.data() + row_ + (column_+j)*
spacing();
9185 template<
typename MT >
9190 return ( matrix_.begin( column_ + j ) + row_ );
9203 template<
typename MT >
9208 return ( matrix_.cbegin( column_ + j ) + row_ );
9221 template<
typename MT >
9226 return ( matrix_.cbegin( column_ + j ) + row_ );
9239 template<
typename MT >
9244 return ( matrix_.begin( column_ + j ) + row_ +
m_ );
9257 template<
typename MT >
9262 return ( matrix_.cbegin( column_ + j ) + row_ +
m_ );
9275 template<
typename MT >
9280 return ( matrix_.cbegin( column_ + j ) + row_ +
m_ );
9305 template<
typename MT >
9306 inline Submatrix<MT,aligned,true,true>&
9307 Submatrix<MT,aligned,true,true>::operator=(
const ElementType& rhs )
9309 const size_t jend( column_ + n_ );
9311 for(
size_t j=column_; j<jend; ++j )
9313 const size_t ibegin( ( IsLower<MT>::value )
9314 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
9315 ?(
max( j+1UL, row_ ) )
9316 :(
max( j, row_ ) ) )
9318 const size_t iend ( ( IsUpper<MT>::value )
9319 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
9320 ?(
min( j, row_+m_ ) )
9321 :(
min( j+1UL, row_+m_ ) ) )
9324 for(
size_t i=ibegin; i<iend; ++i )
9347 template<
typename MT >
9348 inline Submatrix<MT,aligned,true,true>&
9349 Submatrix<MT,aligned,true,true>::operator=( initializer_list< initializer_list<ElementType> > list )
9357 for(
const auto& rowList : list ) {
9359 for(
const auto& element : rowList ) {
9360 matrix_(row_+i,column_+j) = element;
9363 for( ; j<
n_; ++j ) {
9390 template<
typename MT >
9391 inline Submatrix<MT,aligned,true,true>&
9392 Submatrix<MT,aligned,true,true>::operator=(
const Submatrix& rhs )
9397 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
9400 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
9404 if( !tryAssign( matrix_, rhs, row_, column_ ) ) {
9408 DerestrictTrait_<This> left( derestrict( *
this ) );
9410 if( rhs.canAlias( &matrix_ ) ) {
9411 const ResultType tmp( rhs );
9440 template<
typename MT >
9441 template<
typename MT2
9443 inline Submatrix<MT,aligned,true,true>&
9444 Submatrix<MT,aligned,true,true>::operator=(
const Matrix<MT2,SO>& rhs )
9452 typedef If_< IsRestricted<MT>, CompositeType_<MT2>,
const MT2& > Right;
9453 Right right( ~rhs );
9455 if( !tryAssign( matrix_, right, row_, column_ ) ) {
9459 if( IsSparseMatrix<MT2>::value )
9462 DerestrictTrait_<This> left( derestrict( *
this ) );
9464 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
9465 const ResultType_<MT2> tmp( right );
9494 template<
typename MT >
9495 template<
typename MT2
9497 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,true,true>& >
9504 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
9513 if( !tryAddAssign( matrix_, ~rhs, row_, column_ ) ) {
9517 DerestrictTrait_<This> left( derestrict( *
this ) );
9519 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
9520 (~rhs).canAlias( &matrix_ ) ) {
9521 const AddType tmp( *
this + (~rhs) );
9550 template<
typename MT >
9551 template<
typename MT2
9553 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,true,true>& >
9560 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
9569 const AddType tmp( *
this + (~rhs) );
9571 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
9575 DerestrictTrait_<This> left( derestrict( *
this ) );
9601 template<
typename MT >
9602 template<
typename MT2
9604 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,true,true>& >
9611 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
9620 if( !trySubAssign( matrix_, ~rhs, row_, column_ ) ) {
9624 DerestrictTrait_<This> left( derestrict( *
this ) );
9626 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
9627 (~rhs).canAlias( &matrix_ ) ) {
9628 const SubType tmp( *
this - (~rhs ) );
9657 template<
typename MT >
9658 template<
typename MT2
9660 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,true,true>& >
9667 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
9676 const SubType tmp( *
this - (~rhs) );
9678 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
9682 DerestrictTrait_<This> left( derestrict( *
this ) );
9708 template<
typename MT >
9709 template<
typename MT2
9711 inline Submatrix<MT,aligned,true,true>&
9718 typedef MultTrait_< ResultType, ResultType_<MT2> > MultType;
9727 const MultType tmp( *
this * (~rhs) );
9729 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
9733 DerestrictTrait_<This> left( derestrict( *
this ) );
9756 template<
typename MT >
9757 template<
typename Other >
9758 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,aligned,true,true> >&
9763 DerestrictTrait_<This> left( derestrict( *
this ) );
9785 template<
typename MT >
9786 template<
typename Other >
9787 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,aligned,true,true> >&
9794 DerestrictTrait_<This> left( derestrict( *
this ) );
9817 template<
typename MT >
9832 template<
typename MT >
9847 template<
typename MT >
9862 template<
typename MT >
9880 template<
typename MT >
9883 return matrix_.spacing();
9895 template<
typename MT >
9911 template<
typename MT >
9930 template<
typename MT >
9933 const size_t iend( row_ + m_ );
9934 const size_t jend( column_ + n_ );
9935 size_t nonzeros( 0UL );
9937 for(
size_t j=column_; j<jend; ++j )
9938 for(
size_t i=row_; i<iend; ++i )
9955 template<
typename MT >
9960 const size_t iend( row_ + m_ );
9961 size_t nonzeros( 0UL );
9963 for(
size_t i=row_; i<iend; ++i )
9964 if( !
isDefault( matrix_(i,column_+j) ) )
9979 template<
typename MT >
9984 for(
size_t j=column_; j<column_+
n_; ++j )
9986 const size_t ibegin( ( IsLower<MT>::value )
9987 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
9988 ?(
max( j+1UL, row_ ) )
9989 :(
max( j, row_ ) ) )
9991 const size_t iend ( ( IsUpper<MT>::value )
9992 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
9993 ?(
min( j, row_+m_ ) )
9994 :(
min( j+1UL, row_+m_ ) ) )
9997 for(
size_t i=ibegin; i<iend; ++i )
9998 clear( matrix_(i,j) );
10012 template<
typename MT >
10019 const size_t ibegin( ( IsLower<MT>::value )
10020 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
10021 ?(
max( j+1UL, row_ ) )
10022 :(
max( j, row_ ) ) )
10024 const size_t iend ( ( IsUpper<MT>::value )
10025 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
10026 ?(
min( j, row_+m_ ) )
10027 :(
min( j+1UL, row_+m_ ) ) )
10030 for(
size_t i=ibegin; i<iend; ++i )
10031 clear( matrix_(i,column_+j) );
10055 template<
typename MT >
10062 if( !tryAssign( matrix_,
trans( *
this ), row_, column_ ) ) {
10066 DerestrictTrait_<This> left( derestrict( *
this ) );
10067 const ResultType tmp(
trans( *
this ) );
10094 template<
typename MT >
10101 if( !tryAssign( matrix_,
ctrans( *
this ), row_, column_ ) ) {
10105 DerestrictTrait_<This> left( derestrict( *
this ) );
10106 const ResultType tmp(
ctrans( *
this ) );
10126 template<
typename MT >
10127 template<
typename Other >
10128 inline Submatrix<MT,aligned,true,true>& Submatrix<MT,aligned,true,true>::scale(
const Other& scalar )
10132 const size_t jend( column_ + n_ );
10134 for(
size_t j=column_; j<jend; ++j )
10136 const size_t ibegin( ( IsLower<MT>::value )
10137 ?( ( IsStrictlyLower<MT>::value )
10138 ?(
max( j+1UL, row_ ) )
10139 :(
max( j, row_ ) ) )
10141 const size_t iend ( ( IsUpper<MT>::value )
10142 ?( ( IsStrictlyUpper<MT>::value )
10143 ?(
min( j, row_+m_ ) )
10144 :(
min( j+1UL, row_+m_ ) ) )
10147 for(
size_t i=ibegin; i<iend; ++i )
10148 matrix_(i,j) *= scalar;
10167 template<
typename MT >
10168 inline bool Submatrix<MT,aligned,true,true>::hasOverlap() const noexcept
10170 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
10172 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
10199 template<
typename MT >
10200 template<
typename Other >
10201 inline bool Submatrix<MT,aligned,true,true>::canAlias(
const Other* alias )
const noexcept
10203 return matrix_.isAliased( alias );
10220 template<
typename MT >
10221 template<
typename MT2
10224 inline bool Submatrix<MT,aligned,true,true>::canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
10226 return ( matrix_.isAliased( &alias->matrix_ ) &&
10227 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
10228 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
10245 template<
typename MT >
10246 template<
typename Other >
10247 inline bool Submatrix<MT,aligned,true,true>::isAliased(
const Other* alias )
const noexcept
10249 return matrix_.isAliased( alias );
10266 template<
typename MT >
10267 template<
typename MT2
10270 inline bool Submatrix<MT,aligned,true,true>::isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
10272 return ( matrix_.isAliased( &alias->matrix_ ) &&
10273 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
10274 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
10290 template<
typename MT >
10291 inline bool Submatrix<MT,aligned,true,true>::isAligned() const noexcept
10310 template<
typename MT >
10311 inline bool Submatrix<MT,aligned,true,true>::canSMPAssign() const noexcept
10313 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
10334 template<
typename MT >
10336 Submatrix<MT,aligned,true,true>::load(
size_t i,
size_t j )
const noexcept
10338 return loada( i, j );
10359 template<
typename MT >
10370 return matrix_.loada( row_+i, column_+j );
10391 template<
typename MT >
10402 return matrix_.loadu( row_+i, column_+j );
10424 template<
typename MT >
10426 Submatrix<MT,aligned,true,true>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
10450 template<
typename MT >
10461 matrix_.storea( row_+i, column_+j, value );
10483 template<
typename MT >
10494 matrix_.storeu( row_+i, column_+j, value );
10517 template<
typename MT >
10528 matrix_.stream( row_+i, column_+j, value );
10546 template<
typename MT >
10547 template<
typename MT2 >
10548 inline DisableIf_< typename Submatrix<MT,aligned,true,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
10549 Submatrix<MT,aligned,true,true>::assign(
const DenseMatrix<MT2,true>& rhs )
10554 const size_t ipos( m_ &
size_t(-2) );
10557 for(
size_t j=0UL; j<
n_; ++j ) {
10558 for(
size_t i=0UL; i<ipos; i+=2UL ) {
10559 matrix_(row_+i ,column_+j) = (~rhs)(i ,j);
10560 matrix_(row_+i+1UL,column_+j) = (~rhs)(i+1UL,j);
10563 matrix_(row_+ipos,column_+j) = (~rhs)(ipos,j);
10583 template<
typename MT >
10584 template<
typename MT2 >
10585 inline EnableIf_< typename Submatrix<MT,aligned,true,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
10586 Submatrix<MT,aligned,true,true>::assign(
const DenseMatrix<MT2,true>& rhs )
10593 const size_t ipos( m_ &
size_t(-SIMDSIZE) );
10597 m_*n_ > (
cacheSize / (
sizeof(ElementType) * 3UL ) ) &&
10598 !(~rhs).isAliased( &matrix_ ) )
10600 for(
size_t j=0UL; j<
n_; ++j )
10603 Iterator left(
begin(j) );
10604 ConstIterator_<MT2> right( (~rhs).
begin(j) );
10606 for( ; i<ipos; i+=SIMDSIZE ) {
10607 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10609 for( ; i<
m_; ++i ) {
10610 *left = *right; ++left; ++right;
10616 for(
size_t j=0UL; j<
n_; ++j )
10619 Iterator left(
begin(j) );
10620 ConstIterator_<MT2> right( (~rhs).
begin(j) );
10622 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
10623 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10624 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10625 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10626 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10628 for( ; i<ipos; i+=SIMDSIZE ) {
10629 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10631 for( ; i<
m_; ++i ) {
10632 *left = *right; ++left; ++right;
10653 template<
typename MT >
10654 template<
typename MT2 >
10655 inline void Submatrix<MT,aligned,true,true>::assign(
const DenseMatrix<MT2,false>& rhs )
10662 const size_t block( BLOCK_SIZE );
10664 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
10665 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
10666 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
10667 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
10668 for(
size_t j=jj; j<jend; ++j ) {
10669 for(
size_t i=ii; i<iend; ++i ) {
10670 matrix_(row_+i,column_+j) = (~rhs)(i,j);
10692 template<
typename MT >
10693 template<
typename MT2 >
10694 inline void Submatrix<MT,aligned,true,true>::assign(
const SparseMatrix<MT2,true>& rhs )
10699 for(
size_t j=0UL; j<
n_; ++j )
10700 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
10701 matrix_(row_+element->index(),column_+j) = element->value();
10719 template<
typename MT >
10720 template<
typename MT2 >
10721 inline void Submatrix<MT,aligned,true,true>::assign(
const SparseMatrix<MT2,false>& rhs )
10728 for(
size_t i=0UL; i<
m_; ++i )
10729 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
10730 matrix_(row_+i,column_+element->index()) = element->value();
10748 template<
typename MT >
10749 template<
typename MT2 >
10750 inline DisableIf_< typename Submatrix<MT,aligned,true,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
10751 Submatrix<MT,aligned,true,true>::addAssign(
const DenseMatrix<MT2,true>& rhs )
10756 const size_t ipos( m_ &
size_t(-2) );
10759 for(
size_t j=0UL; j<
n_; ++j )
10761 if( IsDiagonal<MT2>::value ) {
10762 matrix_(row_+j,column_+j) += (~rhs)(j,j);
10765 for(
size_t i=0UL; i<ipos; i+=2UL ) {
10766 matrix_(row_+i ,column_+j) += (~rhs)(i ,j);
10767 matrix_(row_+i+1UL,column_+j) += (~rhs)(i+1UL,j);
10770 matrix_(row_+ipos,column_+j) += (~rhs)(ipos,j);
10791 template<
typename MT >
10792 template<
typename MT2 >
10793 inline EnableIf_< typename Submatrix<MT,aligned,true,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
10794 Submatrix<MT,aligned,true,true>::addAssign(
const DenseMatrix<MT2,true>& rhs )
10801 for(
size_t j=0UL; j<
n_; ++j )
10803 const size_t ibegin( ( IsLower<MT>::value )
10804 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-SIMDSIZE) )
10806 const size_t iend ( ( IsUpper<MT>::value )
10807 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
10811 const size_t ipos( iend &
size_t(-SIMDSIZE) );
10814 size_t i( ibegin );
10815 Iterator left(
begin(j) + ibegin );
10816 ConstIterator_<MT2> right( (~rhs).
begin(j) + ibegin );
10818 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
10819 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10820 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10821 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10822 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10824 for( ; i<ipos; i+=SIMDSIZE ) {
10825 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10827 for( ; i<iend; ++i ) {
10828 *left += *right; ++left; ++right;
10848 template<
typename MT >
10849 template<
typename MT2 >
10850 inline void Submatrix<MT,aligned,true,true>::addAssign(
const DenseMatrix<MT2,false>& rhs )
10857 const size_t block( BLOCK_SIZE );
10859 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
10860 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
10861 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
10862 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
10863 for(
size_t j=jj; j<jend; ++j ) {
10864 for(
size_t i=ii; i<iend; ++i ) {
10865 matrix_(row_+i,column_+j) += (~rhs)(i,j);
10887 template<
typename MT >
10888 template<
typename MT2 >
10889 inline void Submatrix<MT,aligned,true,true>::addAssign(
const SparseMatrix<MT2,true>& rhs )
10894 for(
size_t j=0UL; j<
n_; ++j )
10895 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
10896 matrix_(row_+element->index(),column_+j) += element->value();
10914 template<
typename MT >
10915 template<
typename MT2 >
10916 inline void Submatrix<MT,aligned,true,true>::addAssign(
const SparseMatrix<MT2,false>& rhs )
10923 for(
size_t i=0UL; i<
m_; ++i )
10924 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
10925 matrix_(row_+i,column_+element->index()) += element->value();
10943 template<
typename MT >
10944 template<
typename MT2 >
10945 inline DisableIf_< typename Submatrix<MT,aligned,true,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
10946 Submatrix<MT,aligned,true,true>::subAssign(
const DenseMatrix<MT2,true>& rhs )
10951 const size_t ipos( m_ &
size_t(-2) );
10954 for(
size_t j=0UL; j<
n_; ++j )
10956 if( IsDiagonal<MT2>::value ) {
10957 matrix_(row_+j,column_+j) -= (~rhs)(j,j);
10960 for(
size_t i=0UL; i<ipos; i+=2UL ) {
10961 matrix_(row_+i ,column_+j) -= (~rhs)(i ,j);
10962 matrix_(row_+i+1UL,column_+j) -= (~rhs)(i+1UL,j);
10965 matrix_(row_+ipos,column_+j) -= (~rhs)(ipos,j);
10986 template<
typename MT >
10987 template<
typename MT2 >
10988 inline EnableIf_< typename Submatrix<MT,aligned,true,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
10989 Submatrix<MT,aligned,true,true>::subAssign(
const DenseMatrix<MT2,true>& rhs )
10996 for(
size_t j=0UL; j<
n_; ++j )
10998 const size_t ibegin( ( IsLower<MT>::value )
10999 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-SIMDSIZE) )
11001 const size_t iend ( ( IsUpper<MT>::value )
11002 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
11006 const size_t ipos( iend &
size_t(-SIMDSIZE) );
11009 size_t i( ibegin );
11010 Iterator left(
begin(j) + ibegin );
11011 ConstIterator_<MT2> right( (~rhs).
begin(j) + ibegin );
11013 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
11014 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11015 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11016 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11017 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11019 for( ; i<ipos; i+=SIMDSIZE ) {
11020 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11022 for( ; i<iend; ++i ) {
11023 *left -= *right; ++left; ++right;
11043 template<
typename MT >
11044 template<
typename MT2 >
11045 inline void Submatrix<MT,aligned,true,true>::subAssign(
const DenseMatrix<MT2,false>& rhs )
11052 const size_t block( BLOCK_SIZE );
11054 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
11055 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
11056 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
11057 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
11058 for(
size_t j=jj; j<jend; ++j ) {
11059 for(
size_t i=ii; i<iend; ++i ) {
11060 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
11082 template<
typename MT >
11083 template<
typename MT2 >
11084 inline void Submatrix<MT,aligned,true,true>::subAssign(
const SparseMatrix<MT2,true>& rhs )
11089 for(
size_t j=0UL; j<
n_; ++j )
11090 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
11091 matrix_(row_+element->index(),column_+j) -= element->value();
11109 template<
typename MT >
11110 template<
typename MT2 >
11111 inline void Submatrix<MT,aligned,true,true>::subAssign(
const SparseMatrix<MT2,false>& rhs )
11118 for(
size_t i=0UL; i<
m_; ++i )
11119 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
11120 matrix_(row_+i,column_+element->index()) -= element->value();
Constraint on the data type.
#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.
Header file for kernel specific block sizes.
Header file for mathematical functions.
constexpr bool useOptimizedKernels
Configuration switch for optimized kernels.This configuration switch enables/disables all optimized c...
Definition: Optimizations.h:84
typename DerestrictTrait< T >::Type DerestrictTrait_
Auxiliary alias declaration for the DerestrictTrait type trait.The DerestrictTrait_ alias declaration...
Definition: DerestrictTrait.h:110
#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 alignment flag values.
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7800
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:346
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:653
Header file for basic type definitions.
Header file for the View base class.
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:404
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:79
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:160
Header file for the IsSparseMatrix type trait.
Header file for the IsDiagonal 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:258
const CTransExprTrait_< MT > ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatForEachExpr.h:1195
#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
constexpr size_t cacheSize
Cache size of the target architecture.This setting specifies the available cache size in Byte of the ...
Definition: CacheSize.h:48
#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
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
const bool aligned
Alignment flag for aligned vectors and matrices.Via this flag it is possible to specify subvectors...
Definition: AlignmentFlag.h:85
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:188
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
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:699
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2805
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2643
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
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:1669
bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:366
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SUBMATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a submatrix type (i.e. a dense or sparse submatrix), a compilation error is created.
Definition: Submatrix.h:81
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:590
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2636
#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
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:442
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:384
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:731
Constraints on the storage order of matrix types.
#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.
System settings for performance optimizations.
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:77
Header file for the IsUniLower type trait.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
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:129
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2639
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:126
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:298
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:232
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
constexpr bool spacing
Adding an additional spacing line between two log messages.This setting gives the opportunity to add ...
Definition: Logging.h:70
Header file for the std::initializer_list aliases.
Header file for the matrix storage order types.
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for nested template disabiguation.
Header file for the If class template.
constexpr bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Optimizations.h:68
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#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:98
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
Header file for the implementation of the Submatrix base template.
Header file for the HasSIMDAdd type trait.
Header file for the DenseMatrix base class.
Header file for the Not class template.
Header file for all SIMD functionality.
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:330
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:80
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a vectorizable data type...
Definition: Vectorizable.h:61
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
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:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
const bool unaligned
Alignment flag for unaligned vectors and matrices.Via this flag it is possible to specify subvectors...
Definition: AlignmentFlag.h:64
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the DerestrictTrait class template.
Constraint on the data type.
Header file for the IsNumeric type trait.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:126
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > stream(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned, non-temporal store of a vector of 1-byte integral values.
Definition: Stream.h:75
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2642
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:1285
size_t determineColumns(initializer_list< initializer_list< Type > > list) noexcept
Determine the maximum number of columns specified by the given initializer list.
Definition: InitializerList.h:80
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the submatrix trait.
Header file for the cache size of the target architecture.
#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
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
Header file for the HasSIMDSub type trait.
Constraints on the storage order of matrix types.
#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.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition: Storeu.h:76
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:314
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2637
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2806
Header file for the AreSIMDCombinable type trait.
bool operator<(const NegativeAccuracy< A > &lhs, const T &rhs)
Less-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:328
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:950
Header file for the alignment check function.
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2638
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
#define BLAZE_THROW_LOGIC_ERROR(MESSAGE)
Macro for the emission of a std::logic_error exception.This macro encapsulates the default way of Bla...
Definition: Exception.h:187
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:1303
Header file for the IsUpper type trait.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
SubmatrixExprTrait_< MT, unaligned > submatrix(Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:167
Header file for the IsHermitian type trait.
Header file for the IsRestricted type trait.
System settings for the inline keywords.
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.
Constraint on the data type.
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:564