35 #ifndef _BLAZE_MATH_VIEWS_SUBMATRIX_DENSE_H_ 36 #define _BLAZE_MATH_VIEWS_SUBMATRIX_DENSE_H_ 135 template<
typename MT
137 class Submatrix<MT,
unaligned,false,true,CSAs...>
138 :
public View< DenseMatrix< Submatrix<MT,unaligned,false,true,CSAs...>, false > >
139 ,
private SubmatrixData<CSAs...>
143 using DataType = SubmatrixData<CSAs...>;
144 using Operand = If_< IsExpression<MT>, MT, MT& >;
152 using BaseType = DenseMatrix<This,false>;
153 using ViewedType = MT;
158 using SIMDType = SIMDTrait_<ElementType>;
169 using ConstPointer = ConstPointer_<MT>;
172 using Pointer = If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, Pointer_<MT> >;
178 template<
typename IteratorType >
179 class SubmatrixIterator
184 using IteratorCategory =
typename std::iterator_traits<IteratorType>::iterator_category;
187 using ValueType =
typename std::iterator_traits<IteratorType>::value_type;
190 using PointerType =
typename std::iterator_traits<IteratorType>::pointer;
193 using ReferenceType =
typename std::iterator_traits<IteratorType>::reference;
196 using DifferenceType =
typename std::iterator_traits<IteratorType>::difference_type;
199 using iterator_category = IteratorCategory;
200 using value_type = ValueType;
201 using pointer = PointerType;
202 using reference = ReferenceType;
203 using difference_type = DifferenceType;
209 inline SubmatrixIterator()
211 , isAligned_( false )
221 inline SubmatrixIterator( IteratorType iterator,
bool isMemoryAligned )
222 : iterator_ ( iterator )
223 , isAligned_( isMemoryAligned )
232 template<
typename IteratorType2 >
233 inline SubmatrixIterator(
const SubmatrixIterator<IteratorType2>& it )
234 : iterator_ ( it.base() )
235 , isAligned_( it.isAligned() )
245 inline SubmatrixIterator&
operator+=(
size_t inc ) {
257 inline SubmatrixIterator&
operator-=(
size_t dec ) {
268 inline SubmatrixIterator& operator++() {
279 inline const SubmatrixIterator operator++(
int ) {
280 return SubmatrixIterator( iterator_++, isAligned_ );
289 inline SubmatrixIterator& operator--() {
300 inline const SubmatrixIterator operator--(
int ) {
301 return SubmatrixIterator( iterator_--, isAligned_ );
320 inline IteratorType operator->()
const {
335 inline SIMDType load() const noexcept {
353 inline SIMDType
loada() const noexcept {
354 return iterator_.loada();
368 inline SIMDType
loadu() const noexcept {
369 return iterator_.loadu();
384 inline void store(
const SIMDType& value )
const {
400 inline void storea(
const SIMDType& value )
const {
401 iterator_.storea( value );
416 inline void storeu(
const SIMDType& value )
const {
418 iterator_.storea( value );
421 iterator_.storeu( value );
437 inline void stream(
const SIMDType& value )
const {
438 iterator_.stream( value );
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 bool operator<=(
const SubmatrixIterator& rhs )
const {
493 return iterator_ <= rhs.iterator_;
503 inline bool operator>=(
const SubmatrixIterator& rhs )
const {
504 return iterator_ >= rhs.iterator_;
514 inline DifferenceType
operator-(
const SubmatrixIterator& rhs )
const {
515 return iterator_ - rhs.iterator_;
526 friend inline const SubmatrixIterator
operator+(
const SubmatrixIterator& it,
size_t inc ) {
527 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
538 friend inline const SubmatrixIterator
operator+(
size_t inc,
const SubmatrixIterator& it ) {
539 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
550 friend inline const SubmatrixIterator
operator-(
const SubmatrixIterator& it,
size_t dec ) {
551 return SubmatrixIterator( it.iterator_ - dec, it.isAligned_ );
560 inline IteratorType base()
const {
570 inline bool isAligned() const noexcept {
577 IteratorType iterator_;
585 using ConstIterator = SubmatrixIterator< ConstIterator_<MT> >;
593 enum :
bool { simdEnabled = MT::simdEnabled };
596 enum :
bool { smpAssignable = MT::smpAssignable };
602 template<
typename... RSAs >
603 explicit inline Submatrix( MT& matrix, RSAs... args );
615 inline Reference operator()(
size_t i,
size_t j );
616 inline ConstReference operator()(
size_t i,
size_t j )
const;
617 inline Reference at(
size_t i,
size_t j );
618 inline ConstReference at(
size_t i,
size_t j )
const;
619 inline Pointer
data () noexcept;
620 inline ConstPointer
data () const noexcept;
621 inline Pointer
data (
size_t i ) noexcept;
622 inline ConstPointer
data (
size_t i ) const noexcept;
624 inline ConstIterator
begin (
size_t i ) const;
625 inline ConstIterator
cbegin(
size_t i ) const;
627 inline ConstIterator
end (
size_t i ) const;
628 inline ConstIterator
cend (
size_t i ) const;
635 inline Submatrix& operator=( const
ElementType& rhs );
636 inline Submatrix& operator=( initializer_list< initializer_list<
ElementType> > list );
637 inline Submatrix& operator=( const Submatrix& rhs );
639 template< typename MT2,
bool SO2 >
640 inline Submatrix& operator=( const Matrix<MT2,SO2>& rhs );
642 template< typename MT2,
bool SO2 >
643 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
644 operator+=( const Matrix<MT2,SO2>& rhs );
646 template< typename MT2,
bool SO2 >
647 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
648 operator+=( const Matrix<MT2,SO2>& rhs );
650 template< typename MT2,
bool SO2 >
651 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
652 operator-=( const Matrix<MT2,SO2>& rhs );
654 template< typename MT2,
bool SO2 >
655 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
656 operator-=( const Matrix<MT2,SO2>& rhs );
658 template< typename MT2,
bool SO2 >
659 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
660 operator%=( const Matrix<MT2,SO2>& rhs );
662 template< typename MT2,
bool SO2 >
663 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
664 operator%=( const Matrix<MT2,SO2>& rhs );
673 using DataType::
rows;
676 inline MT& operand() noexcept;
677 inline const MT& operand() const noexcept;
679 inline
size_t spacing() const noexcept;
680 inline
size_t capacity() const noexcept;
681 inline
size_t capacity(
size_t i ) const noexcept;
683 inline
size_t nonZeros(
size_t i ) const;
685 inline
void reset(
size_t i );
695 template< typename Other > inline Submatrix& scale( const Other& scalar );
702 template< typename MT2 >
703 struct VectorizedAssign {
704 enum :
bool { value = useOptimizedKernels &&
705 simdEnabled && MT2::simdEnabled &&
706 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value };
712 template<
typename MT2 >
713 struct VectorizedAddAssign {
714 enum :
bool { value = useOptimizedKernels &&
715 simdEnabled && MT2::simdEnabled &&
716 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
717 HasSIMDAdd< ElementType, ElementType_<MT2> >::value &&
718 !IsDiagonal<MT2>::value };
724 template<
typename MT2 >
725 struct VectorizedSubAssign {
726 enum :
bool { value = useOptimizedKernels &&
727 simdEnabled && MT2::simdEnabled &&
728 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
729 HasSIMDSub< ElementType, ElementType_<MT2> >::value &&
730 !IsDiagonal<MT2>::value };
736 template<
typename MT2 >
737 struct VectorizedSchurAssign {
738 enum :
bool { value = useOptimizedKernels &&
739 simdEnabled && MT2::simdEnabled &&
740 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
741 HasSIMDMult< ElementType, ElementType_<MT2> >::value };
754 template<
typename Other >
755 inline bool canAlias(
const Other* alias )
const noexcept;
757 template<
typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
758 inline bool canAlias(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept;
760 template<
typename Other >
761 inline bool isAliased(
const Other* alias )
const noexcept;
763 template<
typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
764 inline bool isAliased(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept;
766 inline bool isAligned () const noexcept;
767 inline
bool canSMPAssign() const noexcept;
778 template< typename MT2 >
779 inline
DisableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,false>& rhs );
781 template< typename MT2 >
782 inline
EnableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,false>& rhs );
784 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,true>& rhs );
785 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
786 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
788 template< typename MT2 >
789 inline
DisableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,false>& rhs );
791 template< typename MT2 >
792 inline
EnableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,false>& rhs );
794 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,true>& rhs );
795 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
796 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
798 template< typename MT2 >
799 inline
DisableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,false>& rhs );
801 template< typename MT2 >
802 inline
EnableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,false>& rhs );
804 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,true>& rhs );
805 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
806 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
808 template< typename MT2 >
809 inline
DisableIf_< VectorizedSchurAssign<MT2> > schurAssign( const DenseMatrix<MT2,false>& rhs );
811 template< typename MT2 >
812 inline
EnableIf_< VectorizedSchurAssign<MT2> > schurAssign( const DenseMatrix<MT2,false>& rhs );
814 template< typename MT2 > inline
void schurAssign( const DenseMatrix<MT2,true>& rhs );
815 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,false>& rhs );
816 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,true>& rhs );
824 inline
bool hasOverlap() const noexcept;
832 const
bool isAligned_;
843 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
bool DF2,
size_t... CSAs2 > friend class Submatrix;
881 template< typename MT
883 template< typename... RSAs >
884 inline Submatrix<MT,unaligned,false,true,CSAs...>::Submatrix( MT& matrix, RSAs... args )
885 : DataType ( args... )
888 (
rows() < 2UL || ( matrix.
spacing() &
size_t(-SIMDSIZE) ) == 0UL ) )
890 if( !Contains< TypeList<RSAs...>,
Unchecked >::value ) {
923 template<
typename MT
926 Submatrix<MT,unaligned,false,true,CSAs...>::operator()(
size_t i,
size_t j )
948 template<
typename MT
951 Submatrix<MT,unaligned,false,true,CSAs...>::operator()(
size_t i,
size_t j )
const 956 return const_cast<const MT&
>( matrix_ )(
row()+i,
column()+j);
974 template<
typename MT
977 Submatrix<MT,unaligned,false,true,CSAs...>::at(
size_t i,
size_t j )
1003 template<
typename MT
1006 Submatrix<MT,unaligned,false,true,CSAs...>::at(
size_t i,
size_t j )
const 1014 return (*
this)(i,j);
1030 template<
typename MT
1032 inline typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::Pointer
1051 template<
typename MT
1053 inline typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::ConstPointer
1071 template<
typename MT
1073 inline typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::Pointer
1091 template<
typename MT
1093 inline typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::ConstPointer
1114 template<
typename MT
1138 template<
typename MT
1162 template<
typename MT
1186 template<
typename MT
1210 template<
typename MT
1234 template<
typename MT
1265 template<
typename MT
1267 inline Submatrix<MT,
unaligned,
false,
true,CSAs...>&
1268 Submatrix<MT,unaligned,false,true,CSAs...>::operator=(
const ElementType& rhs )
1270 const size_t iend(
row() +
rows() );
1271 decltype(
auto) left( derestrict( matrix_ ) );
1273 for(
size_t i=
row(); i<iend; ++i )
1275 const size_t jbegin( ( IsUpper<MT>::value )
1276 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
1280 const size_t jend ( ( IsLower<MT>::value )
1281 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
1286 for(
size_t j=jbegin; j<jend; ++j ) {
1287 if( !IsRestricted<MT>::value || IsTriangular<MT>::value || trySet( matrix_, i, j, rhs ) )
1314 template<
typename MT
1316 inline Submatrix<MT,
unaligned,
false,
true,CSAs...>&
1317 Submatrix<MT,unaligned,false,true,CSAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
1319 if( list.size() !=
rows() ) {
1323 if( IsRestricted<MT>::value ) {
1324 const InitializerMatrix<ElementType> tmp( list,
columns() );
1325 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
1330 decltype(
auto) left( derestrict( *this ) );
1333 for( const auto& rowList : list ) {
1334 std::fill( std::copy( rowList.begin(), rowList.end(), left.begin(i) ), left.end(i),
ElementType() );
1359 template<
typename MT
1361 inline Submatrix<MT,
unaligned,
false,
true,CSAs...>&
1362 Submatrix<MT,unaligned,false,true,CSAs...>::operator=(
const Submatrix& rhs )
1367 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row() == rhs.row() &&
column() == rhs.column() ) )
1370 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
1374 if( !tryAssign( matrix_, rhs,
row(),
column() ) ) {
1378 decltype(
auto) left( derestrict( *this ) );
1380 if( rhs.canAlias( &matrix_ ) ) {
1411 template<
typename MT
1413 template<
typename MT2
1415 inline Submatrix<MT,
unaligned,
false,
true,CSAs...>&
1416 Submatrix<MT,unaligned,false,true,CSAs...>::operator=(
const Matrix<MT2,SO2>& rhs )
1424 using Right = If_< IsRestricted<MT>, CompositeType_<MT2>,
const MT2& >;
1425 Right right( ~rhs );
1427 if( !tryAssign( matrix_, right,
row(),
column() ) ) {
1431 decltype(
auto) left( derestrict( *this ) );
1433 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1434 const ResultType_<MT2> tmp( right );
1435 if( IsSparseMatrix<MT2>::value )
1440 if( IsSparseMatrix<MT2>::value )
1467 template<
typename MT
1469 template<
typename MT2
1471 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
unaligned,
false,
true,CSAs...>& >
1478 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
1487 if( !tryAddAssign( matrix_, ~rhs,
row(),
column() ) ) {
1491 decltype(
auto) left( derestrict( *this ) );
1493 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
1494 (~rhs).canAlias( &matrix_ ) ) {
1495 const AddType tmp( *
this + (~rhs) );
1524 template<
typename MT
1526 template<
typename MT2
1528 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
unaligned,
false,
true,CSAs...>& >
1535 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
1544 const AddType tmp( *
this + (~rhs) );
1546 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
1550 decltype(
auto) left( derestrict( *this ) );
1576 template< typename MT
1578 template< typename MT2
1580 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,false,true,CSAs...>& >
1581 Submatrix<MT,unaligned,false,true,CSAs...>::operator-=( const Matrix<MT2,SO2>& rhs )
1587 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
1596 if( !trySubAssign( matrix_, ~rhs,
row(),
column() ) ) {
1600 decltype(
auto) left( derestrict( *this ) );
1602 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
1603 (~rhs).canAlias( &matrix_ ) ) {
1604 const SubType tmp( *
this - (~rhs ) );
1633 template<
typename MT
1635 template<
typename MT2
1637 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
unaligned,
false,
true,CSAs...>& >
1644 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
1653 const SubType tmp( *
this - (~rhs) );
1655 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
1659 decltype(
auto) left( derestrict( *this ) );
1685 template< typename MT
1687 template< typename MT2
1689 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,false,true,CSAs...>& >
1690 Submatrix<MT,unaligned,false,true,CSAs...>::operator%=( const Matrix<MT2,SO2>& rhs )
1696 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
1704 if( !trySchurAssign( matrix_, ~rhs,
row(),
column() ) ) {
1708 decltype(
auto) left( derestrict( *this ) );
1710 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
1711 (~rhs).canAlias( &matrix_ ) ) {
1712 const SchurType tmp( *
this % (~rhs) );
1713 if( IsSparseMatrix<SchurType>::value )
1743 template<
typename MT
1745 template<
typename MT2
1747 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
unaligned,
false,
true,CSAs...>& >
1748 Submatrix<MT,unaligned,false,true,CSAs...>::operator%=(
const Matrix<MT2,SO2>& rhs )
1754 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
1762 const SchurType tmp( *
this % (~rhs) );
1764 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
1768 decltype(
auto) left( derestrict( *this ) );
1770 if( IsSparseMatrix<SchurType>::value ) {
1798 template<
typename MT
1800 inline MT& Submatrix<MT,unaligned,false,true,CSAs...>::operand() noexcept
1814 template<
typename MT
1816 inline const MT& Submatrix<MT,unaligned,false,true,CSAs...>::operand() const noexcept
1835 template<
typename MT
1839 return matrix_.spacing();
1851 template<
typename MT
1873 template<
typename MT
1893 template<
typename MT
1897 const size_t iend(
row() +
rows() );
1899 size_t nonzeros( 0UL );
1901 for(
size_t i=
row(); i<iend; ++i )
1902 for(
size_t j=
column(); j<jend; ++j )
1924 template<
typename MT
1931 size_t nonzeros( 0UL );
1933 for(
size_t j=
column(); j<jend; ++j )
1949 template<
typename MT
1957 const size_t jbegin( ( IsUpper<MT>::value )
1958 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
1962 const size_t jend ( ( IsLower<MT>::value )
1963 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
1968 for(
size_t j=jbegin; j<jend; ++j )
1969 clear( matrix_(i,j) );
1988 template<
typename MT
1996 const size_t jbegin( ( IsUpper<MT>::value )
1997 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
2001 const size_t jend ( ( IsLower<MT>::value )
2002 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
2007 for(
size_t j=jbegin; j<jend; ++j )
2024 template<
typename MT
2026 inline bool Submatrix<MT,unaligned,false,true,CSAs...>::hasOverlap() const noexcept
2028 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
2064 template<
typename MT
2066 inline Submatrix<MT,
unaligned,
false,
true,CSAs...>&
2077 decltype(
auto) left( derestrict( *this ) );
2106 template< typename MT
2108 inline Submatrix<MT,unaligned,false,true,CSAs...>&
2109 Submatrix<MT,unaligned,false,true,CSAs...>::
ctranspose()
2119 decltype(
auto) left( derestrict( *this ) );
2143 template< typename MT
2145 template< typename Other >
2146 inline Submatrix<MT,unaligned,false,true,CSAs...>&
2147 Submatrix<MT,unaligned,false,true,CSAs...>::scale( const Other& scalar )
2151 const size_t iend(
row() +
rows() );
2153 for(
size_t i=
row(); i<iend; ++i )
2155 const size_t jbegin( ( IsUpper<MT>::value )
2156 ?( ( IsStrictlyUpper<MT>::value )
2160 const size_t jend ( ( IsLower<MT>::value )
2161 ?( ( IsStrictlyLower<MT>::value )
2166 for(
size_t j=jbegin; j<jend; ++j )
2167 matrix_(i,j) *= scalar;
2195 template<
typename MT
2197 template<
typename Other >
2198 inline bool Submatrix<MT,unaligned,false,true,CSAs...>::canAlias(
const Other* alias )
const noexcept
2200 return matrix_.isAliased( alias );
2217 template<
typename MT
2219 template<
typename MT2
2224 Submatrix<MT,unaligned,false,true,CSAs...>::canAlias(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
2226 return ( matrix_.isAliased( &alias->matrix_ ) &&
2227 (
row() +
rows() > alias->row() ) &&
2228 (
row() < alias->row() + alias->rows() ) &&
2230 (
column() < alias->column() + alias->columns() ) );
2247 template<
typename MT
2249 template<
typename Other >
2250 inline bool Submatrix<MT,unaligned,false,true,CSAs...>::isAliased(
const Other* alias )
const noexcept
2252 return matrix_.isAliased( alias );
2269 template<
typename MT
2271 template<
typename MT2
2276 Submatrix<MT,unaligned,false,true,CSAs...>::isAliased(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
2278 return ( matrix_.isAliased( &alias->matrix_ ) &&
2279 (
row() +
rows() > alias->row() ) &&
2280 (
row() < alias->row() + alias->rows() ) &&
2282 (
column() < alias->column() + alias->columns() ) );
2298 template<
typename MT
2300 inline bool Submatrix<MT,unaligned,false,true,CSAs...>::isAligned() const noexcept
2319 template<
typename MT
2321 inline bool Submatrix<MT,unaligned,false,true,CSAs...>::canSMPAssign() const noexcept
2323 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
2345 template<
typename MT
2348 Submatrix<MT,unaligned,false,true,CSAs...>::load(
size_t i,
size_t j )
const noexcept
2351 return loada( i, j );
2353 return loadu( i, j );
2375 template<
typename MT
2387 return matrix_.loada(
row()+i,
column()+j );
2409 template<
typename MT
2421 return matrix_.loadu(
row()+i,
column()+j );
2444 template<
typename MT
2447 Submatrix<MT,unaligned,false,true,CSAs...>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
2475 template<
typename MT
2487 matrix_.storea(
row()+i,
column()+j, value );
2510 template<
typename MT
2522 matrix_.storeu(
row()+i,
column()+j, value );
2545 template<
typename MT
2558 matrix_.stream(
row()+i,
column()+j, value );
2560 matrix_.storeu(
row()+i,
column()+j, value );
2578 template<
typename MT
2580 template<
typename MT2 >
2581 inline DisableIf_<
typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
2582 Submatrix<MT,unaligned,false,true,CSAs...>::assign(
const DenseMatrix<MT2,false>& rhs )
2587 const size_t jpos(
columns() &
size_t(-2) );
2590 for(
size_t i=0UL; i<
rows(); ++i ) {
2591 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2592 matrix_(
row()+i,
column()+j ) = (~rhs)(i,j );
2593 matrix_(
row()+i,
column()+j+1UL) = (~rhs)(i,j+1UL);
2596 matrix_(
row()+i,
column()+jpos) = (~rhs)(i,jpos);
2616 template<
typename MT
2618 template<
typename MT2 >
2619 inline EnableIf_<
typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
2620 Submatrix<MT,unaligned,false,true,CSAs...>::assign(
const DenseMatrix<MT2,false>& rhs )
2627 const size_t jpos(
columns() &
size_t(-SIMDSIZE) );
2630 if( useStreaming && isAligned_ &&
2632 !(~rhs).isAliased( &matrix_ ) )
2634 for(
size_t i=0UL; i<
rows(); ++i )
2638 ConstIterator_<MT2> right( (~rhs).
begin(i) );
2640 for( ; j<jpos; j+=SIMDSIZE ) {
2641 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2650 for(
size_t i=0UL; i<
rows(); ++i )
2654 ConstIterator_<MT2> right( (~rhs).
begin(i) );
2656 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2657 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2658 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2659 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2660 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2662 for( ; j<jpos; j+=SIMDSIZE ) {
2663 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2666 *left = *right; ++left; ++right;
2687 template<
typename MT
2689 template<
typename MT2 >
2690 inline void Submatrix<MT,unaligned,false,true,CSAs...>::assign(
const DenseMatrix<MT2,true>& rhs )
2697 constexpr
size_t block( BLOCK_SIZE );
2699 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
2700 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
2701 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
2702 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
2703 for(
size_t i=ii; i<iend; ++i ) {
2704 for(
size_t j=jj; j<jend; ++j ) {
2705 matrix_(
row()+i,
column()+j) = (~rhs)(i,j);
2727 template<
typename MT
2729 template<
typename MT2 >
2730 inline void Submatrix<MT,unaligned,false,true,CSAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
2735 for(
size_t i=0UL; i<
rows(); ++i )
2736 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
2737 matrix_(
row()+i,
column()+element->index()) = element->value();
2755 template<
typename MT
2757 template<
typename MT2 >
2758 inline void Submatrix<MT,unaligned,false,true,CSAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
2765 for(
size_t j=0UL; j<
columns(); ++j )
2766 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
2767 matrix_(
row()+element->index(),
column()+j) = element->value();
2785 template<
typename MT
2787 template<
typename MT2 >
2788 inline DisableIf_<
typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
2789 Submatrix<MT,unaligned,false,true,CSAs...>::addAssign(
const DenseMatrix<MT2,false>& rhs )
2794 const size_t jpos(
columns() &
size_t(-2) );
2797 for(
size_t i=0UL; i<
rows(); ++i )
2799 if( IsDiagonal<MT2>::value ) {
2800 matrix_(
row()+i,
column()+i) += (~rhs)(i,i);
2803 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2804 matrix_(
row()+i,
column()+j ) += (~rhs)(i,j );
2805 matrix_(
row()+i,
column()+j+1UL) += (~rhs)(i,j+1UL);
2808 matrix_(
row()+i,
column()+jpos) += (~rhs)(i,jpos);
2829 template<
typename MT
2831 template<
typename MT2 >
2832 inline EnableIf_<
typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
2833 Submatrix<MT,unaligned,false,true,CSAs...>::addAssign(
const DenseMatrix<MT2,false>& rhs )
2840 for(
size_t i=0UL; i<
rows(); ++i )
2842 const size_t jbegin( ( IsUpper<MT2>::value )
2843 ?( ( IsStrictlyUpper<MT2>::value ? i+1UL : i ) &
size_t(-SIMDSIZE) )
2845 const size_t jend ( ( IsLower<MT2>::value )
2846 ?( IsStrictlyLower<MT2>::value ? i : i+1UL )
2850 const size_t jpos( jend &
size_t(-SIMDSIZE) );
2855 ConstIterator_<MT2> right( (~rhs).
begin(i) + jbegin );
2857 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2858 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2859 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2860 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2861 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2863 for( ; j<jpos; j+=SIMDSIZE ) {
2864 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2866 for( ; j<jend; ++j ) {
2867 *left += *right; ++left; ++right;
2887 template<
typename MT
2889 template<
typename MT2 >
2890 inline void Submatrix<MT,unaligned,false,true,CSAs...>::addAssign(
const DenseMatrix<MT2,true>& rhs )
2897 constexpr
size_t block( BLOCK_SIZE );
2899 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
2900 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
2901 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
2902 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
2903 for(
size_t i=ii; i<iend; ++i ) {
2904 for(
size_t j=jj; j<jend; ++j ) {
2905 matrix_(
row()+i,
column()+j) += (~rhs)(i,j);
2927 template<
typename MT
2929 template<
typename MT2 >
2930 inline void Submatrix<MT,unaligned,false,true,CSAs...>::addAssign(
const SparseMatrix<MT2,false>& rhs )
2935 for(
size_t i=0UL; i<
rows(); ++i )
2936 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
2937 matrix_(
row()+i,
column()+element->index()) += element->value();
2955 template<
typename MT
2957 template<
typename MT2 >
2958 inline void Submatrix<MT,unaligned,false,true,CSAs...>::addAssign(
const SparseMatrix<MT2,true>& rhs )
2965 for(
size_t j=0UL; j<
columns(); ++j )
2966 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
2967 matrix_(
row()+element->index(),
column()+j) += element->value();
2985 template<
typename MT
2987 template<
typename MT2 >
2988 inline DisableIf_<
typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
2989 Submatrix<MT,unaligned,false,true,CSAs...>::subAssign(
const DenseMatrix<MT2,false>& rhs )
2994 const size_t jpos(
columns() &
size_t(-2) );
2997 for(
size_t i=0UL; i<
rows(); ++i )
2999 if( IsDiagonal<MT2>::value ) {
3000 matrix_(
row()+i,
column()+i) -= (~rhs)(i,i);
3003 for(
size_t j=0UL; j<jpos; j+=2UL ) {
3004 matrix_(
row()+i,
column()+j ) -= (~rhs)(i,j );
3005 matrix_(
row()+i,
column()+j+1UL) -= (~rhs)(i,j+1UL);
3008 matrix_(
row()+i,
column()+jpos) -= (~rhs)(i,jpos);
3029 template<
typename MT
3031 template<
typename MT2 >
3032 inline EnableIf_<
typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
3033 Submatrix<MT,unaligned,false,true,CSAs...>::subAssign(
const DenseMatrix<MT2,false>& rhs )
3040 for(
size_t i=0UL; i<
rows(); ++i )
3042 const size_t jbegin( ( IsUpper<MT2>::value )
3043 ?( ( IsStrictlyUpper<MT2>::value ? i+1UL : i ) &
size_t(-SIMDSIZE) )
3045 const size_t jend ( ( IsLower<MT2>::value )
3046 ?( IsStrictlyLower<MT2>::value ? i : i+1UL )
3050 const size_t jpos( jend &
size_t(-SIMDSIZE) );
3055 ConstIterator_<MT2> right( (~rhs).
begin(i) + jbegin );
3057 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
3058 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3059 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3060 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3061 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3063 for( ; j<jpos; j+=SIMDSIZE ) {
3064 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3066 for( ; j<jend; ++j ) {
3067 *left -= *right; ++left; ++right;
3087 template<
typename MT
3089 template<
typename MT2 >
3090 inline void Submatrix<MT,unaligned,false,true,CSAs...>::subAssign(
const DenseMatrix<MT2,true>& rhs )
3097 constexpr
size_t block( BLOCK_SIZE );
3099 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
3100 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
3101 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
3102 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
3103 for(
size_t i=ii; i<iend; ++i ) {
3104 for(
size_t j=jj; j<jend; ++j ) {
3105 matrix_(
row()+i,
column()+j) -= (~rhs)(i,j);
3127 template<
typename MT
3129 template<
typename MT2 >
3130 inline void Submatrix<MT,unaligned,false,true,CSAs...>::subAssign(
const SparseMatrix<MT2,false>& rhs )
3135 for(
size_t i=0UL; i<
rows(); ++i )
3136 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
3137 matrix_(
row()+i,
column()+element->index()) -= element->value();
3155 template<
typename MT
3157 template<
typename MT2 >
3158 inline void Submatrix<MT,unaligned,false,true,CSAs...>::subAssign(
const SparseMatrix<MT2,true>& rhs )
3165 for(
size_t j=0UL; j<
columns(); ++j )
3166 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
3167 matrix_(
row()+element->index(),
column()+j) -= element->value();
3185 template<
typename MT
3187 template<
typename MT2 >
3188 inline DisableIf_<
typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSchurAssign<MT2> >
3189 Submatrix<MT,unaligned,false,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,false>& rhs )
3194 const size_t jpos(
columns() &
size_t(-2) );
3197 for(
size_t i=0UL; i<
rows(); ++i ) {
3198 for(
size_t j=0UL; j<jpos; j+=2UL ) {
3199 matrix_(
row()+i,
column()+j ) *= (~rhs)(i,j );
3200 matrix_(
row()+i,
column()+j+1UL) *= (~rhs)(i,j+1UL);
3203 matrix_(
row()+i,
column()+jpos) *= (~rhs)(i,jpos);
3223 template<
typename MT
3225 template<
typename MT2 >
3226 inline EnableIf_<
typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSchurAssign<MT2> >
3227 Submatrix<MT,unaligned,false,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,false>& rhs )
3234 for(
size_t i=0UL; i<
rows(); ++i )
3236 const size_t jpos(
columns() &
size_t(-SIMDSIZE) );
3241 ConstIterator_<MT2> right( (~rhs).
begin(i) );
3243 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
3244 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3245 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3246 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3247 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3249 for( ; j<jpos; j+=SIMDSIZE ) {
3250 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3253 *left *= *right; ++left; ++right;
3273 template<
typename MT
3275 template<
typename MT2 >
3276 inline void Submatrix<MT,unaligned,false,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,true>& rhs )
3283 constexpr
size_t block( BLOCK_SIZE );
3285 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
3286 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
3287 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
3288 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
3289 for(
size_t i=ii; i<iend; ++i ) {
3290 for(
size_t j=jj; j<jend; ++j ) {
3291 matrix_(
row()+i,
column()+j) *= (~rhs)(i,j);
3313 template<
typename MT
3315 template<
typename MT2 >
3316 inline void Submatrix<MT,unaligned,false,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,false>& rhs )
3323 for(
size_t i=0UL; i<
rows(); ++i )
3327 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
3328 for( ; j<element->index(); ++j )
3330 matrix_(
row()+i,
column()+j) *= element->value();
3355 template<
typename MT
3357 template<
typename MT2 >
3358 inline void Submatrix<MT,unaligned,false,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,true>& rhs )
3367 for(
size_t j=0UL; j<
columns(); ++j )
3371 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
3372 for( ; i<element->index(); ++i )
3374 matrix_(
row()+i,
column()+j) *= element->value();
3378 for( ; i<
rows(); ++i ) {
3407 template<
typename MT
3409 class Submatrix<MT,unaligned,true,true,CSAs...>
3410 :
public View< DenseMatrix< Submatrix<MT,unaligned,true,true,CSAs...>, true > >
3411 ,
private SubmatrixData<CSAs...>
3415 using DataType = SubmatrixData<CSAs...>;
3416 using Operand = If_< IsExpression<MT>, MT, MT& >;
3424 using BaseType = DenseMatrix<This,true>;
3425 using ViewedType = MT;
3430 using SIMDType = SIMDTrait_<ElementType>;
3435 using ConstReference = ConstReference_<MT>;
3441 using ConstPointer = ConstPointer_<MT>;
3444 using Pointer = If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, Pointer_<MT> >;
3450 template<
typename IteratorType >
3451 class SubmatrixIterator
3456 using IteratorCategory =
typename std::iterator_traits<IteratorType>::iterator_category;
3459 using ValueType =
typename std::iterator_traits<IteratorType>::value_type;
3462 using PointerType =
typename std::iterator_traits<IteratorType>::pointer;
3465 using ReferenceType =
typename std::iterator_traits<IteratorType>::reference;
3468 using DifferenceType =
typename std::iterator_traits<IteratorType>::difference_type;
3471 using iterator_category = IteratorCategory;
3472 using value_type = ValueType;
3473 using pointer = PointerType;
3474 using reference = ReferenceType;
3475 using difference_type = DifferenceType;
3481 inline SubmatrixIterator()
3483 , isAligned_( false )
3495 inline SubmatrixIterator( IteratorType iterator,
bool isMemoryAligned )
3496 : iterator_ ( iterator )
3497 , isAligned_( isMemoryAligned )
3506 template<
typename IteratorType2 >
3507 inline SubmatrixIterator(
const SubmatrixIterator<IteratorType2>& it )
3508 : iterator_ ( it.base() )
3509 , isAligned_( it.isAligned() )
3519 inline SubmatrixIterator&
operator+=(
size_t inc ) {
3531 inline SubmatrixIterator&
operator-=(
size_t dec ) {
3542 inline SubmatrixIterator& operator++() {
3553 inline const SubmatrixIterator operator++(
int ) {
3554 return SubmatrixIterator( iterator_++, isAligned_ );
3563 inline SubmatrixIterator& operator--() {
3574 inline const SubmatrixIterator operator--(
int ) {
3575 return SubmatrixIterator( iterator_--, isAligned_ );
3584 inline ReferenceType
operator*()
const {
3594 inline IteratorType operator->()
const {
3609 inline SIMDType load() const noexcept {
3627 inline SIMDType
loada() const noexcept {
3628 return iterator_.loada();
3642 inline SIMDType
loadu() const noexcept {
3643 return iterator_.loadu();
3658 inline void store(
const SIMDType& value )
const {
3674 inline void storea(
const SIMDType& value )
const {
3675 iterator_.storea( value );
3690 inline void storeu(
const SIMDType& value )
const {
3692 iterator_.storea( value );
3695 iterator_.storeu( value );
3711 inline void stream(
const SIMDType& value )
const {
3712 iterator_.stream( value );
3722 inline bool operator==(
const SubmatrixIterator& rhs )
const {
3723 return iterator_ == rhs.iterator_;
3733 inline bool operator!=(
const SubmatrixIterator& rhs )
const {
3734 return iterator_ != rhs.iterator_;
3744 inline bool operator<(
const SubmatrixIterator& rhs )
const {
3745 return iterator_ < rhs.iterator_;
3755 inline bool operator>(
const SubmatrixIterator& rhs )
const {
3756 return iterator_ > rhs.iterator_;
3766 inline bool operator<=(
const SubmatrixIterator& rhs )
const {
3767 return iterator_ <= rhs.iterator_;
3777 inline bool operator>=(
const SubmatrixIterator& rhs )
const {
3778 return iterator_ >= rhs.iterator_;
3788 inline DifferenceType
operator-(
const SubmatrixIterator& rhs )
const {
3789 return iterator_ - rhs.iterator_;
3800 friend inline const SubmatrixIterator
operator+(
const SubmatrixIterator& it,
size_t inc ) {
3801 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
3812 friend inline const SubmatrixIterator
operator+(
size_t inc,
const SubmatrixIterator& it ) {
3813 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
3824 friend inline const SubmatrixIterator
operator-(
const SubmatrixIterator& it,
size_t dec ) {
3825 return SubmatrixIterator( it.iterator_ - dec, it.isAligned_ );
3834 inline IteratorType base()
const {
3844 inline bool isAligned() const noexcept {
3851 IteratorType iterator_;
3859 using ConstIterator = SubmatrixIterator< ConstIterator_<MT> >;
3867 enum :
bool { simdEnabled = MT::simdEnabled };
3870 enum :
bool { smpAssignable = MT::smpAssignable };
3876 template<
typename... RSAs >
3877 explicit inline Submatrix( MT& matrix, RSAs... args );
3889 inline Reference operator()(
size_t i,
size_t j );
3890 inline ConstReference operator()(
size_t i,
size_t j )
const;
3891 inline Reference at(
size_t i,
size_t j );
3892 inline ConstReference at(
size_t i,
size_t j )
const;
3893 inline Pointer
data () noexcept;
3894 inline ConstPointer
data () const noexcept;
3895 inline Pointer
data (
size_t j ) noexcept;
3896 inline ConstPointer
data (
size_t j ) const noexcept;
3898 inline ConstIterator
begin (
size_t j ) const;
3899 inline ConstIterator
cbegin(
size_t j ) const;
3901 inline ConstIterator
end (
size_t j ) const;
3902 inline ConstIterator
cend (
size_t j ) const;
3909 inline Submatrix& operator=( const
ElementType& rhs );
3910 inline Submatrix& operator=( initializer_list< initializer_list<
ElementType> > list );
3911 inline Submatrix& operator=( const Submatrix& rhs );
3913 template< typename MT2,
bool SO >
3914 inline Submatrix& operator=( const Matrix<MT2,SO>& rhs );
3916 template< typename MT2,
bool SO >
3917 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3918 operator+=( const Matrix<MT2,SO>& rhs );
3920 template< typename MT2,
bool SO >
3921 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3922 operator+=( const Matrix<MT2,SO>& rhs );
3924 template< typename MT2,
bool SO >
3925 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3926 operator-=( const Matrix<MT2,SO>& rhs );
3928 template< typename MT2,
bool SO >
3929 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3930 operator-=( const Matrix<MT2,SO>& rhs );
3932 template< typename MT2,
bool SO >
3933 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3934 operator%=( const Matrix<MT2,SO>& rhs );
3936 template< typename MT2,
bool SO >
3937 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
3938 operator%=( const Matrix<MT2,SO>& rhs );
3945 using DataType::row;
3947 using DataType::
rows;
3950 inline MT& operand() noexcept;
3951 inline const MT& operand() const noexcept;
3953 inline
size_t spacing() const noexcept;
3954 inline
size_t capacity() const noexcept;
3955 inline
size_t capacity(
size_t i ) const noexcept;
3957 inline
size_t nonZeros(
size_t i ) const;
3958 inline
void reset();
3959 inline
void reset(
size_t i );
3967 inline Submatrix& ctranspose();
3969 template< typename Other > inline Submatrix& scale( const Other& scalar );
3976 template< typename MT2 >
3977 struct VectorizedAssign {
3978 enum :
bool { value = useOptimizedKernels &&
3979 simdEnabled && MT2::simdEnabled &&
3980 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value };
3986 template<
typename MT2 >
3987 struct VectorizedAddAssign {
3988 enum :
bool { value = useOptimizedKernels &&
3989 simdEnabled && MT2::simdEnabled &&
3990 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
3991 HasSIMDAdd< ElementType, ElementType_<MT2> >::value &&
3992 !IsDiagonal<MT2>::value };
3998 template<
typename MT2 >
3999 struct VectorizedSubAssign {
4000 enum :
bool { value = useOptimizedKernels &&
4001 simdEnabled && MT2::simdEnabled &&
4002 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
4003 HasSIMDSub< ElementType, ElementType_<MT2> >::value &&
4004 !IsDiagonal<MT2>::value };
4010 template<
typename MT2 >
4011 struct VectorizedSchurAssign {
4012 enum :
bool { value = useOptimizedKernels &&
4013 simdEnabled && MT2::simdEnabled &&
4014 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
4015 HasSIMDMult< ElementType, ElementType_<MT2> >::value };
4028 template<
typename Other >
4029 inline bool canAlias(
const Other* alias )
const noexcept;
4031 template<
typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
4032 inline bool canAlias(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept;
4034 template<
typename Other >
4035 inline bool isAliased(
const Other* alias )
const noexcept;
4037 template<
typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
4038 inline bool isAliased(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept;
4040 inline bool isAligned () const noexcept;
4041 inline
bool canSMPAssign() const noexcept;
4052 template< typename MT2 >
4053 inline
DisableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,true>& rhs );
4055 template< typename MT2 >
4056 inline
EnableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,true>& rhs );
4058 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,false>& rhs );
4059 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
4060 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
4062 template< typename MT2 >
4063 inline
DisableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,true>& rhs );
4065 template< typename MT2 >
4066 inline
EnableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,true>& rhs );
4068 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,false>& rhs );
4069 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
4070 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
4072 template< typename MT2 >
4073 inline
DisableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,true>& rhs );
4075 template< typename MT2 >
4076 inline
EnableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,true>& rhs );
4078 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,false>& rhs );
4079 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
4080 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
4082 template< typename MT2 >
4083 inline
DisableIf_< VectorizedSchurAssign<MT2> > schurAssign( const DenseMatrix<MT2,true>& rhs );
4085 template< typename MT2 >
4086 inline
EnableIf_< VectorizedSchurAssign<MT2> > schurAssign( const DenseMatrix<MT2,true>& rhs );
4088 template< typename MT2 > inline
void schurAssign( const DenseMatrix<MT2,false>& rhs );
4089 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,true>& rhs );
4090 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,false>& rhs );
4098 inline
bool hasOverlap() const noexcept;
4106 const
bool isAligned_;
4117 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
bool DF2,
size_t... CSAs2 > friend class Submatrix;
4155 template< typename MT
4157 template< typename... RSAs >
4158 inline Submatrix<MT,unaligned,true,true,CSAs...>::Submatrix( MT& matrix, RSAs... args )
4159 : DataType ( args... )
4160 , matrix_ ( matrix )
4162 (
columns() < 2UL || ( matrix.
spacing() &
size_t(-SIMDSIZE) ) == 0UL ) )
4164 if( !Contains< TypeList<RSAs...>,
Unchecked >::value ) {
4197 template<
typename MT
4200 Submatrix<MT,unaligned,true,true,CSAs...>::operator()(
size_t i,
size_t j )
4222 template<
typename MT
4225 Submatrix<MT,unaligned,true,true,CSAs...>::operator()(
size_t i,
size_t j )
const 4230 return const_cast<const MT&
>( matrix_ )(
row()+i,
column()+j);
4248 template<
typename MT
4251 Submatrix<MT,unaligned,true,true,CSAs...>::at(
size_t i,
size_t j )
4259 return (*
this)(i,j);
4277 template<
typename MT
4280 Submatrix<MT,unaligned,true,true,CSAs...>::at(
size_t i,
size_t j )
const 4288 return (*
this)(i,j);
4304 template<
typename MT
4306 inline typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::Pointer
4325 template<
typename MT
4327 inline typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::ConstPointer
4345 template<
typename MT
4347 inline typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::Pointer
4365 template<
typename MT
4367 inline typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::ConstPointer
4383 template<
typename MT
4402 template<
typename MT
4421 template<
typename MT
4440 template<
typename MT
4459 template<
typename MT
4478 template<
typename MT
4509 template<
typename MT
4511 inline Submatrix<MT,
unaligned,
true,
true,CSAs...>&
4512 Submatrix<MT,unaligned,true,true,CSAs...>::operator=(
const ElementType& rhs )
4515 decltype(
auto) left( derestrict( matrix_ ) );
4517 for(
size_t j=
column(); j<jend; ++j )
4519 const size_t ibegin( ( IsLower<MT>::value )
4520 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4524 const size_t iend ( ( IsUpper<MT>::value )
4525 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4530 for(
size_t i=ibegin; i<iend; ++i ) {
4531 if( !IsRestricted<MT>::value || IsTriangular<MT>::value || trySet( matrix_, i, j, rhs ) )
4558 template<
typename MT
4560 inline Submatrix<MT,
unaligned,
true,
true,CSAs...>&
4561 Submatrix<MT,unaligned,true,true,CSAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
4565 if( list.size() !=
rows() ) {
4569 if( IsRestricted<MT>::value ) {
4570 const InitializerMatrix<ElementType> tmp( list,
columns() );
4571 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
4576 decltype(
auto) left( derestrict( *this ) );
4579 for( const auto& rowList : list ) {
4581 for(
const auto& element : rowList ) {
4582 left(i,j) = element;
4612 template<
typename MT
4614 inline Submatrix<MT,
unaligned,
true,
true,CSAs...>&
4615 Submatrix<MT,unaligned,true,true,CSAs...>::operator=(
const Submatrix& rhs )
4620 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row() == rhs.row() &&
column() == rhs.column() ) )
4623 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
4627 if( !tryAssign( matrix_, rhs,
row(),
column() ) ) {
4631 decltype(
auto) left( derestrict( *this ) );
4633 if( rhs.canAlias( &matrix_ ) ) {
4664 template<
typename MT
4666 template<
typename MT2
4668 inline Submatrix<MT,
unaligned,
true,
true,CSAs...>&
4669 Submatrix<MT,unaligned,true,true,CSAs...>::operator=(
const Matrix<MT2,SO>& rhs )
4677 using Right = If_< IsRestricted<MT>, CompositeType_<MT2>,
const MT2& >;
4678 Right right( ~rhs );
4680 if( !tryAssign( matrix_, right,
row(),
column() ) ) {
4684 decltype(
auto) left( derestrict( *this ) );
4686 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4687 const ResultType_<MT2> tmp( right );
4688 if( IsSparseMatrix<MT2>::value )
4693 if( IsSparseMatrix<MT2>::value )
4720 template<
typename MT
4722 template<
typename MT2
4724 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
unaligned,
true,
true,CSAs...>& >
4731 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
4740 if( !tryAddAssign( matrix_, ~rhs,
row(),
column() ) ) {
4744 decltype(
auto) left( derestrict( *this ) );
4746 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
4747 (~rhs).canAlias( &matrix_ ) ) {
4748 const AddType tmp( *
this + (~rhs) );
4777 template<
typename MT
4779 template<
typename MT2
4781 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
unaligned,
true,
true,CSAs...>& >
4788 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
4797 const AddType tmp( *
this + (~rhs) );
4799 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
4803 decltype(
auto) left( derestrict( *this ) );
4829 template< typename MT
4831 template< typename MT2
4833 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,true,true,CSAs...>& >
4834 Submatrix<MT,unaligned,true,true,CSAs...>::operator-=( const Matrix<MT2,SO>& rhs )
4840 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
4849 if( !trySubAssign( matrix_, ~rhs,
row(),
column() ) ) {
4853 decltype(
auto) left( derestrict( *this ) );
4855 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
4856 (~rhs).canAlias( &matrix_ ) ) {
4857 const SubType tmp( *
this - (~rhs ) );
4886 template<
typename MT
4888 template<
typename MT2
4890 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
unaligned,
true,
true,CSAs...>& >
4897 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
4906 const SubType tmp( *
this - (~rhs) );
4908 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
4912 decltype(
auto) left( derestrict( *this ) );
4938 template< typename MT
4940 template< typename MT2
4942 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,unaligned,true,true,CSAs...>& >
4943 Submatrix<MT,unaligned,true,true,CSAs...>::operator%=( const Matrix<MT2,SO>& rhs )
4949 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
4957 if( !trySchurAssign( matrix_, ~rhs,
row(),
column() ) ) {
4961 decltype(
auto) left( derestrict( *this ) );
4963 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
4964 (~rhs).canAlias( &matrix_ ) ) {
4965 const SchurType tmp( *
this % (~rhs) );
4966 if( IsSparseMatrix<SchurType>::value )
4996 template<
typename MT
4998 template<
typename MT2
5000 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
unaligned,
true,
true,CSAs...>& >
5001 Submatrix<MT,unaligned,true,true,CSAs...>::operator%=(
const Matrix<MT2,SO>& rhs )
5007 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
5015 const SchurType tmp( *
this % (~rhs) );
5017 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
5021 decltype(
auto) left( derestrict( *this ) );
5023 if( IsSparseMatrix<SchurType>::value ) {
5051 template<
typename MT
5053 inline MT& Submatrix<MT,unaligned,true,true,CSAs...>::operand() noexcept
5067 template<
typename MT
5069 inline const MT& Submatrix<MT,unaligned,true,true,CSAs...>::operand() const noexcept
5086 template<
typename MT
5090 return matrix_.spacing();
5102 template<
typename MT
5119 template<
typename MT
5139 template<
typename MT
5143 const size_t iend(
row() +
rows() );
5145 size_t nonzeros( 0UL );
5147 for(
size_t j=
column(); j<jend; ++j )
5148 for(
size_t i=
row(); i<iend; ++i )
5165 template<
typename MT
5171 const size_t iend(
row() +
rows() );
5172 size_t nonzeros( 0UL );
5174 for(
size_t i=
row(); i<iend; ++i )
5190 template<
typename MT
5198 const size_t ibegin( ( IsLower<MT>::value )
5199 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
5203 const size_t iend ( ( IsUpper<MT>::value )
5204 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
5209 for(
size_t i=ibegin; i<iend; ++i )
5210 clear( matrix_(i,j) );
5224 template<
typename MT
5232 const size_t ibegin( ( IsLower<MT>::value )
5233 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
5237 const size_t iend ( ( IsUpper<MT>::value )
5238 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
5243 for(
size_t i=ibegin; i<iend; ++i )
5260 template<
typename MT
5262 inline bool Submatrix<MT,unaligned,true,true,CSAs...>::hasOverlap() const noexcept
5264 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
5300 template<
typename MT
5302 inline Submatrix<MT,
unaligned,
true,
true,CSAs...>&
5313 decltype(
auto) left( derestrict( *this ) );
5342 template< typename MT
5344 inline Submatrix<MT,unaligned,true,true,CSAs...>&
5345 Submatrix<MT,unaligned,true,true,CSAs...>::ctranspose()
5355 decltype(
auto) left( derestrict( *this ) );
5379 template< typename MT
5381 template< typename Other >
5382 inline Submatrix<MT,unaligned,true,true,CSAs...>&
5383 Submatrix<MT,unaligned,true,true,CSAs...>::scale( const Other& scalar )
5389 for(
size_t j=
column(); j<jend; ++j )
5391 const size_t ibegin( ( IsLower<MT>::value )
5392 ?( ( IsStrictlyLower<MT>::value )
5396 const size_t iend ( ( IsUpper<MT>::value )
5397 ?( ( IsStrictlyUpper<MT>::value )
5402 for(
size_t i=ibegin; i<iend; ++i )
5403 matrix_(i,j) *= scalar;
5431 template<
typename MT
5433 template<
typename Other >
5434 inline bool Submatrix<MT,unaligned,true,true,CSAs...>::canAlias(
const Other* alias )
const noexcept
5436 return matrix_.isAliased( alias );
5453 template<
typename MT
5455 template<
typename MT2
5460 Submatrix<MT,unaligned,true,true,CSAs...>::canAlias(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
5462 return ( matrix_.isAliased( &alias->matrix_ ) &&
5463 (
row() +
rows() > alias->row() ) &&
5464 (
row() < alias->row() + alias->rows() ) &&
5466 (
column() < alias->column() + alias->columns() ) );
5483 template<
typename MT
5485 template<
typename Other >
5486 inline bool Submatrix<MT,unaligned,true,true,CSAs...>::isAliased(
const Other* alias )
const noexcept
5488 return matrix_.isAliased( alias );
5505 template<
typename MT
5507 template<
typename MT2
5512 Submatrix<MT,unaligned,true,true,CSAs...>::isAliased(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
5514 return ( matrix_.isAliased( &alias->matrix_ ) &&
5515 (
row() +
rows() > alias->row() ) &&
5516 (
row() < alias->row() + alias->rows() ) &&
5518 (
column() < alias->column() + alias->columns() ) );
5534 template<
typename MT
5536 inline bool Submatrix<MT,unaligned,true,true,CSAs...>::isAligned() const noexcept
5555 template<
typename MT
5557 inline bool Submatrix<MT,unaligned,true,true,CSAs...>::canSMPAssign() const noexcept
5559 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
5580 template<
typename MT
5583 Submatrix<MT,unaligned,true,true,CSAs...>::load(
size_t i,
size_t j )
const noexcept
5586 return loada( i, j );
5588 return loadu( i, j );
5609 template<
typename MT
5621 return matrix_.loada(
row()+i,
column()+j );
5642 template<
typename MT
5654 return matrix_.loadu(
row()+i,
column()+j );
5676 template<
typename MT
5679 Submatrix<MT,unaligned,true,true,CSAs...>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
5706 template<
typename MT
5718 matrix_.storea(
row()+i,
column()+j, value );
5740 template<
typename MT
5752 matrix_.storeu(
row()+i,
column()+j, value );
5775 template<
typename MT
5788 matrix_.stream(
row()+i,
column()+j, value );
5790 matrix_.storeu(
row()+i,
column()+j, value );
5808 template<
typename MT
5810 template<
typename MT2 >
5811 inline DisableIf_<
typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
5812 Submatrix<MT,unaligned,true,true,CSAs...>::assign(
const DenseMatrix<MT2,true>& rhs )
5817 const size_t ipos(
rows() &
size_t(-2) );
5820 for(
size_t j=0UL; j<
columns(); ++j ) {
5821 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5822 matrix_(
row()+i ,
column()+j) = (~rhs)(i ,j);
5823 matrix_(
row()+i+1UL,
column()+j) = (~rhs)(i+1UL,j);
5825 if( ipos <
rows() ) {
5826 matrix_(
row()+ipos,
column()+j) = (~rhs)(ipos,j);
5846 template<
typename MT
5848 template<
typename MT2 >
5849 inline EnableIf_<
typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
5850 Submatrix<MT,unaligned,true,true,CSAs...>::assign(
const DenseMatrix<MT2,true>& rhs )
5857 const size_t ipos(
rows() &
size_t(-SIMDSIZE) );
5860 if( useStreaming && isAligned_ &&
5862 !(~rhs).isAliased( &matrix_ ) )
5864 for(
size_t j=0UL; j<
columns(); ++j )
5868 ConstIterator_<MT2> right( (~rhs).
begin(j) );
5870 for( ; i<ipos; i+=SIMDSIZE ) {
5871 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5873 for( ; i<
rows(); ++i ) {
5874 *left = *right; ++left; ++right;
5880 for(
size_t j=0UL; j<
columns(); ++j )
5884 ConstIterator_<MT2> right( (~rhs).
begin(j) );
5886 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5887 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5888 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5889 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5890 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5892 for( ; i<ipos; i+=SIMDSIZE ) {
5893 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5895 for( ; i<
rows(); ++i ) {
5896 *left = *right; ++left; ++right;
5917 template<
typename MT
5919 template<
typename MT2 >
5920 inline void Submatrix<MT,unaligned,true,true,CSAs...>::assign(
const DenseMatrix<MT2,false>& rhs )
5927 constexpr
size_t block( BLOCK_SIZE );
5929 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
5930 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
5931 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
5932 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
5933 for(
size_t j=jj; j<jend; ++j ) {
5934 for(
size_t i=ii; i<iend; ++i ) {
5935 matrix_(
row()+i,
column()+j) = (~rhs)(i,j);
5957 template<
typename MT
5959 template<
typename MT2 >
5960 inline void Submatrix<MT,unaligned,true,true,CSAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
5965 for(
size_t j=0UL; j<
columns(); ++j )
5966 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
5967 matrix_(
row()+element->index(),
column()+j) = element->value();
5985 template<
typename MT
5987 template<
typename MT2 >
5988 inline void Submatrix<MT,unaligned,true,true,CSAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
5995 for(
size_t i=0UL; i<
rows(); ++i )
5996 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
5997 matrix_(
row()+i,
column()+element->index()) = element->value();
6015 template<
typename MT
6017 template<
typename MT2 >
6018 inline DisableIf_<
typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
6019 Submatrix<MT,unaligned,true,true,CSAs...>::addAssign(
const DenseMatrix<MT2,true>& rhs )
6024 const size_t ipos(
rows() &
size_t(-2) );
6027 for(
size_t j=0UL; j<
columns(); ++j )
6029 if( IsDiagonal<MT2>::value ) {
6030 matrix_(
row()+j,
column()+j) += (~rhs)(j,j);
6033 for(
size_t i=0UL; i<ipos; i+=2UL ) {
6034 matrix_(
row()+i ,
column()+j) += (~rhs)(i ,j);
6035 matrix_(
row()+i+1UL,
column()+j) += (~rhs)(i+1UL,j);
6037 if( ipos <
rows() ) {
6038 matrix_(
row()+ipos,
column()+j) += (~rhs)(ipos,j);
6059 template<
typename MT
6061 template<
typename MT2 >
6062 inline EnableIf_<
typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
6063 Submatrix<MT,unaligned,true,true,CSAs...>::addAssign(
const DenseMatrix<MT2,true>& rhs )
6070 for(
size_t j=0UL; j<
columns(); ++j )
6072 const size_t ibegin( ( IsLower<MT>::value )
6073 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-SIMDSIZE) )
6075 const size_t iend ( ( IsUpper<MT>::value )
6076 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
6080 const size_t ipos( iend &
size_t(-SIMDSIZE) );
6085 ConstIterator_<MT2> right( (~rhs).
begin(j) + ibegin );
6087 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
6088 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6089 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6090 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6091 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6093 for( ; i<ipos; i+=SIMDSIZE ) {
6094 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6096 for( ; i<iend; ++i ) {
6097 *left += *right; ++left; ++right;
6117 template<
typename MT
6119 template<
typename MT2 >
6120 inline void Submatrix<MT,unaligned,true,true,CSAs...>::addAssign(
const DenseMatrix<MT2,false>& rhs )
6127 constexpr
size_t block( BLOCK_SIZE );
6129 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
6130 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
6131 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
6132 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
6133 for(
size_t j=jj; j<jend; ++j ) {
6134 for(
size_t i=ii; i<iend; ++i ) {
6135 matrix_(
row()+i,
column()+j) += (~rhs)(i,j);
6157 template<
typename MT
6159 template<
typename MT2 >
6160 inline void Submatrix<MT,unaligned,true,true,CSAs...>::addAssign(
const SparseMatrix<MT2,true>& rhs )
6165 for(
size_t j=0UL; j<
columns(); ++j )
6166 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
6167 matrix_(
row()+element->index(),
column()+j) += element->value();
6185 template<
typename MT
6187 template<
typename MT2 >
6188 inline void Submatrix<MT,unaligned,true,true,CSAs...>::addAssign(
const SparseMatrix<MT2,false>& rhs )
6195 for(
size_t i=0UL; i<
rows(); ++i )
6196 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
6197 matrix_(
row()+i,
column()+element->index()) += element->value();
6215 template<
typename MT
6217 template<
typename MT2 >
6218 inline DisableIf_<
typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
6219 Submatrix<MT,unaligned,true,true,CSAs...>::subAssign(
const DenseMatrix<MT2,true>& rhs )
6224 const size_t ipos(
rows() &
size_t(-2) );
6227 for(
size_t j=0UL; j<
columns(); ++j )
6229 if( IsDiagonal<MT2>::value ) {
6230 matrix_(
row()+j,
column()+j) -= (~rhs)(j,j);
6233 for(
size_t i=0UL; i<ipos; i+=2UL ) {
6234 matrix_(
row()+i ,
column()+j) -= (~rhs)(i ,j);
6235 matrix_(
row()+i+1UL,
column()+j) -= (~rhs)(i+1UL,j);
6237 if( ipos <
rows() ) {
6238 matrix_(
row()+ipos,
column()+j) -= (~rhs)(ipos,j);
6259 template<
typename MT
6261 template<
typename MT2 >
6262 inline EnableIf_<
typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
6263 Submatrix<MT,unaligned,true,true,CSAs...>::subAssign(
const DenseMatrix<MT2,true>& rhs )
6270 for(
size_t j=0UL; j<
columns(); ++j )
6272 const size_t ibegin( ( IsLower<MT>::value )
6273 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-SIMDSIZE) )
6275 const size_t iend ( ( IsUpper<MT>::value )
6276 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
6280 const size_t ipos( iend &
size_t(-SIMDSIZE) );
6285 ConstIterator_<MT2> right( (~rhs).
begin(j) + ibegin );
6287 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
6288 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6289 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6290 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6291 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6293 for( ; i<ipos; i+=SIMDSIZE ) {
6294 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6296 for( ; i<iend; ++i ) {
6297 *left -= *right; ++left; ++right;
6317 template<
typename MT
6319 template<
typename MT2 >
6320 inline void Submatrix<MT,unaligned,true,true,CSAs...>::subAssign(
const DenseMatrix<MT2,false>& rhs )
6327 constexpr
size_t block( BLOCK_SIZE );
6329 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
6330 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
6331 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
6332 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
6333 for(
size_t j=jj; j<jend; ++j ) {
6334 for(
size_t i=ii; i<iend; ++i ) {
6335 matrix_(
row()+i,
column()+j) -= (~rhs)(i,j);
6357 template<
typename MT
6359 template<
typename MT2 >
6360 inline void Submatrix<MT,unaligned,true,true,CSAs...>::subAssign(
const SparseMatrix<MT2,true>& rhs )
6365 for(
size_t j=0UL; j<
columns(); ++j )
6366 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
6367 matrix_(
row()+element->index(),
column()+j) -= element->value();
6385 template<
typename MT
6387 template<
typename MT2 >
6388 inline void Submatrix<MT,unaligned,true,true,CSAs...>::subAssign(
const SparseMatrix<MT2,false>& rhs )
6395 for(
size_t i=0UL; i<
rows(); ++i )
6396 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
6397 matrix_(
row()+i,
column()+element->index()) -= element->value();
6415 template<
typename MT
6417 template<
typename MT2 >
6418 inline DisableIf_<
typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSchurAssign<MT2> >
6419 Submatrix<MT,unaligned,true,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,true>& rhs )
6424 const size_t ipos(
rows() &
size_t(-2) );
6427 for(
size_t j=0UL; j<
columns(); ++j ) {
6428 for(
size_t i=0UL; i<ipos; i+=2UL ) {
6429 matrix_(
row()+i ,
column()+j) *= (~rhs)(i ,j);
6430 matrix_(
row()+i+1UL,
column()+j) *= (~rhs)(i+1UL,j);
6432 if( ipos <
rows() ) {
6433 matrix_(
row()+ipos,
column()+j) *= (~rhs)(ipos,j);
6454 template<
typename MT
6456 template<
typename MT2 >
6457 inline EnableIf_<
typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSchurAssign<MT2> >
6458 Submatrix<MT,unaligned,true,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,true>& rhs )
6465 for(
size_t j=0UL; j<
columns(); ++j )
6467 const size_t ipos(
rows() &
size_t(-SIMDSIZE) );
6472 ConstIterator_<MT2> right( (~rhs).
begin(j) );
6474 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
6475 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6476 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6477 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6478 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6480 for( ; i<ipos; i+=SIMDSIZE ) {
6481 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6483 for( ; i<
rows(); ++i ) {
6484 *left *= *right; ++left; ++right;
6504 template<
typename MT
6506 template<
typename MT2 >
6507 inline void Submatrix<MT,unaligned,true,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,false>& rhs )
6514 constexpr
size_t block( BLOCK_SIZE );
6516 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
6517 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
6518 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
6519 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
6520 for(
size_t j=jj; j<jend; ++j ) {
6521 for(
size_t i=ii; i<iend; ++i ) {
6522 matrix_(
row()+i,
column()+j) *= (~rhs)(i,j);
6544 template<
typename MT
6546 template<
typename MT2 >
6547 inline void Submatrix<MT,unaligned,true,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,true>& rhs )
6554 for(
size_t j=0UL; j<
columns(); ++j )
6558 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
6559 for( ; i<element->index(); ++i )
6561 matrix_(
row()+i,
column()+j) *= element->value();
6565 for( ; i<
rows(); ++i ) {
6586 template<
typename MT
6588 template<
typename MT2 >
6589 inline void Submatrix<MT,unaligned,true,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,false>& rhs )
6598 for(
size_t i=0UL; i<
rows(); ++i )
6602 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
6603 for( ; j<element->index(); ++j )
6605 matrix_(
row()+i,
column()+j) *= element->value();
6638 template<
typename MT
6640 class Submatrix<MT,
aligned,false,true,CSAs...>
6641 :
public View< DenseMatrix< Submatrix<MT,aligned,false,true,CSAs...>, false > >
6642 ,
private SubmatrixData<CSAs...>
6646 using DataType = SubmatrixData<CSAs...>;
6647 using Operand = If_< IsExpression<MT>, MT, MT& >;
6653 using This = Submatrix<MT,
aligned,
false,
true,CSAs...>;
6655 using BaseType = DenseMatrix<This,false>;
6656 using ViewedType = MT;
6661 using SIMDType = SIMDTrait_<ElementType>;
6666 using ConstReference = ConstReference_<MT>;
6672 using ConstPointer = ConstPointer_<MT>;
6675 using Pointer = If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, Pointer_<MT> >;
6678 using ConstIterator = ConstIterator_<MT>;
6686 enum :
bool { simdEnabled = MT::simdEnabled };
6689 enum :
bool { smpAssignable = MT::smpAssignable };
6695 template<
typename... RSAs >
6696 explicit inline Submatrix( MT& matrix, RSAs... args );
6708 inline Reference operator()(
size_t i,
size_t j );
6709 inline ConstReference operator()(
size_t i,
size_t j )
const;
6710 inline Reference at(
size_t i,
size_t j );
6711 inline ConstReference at(
size_t i,
size_t j )
const;
6712 inline Pointer
data () noexcept;
6713 inline ConstPointer
data () const noexcept;
6714 inline Pointer
data (
size_t i ) noexcept;
6715 inline ConstPointer
data (
size_t i ) const noexcept;
6717 inline ConstIterator
begin (
size_t i ) const;
6718 inline ConstIterator
cbegin(
size_t i ) const;
6720 inline ConstIterator
end (
size_t i ) const;
6721 inline ConstIterator
cend (
size_t i ) const;
6728 inline Submatrix& operator=( const
ElementType& rhs );
6729 inline Submatrix& operator=( initializer_list< initializer_list<
ElementType> > list );
6730 inline Submatrix& operator=( const Submatrix& rhs );
6732 template< typename MT2,
bool SO >
6733 inline Submatrix& operator=( const Matrix<MT2,SO>& rhs );
6735 template< typename MT2,
bool SO >
6736 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6737 operator+=( const Matrix<MT2,SO>& rhs );
6739 template< typename MT2,
bool SO >
6740 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6741 operator+=( const Matrix<MT2,SO>& rhs );
6743 template< typename MT2,
bool SO >
6744 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6745 operator-=( const Matrix<MT2,SO>& rhs );
6747 template< typename MT2,
bool SO >
6748 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6749 operator-=( const Matrix<MT2,SO>& rhs );
6751 template< typename MT2,
bool SO >
6752 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6753 operator%=( const Matrix<MT2,SO>& rhs );
6755 template< typename MT2,
bool SO >
6756 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
6757 operator%=( const Matrix<MT2,SO>& rhs );
6764 using DataType::row;
6765 using DataType::column;
6766 using DataType::
rows;
6769 inline MT& operand() noexcept;
6770 inline const MT& operand() const noexcept;
6772 inline
size_t spacing() const noexcept;
6773 inline
size_t capacity() const noexcept;
6774 inline
size_t capacity(
size_t i ) const noexcept;
6776 inline
size_t nonZeros(
size_t i ) const;
6777 inline
void reset();
6778 inline
void reset(
size_t i );
6786 inline Submatrix& ctranspose();
6788 template< typename Other > inline Submatrix& scale( const Other& scalar );
6795 template< typename MT2 >
6796 struct VectorizedAssign {
6797 enum :
bool { value = useOptimizedKernels &&
6798 simdEnabled && MT2::simdEnabled &&
6799 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value };
6805 template<
typename MT2 >
6806 struct VectorizedAddAssign {
6807 enum :
bool { value = useOptimizedKernels &&
6808 simdEnabled && MT2::simdEnabled &&
6809 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
6810 HasSIMDAdd< ElementType, ElementType_<MT2> >::value &&
6811 !IsDiagonal<MT2>::value };
6817 template<
typename MT2 >
6818 struct VectorizedSubAssign {
6819 enum :
bool { value = useOptimizedKernels &&
6820 simdEnabled && MT2::simdEnabled &&
6821 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
6822 HasSIMDSub< ElementType, ElementType_<MT2> >::value &&
6823 !IsDiagonal<MT2>::value };
6829 template<
typename MT2 >
6830 struct VectorizedSchurAssign {
6831 enum :
bool { value = useOptimizedKernels &&
6832 simdEnabled && MT2::simdEnabled &&
6833 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
6834 HasSIMDMult< ElementType, ElementType_<MT2> >::value };
6847 template<
typename Other >
6848 inline bool canAlias(
const Other* alias )
const noexcept;
6850 template<
typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
6851 inline bool canAlias(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept;
6853 template<
typename Other >
6854 inline bool isAliased(
const Other* alias )
const noexcept;
6856 template<
typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
6857 inline bool isAliased(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept;
6859 inline bool isAligned () const noexcept;
6860 inline
bool canSMPAssign() const noexcept;
6871 template< typename MT2 >
6872 inline
DisableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,false>& rhs );
6874 template< typename MT2 >
6875 inline
EnableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,false>& rhs );
6877 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,true>& rhs );
6878 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
6879 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
6881 template< typename MT2 >
6882 inline
DisableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,false>& rhs );
6884 template< typename MT2 >
6885 inline
EnableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,false>& rhs );
6887 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,true>& rhs );
6888 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
6889 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
6891 template< typename MT2 >
6892 inline
DisableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,false>& rhs );
6894 template< typename MT2 >
6895 inline
EnableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,false>& rhs );
6897 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,true>& rhs );
6898 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
6899 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
6901 template< typename MT2 >
6902 inline
DisableIf_< VectorizedSchurAssign<MT2> > schurAssign( const DenseMatrix<MT2,false>& rhs );
6904 template< typename MT2 >
6905 inline
EnableIf_< VectorizedSchurAssign<MT2> > schurAssign( const DenseMatrix<MT2,false>& rhs );
6907 template< typename MT2 > inline
void schurAssign( const DenseMatrix<MT2,true>& rhs );
6908 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,false>& rhs );
6909 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,true>& rhs );
6917 inline
bool hasOverlap() const noexcept;
6929 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
bool DF2,
size_t... CSAs2 > friend class Submatrix;
6967 template< typename MT
6969 template< typename... RSAs >
6970 inline Submatrix<MT,aligned,false,true,CSAs...>::Submatrix( MT& matrix, RSAs... args )
6971 : DataType( args... )
6972 , matrix_ ( matrix )
6974 if( !Contains< TypeList<RSAs...>,
Unchecked >::value ) {
6979 (
rows() > 1UL && matrix_.spacing() % SIMDSIZE != 0UL ) ) {
6988 BLAZE_USER_ASSERT(
rows() <= 1UL || matrix_.spacing() % SIMDSIZE == 0UL,
"Invalid submatrix alignment" );
7014 template<
typename MT
7017 Submatrix<MT,aligned,false,true,CSAs...>::operator()(
size_t i,
size_t j )
7039 template<
typename MT
7042 Submatrix<MT,aligned,false,true,CSAs...>::operator()(
size_t i,
size_t j )
const 7047 return const_cast<const MT&
>( matrix_ )(
row()+i,
column()+j);
7065 template<
typename MT
7068 Submatrix<MT,aligned,false,true,CSAs...>::at(
size_t i,
size_t j )
7076 return (*
this)(i,j);
7094 template<
typename MT
7097 Submatrix<MT,aligned,false,true,CSAs...>::at(
size_t i,
size_t j )
const 7105 return (*
this)(i,j);
7121 template<
typename MT
7123 inline typename Submatrix<MT,
aligned,
false,
true,CSAs...>::Pointer
7142 template<
typename MT
7144 inline typename Submatrix<MT,
aligned,
false,
true,CSAs...>::ConstPointer
7162 template<
typename MT
7164 inline typename Submatrix<MT,
aligned,
false,
true,CSAs...>::Pointer
7182 template<
typename MT
7184 inline typename Submatrix<MT,
aligned,
false,
true,CSAs...>::ConstPointer
7205 template<
typename MT
7211 return ( matrix_.begin( row() + i ) +
column() );
7229 template<
typename MT
7235 return ( matrix_.cbegin( row() + i ) +
column() );
7253 template<
typename MT
7259 return ( matrix_.cbegin( row() + i ) +
column() );
7277 template<
typename MT
7283 return ( matrix_.begin( row() + i ) +
column() +
columns() );
7301 template<
typename MT
7307 return ( matrix_.cbegin( row() + i ) +
column() +
columns() );
7325 template<
typename MT
7331 return ( matrix_.cbegin( row() + i ) +
column() +
columns() );
7356 template<
typename MT
7358 inline Submatrix<MT,
aligned,
false,
true,CSAs...>&
7359 Submatrix<MT,aligned,false,true,CSAs...>::operator=(
const ElementType& rhs )
7361 const size_t iend(
row() +
rows() );
7362 decltype(
auto) left( derestrict( matrix_ ) );
7364 for(
size_t i=row(); i<iend; ++i )
7366 const size_t jbegin( ( IsUpper<MT>::value )
7367 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
7371 const size_t jend ( ( IsLower<MT>::value )
7372 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
7377 for(
size_t j=jbegin; j<jend; ++j ) {
7378 if( !IsRestricted<MT>::value || IsTriangular<MT>::value || trySet( matrix_, i, j, rhs ) )
7405 template<
typename MT
7407 inline Submatrix<MT,
aligned,
false,
true,CSAs...>&
7408 Submatrix<MT,aligned,false,true,CSAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
7410 if( list.size() !=
rows() ) {
7414 if( IsRestricted<MT>::value ) {
7415 const InitializerMatrix<ElementType> tmp( list,
columns() );
7416 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
7421 decltype(
auto) left( derestrict( *this ) );
7424 for( const auto& rowList : list ) {
7425 std::fill( std::copy( rowList.begin(), rowList.end(), left.begin(i) ), left.end(i),
ElementType() );
7450 template<
typename MT
7452 inline Submatrix<MT,
aligned,
false,
true,CSAs...>&
7453 Submatrix<MT,aligned,false,true,CSAs...>::operator=(
const Submatrix& rhs )
7458 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row() == rhs.row() &&
column() == rhs.column() ) )
7461 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
7465 if( !tryAssign( matrix_, rhs,
row(),
column() ) ) {
7469 decltype(
auto) left( derestrict( *this ) );
7471 if( rhs.canAlias( &matrix_ ) ) {
7502 template<
typename MT
7504 template<
typename MT2
7506 inline Submatrix<MT,
aligned,
false,
true,CSAs...>&
7507 Submatrix<MT,aligned,false,true,CSAs...>::operator=(
const Matrix<MT2,SO>& rhs )
7515 using Right = If_< IsRestricted<MT>, CompositeType_<MT2>,
const MT2& >;
7516 Right right( ~rhs );
7518 if( !tryAssign( matrix_, right,
row(),
column() ) ) {
7522 decltype(
auto) left( derestrict( *this ) );
7524 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
7525 const ResultType_<MT2> tmp( right );
7526 if( IsSparseMatrix<MT2>::value )
7531 if( IsSparseMatrix<MT2>::value )
7558 template<
typename MT
7560 template<
typename MT2
7562 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
aligned,
false,
true,CSAs...>& >
7569 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
7578 if( !tryAddAssign( matrix_, ~rhs,
row(),
column() ) ) {
7582 decltype(
auto) left( derestrict( *this ) );
7584 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
7585 (~rhs).canAlias( &matrix_ ) ) {
7586 const AddType tmp( *
this + (~rhs) );
7615 template<
typename MT
7617 template<
typename MT2
7619 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
aligned,
false,
true,CSAs...>& >
7626 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
7635 const AddType tmp( *
this + (~rhs) );
7637 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
7641 decltype(
auto) left( derestrict( *this ) );
7667 template< typename MT
7669 template< typename MT2
7671 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,false,true,CSAs...>& >
7672 Submatrix<MT,aligned,false,true,CSAs...>::operator-=( const Matrix<MT2,SO>& rhs )
7678 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
7687 if( !trySubAssign( matrix_, ~rhs,
row(),
column() ) ) {
7691 decltype(
auto) left( derestrict( *this ) );
7693 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
7694 (~rhs).canAlias( &matrix_ ) ) {
7695 const SubType tmp( *
this - (~rhs ) );
7724 template<
typename MT
7726 template<
typename MT2
7728 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
aligned,
false,
true,CSAs...>& >
7735 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
7744 const SubType tmp( *
this - (~rhs) );
7746 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
7750 decltype(
auto) left( derestrict( *this ) );
7776 template< typename MT
7778 template< typename MT2
7780 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,false,true,CSAs...>& >
7781 Submatrix<MT,aligned,false,true,CSAs...>::operator%=( const Matrix<MT2,SO>& rhs )
7787 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
7795 if( !trySchurAssign( matrix_, ~rhs,
row(),
column() ) ) {
7799 decltype(
auto) left( derestrict( *this ) );
7801 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
7802 (~rhs).canAlias( &matrix_ ) ) {
7803 const SchurType tmp( *
this % (~rhs) );
7804 if( IsSparseMatrix<SchurType>::value )
7834 template<
typename MT
7836 template<
typename MT2
7838 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
aligned,
false,
true,CSAs...>& >
7839 Submatrix<MT,aligned,false,true,CSAs...>::operator%=(
const Matrix<MT2,SO>& rhs )
7845 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
7853 const SchurType tmp( *
this % (~rhs) );
7855 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
7859 decltype(
auto) left( derestrict( *this ) );
7861 if( IsSparseMatrix<SchurType>::value ) {
7889 template<
typename MT
7891 inline MT& Submatrix<MT,aligned,false,true,CSAs...>::operand() noexcept
7905 template<
typename MT
7907 inline const MT& Submatrix<MT,aligned,false,true,CSAs...>::operand() const noexcept
7926 template<
typename MT
7930 return matrix_.spacing();
7942 template<
typename MT
7964 template<
typename MT
7984 template<
typename MT
7988 const size_t iend(
row() +
rows() );
7990 size_t nonzeros( 0UL );
7992 for(
size_t i=
row(); i<iend; ++i )
7993 for(
size_t j=
column(); j<jend; ++j )
8015 template<
typename MT
8022 size_t nonzeros( 0UL );
8024 for(
size_t j=
column(); j<jend; ++j )
8040 template<
typename MT
8048 const size_t jbegin( ( IsUpper<MT>::value )
8049 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
8053 const size_t jend ( ( IsLower<MT>::value )
8054 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
8059 for(
size_t j=jbegin; j<jend; ++j )
8060 clear( matrix_(i,j) );
8079 template<
typename MT
8087 const size_t jbegin( ( IsUpper<MT>::value )
8088 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
8092 const size_t jend ( ( IsLower<MT>::value )
8093 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
8098 for(
size_t j=jbegin; j<jend; ++j )
8115 template<
typename MT
8117 inline bool Submatrix<MT,aligned,false,true,CSAs...>::hasOverlap() const noexcept
8119 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
8155 template<
typename MT
8157 inline Submatrix<MT,
aligned,
false,
true,CSAs...>&
8168 decltype(
auto) left( derestrict( *this ) );
8197 template< typename MT
8199 inline Submatrix<MT,aligned,false,true,CSAs...>&
8200 Submatrix<MT,aligned,false,true,CSAs...>::ctranspose()
8210 decltype(
auto) left( derestrict( *this ) );
8234 template< typename MT
8236 template< typename Other >
8237 inline Submatrix<MT,aligned,false,true,CSAs...>&
8238 Submatrix<MT,aligned,false,true,CSAs...>::scale( const Other& scalar )
8242 const size_t iend(
row() +
rows() );
8244 for(
size_t i=
row(); i<iend; ++i )
8246 const size_t jbegin( ( IsUpper<MT>::value )
8247 ?( ( IsStrictlyUpper<MT>::value )
8251 const size_t jend ( ( IsLower<MT>::value )
8252 ?( ( IsStrictlyLower<MT>::value )
8257 for(
size_t j=jbegin; j<jend; ++j )
8258 matrix_(i,j) *= scalar;
8286 template<
typename MT
8288 template<
typename Other >
8289 inline bool Submatrix<MT,aligned,false,true,CSAs...>::canAlias(
const Other* alias )
const noexcept
8291 return matrix_.isAliased( alias );
8308 template<
typename MT
8310 template<
typename MT2
8315 Submatrix<MT,aligned,false,true,CSAs...>::canAlias(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
8317 return ( matrix_.isAliased( &alias->matrix_ ) &&
8318 (
row() +
rows() > alias->row() ) &&
8319 (
row() < alias->row() + alias->rows() ) &&
8321 (
column() < alias->column() + alias->columns() ) );
8338 template<
typename MT
8340 template<
typename Other >
8341 inline bool Submatrix<MT,aligned,false,true,CSAs...>::isAliased(
const Other* alias )
const noexcept
8343 return matrix_.isAliased( alias );
8360 template<
typename MT
8362 template<
typename MT2
8367 Submatrix<MT,aligned,false,true,CSAs...>::isAliased(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
8369 return ( matrix_.isAliased( &alias->matrix_ ) &&
8370 (
row() +
rows() > alias->row() ) &&
8371 (
row() < alias->row() + alias->rows() ) &&
8373 (
column() < alias->column() + alias->columns() ) );
8389 template<
typename MT
8391 inline bool Submatrix<MT,aligned,false,true,CSAs...>::isAligned() const noexcept
8410 template<
typename MT
8412 inline bool Submatrix<MT,aligned,false,true,CSAs...>::canSMPAssign() const noexcept
8414 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
8436 template<
typename MT
8439 Submatrix<MT,aligned,false,true,CSAs...>::load(
size_t i,
size_t j )
const noexcept
8441 return loada( i, j );
8463 template<
typename MT
8475 return matrix_.loada(
row()+i,
column()+j );
8497 template<
typename MT
8509 return matrix_.loadu(
row()+i,
column()+j );
8532 template<
typename MT
8535 Submatrix<MT,aligned,false,true,CSAs...>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
8537 return storea( i, j, value );
8560 template<
typename MT
8572 return matrix_.storea(
row()+i,
column()+j, value );
8595 template<
typename MT
8607 matrix_.storeu(
row()+i,
column()+j, value );
8631 template<
typename MT
8643 matrix_.stream(
row()+i,
column()+j, value );
8661 template<
typename MT
8663 template<
typename MT2 >
8664 inline DisableIf_<
typename Submatrix<MT,
aligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
8665 Submatrix<MT,aligned,false,true,CSAs...>::assign(
const DenseMatrix<MT2,false>& rhs )
8670 const size_t jpos(
columns() &
size_t(-2) );
8673 for(
size_t i=0UL; i<
rows(); ++i ) {
8674 for(
size_t j=0UL; j<jpos; j+=2UL ) {
8675 matrix_(
row()+i,
column()+j ) = (~rhs)(i,j );
8676 matrix_(
row()+i,
column()+j+1UL) = (~rhs)(i,j+1UL);
8679 matrix_(
row()+i,
column()+jpos) = (~rhs)(i,jpos);
8699 template<
typename MT
8701 template<
typename MT2 >
8702 inline EnableIf_<
typename Submatrix<MT,
aligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
8703 Submatrix<MT,aligned,false,true,CSAs...>::assign(
const DenseMatrix<MT2,false>& rhs )
8710 const size_t jpos(
columns() &
size_t(-SIMDSIZE) );
8715 !(~rhs).isAliased( &matrix_ ) )
8717 for(
size_t i=0UL; i<
rows(); ++i )
8721 ConstIterator_<MT2> right( (~rhs).
begin(i) );
8723 for( ; j<jpos; j+=SIMDSIZE ) {
8724 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8727 *left = *right; ++left; ++right;
8733 for(
size_t i=0UL; i<
rows(); ++i )
8737 ConstIterator_<MT2> right( (~rhs).
begin(i) );
8739 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
8740 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8741 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8742 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8743 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8745 for( ; j<jpos; j+=SIMDSIZE ) {
8746 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8749 *left = *right; ++left; ++right;
8770 template<
typename MT
8772 template<
typename MT2 >
8773 inline void Submatrix<MT,aligned,false,true,CSAs...>::assign(
const DenseMatrix<MT2,true>& rhs )
8780 constexpr
size_t block( BLOCK_SIZE );
8782 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
8783 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
8784 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
8785 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
8786 for(
size_t i=ii; i<iend; ++i ) {
8787 for(
size_t j=jj; j<jend; ++j ) {
8788 matrix_(
row()+i,
column()+j) = (~rhs)(i,j);
8810 template<
typename MT
8812 template<
typename MT2 >
8813 inline void Submatrix<MT,aligned,false,true,CSAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
8818 for(
size_t i=0UL; i<
rows(); ++i )
8819 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
8820 matrix_(
row()+i,
column()+element->index()) = element->value();
8838 template<
typename MT
8840 template<
typename MT2 >
8841 inline void Submatrix<MT,aligned,false,true,CSAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
8848 for(
size_t j=0UL; j<
columns(); ++j )
8849 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
8850 matrix_(
row()+element->index(),
column()+j) = element->value();
8868 template<
typename MT
8870 template<
typename MT2 >
8871 inline DisableIf_<
typename Submatrix<MT,
aligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
8872 Submatrix<MT,aligned,false,true,CSAs...>::addAssign(
const DenseMatrix<MT2,false>& rhs )
8877 const size_t jpos(
columns() &
size_t(-2) );
8880 for(
size_t i=0UL; i<
rows(); ++i )
8882 if( IsDiagonal<MT2>::value ) {
8883 matrix_(
row()+i,
column()+i) += (~rhs)(i,i);
8886 for(
size_t j=0UL; j<jpos; j+=2UL ) {
8887 matrix_(
row()+i,
column()+j ) += (~rhs)(i,j );
8888 matrix_(
row()+i,
column()+j+1UL) += (~rhs)(i,j+1UL);
8891 matrix_(
row()+i,
column()+jpos) += (~rhs)(i,jpos);
8912 template<
typename MT
8914 template<
typename MT2 >
8915 inline EnableIf_<
typename Submatrix<MT,
aligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
8916 Submatrix<MT,aligned,false,true,CSAs...>::addAssign(
const DenseMatrix<MT2,false>& rhs )
8923 for(
size_t i=0UL; i<
rows(); ++i )
8925 const size_t jbegin( ( IsUpper<MT2>::value )
8926 ?( ( IsStrictlyUpper<MT2>::value ? i+1UL : i ) &
size_t(-SIMDSIZE) )
8928 const size_t jend ( ( IsLower<MT2>::value )
8929 ?( IsStrictlyLower<MT2>::value ? i : i+1UL )
8933 const size_t jpos( jend &
size_t(-SIMDSIZE) );
8938 ConstIterator_<MT2> right( (~rhs).
begin(i) + jbegin );
8940 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
8941 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8942 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8943 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8944 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8946 for( ; j<jpos; j+=SIMDSIZE ) {
8947 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8949 for( ; j<jend; ++j ) {
8950 *left += *right; ++left; ++right;
8970 template<
typename MT
8972 template<
typename MT2 >
8973 inline void Submatrix<MT,aligned,false,true,CSAs...>::addAssign(
const DenseMatrix<MT2,true>& rhs )
8980 constexpr
size_t block( BLOCK_SIZE );
8982 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
8983 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
8984 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
8985 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
8986 for(
size_t i=ii; i<iend; ++i ) {
8987 for(
size_t j=jj; j<jend; ++j ) {
8988 matrix_(
row()+i,
column()+j) += (~rhs)(i,j);
9010 template<
typename MT
9012 template<
typename MT2 >
9013 inline void Submatrix<MT,aligned,false,true,CSAs...>::addAssign(
const SparseMatrix<MT2,false>& rhs )
9018 for(
size_t i=0UL; i<
rows(); ++i )
9019 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
9020 matrix_(
row()+i,
column()+element->index()) += element->value();
9038 template<
typename MT
9040 template<
typename MT2 >
9041 inline void Submatrix<MT,aligned,false,true,CSAs...>::addAssign(
const SparseMatrix<MT2,true>& rhs )
9048 for(
size_t j=0UL; j<
columns(); ++j )
9049 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
9050 matrix_(
row()+element->index(),
column()+j) += element->value();
9068 template<
typename MT
9070 template<
typename MT2 >
9071 inline DisableIf_<
typename Submatrix<MT,
aligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
9072 Submatrix<MT,aligned,false,true,CSAs...>::subAssign(
const DenseMatrix<MT2,false>& rhs )
9077 const size_t jpos(
columns() &
size_t(-2) );
9080 for(
size_t i=0UL; i<
rows(); ++i )
9082 if( IsDiagonal<MT2>::value ) {
9083 matrix_(
row()+i,
column()+i) -= (~rhs)(i,i);
9086 for(
size_t j=0UL; j<jpos; j+=2UL ) {
9087 matrix_(
row()+i,
column()+j ) -= (~rhs)(i,j );
9088 matrix_(
row()+i,
column()+j+1UL) -= (~rhs)(i,j+1UL);
9091 matrix_(
row()+i,
column()+jpos) -= (~rhs)(i,jpos);
9112 template<
typename MT
9114 template<
typename MT2 >
9115 inline EnableIf_<
typename Submatrix<MT,
aligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
9116 Submatrix<MT,aligned,false,true,CSAs...>::subAssign(
const DenseMatrix<MT2,false>& rhs )
9123 for(
size_t i=0UL; i<
rows(); ++i )
9125 const size_t jbegin( ( IsUpper<MT2>::value )
9126 ?( ( IsStrictlyUpper<MT2>::value ? i+1UL : i ) &
size_t(-SIMDSIZE) )
9128 const size_t jend ( ( IsLower<MT2>::value )
9129 ?( IsStrictlyLower<MT2>::value ? i : i+1UL )
9133 const size_t jpos( jend &
size_t(-SIMDSIZE) );
9138 ConstIterator_<MT2> right( (~rhs).
begin(i) + jbegin );
9140 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
9141 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9142 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9143 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9144 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9146 for( ; j<jpos; j+=SIMDSIZE ) {
9147 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9149 for( ; j<jend; ++j ) {
9150 *left -= *right; ++left; ++right;
9170 template<
typename MT
9172 template<
typename MT2 >
9173 inline void Submatrix<MT,aligned,false,true,CSAs...>::subAssign(
const DenseMatrix<MT2,true>& rhs )
9180 constexpr
size_t block( BLOCK_SIZE );
9182 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
9183 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
9184 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
9185 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
9186 for(
size_t i=ii; i<iend; ++i ) {
9187 for(
size_t j=jj; j<jend; ++j ) {
9188 matrix_(
row()+i,
column()+j) -= (~rhs)(i,j);
9210 template<
typename MT
9212 template<
typename MT2 >
9213 inline void Submatrix<MT,aligned,false,true,CSAs...>::subAssign(
const SparseMatrix<MT2,false>& rhs )
9218 for(
size_t i=0UL; i<
rows(); ++i )
9219 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
9220 matrix_(
row()+i,
column()+element->index()) -= element->value();
9238 template<
typename MT
9240 template<
typename MT2 >
9241 inline void Submatrix<MT,aligned,false,true,CSAs...>::subAssign(
const SparseMatrix<MT2,true>& rhs )
9248 for(
size_t j=0UL; j<
columns(); ++j )
9249 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
9250 matrix_(
row()+element->index(),
column()+j) -= element->value();
9268 template<
typename MT
9270 template<
typename MT2 >
9271 inline DisableIf_<
typename Submatrix<MT,
aligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSchurAssign<MT2> >
9272 Submatrix<MT,aligned,false,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,false>& rhs )
9277 const size_t jpos(
columns() &
size_t(-2) );
9280 for(
size_t i=0UL; i<
rows(); ++i ) {
9281 for(
size_t j=0UL; j<jpos; j+=2UL ) {
9282 matrix_(
row()+i,
column()+j ) *= (~rhs)(i,j );
9283 matrix_(
row()+i,
column()+j+1UL) *= (~rhs)(i,j+1UL);
9286 matrix_(
row()+i,
column()+jpos) *= (~rhs)(i,jpos);
9306 template<
typename MT
9308 template<
typename MT2 >
9309 inline EnableIf_<
typename Submatrix<MT,
aligned,
false,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSchurAssign<MT2> >
9310 Submatrix<MT,aligned,false,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,false>& rhs )
9317 for(
size_t i=0UL; i<
rows(); ++i )
9319 const size_t jpos(
columns() &
size_t(-SIMDSIZE) );
9324 ConstIterator_<MT2> right( (~rhs).
begin(i) );
9326 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
9327 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9328 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9329 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9330 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9332 for( ; j<jpos; j+=SIMDSIZE ) {
9333 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9336 *left *= *right; ++left; ++right;
9356 template<
typename MT
9358 template<
typename MT2 >
9359 inline void Submatrix<MT,aligned,false,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,true>& rhs )
9366 constexpr
size_t block( BLOCK_SIZE );
9368 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
9369 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
9370 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
9371 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
9372 for(
size_t i=ii; i<iend; ++i ) {
9373 for(
size_t j=jj; j<jend; ++j ) {
9374 matrix_(
row()+i,
column()+j) *= (~rhs)(i,j);
9396 template<
typename MT
9398 template<
typename MT2 >
9399 inline void Submatrix<MT,aligned,false,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,false>& rhs )
9406 for(
size_t i=0UL; i<
rows(); ++i )
9410 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
9411 for( ; j<element->index(); ++j )
9413 matrix_(
row()+i,
column()+j) *= element->value();
9438 template<
typename MT
9440 template<
typename MT2 >
9441 inline void Submatrix<MT,aligned,false,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,true>& rhs )
9450 for(
size_t j=0UL; j<
columns(); ++j )
9454 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
9455 for( ; i<element->index(); ++i )
9457 matrix_(
row()+element->index(),
column()+j) *= element->value();
9461 for( ; i<
rows(); ++i ) {
9490 template<
typename MT
9492 class Submatrix<MT,aligned,true,true,CSAs...>
9493 :
public View< DenseMatrix< Submatrix<MT,aligned,true,true,CSAs...>, true > >
9494 ,
private SubmatrixData<CSAs...>
9498 using DataType = SubmatrixData<CSAs...>;
9499 using Operand = If_< IsExpression<MT>, MT, MT& >;
9505 using This = Submatrix<MT,
aligned,
true,
true,CSAs...>;
9507 using BaseType = DenseMatrix<This,true>;
9508 using ViewedType = MT;
9513 using SIMDType = SIMDTrait_<ElementType>;
9518 using ConstReference = ConstReference_<MT>;
9524 using ConstPointer = ConstPointer_<MT>;
9527 using Pointer = If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, Pointer_<MT> >;
9530 using ConstIterator = ConstIterator_<MT>;
9538 enum :
bool { simdEnabled = MT::simdEnabled };
9541 enum :
bool { smpAssignable = MT::smpAssignable };
9547 template<
typename... RSAs >
9548 explicit inline Submatrix( MT& matrix, RSAs... args );
9560 inline Reference operator()(
size_t i,
size_t j );
9561 inline ConstReference operator()(
size_t i,
size_t j )
const;
9562 inline Reference at(
size_t i,
size_t j );
9563 inline ConstReference at(
size_t i,
size_t j )
const;
9564 inline Pointer
data () noexcept;
9565 inline ConstPointer
data () const noexcept;
9566 inline Pointer
data (
size_t j ) noexcept;
9567 inline ConstPointer
data (
size_t j ) const noexcept;
9569 inline ConstIterator
begin (
size_t j ) const;
9570 inline ConstIterator
cbegin(
size_t j ) const;
9572 inline ConstIterator
end (
size_t j ) const;
9573 inline ConstIterator
cend (
size_t j ) const;
9580 inline Submatrix& operator=( const
ElementType& rhs );
9581 inline Submatrix& operator=( initializer_list< initializer_list<
ElementType> > list );
9582 inline Submatrix& operator=( const Submatrix& rhs );
9584 template< typename MT2,
bool SO >
9585 inline Submatrix& operator=( const Matrix<MT2,SO>& rhs );
9587 template< typename MT2,
bool SO >
9588 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
9589 operator+=( const Matrix<MT2,SO>& rhs );
9591 template< typename MT2,
bool SO >
9592 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
9593 operator+=( const Matrix<MT2,SO>& rhs );
9595 template< typename MT2,
bool SO >
9596 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
9597 operator-=( const Matrix<MT2,SO>& rhs );
9599 template< typename MT2,
bool SO >
9600 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
9601 operator-=( const Matrix<MT2,SO>& rhs );
9603 template< typename MT2,
bool SO >
9604 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
9605 operator%=( const Matrix<MT2,SO>& rhs );
9607 template< typename MT2,
bool SO >
9608 inline
EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix& >
9609 operator%=( const Matrix<MT2,SO>& rhs );
9616 using DataType::row;
9617 using DataType::column;
9618 using DataType::
rows;
9621 inline MT& operand() noexcept;
9622 inline const MT& operand() const noexcept;
9624 inline
size_t spacing() const noexcept;
9625 inline
size_t capacity() const noexcept;
9626 inline
size_t capacity(
size_t i ) const noexcept;
9628 inline
size_t nonZeros(
size_t i ) const;
9629 inline
void reset();
9630 inline
void reset(
size_t i );
9638 inline Submatrix& ctranspose();
9640 template< typename Other > inline Submatrix& scale( const Other& scalar );
9647 template< typename MT2 >
9648 struct VectorizedAssign {
9649 enum :
bool { value = useOptimizedKernels &&
9650 simdEnabled && MT2::simdEnabled &&
9651 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value };
9657 template<
typename MT2 >
9658 struct VectorizedAddAssign {
9659 enum :
bool { value = useOptimizedKernels &&
9660 simdEnabled && MT2::simdEnabled &&
9661 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
9662 HasSIMDAdd< ElementType, ElementType_<MT2> >::value &&
9663 !IsDiagonal<MT2>::value };
9669 template<
typename MT2 >
9670 struct VectorizedSubAssign {
9671 enum :
bool { value = useOptimizedKernels &&
9672 simdEnabled && MT2::simdEnabled &&
9673 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
9674 HasSIMDSub< ElementType, ElementType_<MT2> >::value &&
9675 !IsDiagonal<MT2>::value };
9681 template<
typename MT2 >
9682 struct VectorizedSchurAssign {
9683 enum :
bool { value = useOptimizedKernels &&
9684 simdEnabled && MT2::simdEnabled &&
9685 IsSIMDCombinable< ElementType, ElementType_<MT2> >::value &&
9686 HasSIMDMult< ElementType, ElementType_<MT2> >::value };
9699 template<
typename Other >
9700 inline bool canAlias(
const Other* alias )
const noexcept;
9702 template<
typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
9703 inline bool canAlias(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept;
9705 template<
typename Other >
9706 inline bool isAliased(
const Other* alias )
const noexcept;
9708 template<
typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
9709 inline bool isAliased(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept;
9711 inline bool isAligned () const noexcept;
9712 inline
bool canSMPAssign() const noexcept;
9723 template< typename MT2 >
9724 inline
DisableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,true>& rhs );
9726 template< typename MT2 >
9727 inline
EnableIf_< VectorizedAssign<MT2> > assign( const DenseMatrix<MT2,true>& rhs );
9729 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,false>& rhs );
9730 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
9731 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
9733 template< typename MT2 >
9734 inline
DisableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,true>& rhs );
9736 template< typename MT2 >
9737 inline
EnableIf_< VectorizedAddAssign<MT2> > addAssign( const DenseMatrix<MT2,true>& rhs );
9739 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,false>& rhs );
9740 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
9741 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
9743 template< typename MT2 >
9744 inline
DisableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,true>& rhs );
9746 template< typename MT2 >
9747 inline
EnableIf_< VectorizedSubAssign<MT2> > subAssign( const DenseMatrix<MT2,true>& rhs );
9749 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,false>& rhs );
9750 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
9751 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
9753 template< typename MT2 >
9754 inline
DisableIf_< VectorizedSchurAssign<MT2> > schurAssign( const DenseMatrix<MT2,true>& rhs );
9756 template< typename MT2 >
9757 inline
EnableIf_< VectorizedSchurAssign<MT2> > schurAssign( const DenseMatrix<MT2,true>& rhs );
9759 template< typename MT2 > inline
void schurAssign( const DenseMatrix<MT2,false>& rhs );
9760 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,true>& rhs );
9761 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,false>& rhs );
9769 inline
bool hasOverlap() const noexcept;
9781 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
bool DF2,
size_t... CSAs2 > friend class Submatrix;
9819 template< typename MT
9821 template< typename... RSAs >
9822 inline Submatrix<MT,aligned,true,true,CSAs...>::Submatrix( MT& matrix, RSAs... args )
9823 : DataType( args... )
9824 , matrix_ ( matrix )
9826 if( !Contains< TypeList<RSAs...>,
Unchecked >::value )
9833 (
columns() > 1UL && matrix_.spacing() % SIMDSIZE != 0UL ) ) {
9868 template<
typename MT
9871 Submatrix<MT,aligned,true,true,CSAs...>::operator()(
size_t i,
size_t j )
9893 template<
typename MT
9896 Submatrix<MT,aligned,true,true,CSAs...>::operator()(
size_t i,
size_t j )
const 9901 return const_cast<const MT&
>( matrix_ )(
row()+i,
column()+j);
9919 template<
typename MT
9922 Submatrix<MT,aligned,true,true,CSAs...>::at(
size_t i,
size_t j )
9930 return (*
this)(i,j);
9948 template<
typename MT
9951 Submatrix<MT,aligned,true,true,CSAs...>::at(
size_t i,
size_t j )
const 9959 return (*
this)(i,j);
9975 template<
typename MT
9977 inline typename Submatrix<MT,
aligned,
true,
true,CSAs...>::Pointer
9996 template<
typename MT
9998 inline typename Submatrix<MT,
aligned,
true,
true,CSAs...>::ConstPointer
10016 template<
typename MT
10018 inline typename Submatrix<MT,
aligned,
true,
true,CSAs...>::Pointer
10036 template<
typename MT
10038 inline typename Submatrix<MT,
aligned,
true,
true,CSAs...>::ConstPointer
10054 template<
typename MT
10060 return ( matrix_.begin( column() + j ) +
row() );
10073 template<
typename MT
10079 return ( matrix_.cbegin( column() + j ) +
row() );
10092 template<
typename MT
10098 return ( matrix_.cbegin( column() + j ) +
row() );
10111 template<
typename MT
10117 return ( matrix_.begin( column() + j ) +
row() +
rows() );
10130 template<
typename MT
10136 return ( matrix_.cbegin( column() + j ) +
row() +
rows() );
10149 template<
typename MT
10155 return ( matrix_.cbegin( column() + j ) +
row() +
rows() );
10180 template<
typename MT
10182 inline Submatrix<MT,
aligned,
true,
true,CSAs...>&
10183 Submatrix<MT,aligned,true,true,CSAs...>::operator=(
const ElementType& rhs )
10186 decltype(
auto) left( derestrict( matrix_ ) );
10188 for(
size_t j=column(); j<jend; ++j )
10190 const size_t ibegin( ( IsLower<MT>::value )
10191 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
10192 ?(
max( j+1UL,
row() ) )
10195 const size_t iend ( ( IsUpper<MT>::value )
10196 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
10201 for(
size_t i=ibegin; i<iend; ++i ) {
10202 if( !IsRestricted<MT>::value || IsTriangular<MT>::value || trySet( matrix_, i, j, rhs ) )
10229 template<
typename MT
10231 inline Submatrix<MT,
aligned,
true,
true,CSAs...>&
10232 Submatrix<MT,aligned,true,true,CSAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
10236 if( list.size() !=
rows() ) {
10240 if( IsRestricted<MT>::value ) {
10241 const InitializerMatrix<ElementType> tmp( list,
columns() );
10242 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
10247 decltype(
auto) left( derestrict( *this ) );
10250 for( const auto& rowList : list ) {
10252 for(
const auto& element : rowList ) {
10253 left(i,j) = element;
10257 reset( left(i,j) );
10283 template<
typename MT
10285 inline Submatrix<MT,
aligned,
true,
true,CSAs...>&
10286 Submatrix<MT,aligned,true,true,CSAs...>::operator=(
const Submatrix& rhs )
10291 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row() == rhs.row() &&
column() == rhs.column() ) )
10294 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
10298 if( !tryAssign( matrix_, rhs,
row(),
column() ) ) {
10302 decltype(
auto) left( derestrict( *this ) );
10304 if( rhs.canAlias( &matrix_ ) ) {
10334 template<
typename MT
10336 template<
typename MT2
10338 inline Submatrix<MT,
aligned,
true,
true,CSAs...>&
10339 Submatrix<MT,aligned,true,true,CSAs...>::operator=(
const Matrix<MT2,SO>& rhs )
10347 using Right = If_< IsRestricted<MT>, CompositeType_<MT2>,
const MT2& >;
10348 Right right( ~rhs );
10350 if( !tryAssign( matrix_, right,
row(),
column() ) ) {
10354 decltype(
auto) left( derestrict( *this ) );
10356 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
10357 const ResultType_<MT2> tmp( right );
10358 if( IsSparseMatrix<MT2>::value )
10363 if( IsSparseMatrix<MT2>::value )
10390 template<
typename MT
10392 template<
typename MT2
10394 inline DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
aligned,
true,
true,CSAs...>& >
10401 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
10410 if( !tryAddAssign( matrix_, ~rhs,
row(),
column() ) ) {
10414 decltype(
auto) left( derestrict( *this ) );
10416 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
10417 (~rhs).canAlias( &matrix_ ) ) {
10418 const AddType tmp( *
this + (~rhs) );
10447 template<
typename MT
10449 template<
typename MT2
10451 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
aligned,
true,
true,CSAs...>& >
10458 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
10467 const AddType tmp( *
this + (~rhs) );
10469 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
10473 decltype(
auto) left( derestrict( *this ) );
10499 template< typename MT
10501 template< typename MT2
10503 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,true,true,CSAs...>& >
10504 Submatrix<MT,aligned,true,true,CSAs...>::operator-=( const Matrix<MT2,SO>& rhs )
10510 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
10519 if( !trySubAssign( matrix_, ~rhs,
row(),
column() ) ) {
10523 decltype(
auto) left( derestrict( *this ) );
10525 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
10526 (~rhs).canAlias( &matrix_ ) ) {
10527 const SubType tmp( *
this - (~rhs ) );
10556 template<
typename MT
10558 template<
typename MT2
10560 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
aligned,
true,
true,CSAs...>& >
10567 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
10576 const SubType tmp( *
this - (~rhs) );
10578 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
10582 decltype(
auto) left( derestrict( *this ) );
10608 template< typename MT
10610 template< typename MT2
10612 inline
DisableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,aligned,true,true,CSAs...>& >
10613 Submatrix<MT,aligned,true,true,CSAs...>::operator%=( const Matrix<MT2,SO>& rhs )
10619 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
10627 if( !trySchurAssign( matrix_, ~rhs,
row(),
column() ) ) {
10631 decltype(
auto) left( derestrict( *this ) );
10633 if( ( ( IsSymmetric<MT>::value || IsHermitian<MT>::value ) && hasOverlap() ) ||
10634 (~rhs).canAlias( &matrix_ ) ) {
10635 const SchurType tmp( *
this % (~rhs) );
10636 if( IsSparseMatrix<SchurType>::value )
10666 template<
typename MT
10668 template<
typename MT2
10670 inline EnableIf_< And< IsRestricted<MT>, RequiresEvaluation<MT2> >, Submatrix<MT,
aligned,
true,
true,CSAs...>& >
10671 Submatrix<MT,aligned,true,true,CSAs...>::operator%=(
const Matrix<MT2,SO>& rhs )
10677 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
10685 const SchurType tmp( *
this % (~rhs) );
10687 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
10691 decltype(
auto) left( derestrict( *this ) );
10693 if( IsSparseMatrix<SchurType>::value ) {
10721 template<
typename MT
10723 inline MT& Submatrix<MT,aligned,true,true,CSAs...>::operand() noexcept
10737 template<
typename MT
10739 inline const MT& Submatrix<MT,aligned,true,true,CSAs...>::operand() const noexcept
10756 template<
typename MT
10760 return matrix_.spacing();
10772 template<
typename MT
10789 template<
typename MT
10809 template<
typename MT
10813 const size_t iend(
row() +
rows() );
10815 size_t nonzeros( 0UL );
10817 for(
size_t j=
column(); j<jend; ++j )
10818 for(
size_t i=
row(); i<iend; ++i )
10835 template<
typename MT
10841 const size_t iend(
row() +
rows() );
10842 size_t nonzeros( 0UL );
10844 for(
size_t i=
row(); i<iend; ++i )
10860 template<
typename MT
10868 const size_t ibegin( ( IsLower<MT>::value )
10869 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
10870 ?(
max( j+1UL,
row() ) )
10873 const size_t iend ( ( IsUpper<MT>::value )
10874 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
10879 for(
size_t i=ibegin; i<iend; ++i )
10880 clear( matrix_(i,j) );
10894 template<
typename MT
10902 const size_t ibegin( ( IsLower<MT>::value )
10903 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
10904 ?(
max( j+1UL,
row() ) )
10907 const size_t iend ( ( IsUpper<MT>::value )
10908 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
10913 for(
size_t i=ibegin; i<iend; ++i )
10930 template<
typename MT
10932 inline bool Submatrix<MT,aligned,true,true,CSAs...>::hasOverlap() const noexcept
10934 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
10970 template<
typename MT
10972 inline Submatrix<MT,
aligned,
true,
true,CSAs...>&
10983 decltype(
auto) left( derestrict( *this ) );
11012 template< typename MT
11014 inline Submatrix<MT,aligned,true,true,CSAs...>&
11015 Submatrix<MT,aligned,true,true,CSAs...>::ctranspose()
11025 decltype(
auto) left( derestrict( *this ) );
11049 template< typename MT
11051 template< typename Other >
11052 inline Submatrix<MT,aligned,true,true,CSAs...>&
11053 Submatrix<MT,aligned,true,true,CSAs...>::scale( const Other& scalar )
11059 for(
size_t j=
column(); j<jend; ++j )
11061 const size_t ibegin( ( IsLower<MT>::value )
11062 ?( ( IsStrictlyLower<MT>::value )
11063 ?(
max( j+1UL,
row() ) )
11066 const size_t iend ( ( IsUpper<MT>::value )
11067 ?( ( IsStrictlyUpper<MT>::value )
11072 for(
size_t i=ibegin; i<iend; ++i )
11073 matrix_(i,j) *= scalar;
11101 template<
typename MT
11103 template<
typename Other >
11104 inline bool Submatrix<MT,aligned,true,true,CSAs...>::canAlias(
const Other* alias )
const noexcept
11106 return matrix_.isAliased( alias );
11123 template<
typename MT
11125 template<
typename MT2
11128 ,
size_t... CSAs2 >
11130 Submatrix<MT,aligned,true,true,CSAs...>::canAlias(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
11132 return ( matrix_.isAliased( &alias->matrix_ ) &&
11133 (
row() +
rows() > alias->row() ) &&
11134 (
row() < alias->row() + alias->rows() ) &&
11136 (
column() < alias->column() + alias->columns() ) );
11153 template<
typename MT
11155 template<
typename Other >
11156 inline bool Submatrix<MT,aligned,true,true,CSAs...>::isAliased(
const Other* alias )
const noexcept
11158 return matrix_.isAliased( alias );
11175 template<
typename MT
11177 template<
typename MT2
11180 ,
size_t... CSAs2 >
11182 Submatrix<MT,aligned,true,true,CSAs...>::isAliased(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
11184 return ( matrix_.isAliased( &alias->matrix_ ) &&
11185 (
row() +
rows() > alias->row() ) &&
11186 (
row() < alias->row() + alias->rows() ) &&
11188 (
column() < alias->column() + alias->columns() ) );
11204 template<
typename MT
11206 inline bool Submatrix<MT,aligned,true,true,CSAs...>::isAligned() const noexcept
11225 template<
typename MT
11227 inline bool Submatrix<MT,aligned,true,true,CSAs...>::canSMPAssign() const noexcept
11229 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
11250 template<
typename MT
11253 Submatrix<MT,aligned,true,true,CSAs...>::load(
size_t i,
size_t j )
const noexcept
11255 return loada( i, j );
11276 template<
typename MT
11288 return matrix_.loada(
row()+i,
column()+j );
11309 template<
typename MT
11321 return matrix_.loadu(
row()+i,
column()+j );
11343 template<
typename MT
11346 Submatrix<MT,aligned,true,true,CSAs...>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
11370 template<
typename MT
11382 matrix_.storea(
row()+i,
column()+j, value );
11404 template<
typename MT
11416 matrix_.storeu(
row()+i,
column()+j, value );
11439 template<
typename MT
11451 matrix_.stream(
row()+i,
column()+j, value );
11469 template<
typename MT
11471 template<
typename MT2 >
11472 inline DisableIf_<
typename Submatrix<MT,
aligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
11473 Submatrix<MT,aligned,true,true,CSAs...>::assign(
const DenseMatrix<MT2,true>& rhs )
11478 const size_t ipos(
rows() &
size_t(-2) );
11481 for(
size_t j=0UL; j<
columns(); ++j ) {
11482 for(
size_t i=0UL; i<ipos; i+=2UL ) {
11483 matrix_(
row()+i ,
column()+j) = (~rhs)(i ,j);
11484 matrix_(
row()+i+1UL,
column()+j) = (~rhs)(i+1UL,j);
11486 if( ipos <
rows() ) {
11487 matrix_(
row()+ipos,
column()+j) = (~rhs)(ipos,j);
11507 template<
typename MT
11509 template<
typename MT2 >
11510 inline EnableIf_<
typename Submatrix<MT,
aligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAssign<MT2> >
11511 Submatrix<MT,aligned,true,true,CSAs...>::assign(
const DenseMatrix<MT2,true>& rhs )
11518 const size_t ipos(
rows() &
size_t(-SIMDSIZE) );
11521 if( useStreaming &&
11523 !(~rhs).isAliased( &matrix_ ) )
11525 for(
size_t j=0UL; j<
columns(); ++j )
11529 ConstIterator_<MT2> right( (~rhs).
begin(j) );
11531 for( ; i<ipos; i+=SIMDSIZE ) {
11532 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11534 for( ; i<
rows(); ++i ) {
11535 *left = *right; ++left; ++right;
11541 for(
size_t j=0UL; j<
columns(); ++j )
11545 ConstIterator_<MT2> right( (~rhs).
begin(j) );
11547 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
11548 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11549 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11550 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11551 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11553 for( ; i<ipos; i+=SIMDSIZE ) {
11554 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11556 for( ; i<
rows(); ++i ) {
11557 *left = *right; ++left; ++right;
11578 template<
typename MT
11580 template<
typename MT2 >
11581 inline void Submatrix<MT,aligned,true,true,CSAs...>::assign(
const DenseMatrix<MT2,false>& rhs )
11588 constexpr
size_t block( BLOCK_SIZE );
11590 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
11591 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
11592 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
11593 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
11594 for(
size_t j=jj; j<jend; ++j ) {
11595 for(
size_t i=ii; i<iend; ++i ) {
11596 matrix_(
row()+i,
column()+j) = (~rhs)(i,j);
11618 template<
typename MT
11620 template<
typename MT2 >
11621 inline void Submatrix<MT,aligned,true,true,CSAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
11626 for(
size_t j=0UL; j<
columns(); ++j )
11627 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
11628 matrix_(
row()+element->index(),
column()+j) = element->value();
11646 template<
typename MT
11648 template<
typename MT2 >
11649 inline void Submatrix<MT,aligned,true,true,CSAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
11656 for(
size_t i=0UL; i<
rows(); ++i )
11657 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
11658 matrix_(
row()+i,
column()+element->index()) = element->value();
11676 template<
typename MT
11678 template<
typename MT2 >
11679 inline DisableIf_<
typename Submatrix<MT,
aligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
11680 Submatrix<MT,aligned,true,true,CSAs...>::addAssign(
const DenseMatrix<MT2,true>& rhs )
11685 const size_t ipos(
rows() &
size_t(-2) );
11688 for(
size_t j=0UL; j<
columns(); ++j )
11690 if( IsDiagonal<MT2>::value ) {
11691 matrix_(
row()+j,
column()+j) += (~rhs)(j,j);
11694 for(
size_t i=0UL; i<ipos; i+=2UL ) {
11695 matrix_(
row()+i ,
column()+j) += (~rhs)(i ,j);
11696 matrix_(
row()+i+1UL,
column()+j) += (~rhs)(i+1UL,j);
11698 if( ipos <
rows() ) {
11699 matrix_(
row()+ipos,
column()+j) += (~rhs)(ipos,j);
11720 template<
typename MT
11722 template<
typename MT2 >
11723 inline EnableIf_<
typename Submatrix<MT,
aligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >
11724 Submatrix<MT,aligned,true,true,CSAs...>::addAssign(
const DenseMatrix<MT2,true>& rhs )
11731 for(
size_t j=0UL; j<
columns(); ++j )
11733 const size_t ibegin( ( IsLower<MT>::value )
11734 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-SIMDSIZE) )
11736 const size_t iend ( ( IsUpper<MT>::value )
11737 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
11741 const size_t ipos( iend &
size_t(-SIMDSIZE) );
11744 size_t i( ibegin );
11746 ConstIterator_<MT2> right( (~rhs).
begin(j) + ibegin );
11748 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
11749 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11750 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11751 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11752 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11754 for( ; i<ipos; i+=SIMDSIZE ) {
11755 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11757 for( ; i<iend; ++i ) {
11758 *left += *right; ++left; ++right;
11778 template<
typename MT
11780 template<
typename MT2 >
11781 inline void Submatrix<MT,aligned,true,true,CSAs...>::addAssign(
const DenseMatrix<MT2,false>& rhs )
11788 constexpr
size_t block( BLOCK_SIZE );
11790 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
11791 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
11792 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
11793 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
11794 for(
size_t j=jj; j<jend; ++j ) {
11795 for(
size_t i=ii; i<iend; ++i ) {
11796 matrix_(
row()+i,
column()+j) += (~rhs)(i,j);
11818 template<
typename MT
11820 template<
typename MT2 >
11821 inline void Submatrix<MT,aligned,true,true,CSAs...>::addAssign(
const SparseMatrix<MT2,true>& rhs )
11826 for(
size_t j=0UL; j<
columns(); ++j )
11827 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
11828 matrix_(
row()+element->index(),
column()+j) += element->value();
11846 template<
typename MT
11848 template<
typename MT2 >
11849 inline void Submatrix<MT,aligned,true,true,CSAs...>::addAssign(
const SparseMatrix<MT2,false>& rhs )
11856 for(
size_t i=0UL; i<
rows(); ++i )
11857 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
11858 matrix_(
row()+i,
column()+element->index()) += element->value();
11876 template<
typename MT
11878 template<
typename MT2 >
11879 inline DisableIf_<
typename Submatrix<MT,
aligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
11880 Submatrix<MT,aligned,true,true,CSAs...>::subAssign(
const DenseMatrix<MT2,true>& rhs )
11885 const size_t ipos(
rows() &
size_t(-2) );
11888 for(
size_t j=0UL; j<
columns(); ++j )
11890 if( IsDiagonal<MT2>::value ) {
11891 matrix_(
row()+j,
column()+j) -= (~rhs)(j,j);
11894 for(
size_t i=0UL; i<ipos; i+=2UL ) {
11895 matrix_(
row()+i ,
column()+j) -= (~rhs)(i ,j);
11896 matrix_(
row()+i+1UL,
column()+j) -= (~rhs)(i+1UL,j);
11898 if( ipos <
rows() ) {
11899 matrix_(
row()+ipos,
column()+j) -= (~rhs)(ipos,j);
11920 template<
typename MT
11922 template<
typename MT2 >
11923 inline EnableIf_<
typename Submatrix<MT,
aligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >
11924 Submatrix<MT,aligned,true,true,CSAs...>::subAssign(
const DenseMatrix<MT2,true>& rhs )
11931 for(
size_t j=0UL; j<
columns(); ++j )
11933 const size_t ibegin( ( IsLower<MT>::value )
11934 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-SIMDSIZE) )
11936 const size_t iend ( ( IsUpper<MT>::value )
11937 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
11941 const size_t ipos( iend &
size_t(-SIMDSIZE) );
11944 size_t i( ibegin );
11946 ConstIterator_<MT2> right( (~rhs).
begin(j) + ibegin );
11948 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
11949 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11950 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11951 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11952 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11954 for( ; i<ipos; i+=SIMDSIZE ) {
11955 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11957 for( ; i<iend; ++i ) {
11958 *left -= *right; ++left; ++right;
11978 template<
typename MT
11980 template<
typename MT2 >
11981 inline void Submatrix<MT,aligned,true,true,CSAs...>::subAssign(
const DenseMatrix<MT2,false>& rhs )
11988 constexpr
size_t block( BLOCK_SIZE );
11990 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
11991 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
11992 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
11993 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
11994 for(
size_t j=jj; j<jend; ++j ) {
11995 for(
size_t i=ii; i<iend; ++i ) {
11996 matrix_(
row()+i,
column()+j) -= (~rhs)(i,j);
12018 template<
typename MT
12020 template<
typename MT2 >
12021 inline void Submatrix<MT,aligned,true,true,CSAs...>::subAssign(
const SparseMatrix<MT2,true>& rhs )
12026 for(
size_t j=0UL; j<
columns(); ++j )
12027 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
12028 matrix_(
row()+element->index(),
column()+j) -= element->value();
12046 template<
typename MT
12048 template<
typename MT2 >
12049 inline void Submatrix<MT,aligned,true,true,CSAs...>::subAssign(
const SparseMatrix<MT2,false>& rhs )
12056 for(
size_t i=0UL; i<
rows(); ++i )
12057 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
12058 matrix_(
row()+i,
column()+element->index()) -= element->value();
12076 template<
typename MT
12078 template<
typename MT2 >
12079 inline DisableIf_<
typename Submatrix<MT,
aligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSchurAssign<MT2> >
12080 Submatrix<MT,aligned,true,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,true>& rhs )
12085 const size_t ipos(
rows() &
size_t(-2) );
12088 for(
size_t j=0UL; j<
columns(); ++j ) {
12089 for(
size_t i=0UL; i<ipos; i+=2UL ) {
12090 matrix_(
row()+i ,
column()+j) *= (~rhs)(i ,j);
12091 matrix_(
row()+i+1UL,
column()+j) *= (~rhs)(i+1UL,j);
12093 if( ipos <
rows() ) {
12094 matrix_(
row()+ipos,
column()+j) *= (~rhs)(ipos,j);
12115 template<
typename MT
12117 template<
typename MT2 >
12118 inline EnableIf_<
typename Submatrix<MT,
aligned,
true,
true,CSAs...>::BLAZE_TEMPLATE VectorizedSchurAssign<MT2> >
12119 Submatrix<MT,aligned,true,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,true>& rhs )
12126 for(
size_t j=0UL; j<
columns(); ++j )
12128 const size_t ipos(
rows() &
size_t(-SIMDSIZE) );
12133 ConstIterator_<MT2> right( (~rhs).
begin(j) );
12135 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
12136 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
12137 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
12138 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
12139 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
12141 for( ; i<ipos; i+=SIMDSIZE ) {
12142 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
12144 for( ; i<
rows(); ++i ) {
12145 *left *= *right; ++left; ++right;
12165 template<
typename MT
12167 template<
typename MT2 >
12168 inline void Submatrix<MT,aligned,true,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,false>& rhs )
12175 constexpr
size_t block( BLOCK_SIZE );
12177 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
12178 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
12179 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
12180 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
12181 for(
size_t j=jj; j<jend; ++j ) {
12182 for(
size_t i=ii; i<iend; ++i ) {
12183 matrix_(
row()+i,
column()+j) *= (~rhs)(i,j);
12205 template<
typename MT
12207 template<
typename MT2 >
12208 inline void Submatrix<MT,aligned,true,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,true>& rhs )
12215 for(
size_t j=0UL; j<
columns(); ++j )
12219 for( ConstIterator_<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
12220 for( ; i<element->index(); ++i )
12222 matrix_(
row()+i,
column()+j) *= element->value();
12226 for( ; i<
rows(); ++i ) {
12247 template<
typename MT
12249 template<
typename MT2 >
12250 inline void Submatrix<MT,aligned,true,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,false>& rhs )
12259 for(
size_t i=0UL; i<
rows(); ++i )
12263 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
12264 for( ; j<element->index(); ++j )
12266 matrix_(
row()+i,
column()+j) *= element->value();
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.Via these flags it is possible to specify subvec...
Definition: AlignmentFlag.h:62
Constraint on the data type.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:131
Headerfile for the generic min algorithm.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for kernel specific block sizes.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3077
Header file for the Schur product trait.
#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.
EnableIf_< IsDenseMatrix< MT1 > > smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:196
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:522
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:164
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:265
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:61
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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3076
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:364
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3074
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:701
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3078
Header file for the And class template.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1903
#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:827
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3083
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:560
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:733
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3084
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.
Header file for the extended initializer_list functionality.
System settings for performance optimizations.
typename SubmatrixTrait< MT, CSAs... >::Type SubmatrixTrait_
Auxiliary alias declaration for the SubmatrixTrait type trait.The SubmatrixTrait_ alias declaration p...
Definition: SubmatrixTrait.h:145
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:1950
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:133
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:474
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:408
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:252
Header file for the matrix storage order types.
Constraint on the data type.
Header file for the implementation of a matrix representation of an initializer list.
Headerfile for the generic max algorithm.
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.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3082
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
decltype(auto) ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatMapExpr.h:1359
Header file for nested template disabiguation.
Header file for the If class template.
#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
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
EnableIf_< IsDenseMatrix< MT1 > > smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:102
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3079
Header file for the Or class template.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
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.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Header file for 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:506
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.
Header file for the IsTriangular type trait.
#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
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:430
Header file for the implementation of the SubmatrixData class template.
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8893
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Constraint on the data type.
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:608
Constraint on the data type.
Flag for aligned vectors and matrices.
Definition: AlignmentFlag.h:65
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
Header file for the HasSIMDMult type trait.
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the Unique class template.
Header file for the submatrix trait.
Check< false > Unchecked
Type of the blaze::unchecked instance.blaze::Unchecked is the type of the blaze::unchecked instance...
Definition: Check.h:96
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:131
Header file for the reset shim.
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
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
Header file for the HasMutableDataAccess type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the IsReference type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
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:490
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
BLAZE_ALWAYS_INLINE MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:169
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:789
Flag for unaligned vectors and matrices.
Definition: AlignmentFlag.h:64
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3081
Header file for the alignment check function.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:254
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
#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:1375
Header file for the IsUpper type trait.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the IsHermitian type trait.
Header file for the IsRestricted type trait.
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the IsExpression type trait class.
Constraint on the data type.
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:801