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 );
669 template< typename Other > inline Submatrix& scale( const Other& scalar );
676 template< typename MT2 >
677 struct VectorizedAssign {
679 simdEnabled && MT2::simdEnabled &&
680 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value };
686 template<
typename MT2 >
687 struct VectorizedAddAssign {
689 simdEnabled && MT2::simdEnabled &&
690 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
691 HasSIMDAdd< ElementType, ElementType_<MT2> >::value &&
692 !IsDiagonal<MT2>::value };
698 template<
typename MT2 >
699 struct VectorizedSubAssign {
701 simdEnabled && MT2::simdEnabled &&
702 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
703 HasSIMDSub< ElementType, ElementType_<MT2> >::value &&
704 !IsDiagonal<MT2>::value };
717 template<
typename Other >
718 inline bool canAlias(
const Other* alias )
const noexcept;
720 template<
typename MT2,
bool AF2,
bool SO2 >
721 inline bool canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
723 template<
typename Other >
724 inline bool isAliased(
const Other* alias )
const noexcept;
726 template<
typename MT2,
bool AF2,
bool SO2 >
727 inline bool isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
729 inline bool isAligned () const noexcept;
730 inline
bool canSMPAssign() const noexcept;
741 template< typename MT2 >
742 inline
DisableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,false>& rhs );
744 template< typename MT2 >
745 inline
EnableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,false>& rhs );
747 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,true>& rhs );
748 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
749 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
751 template< typename MT2 >
752 inline
DisableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,false>& rhs );
754 template< typename MT2 >
755 inline
EnableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,false>& rhs );
757 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,true>& rhs );
758 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
759 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
761 template< typename MT2 >
762 inline
DisableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,false>& rhs );
764 template< typename MT2 >
765 inline
EnableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,false>& rhs );
767 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,true>& rhs );
768 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
769 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
777 inline
bool hasOverlap() const noexcept;
786 const
size_t column_;
789 const
bool isAligned_;
800 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 > friend class Submatrix;
802 template<
bool AF1, typename MT2,
bool AF2,
bool SO2,
bool DF2 >
803 friend const Submatrix<MT2,AF1,SO2,DF2>
804 submatrix( const Submatrix<MT2,AF2,SO2,DF2>& sm,
size_t row,
size_t column,
size_t m,
size_t n );
806 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
807 friend
bool isIntact( const Submatrix<MT2,AF2,SO2,DF2>& sm ) noexcept;
809 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
810 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Matrix<MT2,SO2>& b ) noexcept;
812 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
813 friend
bool isSame( const Matrix<MT2,SO2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
815 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
816 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
818 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
819 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
820 size_t row,
size_t column );
822 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
823 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
824 size_t row,
size_t column );
826 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
827 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
828 size_t row,
size_t column );
830 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
831 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
832 size_t row,
size_t column );
834 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
835 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
836 size_t row,
size_t column );
838 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
839 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
840 size_t row,
size_t column );
842 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
843 friend
bool tryMultAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
844 size_t row,
size_t column );
846 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
847 friend
DerestrictTrait_< Submatrix<MT2,AF2,SO2,DF2> > derestrict( Submatrix<MT2,AF2,SO2,DF2>& sm );
886 template< typename MT >
887 inline Submatrix<MT,
unaligned,false,true>::Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n )
893 , isAligned_( simdEnabled && matrix.data() !=
nullptr &&
checkAlignment( data() ) &&
894 ( m < 2UL || ( matrix.
spacing() &
size_t(-SIMDSIZE) ) == 0UL ) )
896 if( ( row_ + m_ > matrix_.rows() ) || ( column_ + n_ > matrix_.columns() ) ) {
923 template<
typename MT >
925 Submatrix<MT,unaligned,false,true>::operator()(
size_t i,
size_t j )
930 return matrix_(row_+i,column_+j);
947 template<
typename MT >
949 Submatrix<MT,unaligned,false,true>::operator()(
size_t i,
size_t j )
const 954 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
972 template<
typename MT >
974 Submatrix<MT,unaligned,false,true>::at(
size_t i,
size_t j )
1000 template<
typename MT >
1002 Submatrix<MT,unaligned,false,true>::at(
size_t i,
size_t j )
const 1010 return (*
this)(i,j);
1026 template<
typename MT >
1027 inline typename Submatrix<MT,unaligned,false,true>::Pointer
1028 Submatrix<MT,unaligned,false,true>::data() noexcept
1030 return matrix_.data() + row_*
spacing() + column_;
1046 template<
typename MT >
1047 inline typename Submatrix<MT,unaligned,false,true>::ConstPointer
1048 Submatrix<MT,unaligned,false,true>::data() const noexcept
1050 return matrix_.data() + row_*
spacing() + column_;
1065 template<
typename MT >
1066 inline typename Submatrix<MT,unaligned,false,true>::Pointer
1067 Submatrix<MT,unaligned,false,true>::data(
size_t i ) noexcept
1069 return matrix_.data() + (row_+i)*
spacing() + column_;
1084 template<
typename MT >
1085 inline typename Submatrix<MT,unaligned,false,true>::ConstPointer
1086 Submatrix<MT,unaligned,false,true>::data(
size_t i )
const noexcept
1088 return matrix_.data() + (row_+i)*
spacing() + column_;
1106 template<
typename MT >
1111 return Iterator( matrix_.begin( row_ + i ) + column_, isAligned_ );
1129 template<
typename MT >
1134 return ConstIterator( matrix_.cbegin( row_ + i ) + column_, isAligned_ );
1152 template<
typename MT >
1157 return ConstIterator( matrix_.cbegin( row_ + i ) + column_, isAligned_ );
1175 template<
typename MT >
1180 return Iterator( matrix_.begin( row_ + i ) + column_ +
n_, isAligned_ );
1198 template<
typename MT >
1203 return ConstIterator( matrix_.cbegin( row_ + i ) + column_ +
n_, isAligned_ );
1221 template<
typename MT >
1226 return ConstIterator( matrix_.cbegin( row_ + i ) + column_ +
n_, isAligned_ );
1251 template<
typename MT >
1252 inline Submatrix<MT,unaligned,false,true>&
1253 Submatrix<MT,unaligned,false,true>::operator=(
const ElementType& rhs )
1255 const size_t iend( row_ + m_ );
1257 for(
size_t i=row_; i<iend; ++i )
1259 const size_t jbegin( ( IsUpper<MT>::value )
1260 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
1261 ?(
max( i+1UL, column_ ) )
1262 :(
max( i, column_ ) ) )
1264 const size_t jend ( ( IsLower<MT>::value )
1265 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
1266 ?(
min( i, column_+n_ ) )
1267 :(
min( i+1UL, column_+n_ ) ) )
1270 for(
size_t j=jbegin; j<jend; ++j )
1293 template<
typename MT >
1294 inline Submatrix<MT,unaligned,false,true>&
1295 Submatrix<MT,unaligned,false,true>::operator=( initializer_list< initializer_list<ElementType> > list )
1303 for(
const auto& rowList : list ) {
1304 std::fill( std::copy( rowList.begin(), rowList.end(),
begin(i) ),
end(i),
ElementType() );
1329 template<
typename MT >
1330 inline Submatrix<MT,unaligned,false,true>&
1331 Submatrix<MT,unaligned,false,true>::operator=(
const Submatrix& rhs )
1336 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
1339 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
1343 if( !tryAssign( matrix_, rhs, row_, column_ ) ) {
1347 DerestrictTrait_<This> left( derestrict( *
this ) );
1349 if( rhs.canAlias( &matrix_ ) ) {
1350 const ResultType tmp( rhs );
1380 template<
typename MT >
1381 template<
typename MT2
1383 inline Submatrix<MT,unaligned,false,true>&
1384 Submatrix<MT,unaligned,false,true>::operator=(
const Matrix<MT2,SO2>& rhs )
1392 typedef If_< IsRestricted<MT>, CompositeType_<MT2>,
const MT2& > Right;
1393 Right right( ~rhs );
1395 if( !tryAssign( matrix_, right, row_, column_ ) ) {
1399 if( IsSparseMatrix<MT2>::value )
1402 DerestrictTrait_<This> left( derestrict( *
this ) );
1404 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1405 const ResultType_<MT2> tmp( right );
1434 template<
typename MT >
1435 template<
typename MT2
1437 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,false,true>& >
1444 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
1453 if( !tryAddAssign( matrix_, ~rhs, row_, column_ ) ) {
1457 DerestrictTrait_<This> left( derestrict( *
this ) );
1459 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
1460 (~rhs).canAlias( &matrix_ ) ) {
1461 const AddType tmp( *
this + (~rhs) );
1490 template<
typename MT >
1491 template<
typename MT2
1493 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,false,true>& >
1500 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
1509 const AddType tmp( *
this + (~rhs) );
1511 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
1515 DerestrictTrait_<This> left( derestrict( *
this ) );
1541 template<
typename MT >
1542 template<
typename MT2
1544 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,false,true>& >
1551 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
1560 if( !trySubAssign( matrix_, ~rhs, row_, column_ ) ) {
1564 DerestrictTrait_<This> left( derestrict( *
this ) );
1566 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
1567 (~rhs).canAlias( &matrix_ ) ) {
1568 const SubType tmp( *
this - (~rhs ) );
1597 template<
typename MT >
1598 template<
typename MT2
1600 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,false,true>& >
1607 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
1616 const SubType tmp( *
this - (~rhs) );
1618 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
1622 DerestrictTrait_<This> left( derestrict( *
this ) );
1648 template<
typename MT >
1649 template<
typename MT2
1651 inline Submatrix<MT,unaligned,false,true>&
1658 typedef MultTrait_< ResultType, ResultType_<MT2> > MultType;
1667 const MultType tmp( *
this * (~rhs) );
1669 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
1673 DerestrictTrait_<This> left( derestrict( *
this ) );
1696 template<
typename MT >
1697 template<
typename Other >
1698 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,unaligned,false,true> >&
1703 DerestrictTrait_<This> left( derestrict( *
this ) );
1725 template<
typename MT >
1726 template<
typename Other >
1727 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,unaligned,false,true> >&
1734 DerestrictTrait_<This> left( derestrict( *
this ) );
1757 template<
typename MT >
1772 template<
typename MT >
1787 template<
typename MT >
1801 template<
typename MT >
1821 template<
typename MT >
1824 return matrix_.spacing();
1835 template<
typename MT >
1856 template<
typename MT >
1875 template<
typename MT >
1878 const size_t iend( row_ + m_ );
1879 const size_t jend( column_ + n_ );
1880 size_t nonzeros( 0UL );
1882 for(
size_t i=row_; i<iend; ++i )
1883 for(
size_t j=column_; j<jend; ++j )
1905 template<
typename MT >
1910 const size_t jend( column_ + n_ );
1911 size_t nonzeros( 0UL );
1913 for(
size_t j=column_; j<jend; ++j )
1929 template<
typename MT >
1934 for(
size_t i=row_; i<row_+
m_; ++i )
1936 const size_t jbegin( ( IsUpper<MT>::value )
1937 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
1938 ?(
max( i+1UL, column_ ) )
1939 :(
max( i, column_ ) ) )
1941 const size_t jend ( ( IsLower<MT>::value )
1942 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
1943 ?(
min( i, column_+n_ ) )
1944 :(
min( i+1UL, column_+n_ ) ) )
1947 for(
size_t j=jbegin; j<jend; ++j )
1948 clear( matrix_(i,j) );
1967 template<
typename MT >
1974 const size_t jbegin( ( IsUpper<MT>::value )
1975 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
1976 ?(
max( i+1UL, column_ ) )
1977 :(
max( i, column_ ) ) )
1979 const size_t jend ( ( IsLower<MT>::value )
1980 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
1981 ?(
min( i, column_+n_ ) )
1982 :(
min( i+1UL, column_+n_ ) ) )
1985 for(
size_t j=jbegin; j<jend; ++j )
1986 clear( matrix_(row_+i,j) );
2002 template<
typename MT >
2003 inline bool Submatrix<MT,unaligned,false,true>::hasOverlap() const noexcept
2005 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
2007 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
2041 template<
typename MT >
2048 if( !tryAssign( matrix_,
trans( *
this ), row_, column_ ) ) {
2052 DerestrictTrait_<This> left( derestrict( *
this ) );
2053 const ResultType tmp(
trans( *
this ) );
2080 template<
typename MT >
2087 if( !tryAssign( matrix_,
ctrans( *
this ), row_, column_ ) ) {
2091 DerestrictTrait_<This> left( derestrict( *
this ) );
2092 const ResultType tmp(
ctrans( *
this ) );
2112 template<
typename MT >
2113 template<
typename Other >
2114 inline Submatrix<MT,unaligned,false,true>&
2115 Submatrix<MT,unaligned,false,true>::scale(
const Other& scalar )
2119 const size_t iend( row_ + m_ );
2121 for(
size_t i=row_; i<iend; ++i )
2123 const size_t jbegin( ( IsUpper<MT>::value )
2124 ?( ( IsStrictlyUpper<MT>::value )
2125 ?(
max( i+1UL, column_ ) )
2126 :(
max( i, column_ ) ) )
2128 const size_t jend ( ( IsLower<MT>::value )
2129 ?( ( IsStrictlyLower<MT>::value )
2130 ?(
min( i, column_+n_ ) )
2131 :(
min( i+1UL, column_+n_ ) ) )
2134 for(
size_t j=jbegin; j<jend; ++j )
2135 matrix_(i,j) *= scalar;
2163 template<
typename MT >
2164 template<
typename Other >
2165 inline bool Submatrix<MT,unaligned,false,true>::canAlias(
const Other* alias )
const noexcept
2167 return matrix_.isAliased( alias );
2184 template<
typename MT >
2185 template<
typename MT2
2188 inline bool Submatrix<MT,unaligned,false,true>::canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
2190 return ( matrix_.isAliased( &alias->matrix_ ) &&
2191 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
2192 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
2209 template<
typename MT >
2210 template<
typename Other >
2211 inline bool Submatrix<MT,unaligned,false,true>::isAliased(
const Other* alias )
const noexcept
2213 return matrix_.isAliased( alias );
2230 template<
typename MT >
2231 template<
typename MT2
2234 inline bool Submatrix<MT,unaligned,false,true>::isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
2236 return ( matrix_.isAliased( &alias->matrix_ ) &&
2237 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
2238 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
2254 template<
typename MT >
2255 inline bool Submatrix<MT,unaligned,false,true>::isAligned() const noexcept
2274 template<
typename MT >
2275 inline bool Submatrix<MT,unaligned,false,true>::canSMPAssign() const noexcept
2277 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
2299 template<
typename MT >
2301 Submatrix<MT,unaligned,false,true>::load(
size_t i,
size_t j )
const noexcept
2304 return loada( i, j );
2306 return loadu( i, j );
2328 template<
typename MT >
2339 return matrix_.loada( row_+i, column_+j );
2361 template<
typename MT >
2372 return matrix_.loadu( row_+i, column_+j );
2395 template<
typename MT >
2397 Submatrix<MT,unaligned,false,true>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
2425 template<
typename MT >
2436 matrix_.storea( row_+i, column_+j, value );
2459 template<
typename MT >
2470 matrix_.storeu( row_+i, column_+j, value );
2493 template<
typename MT >
2505 matrix_.stream( row_+i, column_+j, value );
2507 matrix_.storeu( row_+i, column_+j, value );
2525 template<
typename MT >
2526 template<
typename MT2 >
2527 inline DisableIf_< typename Submatrix<MT,unaligned,false,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
2528 Submatrix<MT,unaligned,false,true>::assign(
const DenseMatrix<MT2,false>& rhs )
2533 const size_t jpos( n_ &
size_t(-2) );
2536 for(
size_t i=0UL; i<
m_; ++i ) {
2537 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2538 matrix_(row_+i,column_+j ) = (~rhs)(i,j );
2539 matrix_(row_+i,column_+j+1UL) = (~rhs)(i,j+1UL);
2542 matrix_(row_+i,column_+jpos) = (~rhs)(i,jpos);
2562 template<
typename MT >
2563 template<
typename MT2 >
2564 inline EnableIf_< typename Submatrix<MT,unaligned,false,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
2565 Submatrix<MT,unaligned,false,true>::assign(
const DenseMatrix<MT2,false>& rhs )
2572 const size_t jpos( n_ &
size_t(-SIMDSIZE) );
2576 m_*n_ > (
cacheSize / (
sizeof(ElementType) * 3UL ) ) &&
2577 !(~rhs).isAliased( &matrix_ ) )
2579 for(
size_t i=0UL; i<
m_; ++i )
2582 Iterator left(
begin(i) );
2583 ConstIterator_<MT2> right( (~rhs).
begin(i) );
2585 for( ; j<jpos; j+=SIMDSIZE ) {
2586 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2588 for( ; j<
n_; ++j ) {
2595 for(
size_t i=0UL; i<
m_; ++i )
2598 Iterator left(
begin(i) );
2599 ConstIterator_<MT2> right( (~rhs).
begin(i) );
2601 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2602 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2603 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2604 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2605 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2607 for( ; j<jpos; j+=SIMDSIZE ) {
2608 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2610 for( ; j<
n_; ++j ) {
2611 *left = *right; ++left; ++right;
2632 template<
typename MT >
2633 template<
typename MT2 >
2634 inline void Submatrix<MT,unaligned,false,true>::assign(
const DenseMatrix<MT2,true>& rhs )
2641 constexpr
size_t block( BLOCK_SIZE );
2643 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2644 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2645 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2646 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2647 for(
size_t i=ii; i<iend; ++i ) {
2648 for(
size_t j=jj; j<jend; ++j ) {
2649 matrix_(row_+i,column_+j) = (~rhs)(i,j);
2671 template<
typename MT >
2672 template<
typename MT2 >
2673 inline void Submatrix<MT,unaligned,false,true>::assign(
const SparseMatrix<MT2,false>& rhs )
2678 for(
size_t i=0UL; i<
m_; ++i )
2679 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
2680 matrix_(row_+i,column_+element->index()) = element->value();
2698 template<
typename MT >
2699 template<
typename MT2 >
2700 inline void Submatrix<MT,unaligned,false,true>::assign(
const SparseMatrix<MT2,true>& rhs )
2707 for(
size_t j=0UL; j<
n_; ++j )
2708 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2709 matrix_(row_+element->index(),column_+j) = element->value();
2727 template<
typename MT >
2728 template<
typename MT2 >
2729 inline DisableIf_< typename Submatrix<MT,unaligned,false,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
2730 Submatrix<MT,unaligned,false,true>::addAssign(
const DenseMatrix<MT2,false>& rhs )
2735 const size_t jpos( n_ &
size_t(-2) );
2738 for(
size_t i=0UL; i<
m_; ++i )
2740 if( IsDiagonal<MT2>::value ) {
2741 matrix_(row_+i,column_+i) += (~rhs)(i,i);
2744 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2745 matrix_(row_+i,column_+j ) += (~rhs)(i,j );
2746 matrix_(row_+i,column_+j+1UL) += (~rhs)(i,j+1UL);
2749 matrix_(row_+i,column_+jpos) += (~rhs)(i,jpos);
2770 template<
typename MT >
2771 template<
typename MT2 >
2772 inline EnableIf_< typename Submatrix<MT,unaligned,false,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
2773 Submatrix<MT,unaligned,false,true>::addAssign(
const DenseMatrix<MT2,false>& rhs )
2780 for(
size_t i=0UL; i<
m_; ++i )
2782 const size_t jbegin( ( IsUpper<MT2>::value )
2783 ?( ( IsStrictlyUpper<MT2>::value ? i+1UL : i ) &
size_t(-SIMDSIZE) )
2785 const size_t jend ( ( IsLower<MT2>::value )
2786 ?( IsStrictlyLower<MT2>::value ? i : i+1UL )
2790 const size_t jpos( jend &
size_t(-SIMDSIZE) );
2794 Iterator left(
begin(i) + jbegin );
2795 ConstIterator_<MT2> right( (~rhs).
begin(i) + jbegin );
2797 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2798 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2799 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2800 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2801 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2803 for( ; j<jpos; j+=SIMDSIZE ) {
2804 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2806 for( ; j<jend; ++j ) {
2807 *left += *right; ++left; ++right;
2827 template<
typename MT >
2828 template<
typename MT2 >
2829 inline void Submatrix<MT,unaligned,false,true>::addAssign(
const DenseMatrix<MT2,true>& rhs )
2836 constexpr
size_t block( BLOCK_SIZE );
2838 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2839 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2840 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2841 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2842 for(
size_t i=ii; i<iend; ++i ) {
2843 for(
size_t j=jj; j<jend; ++j ) {
2844 matrix_(row_+i,column_+j) += (~rhs)(i,j);
2866 template<
typename MT >
2867 template<
typename MT2 >
2868 inline void Submatrix<MT,unaligned,false,true>::addAssign(
const SparseMatrix<MT2,false>& rhs )
2873 for(
size_t i=0UL; i<
m_; ++i )
2874 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
2875 matrix_(row_+i,column_+element->index()) += element->value();
2893 template<
typename MT >
2894 template<
typename MT2 >
2895 inline void Submatrix<MT,unaligned,false,true>::addAssign(
const SparseMatrix<MT2,true>& rhs )
2902 for(
size_t j=0UL; j<
n_; ++j )
2903 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2904 matrix_(row_+element->index(),column_+j) += element->value();
2922 template<
typename MT >
2923 template<
typename MT2 >
2924 inline DisableIf_< typename Submatrix<MT,unaligned,false,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
2925 Submatrix<MT,unaligned,false,true>::subAssign(
const DenseMatrix<MT2,false>& rhs )
2930 const size_t jpos( n_ &
size_t(-2) );
2933 for(
size_t i=0UL; i<
m_; ++i )
2935 if( IsDiagonal<MT2>::value ) {
2936 matrix_(row_+i,column_+i) -= (~rhs)(i,i);
2939 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2940 matrix_(row_+i,column_+j ) -= (~rhs)(i,j );
2941 matrix_(row_+i,column_+j+1UL) -= (~rhs)(i,j+1UL);
2944 matrix_(row_+i,column_+jpos) -= (~rhs)(i,jpos);
2965 template<
typename MT >
2966 template<
typename MT2 >
2967 inline EnableIf_< typename Submatrix<MT,unaligned,false,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
2968 Submatrix<MT,unaligned,false,true>::subAssign(
const DenseMatrix<MT2,false>& rhs )
2975 for(
size_t i=0UL; i<
m_; ++i )
2977 const size_t jbegin( ( IsUpper<MT2>::value )
2978 ?( ( IsStrictlyUpper<MT2>::value ? i+1UL : i ) &
size_t(-SIMDSIZE) )
2980 const size_t jend ( ( IsLower<MT2>::value )
2981 ?( IsStrictlyLower<MT2>::value ? i : i+1UL )
2985 const size_t jpos( jend &
size_t(-SIMDSIZE) );
2989 Iterator left(
begin(i) + jbegin );
2990 ConstIterator_<MT2> right( (~rhs).
begin(i) + jbegin );
2992 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2993 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2994 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2995 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2996 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2998 for( ; j<jpos; j+=SIMDSIZE ) {
2999 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3001 for( ; j<jend; ++j ) {
3002 *left -= *right; ++left; ++right;
3022 template<
typename MT >
3023 template<
typename MT2 >
3024 inline void Submatrix<MT,unaligned,false,true>::subAssign(
const DenseMatrix<MT2,true>& rhs )
3031 constexpr
size_t block( BLOCK_SIZE );
3033 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
3034 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
3035 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
3036 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
3037 for(
size_t i=ii; i<iend; ++i ) {
3038 for(
size_t j=jj; j<jend; ++j ) {
3039 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
3061 template<
typename MT >
3062 template<
typename MT2 >
3063 inline void Submatrix<MT,unaligned,false,true>::subAssign(
const SparseMatrix<MT2,false>& rhs )
3068 for(
size_t i=0UL; i<
m_; ++i )
3069 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
3070 matrix_(row_+i,column_+element->index()) -= element->value();
3088 template<
typename MT >
3089 template<
typename MT2 >
3090 inline void Submatrix<MT,unaligned,false,true>::subAssign(
const SparseMatrix<MT2,true>& rhs )
3097 for(
size_t j=0UL; j<
n_; ++j )
3098 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
3099 matrix_(row_+element->index(),column_+j) -= element->value();
3125 template<
typename MT >
3126 class Submatrix<MT,unaligned,true,true>
3127 :
public DenseMatrix< Submatrix<MT,unaligned,true,true>, true >
3133 typedef If_< IsExpression<MT>, MT, MT& > Operand;
3138 typedef Submatrix<MT,unaligned,true,true>
This;
3139 typedef DenseMatrix<This,true>
BaseType;
3144 typedef SIMDTrait_<ElementType> SIMDType;
3155 typedef const ElementType* ConstPointer;
3158 typedef If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, ElementType* > Pointer;
3164 template<
typename IteratorType >
3165 class SubmatrixIterator
3170 typedef typename std::iterator_traits<IteratorType>::iterator_category IteratorCategory;
3173 typedef typename std::iterator_traits<IteratorType>::value_type ValueType;
3176 typedef typename std::iterator_traits<IteratorType>::pointer PointerType;
3179 typedef typename std::iterator_traits<IteratorType>::reference ReferenceType;
3182 typedef typename std::iterator_traits<IteratorType>::difference_type DifferenceType;
3185 typedef IteratorCategory iterator_category;
3186 typedef ValueType value_type;
3187 typedef PointerType pointer;
3188 typedef ReferenceType reference;
3189 typedef DifferenceType difference_type;
3195 inline SubmatrixIterator()
3197 , isAligned_( false )
3209 inline SubmatrixIterator( IteratorType iterator,
bool isMemoryAligned )
3210 : iterator_ ( iterator )
3211 , isAligned_( isMemoryAligned )
3220 template<
typename IteratorType2 >
3221 inline SubmatrixIterator(
const SubmatrixIterator<IteratorType2>& it )
3222 : iterator_ ( it.base() )
3223 , isAligned_( it.isAligned() )
3233 inline SubmatrixIterator&
operator+=(
size_t inc ) {
3245 inline SubmatrixIterator&
operator-=(
size_t dec ) {
3256 inline SubmatrixIterator& operator++() {
3267 inline const SubmatrixIterator operator++(
int ) {
3268 return SubmatrixIterator( iterator_++, isAligned_ );
3277 inline SubmatrixIterator& operator--() {
3288 inline const SubmatrixIterator operator--(
int ) {
3289 return SubmatrixIterator( iterator_--, isAligned_ );
3298 inline ReferenceType
operator*()
const {
3313 inline SIMDType load() const noexcept {
3331 inline SIMDType
loada() const noexcept {
3332 return iterator_.loada();
3346 inline SIMDType
loadu() const noexcept {
3347 return iterator_.loadu();
3362 inline void store(
const SIMDType& value )
const {
3378 inline void storea(
const SIMDType& value )
const {
3379 iterator_.storea( value );
3394 inline void storeu(
const SIMDType& value )
const {
3396 iterator_.storea( value );
3399 iterator_.storeu( value );
3415 inline void stream(
const SIMDType& value )
const {
3416 iterator_.stream( value );
3426 inline bool operator==(
const SubmatrixIterator& rhs )
const {
3427 return iterator_ == rhs.iterator_;
3437 inline bool operator!=(
const SubmatrixIterator& rhs )
const {
3438 return iterator_ != rhs.iterator_;
3448 inline bool operator<(
const SubmatrixIterator& rhs )
const {
3449 return iterator_ < rhs.iterator_;
3459 inline bool operator>(
const SubmatrixIterator& rhs )
const {
3460 return iterator_ > rhs.iterator_;
3470 inline bool operator<=(
const SubmatrixIterator& rhs )
const {
3471 return iterator_ <= rhs.iterator_;
3481 inline bool operator>=(
const SubmatrixIterator& rhs )
const {
3482 return iterator_ >= rhs.iterator_;
3492 inline DifferenceType
operator-(
const SubmatrixIterator& rhs )
const {
3493 return iterator_ - rhs.iterator_;
3504 friend inline const SubmatrixIterator
operator+(
const SubmatrixIterator& it,
size_t inc ) {
3505 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
3516 friend inline const SubmatrixIterator
operator+(
size_t inc,
const SubmatrixIterator& it ) {
3517 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
3528 friend inline const SubmatrixIterator
operator-(
const SubmatrixIterator& it,
size_t dec ) {
3529 return SubmatrixIterator( it.iterator_ - dec, it.isAligned_ );
3538 inline IteratorType base()
const {
3548 inline bool isAligned() const noexcept {
3555 IteratorType iterator_;
3563 typedef SubmatrixIterator< ConstIterator_<MT> >
ConstIterator;
3571 enum :
bool { simdEnabled = MT::simdEnabled };
3574 enum :
bool { smpAssignable = MT::smpAssignable };
3580 explicit inline Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n );
3592 inline Reference operator()(
size_t i,
size_t j );
3593 inline ConstReference operator()(
size_t i,
size_t j )
const;
3594 inline Reference at(
size_t i,
size_t j );
3595 inline ConstReference at(
size_t i,
size_t j )
const;
3596 inline Pointer data () noexcept;
3597 inline ConstPointer data () const noexcept;
3598 inline Pointer data (
size_t j ) noexcept;
3599 inline ConstPointer data (
size_t j ) const noexcept;
3600 inline Iterator
begin (
size_t j );
3601 inline ConstIterator
begin (
size_t j ) const;
3602 inline ConstIterator
cbegin(
size_t j ) const;
3603 inline Iterator
end (
size_t j );
3604 inline ConstIterator
end (
size_t j ) const;
3605 inline ConstIterator
cend (
size_t j ) const;
3612 inline Submatrix& operator=( const ElementType& rhs );
3613 inline Submatrix& operator=( initializer_list< initializer_list<ElementType> > list );
3614 inline Submatrix& operator=( const Submatrix& rhs );
3616 template< typename MT2,
bool SO >
3617 inline Submatrix& operator=( const Matrix<MT2,SO>& rhs );
3619 template< typename MT2,
bool SO >
3620 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3621 operator+=( const Matrix<MT2,SO>& rhs );
3623 template< typename MT2,
bool SO >
3624 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3625 operator+=( const Matrix<MT2,SO>& rhs );
3627 template< typename MT2,
bool SO >
3628 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3629 operator-=( const Matrix<MT2,SO>& rhs );
3631 template< typename MT2,
bool SO >
3632 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3633 operator-=( const Matrix<MT2,SO>& rhs );
3635 template< typename MT2,
bool SO >
3636 inline Submatrix& operator*=( const Matrix<MT2,SO>& rhs );
3638 template< typename Other >
3639 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator*=( Other rhs );
3641 template< typename Other >
3642 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator/=( Other rhs );
3649 inline
size_t row() const noexcept;
3650 inline
size_t rows() const noexcept;
3651 inline
size_t column() const noexcept;
3652 inline
size_t columns() const noexcept;
3653 inline
size_t spacing() const noexcept;
3654 inline
size_t capacity() const noexcept;
3655 inline
size_t capacity(
size_t i ) const noexcept;
3657 inline
size_t nonZeros(
size_t i ) const;
3658 inline
void reset();
3659 inline
void reset(
size_t i );
3669 template< typename Other > inline Submatrix& scale( const Other& scalar );
3676 template< typename MT2 >
3677 struct VectorizedAssign {
3679 simdEnabled && MT2::simdEnabled &&
3680 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value };
3686 template<
typename MT2 >
3687 struct VectorizedAddAssign {
3689 simdEnabled && MT2::simdEnabled &&
3690 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
3691 HasSIMDAdd< ElementType, ElementType_<MT2> >::value &&
3692 !IsDiagonal<MT2>::value };
3698 template<
typename MT2 >
3699 struct VectorizedSubAssign {
3701 simdEnabled && MT2::simdEnabled &&
3702 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
3703 HasSIMDSub< ElementType, ElementType_<MT2> >::value &&
3704 !IsDiagonal<MT2>::value };
3717 template<
typename Other >
3718 inline bool canAlias(
const Other* alias )
const noexcept;
3720 template<
typename MT2,
bool AF2,
bool SO2 >
3721 inline bool canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
3723 template<
typename Other >
3724 inline bool isAliased(
const Other* alias )
const noexcept;
3726 template<
typename MT2,
bool AF2,
bool SO2 >
3727 inline bool isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
3729 inline bool isAligned () const noexcept;
3730 inline
bool canSMPAssign() const noexcept;
3741 template< typename MT2 >
3742 inline
DisableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,true>& rhs );
3744 template< typename MT2 >
3745 inline
EnableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,true>& rhs );
3747 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,false>& rhs );
3748 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
3749 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
3751 template< typename MT2 >
3752 inline
DisableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,true>& rhs );
3754 template< typename MT2 >
3755 inline
EnableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,true>& rhs );
3757 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,false>& rhs );
3758 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
3759 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
3761 template< typename MT2 >
3762 inline
DisableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,true>& rhs );
3764 template< typename MT2 >
3765 inline
EnableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,true>& rhs );
3767 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,false>& rhs );
3768 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
3769 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
3777 inline
bool hasOverlap() const noexcept;
3786 const
size_t column_;
3789 const
bool isAligned_;
3800 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 > friend class Submatrix;
3802 template<
bool AF1, typename MT2,
bool AF2,
bool SO2,
bool DF2 >
3803 friend const Submatrix<MT2,AF1,SO2,DF2>
3804 submatrix( const Submatrix<MT2,AF2,SO2,DF2>& sm,
size_t row,
size_t column,
size_t m,
size_t n );
3806 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
3807 friend
bool isIntact( const Submatrix<MT2,AF2,SO2,DF2>& sm ) noexcept;
3809 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
3810 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Matrix<MT2,SO2>& b ) noexcept;
3812 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
3813 friend
bool isSame( const Matrix<MT2,SO2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
3815 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
3816 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
3818 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
3819 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
3820 size_t row,
size_t column );
3822 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
3823 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
3824 size_t row,
size_t column );
3826 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
3827 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
3828 size_t row,
size_t column );
3830 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
3831 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
3832 size_t row,
size_t column );
3834 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
3835 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
3836 size_t row,
size_t column );
3838 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
3839 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
3840 size_t row,
size_t column );
3842 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
3843 friend
bool tryMultAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
3844 size_t row,
size_t column );
3846 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
3847 friend
DerestrictTrait_< Submatrix<MT2,AF2,SO2,DF2> > derestrict( Submatrix<MT2,AF2,SO2,DF2>& sm );
3886 template< typename MT >
3887 inline Submatrix<MT,unaligned,true,true>::Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n )
3888 : matrix_ ( matrix )
3890 , column_ ( cindex )
3893 , isAligned_( simdEnabled && matrix.data() !=
nullptr &&
checkAlignment( data() ) &&
3894 ( n < 2UL || ( matrix.
spacing() &
size_t(-SIMDSIZE) ) == 0UL ) )
3896 if( ( row_ + m_ > matrix_.rows() ) || ( column_ + n_ > matrix_.columns() ) ) {
3923 template<
typename MT >
3925 Submatrix<MT,unaligned,true,true>::operator()(
size_t i,
size_t j )
3930 return matrix_(row_+i,column_+j);
3947 template<
typename MT >
3949 Submatrix<MT,unaligned,true,true>::operator()(
size_t i,
size_t j )
const 3954 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
3972 template<
typename MT >
3974 Submatrix<MT,unaligned,true,true>::at(
size_t i,
size_t j )
3982 return (*
this)(i,j);
4000 template<
typename MT >
4002 Submatrix<MT,unaligned,true,true>::at(
size_t i,
size_t j )
const 4010 return (*
this)(i,j);
4026 template<
typename MT >
4027 inline typename Submatrix<MT,unaligned,true,true>::Pointer
4028 Submatrix<MT,unaligned,true,true>::data() noexcept
4030 return matrix_.data() + row_ + column_*
spacing();
4046 template<
typename MT >
4047 inline typename Submatrix<MT,unaligned,true,true>::ConstPointer
4048 Submatrix<MT,unaligned,true,true>::data() const noexcept
4050 return matrix_.data() + row_ + column_*
spacing();
4065 template<
typename MT >
4066 inline typename Submatrix<MT,unaligned,true,true>::Pointer
4067 Submatrix<MT,unaligned,true,true>::data(
size_t j ) noexcept
4069 return matrix_.data() + row_ + (column_+j)*
spacing();
4084 template<
typename MT >
4085 inline typename Submatrix<MT,unaligned,true,true>::ConstPointer
4086 Submatrix<MT,unaligned,true,true>::data(
size_t j )
const noexcept
4088 return matrix_.data() + row_ + (column_+j)*
spacing();
4101 template<
typename MT >
4106 return Iterator( matrix_.begin( column_ + j ) + row_, isAligned_ );
4119 template<
typename MT >
4124 return ConstIterator( matrix_.cbegin( column_ + j ) + row_, isAligned_ );
4137 template<
typename MT >
4142 return ConstIterator( matrix_.cbegin( column_ + j ) + row_, isAligned_ );
4155 template<
typename MT >
4160 return Iterator( matrix_.begin( column_ + j ) + row_ +
m_, isAligned_ );
4173 template<
typename MT >
4178 return ConstIterator( matrix_.cbegin( column_ + j ) + row_ +
m_, isAligned_ );
4191 template<
typename MT >
4196 return ConstIterator( matrix_.cbegin( column_ + j ) + row_ +
m_, isAligned_ );
4221 template<
typename MT >
4222 inline Submatrix<MT,unaligned,true,true>&
4223 Submatrix<MT,unaligned,true,true>::operator=(
const ElementType& rhs )
4225 const size_t jend( column_ + n_ );
4227 for(
size_t j=column_; j<jend; ++j )
4229 const size_t ibegin( ( IsLower<MT>::value )
4230 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4231 ?(
max( j+1UL, row_ ) )
4232 :(
max( j, row_ ) ) )
4234 const size_t iend ( ( IsUpper<MT>::value )
4235 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4236 ?(
min( j, row_+m_ ) )
4237 :(
min( j+1UL, row_+m_ ) ) )
4240 for(
size_t i=ibegin; i<iend; ++i )
4263 template<
typename MT >
4264 inline Submatrix<MT,unaligned,true,true>&
4265 Submatrix<MT,unaligned,true,true>::operator=( initializer_list< initializer_list<ElementType> > list )
4273 for(
const auto& rowList : list ) {
4275 for(
const auto& element : rowList ) {
4276 matrix_(row_+i,column_+j) = element;
4279 for( ; j<
n_; ++j ) {
4306 template<
typename MT >
4307 inline Submatrix<MT,unaligned,true,true>&
4308 Submatrix<MT,unaligned,true,true>::operator=(
const Submatrix& rhs )
4313 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
4316 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
4320 if( !tryAssign( matrix_, rhs, row_, column_ ) ) {
4324 DerestrictTrait_<This> left( derestrict( *
this ) );
4326 if( rhs.canAlias( &matrix_ ) ) {
4327 const ResultType tmp( rhs );
4357 template<
typename MT >
4358 template<
typename MT2
4360 inline Submatrix<MT,unaligned,true,true>&
4361 Submatrix<MT,unaligned,true,true>::operator=(
const Matrix<MT2,SO>& rhs )
4369 typedef If_< IsRestricted<MT>, CompositeType_<MT2>,
const MT2& > Right;
4370 Right right( ~rhs );
4372 if( !tryAssign( matrix_, right, row_, column_ ) ) {
4376 if( IsSparseMatrix<MT2>::value )
4379 DerestrictTrait_<This> left( derestrict( *
this ) );
4381 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4382 const ResultType_<MT2> tmp( right );
4411 template<
typename MT >
4412 template<
typename MT2
4414 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,true,true>& >
4421 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
4430 if( !tryAddAssign( matrix_, ~rhs, row_, column_ ) ) {
4434 DerestrictTrait_<This> left( derestrict( *
this ) );
4436 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
4437 (~rhs).canAlias( &matrix_ ) ) {
4438 const AddType tmp( *
this + (~rhs) );
4467 template<
typename MT >
4468 template<
typename MT2
4470 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,true,true>& >
4477 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
4486 const AddType tmp( *
this + (~rhs) );
4488 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
4492 DerestrictTrait_<This> left( derestrict( *
this ) );
4518 template<
typename MT >
4519 template<
typename MT2
4521 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,true,true>& >
4528 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
4537 if( !trySubAssign( matrix_, ~rhs, row_, column_ ) ) {
4541 DerestrictTrait_<This> left( derestrict( *
this ) );
4543 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
4544 (~rhs).canAlias( &matrix_ ) ) {
4545 const SubType tmp( *
this - (~rhs ) );
4574 template<
typename MT >
4575 template<
typename MT2
4577 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,true,true>& >
4584 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
4593 const SubType tmp( *
this - (~rhs) );
4595 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
4599 DerestrictTrait_<This> left( derestrict( *
this ) );
4625 template<
typename MT >
4626 template<
typename MT2
4628 inline Submatrix<MT,unaligned,true,true>&
4635 typedef MultTrait_< ResultType, ResultType_<MT2> > MultType;
4644 const MultType tmp( *
this * (~rhs) );
4646 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
4650 DerestrictTrait_<This> left( derestrict( *
this ) );
4673 template<
typename MT >
4674 template<
typename Other >
4675 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,unaligned,true,true> >&
4680 DerestrictTrait_<This> left( derestrict( *
this ) );
4702 template<
typename MT >
4703 template<
typename Other >
4704 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,unaligned,true,true> >&
4711 DerestrictTrait_<This> left( derestrict( *
this ) );
4734 template<
typename MT >
4749 template<
typename MT >
4764 template<
typename MT >
4779 template<
typename MT >
4797 template<
typename MT >
4800 return matrix_.spacing();
4812 template<
typename MT >
4828 template<
typename MT >
4847 template<
typename MT >
4850 const size_t iend( row_ + m_ );
4851 const size_t jend( column_ + n_ );
4852 size_t nonzeros( 0UL );
4854 for(
size_t j=column_; j<jend; ++j )
4855 for(
size_t i=row_; i<iend; ++i )
4872 template<
typename MT >
4877 const size_t iend( row_ + m_ );
4878 size_t nonzeros( 0UL );
4880 for(
size_t i=row_; i<iend; ++i )
4881 if( !
isDefault( matrix_(i,column_+j) ) )
4896 template<
typename MT >
4901 for(
size_t j=column_; j<column_+
n_; ++j )
4903 const size_t ibegin( ( IsLower<MT>::value )
4904 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4905 ?(
max( j+1UL, row_ ) )
4906 :(
max( j, row_ ) ) )
4908 const size_t iend ( ( IsUpper<MT>::value )
4909 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4910 ?(
min( j, row_+m_ ) )
4911 :(
min( j+1UL, row_+m_ ) ) )
4914 for(
size_t i=ibegin; i<iend; ++i )
4915 clear( matrix_(i,j) );
4929 template<
typename MT >
4936 const size_t ibegin( ( IsLower<MT>::value )
4937 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4938 ?(
max( j+1UL, row_ ) )
4939 :(
max( j, row_ ) ) )
4941 const size_t iend ( ( IsUpper<MT>::value )
4942 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4943 ?(
min( j, row_+m_ ) )
4944 :(
min( j+1UL, row_+m_ ) ) )
4947 for(
size_t i=ibegin; i<iend; ++i )
4948 clear( matrix_(i,column_+j) );
4964 template<
typename MT >
4965 inline bool Submatrix<MT,unaligned,true,true>::hasOverlap() const noexcept
4967 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
4969 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
5003 template<
typename MT >
5010 if( !tryAssign( matrix_,
trans( *
this ), row_, column_ ) ) {
5014 DerestrictTrait_<This> left( derestrict( *
this ) );
5015 const ResultType tmp(
trans( *
this ) );
5042 template<
typename MT >
5049 if( !tryAssign( matrix_,
ctrans( *
this ), row_, column_ ) ) {
5053 DerestrictTrait_<This> left( derestrict( *
this ) );
5054 const ResultType tmp(
ctrans( *
this ) );
5074 template<
typename MT >
5075 template<
typename Other >
5076 inline Submatrix<MT,unaligned,true,true>& Submatrix<MT,unaligned,true,true>::scale(
const Other& scalar )
5080 const size_t jend( column_ + n_ );
5082 for(
size_t j=column_; j<jend; ++j )
5084 const size_t ibegin( ( IsLower<MT>::value )
5085 ?( ( IsStrictlyLower<MT>::value )
5086 ?(
max( j+1UL, row_ ) )
5087 :(
max( j, row_ ) ) )
5089 const size_t iend ( ( IsUpper<MT>::value )
5090 ?( ( IsStrictlyUpper<MT>::value )
5091 ?(
min( j, row_+m_ ) )
5092 :(
min( j+1UL, row_+m_ ) ) )
5095 for(
size_t i=ibegin; i<iend; ++i )
5096 matrix_(i,j) *= scalar;
5124 template<
typename MT >
5125 template<
typename Other >
5126 inline bool Submatrix<MT,unaligned,true,true>::canAlias(
const Other* alias )
const noexcept
5128 return matrix_.isAliased( alias );
5145 template<
typename MT >
5146 template<
typename MT2
5149 inline bool Submatrix<MT,unaligned,true,true>::canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
5151 return ( matrix_.isAliased( &alias->matrix_ ) &&
5152 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
5153 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
5170 template<
typename MT >
5171 template<
typename Other >
5172 inline bool Submatrix<MT,unaligned,true,true>::isAliased(
const Other* alias )
const noexcept
5174 return matrix_.isAliased( alias );
5191 template<
typename MT >
5192 template<
typename MT2
5195 inline bool Submatrix<MT,unaligned,true,true>::isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
5197 return ( matrix_.isAliased( &alias->matrix_ ) &&
5198 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
5199 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
5215 template<
typename MT >
5216 inline bool Submatrix<MT,unaligned,true,true>::isAligned() const noexcept
5235 template<
typename MT >
5236 inline bool Submatrix<MT,unaligned,true,true>::canSMPAssign() const noexcept
5238 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
5259 template<
typename MT >
5261 Submatrix<MT,unaligned,true,true>::load(
size_t i,
size_t j )
const noexcept
5264 return loada( i, j );
5266 return loadu( i, j );
5287 template<
typename MT >
5298 return matrix_.loada( row_+i, column_+j );
5319 template<
typename MT >
5330 return matrix_.loadu( row_+i, column_+j );
5352 template<
typename MT >
5354 Submatrix<MT,unaligned,true,true>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
5381 template<
typename MT >
5392 matrix_.storea( row_+i, column_+j, value );
5414 template<
typename MT >
5425 matrix_.storeu( row_+i, column_+j, value );
5448 template<
typename MT >
5460 matrix_.stream( row_+i, column_+j, value );
5462 matrix_.storeu( row_+i, column_+j, value );
5480 template<
typename MT >
5481 template<
typename MT2 >
5482 inline DisableIf_< typename Submatrix<MT,unaligned,true,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
5483 Submatrix<MT,unaligned,true,true>::assign(
const DenseMatrix<MT2,true>& rhs )
5488 const size_t ipos( m_ &
size_t(-2) );
5491 for(
size_t j=0UL; j<
n_; ++j ) {
5492 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5493 matrix_(row_+i ,column_+j) = (~rhs)(i ,j);
5494 matrix_(row_+i+1UL,column_+j) = (~rhs)(i+1UL,j);
5497 matrix_(row_+ipos,column_+j) = (~rhs)(ipos,j);
5517 template<
typename MT >
5518 template<
typename MT2 >
5519 inline EnableIf_< typename Submatrix<MT,unaligned,true,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
5520 Submatrix<MT,unaligned,true,true>::assign(
const DenseMatrix<MT2,true>& rhs )
5527 const size_t ipos( m_ &
size_t(-SIMDSIZE) );
5531 m_*n_ > (
cacheSize / (
sizeof(ElementType) * 3UL ) ) &&
5532 !(~rhs).isAliased( &matrix_ ) )
5534 for(
size_t j=0UL; j<
n_; ++j )
5537 Iterator left(
begin(j) );
5538 ConstIterator_<MT2> right( (~rhs).
begin(j) );
5540 for( ; i<ipos; i+=SIMDSIZE ) {
5541 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5543 for( ; i<
m_; ++i ) {
5544 *left = *right; ++left; ++right;
5550 for(
size_t j=0UL; j<
n_; ++j )
5553 Iterator left(
begin(j) );
5554 ConstIterator_<MT2> right( (~rhs).
begin(j) );
5556 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5557 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5558 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5559 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5560 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5562 for( ; i<ipos; i+=SIMDSIZE ) {
5563 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5565 for( ; i<
m_; ++i ) {
5566 *left = *right; ++left; ++right;
5587 template<
typename MT >
5588 template<
typename MT2 >
5589 inline void Submatrix<MT,unaligned,true,true>::assign(
const DenseMatrix<MT2,false>& rhs )
5596 constexpr
size_t block( BLOCK_SIZE );
5598 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
5599 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
5600 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
5601 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
5602 for(
size_t j=jj; j<jend; ++j ) {
5603 for(
size_t i=ii; i<iend; ++i ) {
5604 matrix_(row_+i,column_+j) = (~rhs)(i,j);
5626 template<
typename MT >
5627 template<
typename MT2 >
5628 inline void Submatrix<MT,unaligned,true,true>::assign(
const SparseMatrix<MT2,true>& rhs )
5633 for(
size_t j=0UL; j<
n_; ++j )
5634 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
5635 matrix_(row_+element->index(),column_+j) = element->value();
5653 template<
typename MT >
5654 template<
typename MT2 >
5655 inline void Submatrix<MT,unaligned,true,true>::assign(
const SparseMatrix<MT2,false>& rhs )
5662 for(
size_t i=0UL; i<
m_; ++i )
5663 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
5664 matrix_(row_+i,column_+element->index()) = element->value();
5682 template<
typename MT >
5683 template<
typename MT2 >
5684 inline DisableIf_< typename Submatrix<MT,unaligned,true,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
5685 Submatrix<MT,unaligned,true,true>::addAssign(
const DenseMatrix<MT2,true>& rhs )
5690 const size_t ipos( m_ &
size_t(-2) );
5693 for(
size_t j=0UL; j<
n_; ++j )
5695 if( IsDiagonal<MT2>::value ) {
5696 matrix_(row_+j,column_+j) += (~rhs)(j,j);
5699 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5700 matrix_(row_+i ,column_+j) += (~rhs)(i ,j);
5701 matrix_(row_+i+1UL,column_+j) += (~rhs)(i+1UL,j);
5704 matrix_(row_+ipos,column_+j) += (~rhs)(ipos,j);
5725 template<
typename MT >
5726 template<
typename MT2 >
5727 inline EnableIf_< typename Submatrix<MT,unaligned,true,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
5728 Submatrix<MT,unaligned,true,true>::addAssign(
const DenseMatrix<MT2,true>& rhs )
5735 for(
size_t j=0UL; j<
n_; ++j )
5737 const size_t ibegin( ( IsLower<MT>::value )
5738 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-SIMDSIZE) )
5740 const size_t iend ( ( IsUpper<MT>::value )
5741 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
5745 const size_t ipos( iend &
size_t(-SIMDSIZE) );
5749 Iterator left(
begin(j) + ibegin );
5750 ConstIterator_<MT2> right( (~rhs).
begin(j) + ibegin );
5752 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5753 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5754 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5755 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5756 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5758 for( ; i<ipos; i+=SIMDSIZE ) {
5759 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5761 for( ; i<iend; ++i ) {
5762 *left += *right; ++left; ++right;
5782 template<
typename MT >
5783 template<
typename MT2 >
5784 inline void Submatrix<MT,unaligned,true,true>::addAssign(
const DenseMatrix<MT2,false>& rhs )
5791 constexpr
size_t block( BLOCK_SIZE );
5793 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
5794 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
5795 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
5796 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
5797 for(
size_t j=jj; j<jend; ++j ) {
5798 for(
size_t i=ii; i<iend; ++i ) {
5799 matrix_(row_+i,column_+j) += (~rhs)(i,j);
5821 template<
typename MT >
5822 template<
typename MT2 >
5823 inline void Submatrix<MT,unaligned,true,true>::addAssign(
const SparseMatrix<MT2,true>& rhs )
5828 for(
size_t j=0UL; j<
n_; ++j )
5829 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
5830 matrix_(row_+element->index(),column_+j) += element->value();
5848 template<
typename MT >
5849 template<
typename MT2 >
5850 inline void Submatrix<MT,unaligned,true,true>::addAssign(
const SparseMatrix<MT2,false>& rhs )
5857 for(
size_t i=0UL; i<
m_; ++i )
5858 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
5859 matrix_(row_+i,column_+element->index()) += element->value();
5877 template<
typename MT >
5878 template<
typename MT2 >
5879 inline DisableIf_< typename Submatrix<MT,unaligned,true,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
5880 Submatrix<MT,unaligned,true,true>::subAssign(
const DenseMatrix<MT2,true>& rhs )
5885 const size_t ipos( m_ &
size_t(-2) );
5888 for(
size_t j=0UL; j<
n_; ++j )
5890 if( IsDiagonal<MT2>::value ) {
5891 matrix_(row_+j,column_+j) -= (~rhs)(j,j);
5894 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5895 matrix_(row_+i ,column_+j) -= (~rhs)(i ,j);
5896 matrix_(row_+i+1UL,column_+j) -= (~rhs)(i+1UL,j);
5899 matrix_(row_+ipos,column_+j) -= (~rhs)(ipos,j);
5920 template<
typename MT >
5921 template<
typename MT2 >
5922 inline EnableIf_< typename Submatrix<MT,unaligned,true,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
5923 Submatrix<MT,unaligned,true,true>::subAssign(
const DenseMatrix<MT2,true>& rhs )
5930 for(
size_t j=0UL; j<
n_; ++j )
5932 const size_t ibegin( ( IsLower<MT>::value )
5933 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-SIMDSIZE) )
5935 const size_t iend ( ( IsUpper<MT>::value )
5936 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
5940 const size_t ipos( iend &
size_t(-SIMDSIZE) );
5944 Iterator left(
begin(j) + ibegin );
5945 ConstIterator_<MT2> right( (~rhs).
begin(j) + ibegin );
5947 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5948 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5949 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5950 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5951 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5953 for( ; i<ipos; i+=SIMDSIZE ) {
5954 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5956 for( ; i<iend; ++i ) {
5957 *left -= *right; ++left; ++right;
5977 template<
typename MT >
5978 template<
typename MT2 >
5979 inline void Submatrix<MT,unaligned,true,true>::subAssign(
const DenseMatrix<MT2,false>& rhs )
5986 constexpr
size_t block( BLOCK_SIZE );
5988 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
5989 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
5990 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
5991 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
5992 for(
size_t j=jj; j<jend; ++j ) {
5993 for(
size_t i=ii; i<iend; ++i ) {
5994 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
6016 template<
typename MT >
6017 template<
typename MT2 >
6018 inline void Submatrix<MT,unaligned,true,true>::subAssign(
const SparseMatrix<MT2,true>& rhs )
6023 for(
size_t j=0UL; j<
n_; ++j )
6024 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
6025 matrix_(row_+element->index(),column_+j) -= element->value();
6043 template<
typename MT >
6044 template<
typename MT2 >
6045 inline void Submatrix<MT,unaligned,true,true>::subAssign(
const SparseMatrix<MT2,false>& rhs )
6052 for(
size_t i=0UL; i<
m_; ++i )
6053 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
6054 matrix_(row_+i,column_+element->index()) -= element->value();
6080 template<
typename MT >
6081 class Submatrix<MT,
aligned,false,true>
6082 :
public DenseMatrix< Submatrix<MT,aligned,false,true>, false >
6088 typedef If_< IsExpression<MT>, MT, MT& > Operand;
6093 typedef Submatrix<MT,aligned,false,true>
This;
6094 typedef DenseMatrix<This,false>
BaseType;
6099 typedef SIMDTrait_<ElementType> SIMDType;
6110 typedef const ElementType* ConstPointer;
6113 typedef If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, ElementType* > Pointer;
6124 enum :
bool { simdEnabled = MT::simdEnabled };
6127 enum :
bool { smpAssignable = MT::smpAssignable };
6133 explicit inline Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n );
6145 inline Reference operator()(
size_t i,
size_t j );
6146 inline ConstReference operator()(
size_t i,
size_t j )
const;
6147 inline Reference at(
size_t i,
size_t j );
6148 inline ConstReference at(
size_t i,
size_t j )
const;
6149 inline Pointer data () noexcept;
6150 inline ConstPointer data () const noexcept;
6151 inline Pointer data (
size_t i ) noexcept;
6152 inline ConstPointer data (
size_t i ) const noexcept;
6153 inline Iterator
begin (
size_t i );
6154 inline ConstIterator
begin (
size_t i ) const;
6155 inline ConstIterator
cbegin(
size_t i ) const;
6156 inline Iterator
end (
size_t i );
6157 inline ConstIterator
end (
size_t i ) const;
6158 inline ConstIterator
cend (
size_t i ) const;
6165 inline Submatrix& operator=( const ElementType& rhs );
6166 inline Submatrix& operator=( initializer_list< initializer_list<ElementType> > list );
6167 inline Submatrix& operator=( const Submatrix& rhs );
6169 template< typename MT2,
bool SO >
6170 inline Submatrix& operator=( const Matrix<MT2,SO>& rhs );
6172 template< typename MT2,
bool SO >
6173 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6174 operator+=( const Matrix<MT2,SO>& rhs );
6176 template< typename MT2,
bool SO >
6177 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6178 operator+=( const Matrix<MT2,SO>& rhs );
6180 template< typename MT2,
bool SO >
6181 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6182 operator-=( const Matrix<MT2,SO>& rhs );
6184 template< typename MT2,
bool SO >
6185 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6186 operator-=( const Matrix<MT2,SO>& rhs );
6188 template< typename MT2,
bool SO >
6189 inline Submatrix& operator*=( const Matrix<MT2,SO>& rhs );
6191 template< typename Other >
6192 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator*=( Other rhs );
6194 template< typename Other >
6195 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator/=( Other rhs );
6202 inline
size_t row() const noexcept;
6203 inline
size_t rows() const noexcept;
6204 inline
size_t column() const noexcept;
6205 inline
size_t columns() const noexcept;
6206 inline
size_t spacing() const noexcept;
6207 inline
size_t capacity() const noexcept;
6208 inline
size_t capacity(
size_t i ) const noexcept;
6210 inline
size_t nonZeros(
size_t i ) const;
6211 inline
void reset();
6212 inline
void reset(
size_t i );
6222 template< typename Other > inline Submatrix& scale( const Other& scalar );
6229 template< typename MT2 >
6230 struct VectorizedAssign {
6232 simdEnabled && MT2::simdEnabled &&
6233 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value };
6239 template<
typename MT2 >
6240 struct VectorizedAddAssign {
6242 simdEnabled && MT2::simdEnabled &&
6243 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
6244 HasSIMDAdd< ElementType, ElementType_<MT2> >::value &&
6245 !IsDiagonal<MT2>::value };
6251 template<
typename MT2 >
6252 struct VectorizedSubAssign {
6254 simdEnabled && MT2::simdEnabled &&
6255 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
6256 HasSIMDSub< ElementType, ElementType_<MT2> >::value &&
6257 !IsDiagonal<MT2>::value };
6270 template<
typename Other >
6271 inline bool canAlias(
const Other* alias )
const noexcept;
6273 template<
typename MT2,
bool AF2,
bool SO2 >
6274 inline bool canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
6276 template<
typename Other >
6277 inline bool isAliased(
const Other* alias )
const noexcept;
6279 template<
typename MT2,
bool AF2,
bool SO2 >
6280 inline bool isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
6282 inline bool isAligned () const noexcept;
6283 inline
bool canSMPAssign() const noexcept;
6294 template< typename MT2 >
6295 inline
DisableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,false>& rhs );
6297 template< typename MT2 >
6298 inline
EnableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,false>& rhs );
6300 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,true>& rhs );
6301 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
6302 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
6304 template< typename MT2 >
6305 inline
DisableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,false>& rhs );
6307 template< typename MT2 >
6308 inline
EnableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,false>& rhs );
6310 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,true>& rhs );
6311 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
6312 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
6314 template< typename MT2 >
6315 inline
DisableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,false>& rhs );
6317 template< typename MT2 >
6318 inline
EnableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,false>& rhs );
6320 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,true>& rhs );
6321 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
6322 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
6330 inline
bool hasOverlap() const noexcept;
6339 const
size_t column_;
6346 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 > friend class Submatrix;
6348 template<
bool AF1, typename MT2,
bool AF2,
bool SO2,
bool DF2 >
6349 friend const Submatrix<MT2,AF1,SO2,DF2>
6350 submatrix( const Submatrix<MT2,AF2,SO2,DF2>& sm,
size_t row,
size_t column,
size_t m,
size_t n );
6352 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
6353 friend
bool isIntact( const Submatrix<MT2,AF2,SO2,DF2>& sm ) noexcept;
6355 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
6356 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Matrix<MT2,SO2>& b ) noexcept;
6358 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
6359 friend
bool isSame( const Matrix<MT2,SO2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
6361 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
6362 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
6364 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
6365 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
6366 size_t row,
size_t column );
6368 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
6369 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
6370 size_t row,
size_t column );
6372 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
6373 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
6374 size_t row,
size_t column );
6376 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
6377 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
6378 size_t row,
size_t column );
6380 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
6381 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
6382 size_t row,
size_t column );
6384 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
6385 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
6386 size_t row,
size_t column );
6388 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
6389 friend
bool tryMultAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
6390 size_t row,
size_t column );
6392 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
6393 friend
DerestrictTrait_< Submatrix<MT2,AF2,SO2,DF2> > derestrict( Submatrix<MT2,AF2,SO2,DF2>& sm );
6432 template< typename MT >
6433 inline Submatrix<MT,
aligned,false,true>::Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n )
6440 if( ( row_ + m_ > matrix_.rows() ) || ( column_ + n_ > matrix_.columns() ) ) {
6444 if( ( simdEnabled && matrix_.data() !=
nullptr && !
checkAlignment( data() ) ) ||
6445 ( m_ > 1UL && matrix_.spacing() % SIMDSIZE != 0UL ) ) {
6472 template<
typename MT >
6474 Submatrix<MT,aligned,false,true>::operator()(
size_t i,
size_t j )
6479 return matrix_(row_+i,column_+j);
6496 template<
typename MT >
6498 Submatrix<MT,aligned,false,true>::operator()(
size_t i,
size_t j )
const 6503 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
6521 template<
typename MT >
6523 Submatrix<MT,aligned,false,true>::at(
size_t i,
size_t j )
6531 return (*
this)(i,j);
6549 template<
typename MT >
6551 Submatrix<MT,aligned,false,true>::at(
size_t i,
size_t j )
const 6559 return (*
this)(i,j);
6575 template<
typename MT >
6576 inline typename Submatrix<MT,aligned,false,true>::Pointer
6577 Submatrix<MT,aligned,false,true>::data() noexcept
6579 return matrix_.data() + row_*
spacing() + column_;
6595 template<
typename MT >
6596 inline typename Submatrix<MT,aligned,false,true>::ConstPointer
6597 Submatrix<MT,aligned,false,true>::data() const noexcept
6599 return matrix_.data() + row_*
spacing() + column_;
6614 template<
typename MT >
6615 inline typename Submatrix<MT,aligned,false,true>::Pointer
6616 Submatrix<MT,aligned,false,true>::data(
size_t i ) noexcept
6618 return matrix_.data() + (row_+i)*
spacing() + column_;
6633 template<
typename MT >
6634 inline typename Submatrix<MT,aligned,false,true>::ConstPointer
6635 Submatrix<MT,aligned,false,true>::data(
size_t i )
const noexcept
6637 return matrix_.data() + (row_+i)*
spacing() + column_;
6655 template<
typename MT >
6660 return ( matrix_.begin( row_ + i ) + column_ );
6678 template<
typename MT >
6683 return ( matrix_.cbegin( row_ + i ) + column_ );
6701 template<
typename MT >
6706 return ( matrix_.cbegin( row_ + i ) + column_ );
6724 template<
typename MT >
6729 return ( matrix_.begin( row_ + i ) + column_ +
n_ );
6747 template<
typename MT >
6752 return ( matrix_.cbegin( row_ + i ) + column_ +
n_ );
6770 template<
typename MT >
6775 return ( matrix_.cbegin( row_ + i ) + column_ +
n_ );
6800 template<
typename MT >
6801 inline Submatrix<MT,aligned,false,true>&
6802 Submatrix<MT,aligned,false,true>::operator=(
const ElementType& rhs )
6804 const size_t iend( row_ + m_ );
6806 for(
size_t i=row_; i<iend; ++i )
6808 const size_t jbegin( ( IsUpper<MT>::value )
6809 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
6810 ?(
max( i+1UL, column_ ) )
6811 :(
max( i, column_ ) ) )
6813 const size_t jend ( ( IsLower<MT>::value )
6814 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
6815 ?(
min( i, column_+n_ ) )
6816 :(
min( i+1UL, column_+n_ ) ) )
6819 for(
size_t j=jbegin; j<jend; ++j )
6842 template<
typename MT >
6843 inline Submatrix<MT,aligned,false,true>&
6844 Submatrix<MT,aligned,false,true>::operator=( initializer_list< initializer_list<ElementType> > list )
6852 for(
const auto& rowList : list ) {
6853 std::fill( std::copy( rowList.begin(), rowList.end(),
begin(i) ),
end(i),
ElementType() );
6878 template<
typename MT >
6879 inline Submatrix<MT,aligned,false,true>&
6880 Submatrix<MT,aligned,false,true>::operator=(
const Submatrix& rhs )
6885 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
6888 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
6892 if( !tryAssign( matrix_, rhs, row_, column_ ) ) {
6896 DerestrictTrait_<This> left( derestrict( *
this ) );
6898 if( rhs.canAlias( &matrix_ ) ) {
6899 const ResultType tmp( rhs );
6929 template<
typename MT >
6930 template<
typename MT2
6932 inline Submatrix<MT,aligned,false,true>&
6933 Submatrix<MT,aligned,false,true>::operator=(
const Matrix<MT2,SO>& rhs )
6941 typedef If_< IsRestricted<MT>, CompositeType_<MT2>,
const MT2& > Right;
6942 Right right( ~rhs );
6944 if( !tryAssign( matrix_, right, row_, column_ ) ) {
6948 if( IsSparseMatrix<MT2>::value )
6951 DerestrictTrait_<This> left( derestrict( *
this ) );
6953 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
6954 const ResultType_<MT2> tmp( right );
6983 template<
typename MT >
6984 template<
typename MT2
6986 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,false,true>& >
6993 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
7002 if( !tryAddAssign( matrix_, ~rhs, row_, column_ ) ) {
7006 DerestrictTrait_<This> left( derestrict( *
this ) );
7008 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
7009 (~rhs).canAlias( &matrix_ ) ) {
7010 const AddType tmp( *
this + (~rhs) );
7039 template<
typename MT >
7040 template<
typename MT2
7042 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,false,true>& >
7049 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
7058 const AddType tmp( *
this + (~rhs) );
7060 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
7064 DerestrictTrait_<This> left( derestrict( *
this ) );
7090 template<
typename MT >
7091 template<
typename MT2
7093 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,false,true>& >
7100 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
7109 if( !trySubAssign( matrix_, ~rhs, row_, column_ ) ) {
7113 DerestrictTrait_<This> left( derestrict( *
this ) );
7115 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
7116 (~rhs).canAlias( &matrix_ ) ) {
7117 const SubType tmp( *
this - (~rhs ) );
7146 template<
typename MT >
7147 template<
typename MT2
7149 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,false,true>& >
7156 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
7165 const SubType tmp( *
this - (~rhs) );
7167 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
7171 DerestrictTrait_<This> left( derestrict( *
this ) );
7197 template<
typename MT >
7198 template<
typename MT2
7200 inline Submatrix<MT,aligned,false,true>&
7207 typedef MultTrait_< ResultType, ResultType_<MT2> > MultType;
7216 const MultType tmp( *
this * (~rhs) );
7218 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
7222 DerestrictTrait_<This> left( derestrict( *
this ) );
7245 template<
typename MT >
7246 template<
typename Other >
7247 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,aligned,false,true> >&
7252 DerestrictTrait_<This> left( derestrict( *
this ) );
7274 template<
typename MT >
7275 template<
typename Other >
7276 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,aligned,false,true> >&
7283 DerestrictTrait_<This> left( derestrict( *
this ) );
7306 template<
typename MT >
7321 template<
typename MT >
7336 template<
typename MT >
7351 template<
typename MT >
7371 template<
typename MT >
7374 return matrix_.spacing();
7386 template<
typename MT >
7407 template<
typename MT >
7426 template<
typename MT >
7429 const size_t iend( row_ + m_ );
7430 const size_t jend( column_ + n_ );
7431 size_t nonzeros( 0UL );
7433 for(
size_t i=row_; i<iend; ++i )
7434 for(
size_t j=column_; j<jend; ++j )
7456 template<
typename MT >
7461 const size_t jend( column_ + n_ );
7462 size_t nonzeros( 0UL );
7464 for(
size_t j=column_; j<jend; ++j )
7480 template<
typename MT >
7485 for(
size_t i=row_; i<row_+
m_; ++i )
7487 const size_t jbegin( ( IsUpper<MT>::value )
7488 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
7489 ?(
max( i+1UL, column_ ) )
7490 :(
max( i, column_ ) ) )
7492 const size_t jend ( ( IsLower<MT>::value )
7493 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
7494 ?(
min( i, column_+n_ ) )
7495 :(
min( i+1UL, column_+n_ ) ) )
7498 for(
size_t j=jbegin; j<jend; ++j )
7499 clear( matrix_(i,j) );
7518 template<
typename MT >
7525 const size_t jbegin( ( IsUpper<MT>::value )
7526 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
7527 ?(
max( i+1UL, column_ ) )
7528 :(
max( i, column_ ) ) )
7530 const size_t jend ( ( IsLower<MT>::value )
7531 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
7532 ?(
min( i, column_+n_ ) )
7533 :(
min( i+1UL, column_+n_ ) ) )
7536 for(
size_t j=jbegin; j<jend; ++j )
7537 clear( matrix_(row_+i,j) );
7553 template<
typename MT >
7554 inline bool Submatrix<MT,aligned,false,true>::hasOverlap() const noexcept
7556 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
7558 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
7592 template<
typename MT >
7599 if( !tryAssign( matrix_,
trans( *
this ), row_, column_ ) ) {
7603 DerestrictTrait_<This> left( derestrict( *
this ) );
7604 const ResultType tmp(
trans( *
this ) );
7631 template<
typename MT >
7638 if( !tryAssign( matrix_,
ctrans( *
this ), row_, column_ ) ) {
7642 DerestrictTrait_<This> left( derestrict( *
this ) );
7643 const ResultType tmp(
ctrans( *
this ) );
7663 template<
typename MT >
7664 template<
typename Other >
7665 inline Submatrix<MT,aligned,false,true>& Submatrix<MT,aligned,false,true>::scale(
const Other& scalar )
7669 const size_t iend( row_ + m_ );
7671 for(
size_t i=row_; i<iend; ++i )
7673 const size_t jbegin( ( IsUpper<MT>::value )
7674 ?( ( IsStrictlyUpper<MT>::value )
7675 ?(
max( i+1UL, column_ ) )
7676 :(
max( i, column_ ) ) )
7678 const size_t jend ( ( IsLower<MT>::value )
7679 ?( ( IsStrictlyLower<MT>::value )
7680 ?(
min( i, column_+n_ ) )
7681 :(
min( i+1UL, column_+n_ ) ) )
7684 for(
size_t j=jbegin; j<jend; ++j )
7685 matrix_(i,j) *= scalar;
7713 template<
typename MT >
7714 template<
typename Other >
7715 inline bool Submatrix<MT,aligned,false,true>::canAlias(
const Other* alias )
const noexcept
7717 return matrix_.isAliased( alias );
7734 template<
typename MT >
7735 template<
typename MT2
7738 inline bool Submatrix<MT,aligned,false,true>::canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
7740 return ( matrix_.isAliased( &alias->matrix_ ) &&
7741 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
7742 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
7759 template<
typename MT >
7760 template<
typename Other >
7761 inline bool Submatrix<MT,aligned,false,true>::isAliased(
const Other* alias )
const noexcept
7763 return matrix_.isAliased( alias );
7780 template<
typename MT >
7781 template<
typename MT2
7784 inline bool Submatrix<MT,aligned,false,true>::isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
7786 return ( matrix_.isAliased( &alias->matrix_ ) &&
7787 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
7788 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
7804 template<
typename MT >
7805 inline bool Submatrix<MT,aligned,false,true>::isAligned() const noexcept
7824 template<
typename MT >
7825 inline bool Submatrix<MT,aligned,false,true>::canSMPAssign() const noexcept
7827 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
7849 template<
typename MT >
7851 Submatrix<MT,aligned,false,true>::load(
size_t i,
size_t j )
const noexcept
7853 return loada( i, j );
7875 template<
typename MT >
7886 return matrix_.loada( row_+i, column_+j );
7908 template<
typename MT >
7919 return matrix_.loadu( row_+i, column_+j );
7942 template<
typename MT >
7944 Submatrix<MT,aligned,false,true>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
7946 return storea( i, j, value );
7969 template<
typename MT >
7980 return matrix_.storea( row_+i, column_+j, value );
8003 template<
typename MT >
8014 matrix_.storeu( row_+i, column_+j, value );
8038 template<
typename MT >
8049 matrix_.stream( row_+i, column_+j, value );
8067 template<
typename MT >
8068 template<
typename MT2 >
8069 inline DisableIf_< typename Submatrix<MT,aligned,false,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
8070 Submatrix<MT,aligned,false,true>::assign(
const DenseMatrix<MT2,false>& rhs )
8075 const size_t jpos( n_ &
size_t(-2) );
8078 for(
size_t i=0UL; i<
m_; ++i ) {
8079 for(
size_t j=0UL; j<jpos; j+=2UL ) {
8080 matrix_(row_+i,column_+j ) = (~rhs)(i,j );
8081 matrix_(row_+i,column_+j+1UL) = (~rhs)(i,j+1UL);
8084 matrix_(row_+i,column_+jpos) = (~rhs)(i,jpos);
8104 template<
typename MT >
8105 template<
typename MT2 >
8106 inline EnableIf_< typename Submatrix<MT,aligned,false,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
8107 Submatrix<MT,aligned,false,true>::assign(
const DenseMatrix<MT2,false>& rhs )
8114 const size_t jpos( n_ &
size_t(-SIMDSIZE) );
8118 m_*n_ > (
cacheSize / (
sizeof(ElementType) * 3UL ) ) &&
8119 !(~rhs).isAliased( &matrix_ ) )
8121 for(
size_t i=0UL; i<
m_; ++i )
8124 Iterator left(
begin(i) );
8125 ConstIterator_<MT2> right( (~rhs).
begin(i) );
8127 for( ; j<jpos; j+=SIMDSIZE ) {
8128 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8130 for( ; j<
n_; ++j ) {
8131 *left = *right; ++left; ++right;
8137 for(
size_t i=0UL; i<
m_; ++i )
8140 Iterator left(
begin(i) );
8141 ConstIterator_<MT2> right( (~rhs).
begin(i) );
8143 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
8144 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8145 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8146 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8147 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8149 for( ; j<jpos; j+=SIMDSIZE ) {
8150 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8152 for( ; j<
n_; ++j ) {
8153 *left = *right; ++left; ++right;
8174 template<
typename MT >
8175 template<
typename MT2 >
8176 inline void Submatrix<MT,aligned,false,true>::assign(
const DenseMatrix<MT2,true>& rhs )
8183 constexpr
size_t block( BLOCK_SIZE );
8185 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
8186 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
8187 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
8188 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
8189 for(
size_t i=ii; i<iend; ++i ) {
8190 for(
size_t j=jj; j<jend; ++j ) {
8191 matrix_(row_+i,column_+j) = (~rhs)(i,j);
8213 template<
typename MT >
8214 template<
typename MT2 >
8215 inline void Submatrix<MT,aligned,false,true>::assign(
const SparseMatrix<MT2,false>& rhs )
8220 for(
size_t i=0UL; i<
m_; ++i )
8221 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
8222 matrix_(row_+i,column_+element->index()) = element->value();
8240 template<
typename MT >
8241 template<
typename MT2 >
8242 inline void Submatrix<MT,aligned,false,true>::assign(
const SparseMatrix<MT2,true>& rhs )
8249 for(
size_t j=0UL; j<
n_; ++j )
8250 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
8251 matrix_(row_+element->index(),column_+j) = element->value();
8269 template<
typename MT >
8270 template<
typename MT2 >
8271 inline DisableIf_< typename Submatrix<MT,aligned,false,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
8272 Submatrix<MT,aligned,false,true>::addAssign(
const DenseMatrix<MT2,false>& rhs )
8277 const size_t jpos( n_ &
size_t(-2) );
8280 for(
size_t i=0UL; i<
m_; ++i )
8282 if( IsDiagonal<MT2>::value ) {
8283 matrix_(row_+i,column_+i) += (~rhs)(i,i);
8286 for(
size_t j=0UL; j<jpos; j+=2UL ) {
8287 matrix_(row_+i,column_+j ) += (~rhs)(i,j );
8288 matrix_(row_+i,column_+j+1UL) += (~rhs)(i,j+1UL);
8291 matrix_(row_+i,column_+jpos) += (~rhs)(i,jpos);
8312 template<
typename MT >
8313 template<
typename MT2 >
8314 inline EnableIf_< typename Submatrix<MT,aligned,false,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
8315 Submatrix<MT,aligned,false,true>::addAssign(
const DenseMatrix<MT2,false>& rhs )
8322 for(
size_t i=0UL; i<
m_; ++i )
8324 const size_t jbegin( ( IsUpper<MT2>::value )
8325 ?( ( IsStrictlyUpper<MT2>::value ? i+1UL : i ) &
size_t(-SIMDSIZE) )
8327 const size_t jend ( ( IsLower<MT2>::value )
8328 ?( IsStrictlyLower<MT2>::value ? i : i+1UL )
8332 const size_t jpos( jend &
size_t(-SIMDSIZE) );
8336 Iterator left(
begin(i) + jbegin );
8337 ConstIterator_<MT2> right( (~rhs).
begin(i) + jbegin );
8339 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
8340 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8341 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8342 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8343 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8345 for( ; j<jpos; j+=SIMDSIZE ) {
8346 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8348 for( ; j<jend; ++j ) {
8349 *left += *right; ++left; ++right;
8369 template<
typename MT >
8370 template<
typename MT2 >
8371 inline void Submatrix<MT,aligned,false,true>::addAssign(
const DenseMatrix<MT2,true>& rhs )
8378 constexpr
size_t block( BLOCK_SIZE );
8380 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
8381 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
8382 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
8383 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
8384 for(
size_t i=ii; i<iend; ++i ) {
8385 for(
size_t j=jj; j<jend; ++j ) {
8386 matrix_(row_+i,column_+j) += (~rhs)(i,j);
8408 template<
typename MT >
8409 template<
typename MT2 >
8410 inline void Submatrix<MT,aligned,false,true>::addAssign(
const SparseMatrix<MT2,false>& rhs )
8415 for(
size_t i=0UL; i<
m_; ++i )
8416 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
8417 matrix_(row_+i,column_+element->index()) += element->value();
8435 template<
typename MT >
8436 template<
typename MT2 >
8437 inline void Submatrix<MT,aligned,false,true>::addAssign(
const SparseMatrix<MT2,true>& rhs )
8444 for(
size_t j=0UL; j<
n_; ++j )
8445 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
8446 matrix_(row_+element->index(),column_+j) += element->value();
8464 template<
typename MT >
8465 template<
typename MT2 >
8466 inline DisableIf_< typename Submatrix<MT,aligned,false,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
8467 Submatrix<MT,aligned,false,true>::subAssign(
const DenseMatrix<MT2,false>& rhs )
8472 const size_t jpos( n_ &
size_t(-2) );
8475 for(
size_t i=0UL; i<
m_; ++i )
8477 if( IsDiagonal<MT2>::value ) {
8478 matrix_(row_+i,column_+i) -= (~rhs)(i,i);
8481 for(
size_t j=0UL; j<jpos; j+=2UL ) {
8482 matrix_(row_+i,column_+j ) -= (~rhs)(i,j );
8483 matrix_(row_+i,column_+j+1UL) -= (~rhs)(i,j+1UL);
8486 matrix_(row_+i,column_+jpos) -= (~rhs)(i,jpos);
8507 template<
typename MT >
8508 template<
typename MT2 >
8509 inline EnableIf_< typename Submatrix<MT,aligned,false,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
8510 Submatrix<MT,aligned,false,true>::subAssign(
const DenseMatrix<MT2,false>& rhs )
8517 for(
size_t i=0UL; i<
m_; ++i )
8519 const size_t jbegin( ( IsUpper<MT2>::value )
8520 ?( ( IsStrictlyUpper<MT2>::value ? i+1UL : i ) &
size_t(-SIMDSIZE) )
8522 const size_t jend ( ( IsLower<MT2>::value )
8523 ?( IsStrictlyLower<MT2>::value ? i : i+1UL )
8527 const size_t jpos( jend &
size_t(-SIMDSIZE) );
8531 Iterator left(
begin(i) + jbegin );
8532 ConstIterator_<MT2> right( (~rhs).
begin(i) + jbegin );
8534 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
8535 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8536 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8537 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8538 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8540 for( ; j<jpos; j+=SIMDSIZE ) {
8541 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8543 for( ; j<jend; ++j ) {
8544 *left -= *right; ++left; ++right;
8564 template<
typename MT >
8565 template<
typename MT2 >
8566 inline void Submatrix<MT,aligned,false,true>::subAssign(
const DenseMatrix<MT2,true>& rhs )
8573 constexpr
size_t block( BLOCK_SIZE );
8575 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
8576 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
8577 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
8578 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
8579 for(
size_t i=ii; i<iend; ++i ) {
8580 for(
size_t j=jj; j<jend; ++j ) {
8581 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
8603 template<
typename MT >
8604 template<
typename MT2 >
8605 inline void Submatrix<MT,aligned,false,true>::subAssign(
const SparseMatrix<MT2,false>& rhs )
8610 for(
size_t i=0UL; i<
m_; ++i )
8611 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
8612 matrix_(row_+i,column_+element->index()) -= element->value();
8630 template<
typename MT >
8631 template<
typename MT2 >
8632 inline void Submatrix<MT,aligned,false,true>::subAssign(
const SparseMatrix<MT2,true>& rhs )
8639 for(
size_t j=0UL; j<
n_; ++j )
8640 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
8641 matrix_(row_+element->index(),column_+j) -= element->value();
8667 template<
typename MT >
8668 class Submatrix<MT,aligned,true,true>
8669 :
public DenseMatrix< Submatrix<MT,aligned,true,true>, true >
8675 typedef If_< IsExpression<MT>, MT, MT& > Operand;
8680 typedef Submatrix<MT,aligned,true,true>
This;
8681 typedef DenseMatrix<This,true>
BaseType;
8686 typedef SIMDTrait_<ElementType> SIMDType;
8697 typedef const ElementType* ConstPointer;
8700 typedef If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, ElementType* > Pointer;
8711 enum :
bool { simdEnabled = MT::simdEnabled };
8714 enum :
bool { smpAssignable = MT::smpAssignable };
8720 explicit inline Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n );
8732 inline Reference operator()(
size_t i,
size_t j );
8733 inline ConstReference operator()(
size_t i,
size_t j )
const;
8734 inline Reference at(
size_t i,
size_t j );
8735 inline ConstReference at(
size_t i,
size_t j )
const;
8736 inline Pointer data () noexcept;
8737 inline ConstPointer data () const noexcept;
8738 inline Pointer data (
size_t j ) noexcept;
8739 inline ConstPointer data (
size_t j ) const noexcept;
8740 inline Iterator
begin (
size_t j );
8741 inline ConstIterator
begin (
size_t j ) const;
8742 inline ConstIterator
cbegin(
size_t j ) const;
8743 inline Iterator
end (
size_t j );
8744 inline ConstIterator
end (
size_t j ) const;
8745 inline ConstIterator
cend (
size_t j ) const;
8752 inline Submatrix& operator=( const ElementType& rhs );
8753 inline Submatrix& operator=( initializer_list< initializer_list<ElementType> > list );
8754 inline Submatrix& operator=( const Submatrix& rhs );
8756 template< typename MT2,
bool SO >
8757 inline Submatrix& operator=( const Matrix<MT2,SO>& rhs );
8759 template< typename MT2,
bool SO >
8760 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
8761 operator+=( const Matrix<MT2,SO>& rhs );
8763 template< typename MT2,
bool SO >
8764 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
8765 operator+=( const Matrix<MT2,SO>& rhs );
8767 template< typename MT2,
bool SO >
8768 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
8769 operator-=( const Matrix<MT2,SO>& rhs );
8771 template< typename MT2,
bool SO >
8772 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
8773 operator-=( const Matrix<MT2,SO>& rhs );
8775 template< typename MT2,
bool SO >
8776 inline Submatrix& operator*=( const Matrix<MT2,SO>& rhs );
8778 template< typename Other >
8779 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator*=( Other rhs );
8781 template< typename Other >
8782 inline
EnableIf_< IsNumeric<Other>, Submatrix >& operator/=( Other rhs );
8789 inline
size_t row() const noexcept;
8790 inline
size_t rows() const noexcept;
8791 inline
size_t column() const noexcept;
8792 inline
size_t columns() const noexcept;
8793 inline
size_t spacing() const noexcept;
8794 inline
size_t capacity() const noexcept;
8795 inline
size_t capacity(
size_t i ) const noexcept;
8797 inline
size_t nonZeros(
size_t i ) const;
8798 inline
void reset();
8799 inline
void reset(
size_t i );
8809 template< typename Other > inline Submatrix& scale( const Other& scalar );
8816 template< typename MT2 >
8817 struct VectorizedAssign {
8819 simdEnabled && MT2::simdEnabled &&
8820 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value };
8826 template<
typename MT2 >
8827 struct VectorizedAddAssign {
8829 simdEnabled && MT2::simdEnabled &&
8830 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
8831 HasSIMDAdd< ElementType, ElementType_<MT2> >::value &&
8832 !IsDiagonal<MT2>::value };
8838 template<
typename MT2 >
8839 struct VectorizedSubAssign {
8841 simdEnabled && MT2::simdEnabled &&
8842 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
8843 HasSIMDSub< ElementType, ElementType_<MT2> >::value &&
8844 !IsDiagonal<MT2>::value };
8857 template<
typename Other >
8858 inline bool canAlias(
const Other* alias )
const noexcept;
8860 template<
typename MT2,
bool AF2,
bool SO2 >
8861 inline bool canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
8863 template<
typename Other >
8864 inline bool isAliased(
const Other* alias )
const noexcept;
8866 template<
typename MT2,
bool AF2,
bool SO2 >
8867 inline bool isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept;
8869 inline bool isAligned () const noexcept;
8870 inline
bool canSMPAssign() const noexcept;
8881 template< typename MT2 >
8882 inline
DisableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,true>& rhs );
8884 template< typename MT2 >
8885 inline
EnableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,true>& rhs );
8887 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,false>& rhs );
8888 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
8889 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
8891 template< typename MT2 >
8892 inline
DisableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,true>& rhs );
8894 template< typename MT2 >
8895 inline
EnableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,true>& rhs );
8897 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,false>& rhs );
8898 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
8899 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
8901 template< typename MT2 >
8902 inline
DisableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,true>& rhs );
8904 template< typename MT2 >
8905 inline
EnableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,true>& rhs );
8907 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,false>& rhs );
8908 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
8909 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
8917 inline
bool hasOverlap() const noexcept;
8926 const
size_t column_;
8933 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 > friend class Submatrix;
8935 template<
bool AF1, typename MT2,
bool AF2,
bool SO2,
bool DF2 >
8936 friend const Submatrix<MT2,AF1,SO2,DF2>
8937 submatrix( const Submatrix<MT2,AF2,SO2,DF2>& sm,
size_t row,
size_t column,
size_t m,
size_t n );
8939 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
8940 friend
bool isIntact( const Submatrix<MT2,AF2,SO2,DF2>& sm ) noexcept;
8942 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
8943 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Matrix<MT2,SO2>& b ) noexcept;
8945 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
8946 friend
bool isSame( const Matrix<MT2,SO2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
8948 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
8949 friend
bool isSame( const Submatrix<MT2,AF2,SO2,DF2>& a, const Submatrix<MT2,AF2,SO2,DF2>& b ) noexcept;
8951 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
8952 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
8953 size_t row,
size_t column );
8955 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
8956 friend
bool tryAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
8957 size_t row,
size_t column );
8959 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
8960 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
8961 size_t row,
size_t column );
8963 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
8964 friend
bool tryAddAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
8965 size_t row,
size_t column );
8967 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
8968 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
8969 size_t row,
size_t column );
8971 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename MT3,
bool SO3 >
8972 friend
bool trySubAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Matrix<MT3,SO3>& rhs,
8973 size_t row,
size_t column );
8975 template< typename MT2,
bool AF2,
bool SO2,
bool DF2, typename VT,
bool TF >
8976 friend
bool tryMultAssign( const Submatrix<MT2,AF2,SO2,DF2>& lhs, const Vector<VT,TF>& rhs,
8977 size_t row,
size_t column );
8979 template< typename MT2,
bool AF2,
bool SO2,
bool DF2 >
8980 friend
DerestrictTrait_< Submatrix<MT2,AF2,SO2,DF2> > derestrict( Submatrix<MT2,AF2,SO2,DF2>& sm );
9019 template< typename MT >
9020 inline Submatrix<MT,aligned,true,true>::Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n )
9027 if( ( row_ + m_ > matrix_.rows() ) || ( column_ + n_ > matrix_.columns() ) ) {
9031 if( ( simdEnabled && matrix_.data() !=
nullptr && !
checkAlignment( data() ) ) ||
9032 ( n_ > 1UL && matrix_.spacing() % SIMDSIZE != 0UL ) ) {
9059 template<
typename MT >
9061 Submatrix<MT,aligned,true,true>::operator()(
size_t i,
size_t j )
9066 return matrix_(row_+i,column_+j);
9083 template<
typename MT >
9085 Submatrix<MT,aligned,true,true>::operator()(
size_t i,
size_t j )
const 9090 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
9108 template<
typename MT >
9110 Submatrix<MT,aligned,true,true>::at(
size_t i,
size_t j )
9118 return (*
this)(i,j);
9136 template<
typename MT >
9138 Submatrix<MT,aligned,true,true>::at(
size_t i,
size_t j )
const 9146 return (*
this)(i,j);
9162 template<
typename MT >
9163 inline typename Submatrix<MT,aligned,true,true>::Pointer
9164 Submatrix<MT,aligned,true,true>::data() noexcept
9166 return matrix_.data() + row_ + column_*
spacing();
9182 template<
typename MT >
9183 inline typename Submatrix<MT,aligned,true,true>::ConstPointer
9184 Submatrix<MT,aligned,true,true>::data() const noexcept
9186 return matrix_.data() + row_ + column_*
spacing();
9201 template<
typename MT >
9202 inline typename Submatrix<MT,aligned,true,true>::Pointer
9203 Submatrix<MT,aligned,true,true>::data(
size_t j ) noexcept
9205 return matrix_.data() + row_ + (column_+j)*
spacing();
9220 template<
typename MT >
9221 inline typename Submatrix<MT,aligned,true,true>::ConstPointer
9222 Submatrix<MT,aligned,true,true>::data(
size_t j )
const noexcept
9224 return matrix_.data() + row_ + (column_+j)*
spacing();
9237 template<
typename MT >
9242 return ( matrix_.begin( column_ + j ) + row_ );
9255 template<
typename MT >
9260 return ( matrix_.cbegin( column_ + j ) + row_ );
9273 template<
typename MT >
9278 return ( matrix_.cbegin( column_ + j ) + row_ );
9291 template<
typename MT >
9296 return ( matrix_.begin( column_ + j ) + row_ +
m_ );
9309 template<
typename MT >
9314 return ( matrix_.cbegin( column_ + j ) + row_ +
m_ );
9327 template<
typename MT >
9332 return ( matrix_.cbegin( column_ + j ) + row_ +
m_ );
9357 template<
typename MT >
9358 inline Submatrix<MT,aligned,true,true>&
9359 Submatrix<MT,aligned,true,true>::operator=(
const ElementType& rhs )
9361 const size_t jend( column_ + n_ );
9363 for(
size_t j=column_; j<jend; ++j )
9365 const size_t ibegin( ( IsLower<MT>::value )
9366 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
9367 ?(
max( j+1UL, row_ ) )
9368 :(
max( j, row_ ) ) )
9370 const size_t iend ( ( IsUpper<MT>::value )
9371 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
9372 ?(
min( j, row_+m_ ) )
9373 :(
min( j+1UL, row_+m_ ) ) )
9376 for(
size_t i=ibegin; i<iend; ++i )
9399 template<
typename MT >
9400 inline Submatrix<MT,aligned,true,true>&
9401 Submatrix<MT,aligned,true,true>::operator=( initializer_list< initializer_list<ElementType> > list )
9409 for(
const auto& rowList : list ) {
9411 for(
const auto& element : rowList ) {
9412 matrix_(row_+i,column_+j) = element;
9415 for( ; j<
n_; ++j ) {
9442 template<
typename MT >
9443 inline Submatrix<MT,aligned,true,true>&
9444 Submatrix<MT,aligned,true,true>::operator=(
const Submatrix& rhs )
9449 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
9452 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
9456 if( !tryAssign( matrix_, rhs, row_, column_ ) ) {
9460 DerestrictTrait_<This> left( derestrict( *
this ) );
9462 if( rhs.canAlias( &matrix_ ) ) {
9463 const ResultType tmp( rhs );
9492 template<
typename MT >
9493 template<
typename MT2
9495 inline Submatrix<MT,aligned,true,true>&
9496 Submatrix<MT,aligned,true,true>::operator=(
const Matrix<MT2,SO>& rhs )
9504 typedef If_< IsRestricted<MT>, CompositeType_<MT2>,
const MT2& > Right;
9505 Right right( ~rhs );
9507 if( !tryAssign( matrix_, right, row_, column_ ) ) {
9511 if( IsSparseMatrix<MT2>::value )
9514 DerestrictTrait_<This> left( derestrict( *
this ) );
9516 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
9517 const ResultType_<MT2> tmp( right );
9546 template<
typename MT >
9547 template<
typename MT2
9549 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,true,true>& >
9556 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
9565 if( !tryAddAssign( matrix_, ~rhs, row_, column_ ) ) {
9569 DerestrictTrait_<This> left( derestrict( *
this ) );
9571 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
9572 (~rhs).canAlias( &matrix_ ) ) {
9573 const AddType tmp( *
this + (~rhs) );
9602 template<
typename MT >
9603 template<
typename MT2
9605 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,true,true>& >
9612 typedef AddTrait_< ResultType, ResultType_<MT2> > AddType;
9621 const AddType tmp( *
this + (~rhs) );
9623 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
9627 DerestrictTrait_<This> left( derestrict( *
this ) );
9653 template<
typename MT >
9654 template<
typename MT2
9656 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,true,true>& >
9663 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
9672 if( !trySubAssign( matrix_, ~rhs, row_, column_ ) ) {
9676 DerestrictTrait_<This> left( derestrict( *
this ) );
9678 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
9679 (~rhs).canAlias( &matrix_ ) ) {
9680 const SubType tmp( *
this - (~rhs ) );
9709 template<
typename MT >
9710 template<
typename MT2
9712 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,true,true>& >
9719 typedef SubTrait_< ResultType, ResultType_<MT2> > SubType;
9728 const SubType tmp( *
this - (~rhs) );
9730 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
9734 DerestrictTrait_<This> left( derestrict( *
this ) );
9760 template<
typename MT >
9761 template<
typename MT2
9763 inline Submatrix<MT,aligned,true,true>&
9770 typedef MultTrait_< ResultType, ResultType_<MT2> > MultType;
9779 const MultType tmp( *
this * (~rhs) );
9781 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
9785 DerestrictTrait_<This> left( derestrict( *
this ) );
9808 template<
typename MT >
9809 template<
typename Other >
9810 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,aligned,true,true> >&
9815 DerestrictTrait_<This> left( derestrict( *
this ) );
9837 template<
typename MT >
9838 template<
typename Other >
9839 inline EnableIf_< IsNumeric<Other>, Submatrix<MT,aligned,true,true> >&
9846 DerestrictTrait_<This> left( derestrict( *
this ) );
9869 template<
typename MT >
9884 template<
typename MT >
9899 template<
typename MT >
9914 template<
typename MT >
9932 template<
typename MT >
9935 return matrix_.spacing();
9947 template<
typename MT >
9963 template<
typename MT >
9982 template<
typename MT >
9985 const size_t iend( row_ + m_ );
9986 const size_t jend( column_ + n_ );
9987 size_t nonzeros( 0UL );
9989 for(
size_t j=column_; j<jend; ++j )
9990 for(
size_t i=row_; i<iend; ++i )
10007 template<
typename MT >
10012 const size_t iend( row_ + m_ );
10013 size_t nonzeros( 0UL );
10015 for(
size_t i=row_; i<iend; ++i )
10016 if( !
isDefault( matrix_(i,column_+j) ) )
10031 template<
typename MT >
10036 for(
size_t j=column_; j<column_+
n_; ++j )
10038 const size_t ibegin( ( IsLower<MT>::value )
10039 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
10040 ?(
max( j+1UL, row_ ) )
10041 :(
max( j, row_ ) ) )
10043 const size_t iend ( ( IsUpper<MT>::value )
10044 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
10045 ?(
min( j, row_+m_ ) )
10046 :(
min( j+1UL, row_+m_ ) ) )
10049 for(
size_t i=ibegin; i<iend; ++i )
10050 clear( matrix_(i,j) );
10064 template<
typename MT >
10071 const size_t ibegin( ( IsLower<MT>::value )
10072 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
10073 ?(
max( j+1UL, row_ ) )
10074 :(
max( j, row_ ) ) )
10076 const size_t iend ( ( IsUpper<MT>::value )
10077 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
10078 ?(
min( j, row_+m_ ) )
10079 :(
min( j+1UL, row_+m_ ) ) )
10082 for(
size_t i=ibegin; i<iend; ++i )
10083 clear( matrix_(i,column_+j) );
10099 template<
typename MT >
10100 inline bool Submatrix<MT,aligned,true,true>::hasOverlap() const noexcept
10102 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
10104 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
10138 template<
typename MT >
10145 if( !tryAssign( matrix_,
trans( *
this ), row_, column_ ) ) {
10149 DerestrictTrait_<This> left( derestrict( *
this ) );
10150 const ResultType tmp(
trans( *
this ) );
10177 template<
typename MT >
10184 if( !tryAssign( matrix_,
ctrans( *
this ), row_, column_ ) ) {
10188 DerestrictTrait_<This> left( derestrict( *
this ) );
10189 const ResultType tmp(
ctrans( *
this ) );
10209 template<
typename MT >
10210 template<
typename Other >
10211 inline Submatrix<MT,aligned,true,true>& Submatrix<MT,aligned,true,true>::scale(
const Other& scalar )
10215 const size_t jend( column_ + n_ );
10217 for(
size_t j=column_; j<jend; ++j )
10219 const size_t ibegin( ( IsLower<MT>::value )
10220 ?( ( IsStrictlyLower<MT>::value )
10221 ?(
max( j+1UL, row_ ) )
10222 :(
max( j, row_ ) ) )
10224 const size_t iend ( ( IsUpper<MT>::value )
10225 ?( ( IsStrictlyUpper<MT>::value )
10226 ?(
min( j, row_+m_ ) )
10227 :(
min( j+1UL, row_+m_ ) ) )
10230 for(
size_t i=ibegin; i<iend; ++i )
10231 matrix_(i,j) *= scalar;
10259 template<
typename MT >
10260 template<
typename Other >
10261 inline bool Submatrix<MT,aligned,true,true>::canAlias(
const Other* alias )
const noexcept
10263 return matrix_.isAliased( alias );
10280 template<
typename MT >
10281 template<
typename MT2
10284 inline bool Submatrix<MT,aligned,true,true>::canAlias(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
10286 return ( matrix_.isAliased( &alias->matrix_ ) &&
10287 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
10288 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
10305 template<
typename MT >
10306 template<
typename Other >
10307 inline bool Submatrix<MT,aligned,true,true>::isAliased(
const Other* alias )
const noexcept
10309 return matrix_.isAliased( alias );
10326 template<
typename MT >
10327 template<
typename MT2
10330 inline bool Submatrix<MT,aligned,true,true>::isAliased(
const Submatrix<MT2,AF2,SO2,true>* alias )
const noexcept
10332 return ( matrix_.isAliased( &alias->matrix_ ) &&
10333 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
10334 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
10350 template<
typename MT >
10351 inline bool Submatrix<MT,aligned,true,true>::isAligned() const noexcept
10370 template<
typename MT >
10371 inline bool Submatrix<MT,aligned,true,true>::canSMPAssign() const noexcept
10373 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
10394 template<
typename MT >
10396 Submatrix<MT,aligned,true,true>::load(
size_t i,
size_t j )
const noexcept
10398 return loada( i, j );
10419 template<
typename MT >
10430 return matrix_.loada( row_+i, column_+j );
10451 template<
typename MT >
10462 return matrix_.loadu( row_+i, column_+j );
10484 template<
typename MT >
10486 Submatrix<MT,aligned,true,true>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
10510 template<
typename MT >
10521 matrix_.storea( row_+i, column_+j, value );
10543 template<
typename MT >
10554 matrix_.storeu( row_+i, column_+j, value );
10577 template<
typename MT >
10588 matrix_.stream( row_+i, column_+j, value );
10606 template<
typename MT >
10607 template<
typename MT2 >
10608 inline DisableIf_< typename Submatrix<MT,aligned,true,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
10609 Submatrix<MT,aligned,true,true>::assign(
const DenseMatrix<MT2,true>& rhs )
10614 const size_t ipos( m_ &
size_t(-2) );
10617 for(
size_t j=0UL; j<
n_; ++j ) {
10618 for(
size_t i=0UL; i<ipos; i+=2UL ) {
10619 matrix_(row_+i ,column_+j) = (~rhs)(i ,j);
10620 matrix_(row_+i+1UL,column_+j) = (~rhs)(i+1UL,j);
10623 matrix_(row_+ipos,column_+j) = (~rhs)(ipos,j);
10643 template<
typename MT >
10644 template<
typename MT2 >
10645 inline EnableIf_< typename Submatrix<MT,aligned,true,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
10646 Submatrix<MT,aligned,true,true>::assign(
const DenseMatrix<MT2,true>& rhs )
10653 const size_t ipos( m_ &
size_t(-SIMDSIZE) );
10657 m_*n_ > (
cacheSize / (
sizeof(ElementType) * 3UL ) ) &&
10658 !(~rhs).isAliased( &matrix_ ) )
10660 for(
size_t j=0UL; j<
n_; ++j )
10663 Iterator left(
begin(j) );
10664 ConstIterator_<MT2> right( (~rhs).
begin(j) );
10666 for( ; i<ipos; i+=SIMDSIZE ) {
10667 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10669 for( ; i<
m_; ++i ) {
10670 *left = *right; ++left; ++right;
10676 for(
size_t j=0UL; j<
n_; ++j )
10679 Iterator left(
begin(j) );
10680 ConstIterator_<MT2> right( (~rhs).
begin(j) );
10682 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
10683 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10684 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10685 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10686 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10688 for( ; i<ipos; i+=SIMDSIZE ) {
10689 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10691 for( ; i<
m_; ++i ) {
10692 *left = *right; ++left; ++right;
10713 template<
typename MT >
10714 template<
typename MT2 >
10715 inline void Submatrix<MT,aligned,true,true>::assign(
const DenseMatrix<MT2,false>& rhs )
10722 constexpr
size_t block( BLOCK_SIZE );
10724 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
10725 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
10726 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
10727 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
10728 for(
size_t j=jj; j<jend; ++j ) {
10729 for(
size_t i=ii; i<iend; ++i ) {
10730 matrix_(row_+i,column_+j) = (~rhs)(i,j);
10752 template<
typename MT >
10753 template<
typename MT2 >
10754 inline void Submatrix<MT,aligned,true,true>::assign(
const SparseMatrix<MT2,true>& rhs )
10759 for(
size_t j=0UL; j<
n_; ++j )
10760 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
10761 matrix_(row_+element->index(),column_+j) = element->value();
10779 template<
typename MT >
10780 template<
typename MT2 >
10781 inline void Submatrix<MT,aligned,true,true>::assign(
const SparseMatrix<MT2,false>& rhs )
10788 for(
size_t i=0UL; i<
m_; ++i )
10789 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
10790 matrix_(row_+i,column_+element->index()) = element->value();
10808 template<
typename MT >
10809 template<
typename MT2 >
10810 inline DisableIf_< typename Submatrix<MT,aligned,true,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
10811 Submatrix<MT,aligned,true,true>::addAssign(
const DenseMatrix<MT2,true>& rhs )
10816 const size_t ipos( m_ &
size_t(-2) );
10819 for(
size_t j=0UL; j<
n_; ++j )
10821 if( IsDiagonal<MT2>::value ) {
10822 matrix_(row_+j,column_+j) += (~rhs)(j,j);
10825 for(
size_t i=0UL; i<ipos; i+=2UL ) {
10826 matrix_(row_+i ,column_+j) += (~rhs)(i ,j);
10827 matrix_(row_+i+1UL,column_+j) += (~rhs)(i+1UL,j);
10830 matrix_(row_+ipos,column_+j) += (~rhs)(ipos,j);
10851 template<
typename MT >
10852 template<
typename MT2 >
10853 inline EnableIf_< typename Submatrix<MT,aligned,true,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
10854 Submatrix<MT,aligned,true,true>::addAssign(
const DenseMatrix<MT2,true>& rhs )
10861 for(
size_t j=0UL; j<
n_; ++j )
10863 const size_t ibegin( ( IsLower<MT>::value )
10864 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-SIMDSIZE) )
10866 const size_t iend ( ( IsUpper<MT>::value )
10867 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
10871 const size_t ipos( iend &
size_t(-SIMDSIZE) );
10874 size_t i( ibegin );
10875 Iterator left(
begin(j) + ibegin );
10876 ConstIterator_<MT2> right( (~rhs).
begin(j) + ibegin );
10878 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
10879 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10880 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10881 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10882 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10884 for( ; i<ipos; i+=SIMDSIZE ) {
10885 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
10887 for( ; i<iend; ++i ) {
10888 *left += *right; ++left; ++right;
10908 template<
typename MT >
10909 template<
typename MT2 >
10910 inline void Submatrix<MT,aligned,true,true>::addAssign(
const DenseMatrix<MT2,false>& rhs )
10917 constexpr
size_t block( BLOCK_SIZE );
10919 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
10920 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
10921 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
10922 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
10923 for(
size_t j=jj; j<jend; ++j ) {
10924 for(
size_t i=ii; i<iend; ++i ) {
10925 matrix_(row_+i,column_+j) += (~rhs)(i,j);
10947 template<
typename MT >
10948 template<
typename MT2 >
10949 inline void Submatrix<MT,aligned,true,true>::addAssign(
const SparseMatrix<MT2,true>& rhs )
10954 for(
size_t j=0UL; j<
n_; ++j )
10955 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
10956 matrix_(row_+element->index(),column_+j) += element->value();
10974 template<
typename MT >
10975 template<
typename MT2 >
10976 inline void Submatrix<MT,aligned,true,true>::addAssign(
const SparseMatrix<MT2,false>& rhs )
10983 for(
size_t i=0UL; i<
m_; ++i )
10984 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
10985 matrix_(row_+i,column_+element->index()) += element->value();
11003 template<
typename MT >
11004 template<
typename MT2 >
11005 inline DisableIf_< typename Submatrix<MT,aligned,true,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
11006 Submatrix<MT,aligned,true,true>::subAssign(
const DenseMatrix<MT2,true>& rhs )
11011 const size_t ipos( m_ &
size_t(-2) );
11014 for(
size_t j=0UL; j<
n_; ++j )
11016 if( IsDiagonal<MT2>::value ) {
11017 matrix_(row_+j,column_+j) -= (~rhs)(j,j);
11020 for(
size_t i=0UL; i<ipos; i+=2UL ) {
11021 matrix_(row_+i ,column_+j) -= (~rhs)(i ,j);
11022 matrix_(row_+i+1UL,column_+j) -= (~rhs)(i+1UL,j);
11025 matrix_(row_+ipos,column_+j) -= (~rhs)(ipos,j);
11046 template<
typename MT >
11047 template<
typename MT2 >
11048 inline EnableIf_< typename Submatrix<MT,aligned,true,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
11049 Submatrix<MT,aligned,true,true>::subAssign(
const DenseMatrix<MT2,true>& rhs )
11056 for(
size_t j=0UL; j<
n_; ++j )
11058 const size_t ibegin( ( IsLower<MT>::value )
11059 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-SIMDSIZE) )
11061 const size_t iend ( ( IsUpper<MT>::value )
11062 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
11066 const size_t ipos( iend &
size_t(-SIMDSIZE) );
11069 size_t i( ibegin );
11070 Iterator left(
begin(j) + ibegin );
11071 ConstIterator_<MT2> right( (~rhs).
begin(j) + ibegin );
11073 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
11074 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11075 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11076 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11077 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11079 for( ; i<ipos; i+=SIMDSIZE ) {
11080 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11082 for( ; i<iend; ++i ) {
11083 *left -= *right; ++left; ++right;
11103 template<
typename MT >
11104 template<
typename MT2 >
11105 inline void Submatrix<MT,aligned,true,true>::subAssign(
const DenseMatrix<MT2,false>& rhs )
11112 constexpr
size_t block( BLOCK_SIZE );
11114 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
11115 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
11116 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
11117 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
11118 for(
size_t j=jj; j<jend; ++j ) {
11119 for(
size_t i=ii; i<iend; ++i ) {
11120 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
11142 template<
typename MT >
11143 template<
typename MT2 >
11144 inline void Submatrix<MT,aligned,true,true>::subAssign(
const SparseMatrix<MT2,true>& rhs )
11149 for(
size_t j=0UL; j<
n_; ++j )
11150 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
11151 matrix_(row_+element->index(),column_+j) -= element->value();
11169 template<
typename MT >
11170 template<
typename MT2 >
11171 inline void Submatrix<MT,aligned,true,true>::subAssign(
const SparseMatrix<MT2,false>& rhs )
11178 for(
size_t i=0UL; i<
m_; ++i )
11179 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
11180 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.
BLAZE_ALWAYS_INLINE size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:102
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.
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:352
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:721
Header file for basic type definitions.
Header file for the View base class.
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:261
const CTransExprTrait_< MT > ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatForEachExpr.h:1251
#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
constexpr bool operator<(const NegativeAccuracy< A > &lhs, const T &rhs)
Less-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:329
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:194
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 compressed matrix.
Definition: CompressedMatrix.h:3135
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2935
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:1755
#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:596
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2928
#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
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:390
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:1802
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:2931
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:304
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:238
Constraint on the data type.
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:2939
#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.
constexpr bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:367
constexpr bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:443
Header file for the Not class template.
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Header file for 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:336
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.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< 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:128
#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:2932
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:260
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:2933
const bool unaligned
Alignment flag for unaligned vectors and matrices.Via this flag it is possible to specify subvectors...
Definition: AlignmentFlag.h:64
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2937
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< 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:128
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.
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
Header file for the IsSIMDCombinable type trait.
#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:2934
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:2938
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.
constexpr bool operator<=(const NegativeAccuracy< A > &, const T &rhs)
Less-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:405
#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:320
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2929
size_t n_
The current number of columns of the compressed matrix.
Definition: CompressedMatrix.h:3136
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:733
Header file for the alignment check function.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2930
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:249
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2936
#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:168
Header file for the IsHermitian type trait.
Header file for the IsRestricted type trait.
const DMatDMatMultExpr< T1, T2, false, false, false, false > 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:7505
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:570