35 #ifndef _BLAZE_MATH_VIEWS_SUBMATRIX_DENSE_H_ 36 #define _BLAZE_MATH_VIEWS_SUBMATRIX_DENSE_H_ 131 template<
typename MT
133 class Submatrix<MT,
unaligned,false,true,CSAs...>
134 :
public View< DenseMatrix< Submatrix<MT,unaligned,false,true,CSAs...>, false > >
135 ,
private SubmatrixData<CSAs...>
139 using DataType = SubmatrixData<CSAs...>;
140 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
145 template<
typename MT1,
typename MT2 >
146 static constexpr
bool EnforceEvaluation_v =
147 ( IsRestricted_v<MT1> && RequiresEvaluation_v<MT2> );
155 using BaseType = DenseMatrix<This,false>;
156 using ViewedType = MT;
161 using SIMDType = SIMDTrait_t<ElementType>;
172 using ConstPointer = ConstPointer_t<MT>;
175 using Pointer = If_t< IsConst_v<MT> || !HasMutableDataAccess_v<MT>, ConstPointer, Pointer_t<MT> >;
181 template<
typename IteratorType >
182 class SubmatrixIterator
187 using IteratorCategory =
typename std::iterator_traits<IteratorType>::iterator_category;
190 using ValueType =
typename std::iterator_traits<IteratorType>::value_type;
193 using PointerType =
typename std::iterator_traits<IteratorType>::pointer;
196 using ReferenceType =
typename std::iterator_traits<IteratorType>::reference;
199 using DifferenceType =
typename std::iterator_traits<IteratorType>::difference_type;
202 using iterator_category = IteratorCategory;
203 using value_type = ValueType;
204 using pointer = PointerType;
205 using reference = ReferenceType;
206 using difference_type = DifferenceType;
212 inline SubmatrixIterator()
214 , isAligned_( false )
224 inline SubmatrixIterator( IteratorType iterator,
bool isMemoryAligned )
225 : iterator_ ( iterator )
226 , isAligned_( isMemoryAligned )
235 template<
typename IteratorType2 >
236 inline SubmatrixIterator(
const SubmatrixIterator<IteratorType2>& it )
237 : iterator_ ( it.base() )
238 , isAligned_( it.isAligned() )
248 inline SubmatrixIterator&
operator+=(
size_t inc ) {
260 inline SubmatrixIterator&
operator-=(
size_t dec ) {
271 inline SubmatrixIterator& operator++() {
282 inline const SubmatrixIterator operator++(
int ) {
283 return SubmatrixIterator( iterator_++, isAligned_ );
292 inline SubmatrixIterator& operator--() {
303 inline const SubmatrixIterator operator--(
int ) {
304 return SubmatrixIterator( iterator_--, isAligned_ );
323 inline IteratorType operator->()
const {
338 inline SIMDType load() const noexcept {
356 inline SIMDType
loada() const noexcept {
357 return iterator_.loada();
371 inline SIMDType
loadu() const noexcept {
372 return iterator_.loadu();
387 inline void store(
const SIMDType& value )
const {
408 inline void storea(
const SIMDType& value )
const {
409 iterator_.storea( value );
424 inline void storeu(
const SIMDType& value )
const {
425 iterator_.storeu( value );
440 inline void stream(
const SIMDType& value )
const {
441 iterator_.stream( value );
451 inline bool operator==(
const SubmatrixIterator& rhs )
const {
452 return iterator_ == rhs.iterator_;
462 inline bool operator!=(
const SubmatrixIterator& rhs )
const {
463 return iterator_ != rhs.iterator_;
473 inline bool operator<(
const SubmatrixIterator& rhs )
const {
474 return iterator_ < rhs.iterator_;
484 inline bool operator>(
const SubmatrixIterator& rhs )
const {
485 return iterator_ > rhs.iterator_;
495 inline bool operator<=(
const SubmatrixIterator& rhs )
const {
496 return iterator_ <= rhs.iterator_;
506 inline bool operator>=(
const SubmatrixIterator& rhs )
const {
507 return iterator_ >= rhs.iterator_;
517 inline DifferenceType
operator-(
const SubmatrixIterator& rhs )
const {
518 return iterator_ - rhs.iterator_;
529 friend inline const SubmatrixIterator
operator+(
const SubmatrixIterator& it,
size_t inc ) {
530 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
541 friend inline const SubmatrixIterator
operator+(
size_t inc,
const SubmatrixIterator& it ) {
542 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
553 friend inline const SubmatrixIterator
operator-(
const SubmatrixIterator& it,
size_t dec ) {
554 return SubmatrixIterator( it.iterator_ - dec, it.isAligned_ );
563 inline IteratorType base()
const {
573 inline bool isAligned() const noexcept {
580 IteratorType iterator_;
588 using ConstIterator = SubmatrixIterator< ConstIterator_t<MT> >;
596 static constexpr
bool simdEnabled = MT::simdEnabled;
605 template<
typename... RSAs >
606 explicit inline Submatrix( MT& matrix, RSAs... args );
608 Submatrix(
const Submatrix& ) =
default;
615 ~Submatrix() =
default;
622 inline Reference operator()(
size_t i,
size_t j );
624 inline Reference at(
size_t i,
size_t j );
626 inline Pointer
data () noexcept;
627 inline ConstPointer
data () const noexcept;
628 inline Pointer
data (
size_t i ) noexcept;
629 inline ConstPointer
data (
size_t i ) const noexcept;
642 inline Submatrix& operator=( const
ElementType& rhs );
643 inline Submatrix& operator=( initializer_list< initializer_list<
ElementType> > list );
644 inline Submatrix& operator=( const Submatrix& rhs );
646 template< typename MT2,
bool SO2 >
647 inline Submatrix& operator=( const Matrix<MT2,SO2>& rhs );
649 template< typename MT2,
bool SO2 >
650 inline auto operator+=( const Matrix<MT2,SO2>& rhs )
651 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
653 template< typename MT2,
bool SO2 >
654 inline auto operator+=( const Matrix<MT2,SO2>& rhs )
655 ->
EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
657 template< typename MT2,
bool SO2 >
658 inline auto operator-=( const Matrix<MT2,SO2>& rhs )
659 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
661 template< typename MT2,
bool SO2 >
662 inline auto operator-=( const Matrix<MT2,SO2>& rhs )
663 ->
EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
665 template< typename MT2,
bool SO2 >
666 inline auto operator%=( const Matrix<MT2,SO2>& rhs )
667 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
669 template< typename MT2,
bool SO2 >
670 inline auto operator%=( const Matrix<MT2,SO2>& rhs )
671 ->
EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
680 using DataType::
rows;
683 inline MT& operand() noexcept;
684 inline const MT& operand() const noexcept;
686 inline
size_t spacing() const noexcept;
687 inline
size_t capacity() const noexcept;
688 inline
size_t capacity(
size_t i ) const noexcept;
690 inline
size_t nonZeros(
size_t i ) const;
692 inline
void reset(
size_t i );
702 template< typename Other > inline Submatrix& scale( const Other& scalar );
709 template< typename MT2 >
710 static constexpr
bool VectorizedAssign_v =
711 ( useOptimizedKernels &&
712 simdEnabled && MT2::simdEnabled &&
718 template< typename MT2 >
719 static constexpr
bool VectorizedAddAssign_v =
720 ( useOptimizedKernels &&
721 simdEnabled && MT2::simdEnabled &&
729 template< typename MT2 >
730 static constexpr
bool VectorizedSubAssign_v =
731 ( useOptimizedKernels &&
732 simdEnabled && MT2::simdEnabled &&
740 template< typename MT2 >
741 static constexpr
bool VectorizedSchurAssign_v =
742 ( useOptimizedKernels &&
743 simdEnabled && MT2::simdEnabled &&
757 template< typename Other >
758 inline
bool canAlias( const Other* alias ) const noexcept;
760 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
761 inline
bool canAlias( const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias ) const noexcept;
763 template< typename Other >
764 inline
bool isAliased( const Other* alias ) const noexcept;
766 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
767 inline
bool isAliased( const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias ) const noexcept;
769 inline
bool isAligned () const noexcept;
770 inline
bool canSMPAssign() const noexcept;
781 template< typename MT2 >
782 inline auto assign( const DenseMatrix<MT2,false>& rhs ) ->
DisableIf_t< VectorizedAssign_v<MT2> >;
784 template< typename MT2 >
785 inline auto assign( const DenseMatrix<MT2,false>& rhs ) ->
EnableIf_t< VectorizedAssign_v<MT2> >;
787 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,true>& rhs );
788 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
789 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
791 template< typename MT2 >
792 inline auto addAssign( const DenseMatrix<MT2,false>& rhs ) ->
DisableIf_t< VectorizedAddAssign_v<MT2> >;
794 template< typename MT2 >
795 inline auto addAssign( const DenseMatrix<MT2,false>& rhs ) ->
EnableIf_t< VectorizedAddAssign_v<MT2> >;
797 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,true>& rhs );
798 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
799 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
801 template< typename MT2 >
802 inline auto subAssign( const DenseMatrix<MT2,false>& rhs ) ->
DisableIf_t< VectorizedSubAssign_v<MT2> >;
804 template< typename MT2 >
805 inline auto subAssign( const DenseMatrix<MT2,false>& rhs ) ->
EnableIf_t< VectorizedSubAssign_v<MT2> >;
807 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,true>& rhs );
808 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
809 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
811 template< typename MT2 >
812 inline auto schurAssign( const DenseMatrix<MT2,false>& rhs ) ->
DisableIf_t< VectorizedSchurAssign_v<MT2> >;
814 template< typename MT2 >
815 inline auto schurAssign( const DenseMatrix<MT2,false>& rhs ) ->
EnableIf_t< VectorizedSchurAssign_v<MT2> >;
817 template< typename MT2 > inline
void schurAssign( const DenseMatrix<MT2,true>& rhs );
818 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,false>& rhs );
819 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,true>& rhs );
827 inline
bool hasOverlap() const noexcept;
835 const
bool isAligned_;
846 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
bool DF2,
size_t... CSAs2 > friend class Submatrix;
884 template< typename MT
886 template< typename... RSAs >
887 inline Submatrix<MT,
unaligned,false,true,CSAs...>::Submatrix( MT& matrix, RSAs... args )
888 : DataType ( args... )
892 (
rows() < 2UL || ( matrix.
spacing() &
size_t(-SIMDSIZE) ) == 0UL ) )
927 template<
typename MT
930 Submatrix<MT,unaligned,false,true,CSAs...>::operator()(
size_t i,
size_t j )
952 template<
typename MT
955 Submatrix<MT,unaligned,false,true,CSAs...>::operator()(
size_t i,
size_t j )
const 960 return const_cast<const MT&
>( matrix_ )(
row()+i,
column()+j);
978 template<
typename MT
981 Submatrix<MT,unaligned,false,true,CSAs...>::at(
size_t i,
size_t j )
1007 template<
typename MT
1010 Submatrix<MT,unaligned,false,true,CSAs...>::at(
size_t i,
size_t j )
const 1018 return (*
this)(i,j);
1034 template<
typename MT
1036 inline typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::Pointer
1055 template<
typename MT
1057 inline typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::ConstPointer
1075 template<
typename MT
1077 inline typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::Pointer
1095 template<
typename MT
1097 inline typename Submatrix<MT,
unaligned,
false,
true,CSAs...>::ConstPointer
1118 template<
typename MT
1142 template<
typename MT
1166 template<
typename MT
1190 template<
typename MT
1214 template<
typename MT
1238 template<
typename MT
1269 template<
typename MT
1271 inline Submatrix<MT,
unaligned,
false,
true,CSAs...>&
1272 Submatrix<MT,unaligned,false,true,CSAs...>::operator=(
const ElementType& rhs )
1274 const size_t iend(
row() +
rows() );
1275 decltype(
auto) left( derestrict( matrix_ ) );
1277 for(
size_t i=
row(); i<iend; ++i )
1279 const size_t jbegin( ( IsUpper_v<MT> )
1280 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
1284 const size_t jend ( ( IsLower_v<MT> )
1285 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
1290 for(
size_t j=jbegin; j<jend; ++j ) {
1291 if( !IsRestricted_v<MT> || IsTriangular_v<MT> || trySet( matrix_, i, j, rhs ) )
1318 template<
typename MT
1320 inline Submatrix<MT,
unaligned,
false,
true,CSAs...>&
1321 Submatrix<MT,unaligned,false,true,CSAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
1323 if( list.size() !=
rows() ) {
1327 if( IsRestricted_v<MT> ) {
1328 const InitializerMatrix<ElementType> tmp( list,
columns() );
1329 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
1334 decltype(
auto) left( derestrict( *this ) );
1337 for( const auto& rowList : list ) {
1338 std::fill( std::copy( rowList.begin(), rowList.end(), left.begin(i) ), left.end(i),
ElementType() );
1363 template<
typename MT
1365 inline Submatrix<MT,
unaligned,
false,
true,CSAs...>&
1366 Submatrix<MT,unaligned,false,true,CSAs...>::operator=(
const Submatrix& rhs )
1371 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ &&
row() == rhs.row() &&
column() == rhs.column() ) )
1374 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
1378 if( !tryAssign( matrix_, rhs,
row(),
column() ) ) {
1382 decltype(
auto) left( derestrict( *this ) );
1384 if( rhs.canAlias( &matrix_ ) ) {
1415 template<
typename MT
1417 template<
typename MT2
1419 inline Submatrix<MT,
unaligned,
false,
true,CSAs...>&
1420 Submatrix<MT,unaligned,false,true,CSAs...>::operator=(
const Matrix<MT2,SO2>& rhs )
1428 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<MT2>,
const MT2& >;
1429 Right right( ~rhs );
1431 if( !tryAssign( matrix_, right,
row(),
column() ) ) {
1435 decltype(
auto) left( derestrict( *this ) );
1438 const ResultType_t<MT2> tmp( right );
1439 if( IsSparseMatrix_v<MT2> )
1444 if( IsSparseMatrix_v<MT2> )
1471 template<
typename MT
1473 template<
typename MT2
1476 -> DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
1482 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
1491 if( !tryAddAssign( matrix_, ~rhs,
row(),
column() ) ) {
1495 decltype(
auto) left( derestrict( *this ) );
1498 (~rhs).canAlias( &matrix_ ) ) {
1499 const AddType tmp( *
this + (~rhs) );
1528 template<
typename MT
1530 template<
typename MT2
1533 -> EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
1539 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
1548 const AddType tmp( *
this + (~rhs) );
1550 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
1554 decltype(
auto) left( derestrict( *this ) );
1580 template< typename MT
1582 template< typename MT2
1584 inline auto Submatrix<MT,
unaligned,false,true,CSAs...>::operator-=( const Matrix<MT2,SO2>& rhs )
1585 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
1591 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
1600 if( !trySubAssign( matrix_, ~rhs,
row(),
column() ) ) {
1604 decltype(
auto) left( derestrict( *this ) );
1607 (~rhs).canAlias( &matrix_ ) ) {
1608 const SubType tmp( *
this - (~rhs ) );
1637 template<
typename MT
1639 template<
typename MT2
1642 -> EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
1648 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
1657 const SubType tmp( *
this - (~rhs) );
1659 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
1663 decltype(
auto) left( derestrict( *this ) );
1689 template< typename MT
1691 template< typename MT2
1693 inline auto Submatrix<MT,
unaligned,false,true,CSAs...>::operator%=( const Matrix<MT2,SO2>& rhs )
1694 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
1700 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
1708 if( !trySchurAssign( matrix_, ~rhs,
row(),
column() ) ) {
1712 decltype(
auto) left( derestrict( *this ) );
1715 (~rhs).canAlias( &matrix_ ) ) {
1716 const SchurType tmp( *
this % (~rhs) );
1717 if( IsSparseMatrix_v<SchurType> )
1747 template<
typename MT
1749 template<
typename MT2
1751 inline auto Submatrix<MT,unaligned,false,true,CSAs...>::operator%=(
const Matrix<MT2,SO2>& rhs )
1752 -> EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
1758 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
1766 const SchurType tmp( *
this % (~rhs) );
1768 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
1772 decltype(
auto) left( derestrict( *this ) );
1802 template<
typename MT
1804 inline MT& Submatrix<MT,unaligned,false,true,CSAs...>::operand() noexcept
1818 template<
typename MT
1820 inline const MT& Submatrix<MT,unaligned,false,true,CSAs...>::operand() const noexcept
1839 template<
typename MT
1843 return matrix_.spacing();
1855 template<
typename MT
1877 template<
typename MT
1897 template<
typename MT
1901 const size_t iend(
row() +
rows() );
1903 size_t nonzeros( 0UL );
1905 for(
size_t i=
row(); i<iend; ++i )
1906 for(
size_t j=
column(); j<jend; ++j )
1928 template<
typename MT
1935 size_t nonzeros( 0UL );
1937 for(
size_t j=
column(); j<jend; ++j )
1953 template<
typename MT
1961 const size_t jbegin( ( IsUpper_v<MT> )
1962 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
1966 const size_t jend ( ( IsLower_v<MT> )
1967 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
1972 for(
size_t j=jbegin; j<jend; ++j )
1973 clear( matrix_(i,j) );
1992 template<
typename MT
2000 const size_t jbegin( ( IsUpper_v<MT> )
2001 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
2005 const size_t jend ( ( IsLower_v<MT> )
2006 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
2011 for(
size_t j=jbegin; j<jend; ++j )
2028 template<
typename MT
2030 inline bool Submatrix<MT,unaligned,false,true,CSAs...>::hasOverlap() const noexcept
2068 template<
typename MT
2070 inline Submatrix<MT,
unaligned,
false,
true,CSAs...>&
2081 decltype(
auto) left( derestrict( *this ) );
2110 template< typename MT
2112 inline Submatrix<MT,
unaligned,false,true,CSAs...>&
2123 decltype(
auto) left( derestrict( *this ) );
2147 template< typename MT
2149 template< typename Other >
2150 inline Submatrix<MT,
unaligned,false,true,CSAs...>&
2151 Submatrix<MT,
unaligned,false,true,CSAs...>::scale( const Other& scalar )
2155 const size_t iend(
row() +
rows() );
2157 for(
size_t i=
row(); i<iend; ++i )
2159 const size_t jbegin( ( IsUpper_v<MT> )
2160 ?( ( IsStrictlyUpper_v<MT> )
2164 const size_t jend ( ( IsLower_v<MT> )
2165 ?( ( IsStrictlyLower_v<MT> )
2170 for(
size_t j=jbegin; j<jend; ++j )
2171 matrix_(i,j) *= scalar;
2199 template<
typename MT
2201 template<
typename Other >
2202 inline bool Submatrix<MT,unaligned,false,true,CSAs...>::canAlias(
const Other* alias )
const noexcept
2204 return matrix_.isAliased( alias );
2221 template<
typename MT
2223 template<
typename MT2
2228 Submatrix<MT,unaligned,false,true,CSAs...>::canAlias(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
2230 return ( matrix_.isAliased( &alias->matrix_ ) &&
2231 (
row() +
rows() > alias->row() ) &&
2232 (
row() < alias->row() + alias->rows() ) &&
2234 (
column() < alias->column() + alias->columns() ) );
2251 template<
typename MT
2253 template<
typename Other >
2254 inline bool Submatrix<MT,unaligned,false,true,CSAs...>::isAliased(
const Other* alias )
const noexcept
2256 return matrix_.isAliased( alias );
2273 template<
typename MT
2275 template<
typename MT2
2280 Submatrix<MT,unaligned,false,true,CSAs...>::isAliased(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
2282 return ( matrix_.isAliased( &alias->matrix_ ) &&
2283 (
row() +
rows() > alias->row() ) &&
2284 (
row() < alias->row() + alias->rows() ) &&
2286 (
column() < alias->column() + alias->columns() ) );
2302 template<
typename MT
2304 inline bool Submatrix<MT,unaligned,false,true,CSAs...>::isAligned() const noexcept
2323 template<
typename MT
2325 inline bool Submatrix<MT,unaligned,false,true,CSAs...>::canSMPAssign() const noexcept
2327 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
2349 template<
typename MT
2352 Submatrix<MT,unaligned,false,true,CSAs...>::load(
size_t i,
size_t j )
const noexcept
2355 return loada( i, j );
2357 return loadu( i, j );
2379 template<
typename MT
2391 return matrix_.loada(
row()+i,
column()+j );
2413 template<
typename MT
2425 return matrix_.loadu(
row()+i,
column()+j );
2448 template<
typename MT
2451 Submatrix<MT,unaligned,false,true,CSAs...>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
2479 template<
typename MT
2491 matrix_.storea(
row()+i,
column()+j, value );
2514 template<
typename MT
2526 matrix_.storeu(
row()+i,
column()+j, value );
2549 template<
typename MT
2562 matrix_.stream(
row()+i,
column()+j, value );
2564 matrix_.storeu(
row()+i,
column()+j, value );
2582 template<
typename MT
2584 template<
typename MT2 >
2585 inline auto Submatrix<MT,unaligned,false,true,CSAs...>::assign(
const DenseMatrix<MT2,false>& rhs )
2586 -> DisableIf_t< VectorizedAssign_v<MT2> >
2591 const size_t jpos(
columns() &
size_t(-2) );
2594 for(
size_t i=0UL; i<
rows(); ++i ) {
2595 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2596 matrix_(
row()+i,
column()+j ) = (~rhs)(i,j );
2597 matrix_(
row()+i,
column()+j+1UL) = (~rhs)(i,j+1UL);
2600 matrix_(
row()+i,
column()+jpos) = (~rhs)(i,jpos);
2620 template<
typename MT
2622 template<
typename MT2 >
2623 inline auto Submatrix<MT,unaligned,false,true,CSAs...>::assign(
const DenseMatrix<MT2,false>& rhs )
2624 -> EnableIf_t< VectorizedAssign_v<MT2> >
2631 const size_t jpos(
columns() &
size_t(-SIMDSIZE) );
2634 if( useStreaming && isAligned_ &&
2636 !(~rhs).isAliased( &matrix_ ) )
2638 for(
size_t i=0UL; i<
rows(); ++i )
2642 ConstIterator_t<MT2> right( (~rhs).
begin(i) );
2644 for( ; j<jpos; j+=SIMDSIZE ) {
2645 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2654 for(
size_t i=0UL; i<
rows(); ++i )
2658 ConstIterator_t<MT2> right( (~rhs).
begin(i) );
2660 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2661 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2662 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2663 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2664 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2666 for( ; j<jpos; j+=SIMDSIZE ) {
2667 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2670 *left = *right; ++left; ++right;
2691 template<
typename MT
2693 template<
typename MT2 >
2694 inline void Submatrix<MT,unaligned,false,true,CSAs...>::assign(
const DenseMatrix<MT2,true>& rhs )
2701 constexpr
size_t block( BLOCK_SIZE );
2703 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
2704 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
2705 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
2706 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
2707 for(
size_t i=ii; i<iend; ++i ) {
2708 for(
size_t j=jj; j<jend; ++j ) {
2709 matrix_(
row()+i,
column()+j) = (~rhs)(i,j);
2731 template<
typename MT
2733 template<
typename MT2 >
2734 inline void Submatrix<MT,unaligned,false,true,CSAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
2739 for(
size_t i=0UL; i<
rows(); ++i )
2740 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
2741 matrix_(
row()+i,
column()+element->index()) = element->value();
2759 template<
typename MT
2761 template<
typename MT2 >
2762 inline void Submatrix<MT,unaligned,false,true,CSAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
2769 for(
size_t j=0UL; j<
columns(); ++j )
2770 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
2771 matrix_(
row()+element->index(),
column()+j) = element->value();
2789 template<
typename MT
2791 template<
typename MT2 >
2792 inline auto Submatrix<MT,unaligned,false,true,CSAs...>::addAssign(
const DenseMatrix<MT2,false>& rhs )
2793 -> DisableIf_t< VectorizedAddAssign_v<MT2> >
2798 const size_t jpos(
columns() &
size_t(-2) );
2801 for(
size_t i=0UL; i<
rows(); ++i )
2803 if( IsDiagonal_v<MT2> ) {
2804 matrix_(
row()+i,
column()+i) += (~rhs)(i,i);
2807 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2808 matrix_(
row()+i,
column()+j ) += (~rhs)(i,j );
2809 matrix_(
row()+i,
column()+j+1UL) += (~rhs)(i,j+1UL);
2812 matrix_(
row()+i,
column()+jpos) += (~rhs)(i,jpos);
2833 template<
typename MT
2835 template<
typename MT2 >
2836 inline auto Submatrix<MT,unaligned,false,true,CSAs...>::addAssign(
const DenseMatrix<MT2,false>& rhs )
2837 -> EnableIf_t< VectorizedAddAssign_v<MT2> >
2844 for(
size_t i=0UL; i<
rows(); ++i )
2846 const size_t jbegin( ( IsUpper_v<MT2> )
2847 ?( ( IsStrictlyUpper_v<MT2> ? i+1UL : i ) &
size_t(-SIMDSIZE) )
2849 const size_t jend ( ( IsLower_v<MT2> )
2850 ?( IsStrictlyLower_v<MT2> ? i : i+1UL )
2854 const size_t jpos( jend &
size_t(-SIMDSIZE) );
2859 ConstIterator_t<MT2> right( (~rhs).
begin(i) + jbegin );
2861 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2862 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2863 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2864 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2865 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2867 for( ; j<jpos; j+=SIMDSIZE ) {
2868 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2870 for( ; j<jend; ++j ) {
2871 *left += *right; ++left; ++right;
2891 template<
typename MT
2893 template<
typename MT2 >
2894 inline void Submatrix<MT,unaligned,false,true,CSAs...>::addAssign(
const DenseMatrix<MT2,true>& rhs )
2901 constexpr
size_t block( BLOCK_SIZE );
2903 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
2904 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
2905 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
2906 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
2907 for(
size_t i=ii; i<iend; ++i ) {
2908 for(
size_t j=jj; j<jend; ++j ) {
2909 matrix_(
row()+i,
column()+j) += (~rhs)(i,j);
2931 template<
typename MT
2933 template<
typename MT2 >
2934 inline void Submatrix<MT,unaligned,false,true,CSAs...>::addAssign(
const SparseMatrix<MT2,false>& rhs )
2939 for(
size_t i=0UL; i<
rows(); ++i )
2940 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
2941 matrix_(
row()+i,
column()+element->index()) += element->value();
2959 template<
typename MT
2961 template<
typename MT2 >
2962 inline void Submatrix<MT,unaligned,false,true,CSAs...>::addAssign(
const SparseMatrix<MT2,true>& rhs )
2969 for(
size_t j=0UL; j<
columns(); ++j )
2970 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
2971 matrix_(
row()+element->index(),
column()+j) += element->value();
2989 template<
typename MT
2991 template<
typename MT2 >
2992 inline auto Submatrix<MT,unaligned,false,true,CSAs...>::subAssign(
const DenseMatrix<MT2,false>& rhs )
2993 -> DisableIf_t< VectorizedSubAssign_v<MT2> >
2998 const size_t jpos(
columns() &
size_t(-2) );
3001 for(
size_t i=0UL; i<
rows(); ++i )
3003 if( IsDiagonal_v<MT2> ) {
3004 matrix_(
row()+i,
column()+i) -= (~rhs)(i,i);
3007 for(
size_t j=0UL; j<jpos; j+=2UL ) {
3008 matrix_(
row()+i,
column()+j ) -= (~rhs)(i,j );
3009 matrix_(
row()+i,
column()+j+1UL) -= (~rhs)(i,j+1UL);
3012 matrix_(
row()+i,
column()+jpos) -= (~rhs)(i,jpos);
3033 template<
typename MT
3035 template<
typename MT2 >
3036 inline auto Submatrix<MT,unaligned,false,true,CSAs...>::subAssign(
const DenseMatrix<MT2,false>& rhs )
3037 -> EnableIf_t< VectorizedSubAssign_v<MT2> >
3044 for(
size_t i=0UL; i<
rows(); ++i )
3046 const size_t jbegin( ( IsUpper_v<MT2> )
3047 ?( ( IsStrictlyUpper_v<MT2> ? i+1UL : i ) &
size_t(-SIMDSIZE) )
3049 const size_t jend ( ( IsLower_v<MT2> )
3050 ?( IsStrictlyLower_v<MT2> ? i : i+1UL )
3054 const size_t jpos( jend &
size_t(-SIMDSIZE) );
3059 ConstIterator_t<MT2> right( (~rhs).
begin(i) + jbegin );
3061 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
3062 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3063 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3064 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3065 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3067 for( ; j<jpos; j+=SIMDSIZE ) {
3068 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3070 for( ; j<jend; ++j ) {
3071 *left -= *right; ++left; ++right;
3091 template<
typename MT
3093 template<
typename MT2 >
3094 inline void Submatrix<MT,unaligned,false,true,CSAs...>::subAssign(
const DenseMatrix<MT2,true>& rhs )
3101 constexpr
size_t block( BLOCK_SIZE );
3103 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
3104 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
3105 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
3106 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
3107 for(
size_t i=ii; i<iend; ++i ) {
3108 for(
size_t j=jj; j<jend; ++j ) {
3109 matrix_(
row()+i,
column()+j) -= (~rhs)(i,j);
3131 template<
typename MT
3133 template<
typename MT2 >
3134 inline void Submatrix<MT,unaligned,false,true,CSAs...>::subAssign(
const SparseMatrix<MT2,false>& rhs )
3139 for(
size_t i=0UL; i<
rows(); ++i )
3140 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
3141 matrix_(
row()+i,
column()+element->index()) -= element->value();
3159 template<
typename MT
3161 template<
typename MT2 >
3162 inline void Submatrix<MT,unaligned,false,true,CSAs...>::subAssign(
const SparseMatrix<MT2,true>& rhs )
3169 for(
size_t j=0UL; j<
columns(); ++j )
3170 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
3171 matrix_(
row()+element->index(),
column()+j) -= element->value();
3189 template<
typename MT
3191 template<
typename MT2 >
3192 inline auto Submatrix<MT,unaligned,false,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,false>& rhs )
3193 -> DisableIf_t< VectorizedSchurAssign_v<MT2> >
3198 const size_t jpos(
columns() &
size_t(-2) );
3201 for(
size_t i=0UL; i<
rows(); ++i ) {
3202 for(
size_t j=0UL; j<jpos; j+=2UL ) {
3203 matrix_(
row()+i,
column()+j ) *= (~rhs)(i,j );
3204 matrix_(
row()+i,
column()+j+1UL) *= (~rhs)(i,j+1UL);
3207 matrix_(
row()+i,
column()+jpos) *= (~rhs)(i,jpos);
3227 template<
typename MT
3229 template<
typename MT2 >
3230 inline auto Submatrix<MT,unaligned,false,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,false>& rhs )
3231 -> EnableIf_t< VectorizedSchurAssign_v<MT2> >
3238 for(
size_t i=0UL; i<
rows(); ++i )
3240 const size_t jpos(
columns() &
size_t(-SIMDSIZE) );
3245 ConstIterator_t<MT2> right( (~rhs).
begin(i) );
3247 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
3248 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3249 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3250 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3251 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3253 for( ; j<jpos; j+=SIMDSIZE ) {
3254 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3257 *left *= *right; ++left; ++right;
3277 template<
typename MT
3279 template<
typename MT2 >
3280 inline void Submatrix<MT,unaligned,false,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,true>& rhs )
3287 constexpr
size_t block( BLOCK_SIZE );
3289 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
3290 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
3291 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
3292 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
3293 for(
size_t i=ii; i<iend; ++i ) {
3294 for(
size_t j=jj; j<jend; ++j ) {
3295 matrix_(
row()+i,
column()+j) *= (~rhs)(i,j);
3317 template<
typename MT
3319 template<
typename MT2 >
3320 inline void Submatrix<MT,unaligned,false,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,false>& rhs )
3327 for(
size_t i=0UL; i<
rows(); ++i )
3331 for( ConstIterator_t<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
3332 for( ; j<element->index(); ++j )
3334 matrix_(
row()+i,
column()+j) *= element->value();
3359 template<
typename MT
3361 template<
typename MT2 >
3362 inline void Submatrix<MT,unaligned,false,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,true>& rhs )
3371 for(
size_t j=0UL; j<
columns(); ++j )
3375 for( ConstIterator_t<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
3376 for( ; i<element->index(); ++i )
3378 matrix_(
row()+i,
column()+j) *= element->value();
3382 for( ; i<
rows(); ++i ) {
3411 template<
typename MT
3413 class Submatrix<MT,
unaligned,true,true,CSAs...>
3414 :
public View< DenseMatrix< Submatrix<MT,unaligned,true,true,CSAs...>, true > >
3415 ,
private SubmatrixData<CSAs...>
3419 using DataType = SubmatrixData<CSAs...>;
3420 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
3425 template<
typename MT1,
typename MT2 >
3426 static constexpr
bool EnforceEvaluation_v =
3427 ( IsRestricted_v<MT1> && RequiresEvaluation_v<MT2> );
3435 using BaseType = DenseMatrix<This,true>;
3436 using ViewedType = MT;
3441 using SIMDType = SIMDTrait_t<ElementType>;
3452 using ConstPointer = ConstPointer_t<MT>;
3455 using Pointer = If_t< IsConst_v<MT> || !HasMutableDataAccess_v<MT>, ConstPointer, Pointer_t<MT> >;
3461 template<
typename IteratorType >
3462 class SubmatrixIterator
3467 using IteratorCategory =
typename std::iterator_traits<IteratorType>::iterator_category;
3470 using ValueType =
typename std::iterator_traits<IteratorType>::value_type;
3473 using PointerType =
typename std::iterator_traits<IteratorType>::pointer;
3476 using ReferenceType =
typename std::iterator_traits<IteratorType>::reference;
3479 using DifferenceType =
typename std::iterator_traits<IteratorType>::difference_type;
3482 using iterator_category = IteratorCategory;
3483 using value_type = ValueType;
3484 using pointer = PointerType;
3485 using reference = ReferenceType;
3486 using difference_type = DifferenceType;
3492 inline SubmatrixIterator()
3494 , isAligned_( false )
3506 inline SubmatrixIterator( IteratorType iterator,
bool isMemoryAligned )
3507 : iterator_ ( iterator )
3508 , isAligned_( isMemoryAligned )
3517 template<
typename IteratorType2 >
3518 inline SubmatrixIterator(
const SubmatrixIterator<IteratorType2>& it )
3519 : iterator_ ( it.base() )
3520 , isAligned_( it.isAligned() )
3530 inline SubmatrixIterator&
operator+=(
size_t inc ) {
3542 inline SubmatrixIterator&
operator-=(
size_t dec ) {
3553 inline SubmatrixIterator& operator++() {
3564 inline const SubmatrixIterator operator++(
int ) {
3565 return SubmatrixIterator( iterator_++, isAligned_ );
3574 inline SubmatrixIterator& operator--() {
3585 inline const SubmatrixIterator operator--(
int ) {
3586 return SubmatrixIterator( iterator_--, isAligned_ );
3595 inline ReferenceType
operator*()
const {
3605 inline IteratorType operator->()
const {
3620 inline SIMDType load() const noexcept {
3638 inline SIMDType
loada() const noexcept {
3639 return iterator_.loada();
3653 inline SIMDType
loadu() const noexcept {
3654 return iterator_.loadu();
3669 inline void store(
const SIMDType& value )
const {
3690 inline void storea(
const SIMDType& value )
const {
3691 iterator_.storea( value );
3706 inline void storeu(
const SIMDType& value )
const {
3707 iterator_.storeu( value );
3722 inline void stream(
const SIMDType& value )
const {
3723 iterator_.stream( value );
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 bool operator>=(
const SubmatrixIterator& rhs )
const {
3789 return iterator_ >= rhs.iterator_;
3799 inline DifferenceType
operator-(
const SubmatrixIterator& rhs )
const {
3800 return iterator_ - rhs.iterator_;
3811 friend inline const SubmatrixIterator
operator+(
const SubmatrixIterator& it,
size_t inc ) {
3812 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
3823 friend inline const SubmatrixIterator
operator+(
size_t inc,
const SubmatrixIterator& it ) {
3824 return SubmatrixIterator( it.iterator_ + inc, it.isAligned_ );
3835 friend inline const SubmatrixIterator
operator-(
const SubmatrixIterator& it,
size_t dec ) {
3836 return SubmatrixIterator( it.iterator_ - dec, it.isAligned_ );
3845 inline IteratorType base()
const {
3855 inline bool isAligned() const noexcept {
3862 IteratorType iterator_;
3870 using ConstIterator = SubmatrixIterator< ConstIterator_t<MT> >;
3878 static constexpr
bool simdEnabled = MT::simdEnabled;
3887 template<
typename... RSAs >
3888 explicit inline Submatrix( MT& matrix, RSAs... args );
3890 Submatrix(
const Submatrix& ) =
default;
3897 ~Submatrix() =
default;
3904 inline Reference operator()(
size_t i,
size_t j );
3906 inline Reference at(
size_t i,
size_t j );
3908 inline Pointer
data () noexcept;
3909 inline ConstPointer
data () const noexcept;
3910 inline Pointer
data (
size_t j ) noexcept;
3911 inline ConstPointer
data (
size_t j ) const noexcept;
3924 inline Submatrix& operator=( const
ElementType& rhs );
3925 inline Submatrix& operator=( initializer_list< initializer_list<
ElementType> > list );
3926 inline Submatrix& operator=( const Submatrix& rhs );
3928 template< typename MT2,
bool SO >
3929 inline Submatrix& operator=( const Matrix<MT2,SO>& rhs );
3931 template< typename MT2,
bool SO >
3932 inline auto operator+=( const Matrix<MT2,SO>& rhs )
3933 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
3935 template< typename MT2,
bool SO >
3936 inline auto operator+=( const Matrix<MT2,SO>& rhs )
3937 ->
EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
3939 template< typename MT2,
bool SO >
3940 inline auto operator-=( const Matrix<MT2,SO>& rhs )
3941 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
3943 template< typename MT2,
bool SO >
3944 inline auto operator-=( const Matrix<MT2,SO>& rhs )
3945 ->
EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
3947 template< typename MT2,
bool SO >
3948 inline auto operator%=( const Matrix<MT2,SO>& rhs )
3949 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
3951 template< typename MT2,
bool SO >
3952 inline auto operator%=( const Matrix<MT2,SO>& rhs )
3953 ->
EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
3960 using DataType::
row;
3962 using DataType::
rows;
3965 inline MT& operand() noexcept;
3966 inline const MT& operand() const noexcept;
3968 inline
size_t spacing() const noexcept;
3969 inline
size_t capacity() const noexcept;
3970 inline
size_t capacity(
size_t i ) const noexcept;
3972 inline
size_t nonZeros(
size_t i ) const;
3973 inline
void reset();
3974 inline
void reset(
size_t i );
3984 template< typename Other > inline Submatrix& scale( const Other& scalar );
3991 template< typename MT2 >
3992 static constexpr
bool VectorizedAssign_v =
3993 ( useOptimizedKernels &&
3994 simdEnabled && MT2::simdEnabled &&
4000 template< typename MT2 >
4001 static constexpr
bool VectorizedAddAssign_v =
4002 ( useOptimizedKernels &&
4003 simdEnabled && MT2::simdEnabled &&
4011 template< typename MT2 >
4012 static constexpr
bool VectorizedSubAssign_v =
4013 ( useOptimizedKernels &&
4014 simdEnabled && MT2::simdEnabled &&
4022 template< typename MT2 >
4023 static constexpr
bool VectorizedSchurAssign_v =
4024 ( useOptimizedKernels &&
4025 simdEnabled && MT2::simdEnabled &&
4039 template< typename Other >
4040 inline
bool canAlias( const Other* alias ) const noexcept;
4042 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
4043 inline
bool canAlias( const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias ) const noexcept;
4045 template< typename Other >
4046 inline
bool isAliased( const Other* alias ) const noexcept;
4048 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
4049 inline
bool isAliased( const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias ) const noexcept;
4051 inline
bool isAligned () const noexcept;
4052 inline
bool canSMPAssign() const noexcept;
4063 template< typename MT2 >
4064 inline auto assign( const DenseMatrix<MT2,true>& rhs ) ->
DisableIf_t< VectorizedAssign_v<MT2> >;
4066 template< typename MT2 >
4067 inline auto assign( const DenseMatrix<MT2,true>& rhs ) ->
EnableIf_t< VectorizedAssign_v<MT2> >;
4069 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,false>& rhs );
4070 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
4071 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
4073 template< typename MT2 >
4074 inline auto addAssign( const DenseMatrix<MT2,true>& rhs ) ->
DisableIf_t< VectorizedAddAssign_v<MT2> >;
4076 template< typename MT2 >
4077 inline auto addAssign( const DenseMatrix<MT2,true>& rhs ) ->
EnableIf_t< VectorizedAddAssign_v<MT2> >;
4079 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,false>& rhs );
4080 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
4081 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
4083 template< typename MT2 >
4084 inline auto subAssign( const DenseMatrix<MT2,true>& rhs ) ->
DisableIf_t< VectorizedSubAssign_v<MT2> >;
4086 template< typename MT2 >
4087 inline auto subAssign( const DenseMatrix<MT2,true>& rhs ) ->
EnableIf_t< VectorizedSubAssign_v<MT2> >;
4089 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,false>& rhs );
4090 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
4091 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
4093 template< typename MT2 >
4094 inline auto schurAssign( const DenseMatrix<MT2,true>& rhs ) ->
DisableIf_t< VectorizedSchurAssign_v<MT2> >;
4096 template< typename MT2 >
4097 inline auto schurAssign( const DenseMatrix<MT2,true>& rhs ) ->
EnableIf_t< VectorizedSchurAssign_v<MT2> >;
4099 template< typename MT2 > inline
void schurAssign( const DenseMatrix<MT2,false>& rhs );
4100 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,true>& rhs );
4101 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,false>& rhs );
4109 inline
bool hasOverlap() const noexcept;
4117 const
bool isAligned_;
4128 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
bool DF2,
size_t... CSAs2 > friend class Submatrix;
4166 template< typename MT
4168 template< typename... RSAs >
4169 inline Submatrix<MT,
unaligned,true,true,CSAs...>::Submatrix( MT& matrix, RSAs... args )
4170 : DataType ( args... )
4171 , matrix_ ( matrix )
4174 (
columns() < 2UL || ( matrix.
spacing() &
size_t(-SIMDSIZE) ) == 0UL ) )
4209 template<
typename MT
4212 Submatrix<MT,unaligned,true,true,CSAs...>::operator()(
size_t i,
size_t j )
4234 template<
typename MT
4237 Submatrix<MT,unaligned,true,true,CSAs...>::operator()(
size_t i,
size_t j )
const 4242 return const_cast<const MT&
>( matrix_ )(
row()+i,
column()+j);
4260 template<
typename MT
4263 Submatrix<MT,unaligned,true,true,CSAs...>::at(
size_t i,
size_t j )
4271 return (*
this)(i,j);
4289 template<
typename MT
4292 Submatrix<MT,unaligned,true,true,CSAs...>::at(
size_t i,
size_t j )
const 4300 return (*
this)(i,j);
4316 template<
typename MT
4318 inline typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::Pointer
4337 template<
typename MT
4339 inline typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::ConstPointer
4357 template<
typename MT
4359 inline typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::Pointer
4377 template<
typename MT
4379 inline typename Submatrix<MT,
unaligned,
true,
true,CSAs...>::ConstPointer
4395 template<
typename MT
4414 template<
typename MT
4433 template<
typename MT
4452 template<
typename MT
4471 template<
typename MT
4490 template<
typename MT
4521 template<
typename MT
4523 inline Submatrix<MT,
unaligned,
true,
true,CSAs...>&
4524 Submatrix<MT,unaligned,true,true,CSAs...>::operator=(
const ElementType& rhs )
4527 decltype(
auto) left( derestrict( matrix_ ) );
4529 for(
size_t j=
column(); j<jend; ++j )
4531 const size_t ibegin( ( IsLower_v<MT> )
4532 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
4536 const size_t iend ( ( IsUpper_v<MT> )
4537 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
4542 for(
size_t i=ibegin; i<iend; ++i ) {
4543 if( !IsRestricted_v<MT> || IsTriangular_v<MT> || trySet( matrix_, i, j, rhs ) )
4570 template<
typename MT
4572 inline Submatrix<MT,
unaligned,
true,
true,CSAs...>&
4573 Submatrix<MT,unaligned,true,true,CSAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
4577 if( list.size() !=
rows() ) {
4581 if( IsRestricted_v<MT> ) {
4582 const InitializerMatrix<ElementType> tmp( list,
columns() );
4583 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
4588 decltype(
auto) left( derestrict( *this ) );
4591 for( const auto& rowList : list ) {
4593 for(
const auto& element : rowList ) {
4594 left(i,j) = element;
4624 template<
typename MT
4626 inline Submatrix<MT,
unaligned,
true,
true,CSAs...>&
4627 Submatrix<MT,unaligned,true,true,CSAs...>::operator=(
const Submatrix& rhs )
4632 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ &&
row() == rhs.row() &&
column() == rhs.column() ) )
4635 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
4639 if( !tryAssign( matrix_, rhs,
row(),
column() ) ) {
4643 decltype(
auto) left( derestrict( *this ) );
4645 if( rhs.canAlias( &matrix_ ) ) {
4676 template<
typename MT
4678 template<
typename MT2
4680 inline Submatrix<MT,
unaligned,
true,
true,CSAs...>&
4681 Submatrix<MT,unaligned,true,true,CSAs...>::operator=(
const Matrix<MT2,SO>& rhs )
4689 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<MT2>,
const MT2& >;
4690 Right right( ~rhs );
4692 if( !tryAssign( matrix_, right,
row(),
column() ) ) {
4696 decltype(
auto) left( derestrict( *this ) );
4699 const ResultType_t<MT2> tmp( right );
4700 if( IsSparseMatrix_v<MT2> )
4705 if( IsSparseMatrix_v<MT2> )
4732 template<
typename MT
4734 template<
typename MT2
4737 -> DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
4743 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
4752 if( !tryAddAssign( matrix_, ~rhs,
row(),
column() ) ) {
4756 decltype(
auto) left( derestrict( *this ) );
4759 (~rhs).canAlias( &matrix_ ) ) {
4760 const AddType tmp( *
this + (~rhs) );
4789 template<
typename MT
4791 template<
typename MT2
4794 -> EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
4800 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
4809 const AddType tmp( *
this + (~rhs) );
4811 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
4815 decltype(
auto) left( derestrict( *this ) );
4841 template< typename MT
4843 template< typename MT2
4845 inline auto Submatrix<MT,
unaligned,true,true,CSAs...>::operator-=( const Matrix<MT2,SO>& rhs )
4846 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
4852 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
4861 if( !trySubAssign( matrix_, ~rhs,
row(),
column() ) ) {
4865 decltype(
auto) left( derestrict( *this ) );
4868 (~rhs).canAlias( &matrix_ ) ) {
4869 const SubType tmp( *
this - (~rhs ) );
4898 template<
typename MT
4900 template<
typename MT2
4903 -> EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
4909 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
4918 const SubType tmp( *
this - (~rhs) );
4920 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
4924 decltype(
auto) left( derestrict( *this ) );
4950 template< typename MT
4952 template< typename MT2
4954 inline auto Submatrix<MT,
unaligned,true,true,CSAs...>::operator%=( const Matrix<MT2,SO>& rhs )
4955 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
4961 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
4969 if( !trySchurAssign( matrix_, ~rhs,
row(),
column() ) ) {
4973 decltype(
auto) left( derestrict( *this ) );
4976 (~rhs).canAlias( &matrix_ ) ) {
4977 const SchurType tmp( *
this % (~rhs) );
4978 if( IsSparseMatrix_v<SchurType> )
5008 template<
typename MT
5010 template<
typename MT2
5012 inline auto Submatrix<MT,unaligned,true,true,CSAs...>::operator%=(
const Matrix<MT2,SO>& rhs )
5013 -> EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
5019 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
5027 const SchurType tmp( *
this % (~rhs) );
5029 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
5033 decltype(
auto) left( derestrict( *this ) );
5063 template<
typename MT
5065 inline MT& Submatrix<MT,unaligned,true,true,CSAs...>::operand() noexcept
5079 template<
typename MT
5081 inline const MT& Submatrix<MT,unaligned,true,true,CSAs...>::operand() const noexcept
5098 template<
typename MT
5102 return matrix_.spacing();
5114 template<
typename MT
5131 template<
typename MT
5151 template<
typename MT
5155 const size_t iend(
row() +
rows() );
5157 size_t nonzeros( 0UL );
5159 for(
size_t j=
column(); j<jend; ++j )
5160 for(
size_t i=
row(); i<iend; ++i )
5177 template<
typename MT
5183 const size_t iend(
row() +
rows() );
5184 size_t nonzeros( 0UL );
5186 for(
size_t i=
row(); i<iend; ++i )
5202 template<
typename MT
5210 const size_t ibegin( ( IsLower_v<MT> )
5211 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
5215 const size_t iend ( ( IsUpper_v<MT> )
5216 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
5221 for(
size_t i=ibegin; i<iend; ++i )
5222 clear( matrix_(i,j) );
5236 template<
typename MT
5244 const size_t ibegin( ( IsLower_v<MT> )
5245 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
5249 const size_t iend ( ( IsUpper_v<MT> )
5250 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
5255 for(
size_t i=ibegin; i<iend; ++i )
5272 template<
typename MT
5274 inline bool Submatrix<MT,unaligned,true,true,CSAs...>::hasOverlap() const noexcept
5312 template<
typename MT
5314 inline Submatrix<MT,
unaligned,
true,
true,CSAs...>&
5325 decltype(
auto) left( derestrict( *this ) );
5354 template< typename MT
5356 inline Submatrix<MT,
unaligned,true,true,CSAs...>&
5367 decltype(
auto) left( derestrict( *this ) );
5391 template< typename MT
5393 template< typename Other >
5394 inline Submatrix<MT,
unaligned,true,true,CSAs...>&
5395 Submatrix<MT,
unaligned,true,true,CSAs...>::scale( const Other& scalar )
5401 for(
size_t j=
column(); j<jend; ++j )
5403 const size_t ibegin( ( IsLower_v<MT> )
5404 ?( ( IsStrictlyLower_v<MT> )
5408 const size_t iend ( ( IsUpper_v<MT> )
5409 ?( ( IsStrictlyUpper_v<MT> )
5414 for(
size_t i=ibegin; i<iend; ++i )
5415 matrix_(i,j) *= scalar;
5443 template<
typename MT
5445 template<
typename Other >
5446 inline bool Submatrix<MT,unaligned,true,true,CSAs...>::canAlias(
const Other* alias )
const noexcept
5448 return matrix_.isAliased( alias );
5465 template<
typename MT
5467 template<
typename MT2
5472 Submatrix<MT,unaligned,true,true,CSAs...>::canAlias(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
5474 return ( matrix_.isAliased( &alias->matrix_ ) &&
5475 (
row() +
rows() > alias->row() ) &&
5476 (
row() < alias->row() + alias->rows() ) &&
5478 (
column() < alias->column() + alias->columns() ) );
5495 template<
typename MT
5497 template<
typename Other >
5498 inline bool Submatrix<MT,unaligned,true,true,CSAs...>::isAliased(
const Other* alias )
const noexcept
5500 return matrix_.isAliased( alias );
5517 template<
typename MT
5519 template<
typename MT2
5524 Submatrix<MT,unaligned,true,true,CSAs...>::isAliased(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
5526 return ( matrix_.isAliased( &alias->matrix_ ) &&
5527 (
row() +
rows() > alias->row() ) &&
5528 (
row() < alias->row() + alias->rows() ) &&
5530 (
column() < alias->column() + alias->columns() ) );
5546 template<
typename MT
5548 inline bool Submatrix<MT,unaligned,true,true,CSAs...>::isAligned() const noexcept
5567 template<
typename MT
5569 inline bool Submatrix<MT,unaligned,true,true,CSAs...>::canSMPAssign() const noexcept
5571 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
5592 template<
typename MT
5595 Submatrix<MT,unaligned,true,true,CSAs...>::load(
size_t i,
size_t j )
const noexcept
5598 return loada( i, j );
5600 return loadu( i, j );
5621 template<
typename MT
5633 return matrix_.loada(
row()+i,
column()+j );
5654 template<
typename MT
5666 return matrix_.loadu(
row()+i,
column()+j );
5688 template<
typename MT
5691 Submatrix<MT,unaligned,true,true,CSAs...>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
5718 template<
typename MT
5730 matrix_.storea(
row()+i,
column()+j, value );
5752 template<
typename MT
5764 matrix_.storeu(
row()+i,
column()+j, value );
5787 template<
typename MT
5800 matrix_.stream(
row()+i,
column()+j, value );
5802 matrix_.storeu(
row()+i,
column()+j, value );
5820 template<
typename MT
5822 template<
typename MT2 >
5823 inline auto Submatrix<MT,unaligned,true,true,CSAs...>::assign(
const DenseMatrix<MT2,true>& rhs )
5824 -> DisableIf_t< VectorizedAssign_v<MT2> >
5829 const size_t ipos(
rows() &
size_t(-2) );
5832 for(
size_t j=0UL; j<
columns(); ++j ) {
5833 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5834 matrix_(
row()+i ,
column()+j) = (~rhs)(i ,j);
5835 matrix_(
row()+i+1UL,
column()+j) = (~rhs)(i+1UL,j);
5837 if( ipos <
rows() ) {
5838 matrix_(
row()+ipos,
column()+j) = (~rhs)(ipos,j);
5858 template<
typename MT
5860 template<
typename MT2 >
5861 inline auto Submatrix<MT,unaligned,true,true,CSAs...>::assign(
const DenseMatrix<MT2,true>& rhs )
5862 -> EnableIf_t< VectorizedAssign_v<MT2> >
5869 const size_t ipos(
rows() &
size_t(-SIMDSIZE) );
5872 if( useStreaming && isAligned_ &&
5874 !(~rhs).isAliased( &matrix_ ) )
5876 for(
size_t j=0UL; j<
columns(); ++j )
5880 ConstIterator_t<MT2> right( (~rhs).
begin(j) );
5882 for( ; i<ipos; i+=SIMDSIZE ) {
5883 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5885 for( ; i<
rows(); ++i ) {
5886 *left = *right; ++left; ++right;
5892 for(
size_t j=0UL; j<
columns(); ++j )
5896 ConstIterator_t<MT2> right( (~rhs).
begin(j) );
5898 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5899 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5900 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5901 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5902 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5904 for( ; i<ipos; i+=SIMDSIZE ) {
5905 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5907 for( ; i<
rows(); ++i ) {
5908 *left = *right; ++left; ++right;
5929 template<
typename MT
5931 template<
typename MT2 >
5932 inline void Submatrix<MT,unaligned,true,true,CSAs...>::assign(
const DenseMatrix<MT2,false>& rhs )
5939 constexpr
size_t block( BLOCK_SIZE );
5941 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
5942 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
5943 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
5944 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
5945 for(
size_t j=jj; j<jend; ++j ) {
5946 for(
size_t i=ii; i<iend; ++i ) {
5947 matrix_(
row()+i,
column()+j) = (~rhs)(i,j);
5969 template<
typename MT
5971 template<
typename MT2 >
5972 inline void Submatrix<MT,unaligned,true,true,CSAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
5977 for(
size_t j=0UL; j<
columns(); ++j )
5978 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
5979 matrix_(
row()+element->index(),
column()+j) = element->value();
5997 template<
typename MT
5999 template<
typename MT2 >
6000 inline void Submatrix<MT,unaligned,true,true,CSAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
6007 for(
size_t i=0UL; i<
rows(); ++i )
6008 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
6009 matrix_(
row()+i,
column()+element->index()) = element->value();
6027 template<
typename MT
6029 template<
typename MT2 >
6030 inline auto Submatrix<MT,unaligned,true,true,CSAs...>::addAssign(
const DenseMatrix<MT2,true>& rhs )
6031 -> DisableIf_t< VectorizedAddAssign_v<MT2> >
6036 const size_t ipos(
rows() &
size_t(-2) );
6039 for(
size_t j=0UL; j<
columns(); ++j )
6041 if( IsDiagonal_v<MT2> ) {
6042 matrix_(
row()+j,
column()+j) += (~rhs)(j,j);
6045 for(
size_t i=0UL; i<ipos; i+=2UL ) {
6046 matrix_(
row()+i ,
column()+j) += (~rhs)(i ,j);
6047 matrix_(
row()+i+1UL,
column()+j) += (~rhs)(i+1UL,j);
6049 if( ipos <
rows() ) {
6050 matrix_(
row()+ipos,
column()+j) += (~rhs)(ipos,j);
6071 template<
typename MT
6073 template<
typename MT2 >
6074 inline auto Submatrix<MT,unaligned,true,true,CSAs...>::addAssign(
const DenseMatrix<MT2,true>& rhs )
6075 -> EnableIf_t< VectorizedAddAssign_v<MT2> >
6082 for(
size_t j=0UL; j<
columns(); ++j )
6084 const size_t ibegin( ( IsLower_v<MT> )
6085 ?( ( IsStrictlyLower_v<MT> ? j+1UL : j ) &
size_t(-SIMDSIZE) )
6087 const size_t iend ( ( IsUpper_v<MT> )
6088 ?( IsStrictlyUpper_v<MT> ? j : j+1UL )
6092 const size_t ipos( iend &
size_t(-SIMDSIZE) );
6097 ConstIterator_t<MT2> right( (~rhs).
begin(j) + ibegin );
6099 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
6100 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6101 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6102 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6103 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6105 for( ; i<ipos; i+=SIMDSIZE ) {
6106 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6108 for( ; i<iend; ++i ) {
6109 *left += *right; ++left; ++right;
6129 template<
typename MT
6131 template<
typename MT2 >
6132 inline void Submatrix<MT,unaligned,true,true,CSAs...>::addAssign(
const DenseMatrix<MT2,false>& rhs )
6139 constexpr
size_t block( BLOCK_SIZE );
6141 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
6142 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
6143 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
6144 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
6145 for(
size_t j=jj; j<jend; ++j ) {
6146 for(
size_t i=ii; i<iend; ++i ) {
6147 matrix_(
row()+i,
column()+j) += (~rhs)(i,j);
6169 template<
typename MT
6171 template<
typename MT2 >
6172 inline void Submatrix<MT,unaligned,true,true,CSAs...>::addAssign(
const SparseMatrix<MT2,true>& rhs )
6177 for(
size_t j=0UL; j<
columns(); ++j )
6178 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
6179 matrix_(
row()+element->index(),
column()+j) += element->value();
6197 template<
typename MT
6199 template<
typename MT2 >
6200 inline void Submatrix<MT,unaligned,true,true,CSAs...>::addAssign(
const SparseMatrix<MT2,false>& rhs )
6207 for(
size_t i=0UL; i<
rows(); ++i )
6208 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
6209 matrix_(
row()+i,
column()+element->index()) += element->value();
6227 template<
typename MT
6229 template<
typename MT2 >
6230 inline auto Submatrix<MT,unaligned,true,true,CSAs...>::subAssign(
const DenseMatrix<MT2,true>& rhs )
6231 -> DisableIf_t< VectorizedSubAssign_v<MT2> >
6236 const size_t ipos(
rows() &
size_t(-2) );
6239 for(
size_t j=0UL; j<
columns(); ++j )
6241 if( IsDiagonal_v<MT2> ) {
6242 matrix_(
row()+j,
column()+j) -= (~rhs)(j,j);
6245 for(
size_t i=0UL; i<ipos; i+=2UL ) {
6246 matrix_(
row()+i ,
column()+j) -= (~rhs)(i ,j);
6247 matrix_(
row()+i+1UL,
column()+j) -= (~rhs)(i+1UL,j);
6249 if( ipos <
rows() ) {
6250 matrix_(
row()+ipos,
column()+j) -= (~rhs)(ipos,j);
6271 template<
typename MT
6273 template<
typename MT2 >
6274 inline auto Submatrix<MT,unaligned,true,true,CSAs...>::subAssign(
const DenseMatrix<MT2,true>& rhs )
6275 -> EnableIf_t< VectorizedSubAssign_v<MT2> >
6282 for(
size_t j=0UL; j<
columns(); ++j )
6284 const size_t ibegin( ( IsLower_v<MT> )
6285 ?( ( IsStrictlyLower_v<MT> ? j+1UL : j ) &
size_t(-SIMDSIZE) )
6287 const size_t iend ( ( IsUpper_v<MT> )
6288 ?( IsStrictlyUpper_v<MT> ? j : j+1UL )
6292 const size_t ipos( iend &
size_t(-SIMDSIZE) );
6297 ConstIterator_t<MT2> right( (~rhs).
begin(j) + ibegin );
6299 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
6300 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6301 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6302 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6303 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6305 for( ; i<ipos; i+=SIMDSIZE ) {
6306 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6308 for( ; i<iend; ++i ) {
6309 *left -= *right; ++left; ++right;
6329 template<
typename MT
6331 template<
typename MT2 >
6332 inline void Submatrix<MT,unaligned,true,true,CSAs...>::subAssign(
const DenseMatrix<MT2,false>& rhs )
6339 constexpr
size_t block( BLOCK_SIZE );
6341 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
6342 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
6343 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
6344 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
6345 for(
size_t j=jj; j<jend; ++j ) {
6346 for(
size_t i=ii; i<iend; ++i ) {
6347 matrix_(
row()+i,
column()+j) -= (~rhs)(i,j);
6369 template<
typename MT
6371 template<
typename MT2 >
6372 inline void Submatrix<MT,unaligned,true,true,CSAs...>::subAssign(
const SparseMatrix<MT2,true>& rhs )
6377 for(
size_t j=0UL; j<
columns(); ++j )
6378 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
6379 matrix_(
row()+element->index(),
column()+j) -= element->value();
6397 template<
typename MT
6399 template<
typename MT2 >
6400 inline void Submatrix<MT,unaligned,true,true,CSAs...>::subAssign(
const SparseMatrix<MT2,false>& rhs )
6407 for(
size_t i=0UL; i<
rows(); ++i )
6408 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
6409 matrix_(
row()+i,
column()+element->index()) -= element->value();
6427 template<
typename MT
6429 template<
typename MT2 >
6430 inline auto Submatrix<MT,unaligned,true,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,true>& rhs )
6431 -> DisableIf_t< VectorizedSchurAssign_v<MT2> >
6436 const size_t ipos(
rows() &
size_t(-2) );
6439 for(
size_t j=0UL; j<
columns(); ++j ) {
6440 for(
size_t i=0UL; i<ipos; i+=2UL ) {
6441 matrix_(
row()+i ,
column()+j) *= (~rhs)(i ,j);
6442 matrix_(
row()+i+1UL,
column()+j) *= (~rhs)(i+1UL,j);
6444 if( ipos <
rows() ) {
6445 matrix_(
row()+ipos,
column()+j) *= (~rhs)(ipos,j);
6466 template<
typename MT
6468 template<
typename MT2 >
6469 inline auto Submatrix<MT,unaligned,true,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,true>& rhs )
6470 -> EnableIf_t< VectorizedSchurAssign_v<MT2> >
6477 for(
size_t j=0UL; j<
columns(); ++j )
6479 const size_t ipos(
rows() &
size_t(-SIMDSIZE) );
6484 ConstIterator_t<MT2> right( (~rhs).
begin(j) );
6486 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
6487 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6488 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6489 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6490 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6492 for( ; i<ipos; i+=SIMDSIZE ) {
6493 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6495 for( ; i<
rows(); ++i ) {
6496 *left *= *right; ++left; ++right;
6516 template<
typename MT
6518 template<
typename MT2 >
6519 inline void Submatrix<MT,unaligned,true,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,false>& rhs )
6526 constexpr
size_t block( BLOCK_SIZE );
6528 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
6529 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
6530 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
6531 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
6532 for(
size_t j=jj; j<jend; ++j ) {
6533 for(
size_t i=ii; i<iend; ++i ) {
6534 matrix_(
row()+i,
column()+j) *= (~rhs)(i,j);
6556 template<
typename MT
6558 template<
typename MT2 >
6559 inline void Submatrix<MT,unaligned,true,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,true>& rhs )
6566 for(
size_t j=0UL; j<
columns(); ++j )
6570 for( ConstIterator_t<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
6571 for( ; i<element->index(); ++i )
6573 matrix_(
row()+i,
column()+j) *= element->value();
6577 for( ; i<
rows(); ++i ) {
6598 template<
typename MT
6600 template<
typename MT2 >
6601 inline void Submatrix<MT,unaligned,true,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,false>& rhs )
6610 for(
size_t i=0UL; i<
rows(); ++i )
6614 for( ConstIterator_t<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
6615 for( ; j<element->index(); ++j )
6617 matrix_(
row()+i,
column()+j) *= element->value();
6650 template<
typename MT
6652 class Submatrix<MT,
aligned,false,true,CSAs...>
6653 :
public View< DenseMatrix< Submatrix<MT,aligned,false,true,CSAs...>, false > >
6654 ,
private SubmatrixData<CSAs...>
6658 using DataType = SubmatrixData<CSAs...>;
6659 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
6664 template<
typename MT1,
typename MT2 >
6665 static constexpr
bool EnforceEvaluation_v =
6666 ( IsRestricted_v<MT1> && RequiresEvaluation_v<MT2> );
6672 using This = Submatrix<MT,
aligned,
false,
true,CSAs...>;
6674 using BaseType = DenseMatrix<This,false>;
6675 using ViewedType = MT;
6680 using SIMDType = SIMDTrait_t<ElementType>;
6691 using ConstPointer = ConstPointer_t<MT>;
6694 using Pointer = If_t< IsConst_v<MT> || !HasMutableDataAccess_v<MT>, ConstPointer, Pointer_t<MT> >;
6705 static constexpr
bool simdEnabled = MT::simdEnabled;
6714 template<
typename... RSAs >
6715 explicit inline Submatrix( MT& matrix, RSAs... args );
6717 Submatrix(
const Submatrix& ) =
default;
6724 ~Submatrix() =
default;
6731 inline Reference operator()(
size_t i,
size_t j );
6733 inline Reference at(
size_t i,
size_t j );
6735 inline Pointer
data () noexcept;
6736 inline ConstPointer
data () const noexcept;
6737 inline Pointer
data (
size_t i ) noexcept;
6738 inline ConstPointer
data (
size_t i ) const noexcept;
6751 inline Submatrix& operator=( const
ElementType& rhs );
6752 inline Submatrix& operator=( initializer_list< initializer_list<
ElementType> > list );
6753 inline Submatrix& operator=( const Submatrix& rhs );
6755 template< typename MT2,
bool SO >
6756 inline Submatrix& operator=( const Matrix<MT2,SO>& rhs );
6758 template< typename MT2,
bool SO >
6759 inline auto operator+=( const Matrix<MT2,SO>& rhs )
6760 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
6762 template< typename MT2,
bool SO >
6763 inline auto operator+=( const Matrix<MT2,SO>& rhs )
6764 ->
EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
6766 template< typename MT2,
bool SO >
6767 inline auto operator-=( const Matrix<MT2,SO>& rhs )
6768 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
6770 template< typename MT2,
bool SO >
6771 inline auto operator-=( const Matrix<MT2,SO>& rhs )
6772 ->
EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
6774 template< typename MT2,
bool SO >
6775 inline auto operator%=( const Matrix<MT2,SO>& rhs )
6776 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
6778 template< typename MT2,
bool SO >
6779 inline auto operator%=( const Matrix<MT2,SO>& rhs )
6780 ->
EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
6787 using DataType::
row;
6789 using DataType::
rows;
6792 inline MT& operand() noexcept;
6793 inline const MT& operand() const noexcept;
6795 inline
size_t spacing() const noexcept;
6796 inline
size_t capacity() const noexcept;
6797 inline
size_t capacity(
size_t i ) const noexcept;
6799 inline
size_t nonZeros(
size_t i ) const;
6800 inline
void reset();
6801 inline
void reset(
size_t i );
6811 template< typename Other > inline Submatrix& scale( const Other& scalar );
6818 template< typename MT2 >
6819 static constexpr
bool VectorizedAssign_v =
6820 ( useOptimizedKernels &&
6821 simdEnabled && MT2::simdEnabled &&
6827 template< typename MT2 >
6828 static constexpr
bool VectorizedAddAssign_v =
6829 ( useOptimizedKernels &&
6830 simdEnabled && MT2::simdEnabled &&
6838 template< typename MT2 >
6839 static constexpr
bool VectorizedSubAssign_v =
6840 ( useOptimizedKernels &&
6841 simdEnabled && MT2::simdEnabled &&
6849 template< typename MT2 >
6850 static constexpr
bool VectorizedSchurAssign_v =
6851 ( useOptimizedKernels &&
6852 simdEnabled && MT2::simdEnabled &&
6866 template< typename Other >
6867 inline
bool canAlias( const Other* alias ) const noexcept;
6869 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
6870 inline
bool canAlias( const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias ) const noexcept;
6872 template< typename Other >
6873 inline
bool isAliased( const Other* alias ) const noexcept;
6875 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
6876 inline
bool isAliased( const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias ) const noexcept;
6878 inline
bool isAligned () const noexcept;
6879 inline
bool canSMPAssign() const noexcept;
6890 template< typename MT2 >
6891 inline auto assign( const DenseMatrix<MT2,false>& rhs ) ->
DisableIf_t< VectorizedAssign_v<MT2> >;
6893 template< typename MT2 >
6894 inline auto assign( const DenseMatrix<MT2,false>& rhs ) ->
EnableIf_t< VectorizedAssign_v<MT2> >;
6896 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,true>& rhs );
6897 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
6898 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
6900 template< typename MT2 >
6901 inline auto addAssign( const DenseMatrix<MT2,false>& rhs ) ->
DisableIf_t< VectorizedAddAssign_v<MT2> >;
6903 template< typename MT2 >
6904 inline auto addAssign( const DenseMatrix<MT2,false>& rhs ) ->
EnableIf_t< VectorizedAddAssign_v<MT2> >;
6906 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,true>& rhs );
6907 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
6908 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
6910 template< typename MT2 >
6911 inline auto subAssign( const DenseMatrix<MT2,false>& rhs ) ->
DisableIf_t< VectorizedSubAssign_v<MT2> >;
6913 template< typename MT2 >
6914 inline auto subAssign( const DenseMatrix<MT2,false>& rhs ) ->
EnableIf_t< VectorizedSubAssign_v<MT2> >;
6916 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,true>& rhs );
6917 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
6918 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
6920 template< typename MT2 >
6921 inline auto schurAssign( const DenseMatrix<MT2,false>& rhs ) ->
DisableIf_t< VectorizedSchurAssign_v<MT2> >;
6923 template< typename MT2 >
6924 inline auto schurAssign( const DenseMatrix<MT2,false>& rhs ) ->
EnableIf_t< VectorizedSchurAssign_v<MT2> >;
6926 template< typename MT2 > inline
void schurAssign( const DenseMatrix<MT2,true>& rhs );
6927 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,false>& rhs );
6928 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,true>& rhs );
6936 inline
bool hasOverlap() const noexcept;
6948 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
bool DF2,
size_t... CSAs2 > friend class Submatrix;
6986 template< typename MT
6988 template< typename... RSAs >
6989 inline Submatrix<MT,
aligned,false,true,CSAs...>::Submatrix( MT& matrix, RSAs... args )
6990 : DataType( args... )
6991 , matrix_ ( matrix )
6999 if( simdEnabled && IsContiguous_v<MT> &&
7001 (
rows() > 1UL && matrix_.spacing() % SIMDSIZE != 0UL ) ) ) {
7011 BLAZE_USER_ASSERT( !simdEnabled || !IsContiguous_v<MT> ||
rows() <= 1UL || matrix_.spacing() % SIMDSIZE == 0UL,
"Invalid submatrix alignment" );
7037 template<
typename MT
7040 Submatrix<MT,aligned,false,true,CSAs...>::operator()(
size_t i,
size_t j )
7062 template<
typename MT
7065 Submatrix<MT,aligned,false,true,CSAs...>::operator()(
size_t i,
size_t j )
const 7070 return const_cast<const MT&
>( matrix_ )(
row()+i,
column()+j);
7088 template<
typename MT
7091 Submatrix<MT,aligned,false,true,CSAs...>::at(
size_t i,
size_t j )
7099 return (*
this)(i,j);
7117 template<
typename MT
7120 Submatrix<MT,aligned,false,true,CSAs...>::at(
size_t i,
size_t j )
const 7128 return (*
this)(i,j);
7144 template<
typename MT
7146 inline typename Submatrix<MT,
aligned,
false,
true,CSAs...>::Pointer
7165 template<
typename MT
7167 inline typename Submatrix<MT,
aligned,
false,
true,CSAs...>::ConstPointer
7185 template<
typename MT
7187 inline typename Submatrix<MT,
aligned,
false,
true,CSAs...>::Pointer
7205 template<
typename MT
7207 inline typename Submatrix<MT,
aligned,
false,
true,CSAs...>::ConstPointer
7228 template<
typename MT
7234 return ( matrix_.begin(
row() + i ) +
column() );
7252 template<
typename MT
7258 return ( matrix_.cbegin(
row() + i ) +
column() );
7276 template<
typename MT
7282 return ( matrix_.cbegin(
row() + i ) +
column() );
7300 template<
typename MT
7324 template<
typename MT
7348 template<
typename MT
7379 template<
typename MT
7381 inline Submatrix<MT,
aligned,
false,
true,CSAs...>&
7382 Submatrix<MT,aligned,false,true,CSAs...>::operator=(
const ElementType& rhs )
7384 const size_t iend(
row() +
rows() );
7385 decltype(
auto) left( derestrict( matrix_ ) );
7387 for(
size_t i=
row(); i<iend; ++i )
7389 const size_t jbegin( ( IsUpper_v<MT> )
7390 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
7394 const size_t jend ( ( IsLower_v<MT> )
7395 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
7400 for(
size_t j=jbegin; j<jend; ++j ) {
7401 if( !IsRestricted_v<MT> || IsTriangular_v<MT> || trySet( matrix_, i, j, rhs ) )
7428 template<
typename MT
7430 inline Submatrix<MT,
aligned,
false,
true,CSAs...>&
7431 Submatrix<MT,aligned,false,true,CSAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
7433 if( list.size() !=
rows() ) {
7437 if( IsRestricted_v<MT> ) {
7438 const InitializerMatrix<ElementType> tmp( list,
columns() );
7439 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
7444 decltype(
auto) left( derestrict( *this ) );
7447 for( const auto& rowList : list ) {
7448 std::fill( std::copy( rowList.begin(), rowList.end(), left.begin(i) ), left.end(i),
ElementType() );
7473 template<
typename MT
7475 inline Submatrix<MT,
aligned,
false,
true,CSAs...>&
7476 Submatrix<MT,aligned,false,true,CSAs...>::operator=(
const Submatrix& rhs )
7481 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ &&
row() == rhs.row() &&
column() == rhs.column() ) )
7484 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
7488 if( !tryAssign( matrix_, rhs,
row(),
column() ) ) {
7492 decltype(
auto) left( derestrict( *this ) );
7494 if( rhs.canAlias( &matrix_ ) ) {
7525 template<
typename MT
7527 template<
typename MT2
7529 inline Submatrix<MT,
aligned,
false,
true,CSAs...>&
7530 Submatrix<MT,aligned,false,true,CSAs...>::operator=(
const Matrix<MT2,SO>& rhs )
7538 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<MT2>,
const MT2& >;
7539 Right right( ~rhs );
7541 if( !tryAssign( matrix_, right,
row(),
column() ) ) {
7545 decltype(
auto) left( derestrict( *this ) );
7548 const ResultType_t<MT2> tmp( right );
7549 if( IsSparseMatrix_v<MT2> )
7554 if( IsSparseMatrix_v<MT2> )
7581 template<
typename MT
7583 template<
typename MT2
7586 -> DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
7592 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
7601 if( !tryAddAssign( matrix_, ~rhs,
row(),
column() ) ) {
7605 decltype(
auto) left( derestrict( *this ) );
7608 (~rhs).canAlias( &matrix_ ) ) {
7609 const AddType tmp( *
this + (~rhs) );
7638 template<
typename MT
7640 template<
typename MT2
7643 -> EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
7649 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
7658 const AddType tmp( *
this + (~rhs) );
7660 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
7664 decltype(
auto) left( derestrict( *this ) );
7690 template< typename MT
7692 template< typename MT2
7694 inline auto Submatrix<MT,
aligned,false,true,CSAs...>::operator-=( const Matrix<MT2,SO>& rhs )
7695 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
7701 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
7710 if( !trySubAssign( matrix_, ~rhs,
row(),
column() ) ) {
7714 decltype(
auto) left( derestrict( *this ) );
7717 (~rhs).canAlias( &matrix_ ) ) {
7718 const SubType tmp( *
this - (~rhs ) );
7747 template<
typename MT
7749 template<
typename MT2
7752 -> EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
7758 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
7767 const SubType tmp( *
this - (~rhs) );
7769 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
7773 decltype(
auto) left( derestrict( *this ) );
7799 template< typename MT
7801 template< typename MT2
7803 inline auto Submatrix<MT,
aligned,false,true,CSAs...>::operator%=( const Matrix<MT2,SO>& rhs )
7804 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
7810 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
7818 if( !trySchurAssign( matrix_, ~rhs,
row(),
column() ) ) {
7822 decltype(
auto) left( derestrict( *this ) );
7825 (~rhs).canAlias( &matrix_ ) ) {
7826 const SchurType tmp( *
this % (~rhs) );
7827 if( IsSparseMatrix_v<SchurType> )
7857 template<
typename MT
7859 template<
typename MT2
7861 inline auto Submatrix<MT,aligned,false,true,CSAs...>::operator%=(
const Matrix<MT2,SO>& rhs )
7862 -> EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
7868 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
7876 const SchurType tmp( *
this % (~rhs) );
7878 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
7882 decltype(
auto) left( derestrict( *this ) );
7912 template<
typename MT
7914 inline MT& Submatrix<MT,aligned,false,true,CSAs...>::operand() noexcept
7928 template<
typename MT
7930 inline const MT& Submatrix<MT,aligned,false,true,CSAs...>::operand() const noexcept
7949 template<
typename MT
7953 return matrix_.spacing();
7965 template<
typename MT
7987 template<
typename MT
8007 template<
typename MT
8011 const size_t iend(
row() +
rows() );
8013 size_t nonzeros( 0UL );
8015 for(
size_t i=
row(); i<iend; ++i )
8016 for(
size_t j=
column(); j<jend; ++j )
8038 template<
typename MT
8045 size_t nonzeros( 0UL );
8047 for(
size_t j=
column(); j<jend; ++j )
8063 template<
typename MT
8071 const size_t jbegin( ( IsUpper_v<MT> )
8072 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
8076 const size_t jend ( ( IsLower_v<MT> )
8077 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
8082 for(
size_t j=jbegin; j<jend; ++j )
8083 clear( matrix_(i,j) );
8102 template<
typename MT
8110 const size_t jbegin( ( IsUpper_v<MT> )
8111 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
8115 const size_t jend ( ( IsLower_v<MT> )
8116 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
8121 for(
size_t j=jbegin; j<jend; ++j )
8138 template<
typename MT
8140 inline bool Submatrix<MT,aligned,false,true,CSAs...>::hasOverlap() const noexcept
8178 template<
typename MT
8180 inline Submatrix<MT,
aligned,
false,
true,CSAs...>&
8191 decltype(
auto) left( derestrict( *this ) );
8220 template< typename MT
8222 inline Submatrix<MT,
aligned,false,true,CSAs...>&
8233 decltype(
auto) left( derestrict( *this ) );
8257 template< typename MT
8259 template< typename Other >
8260 inline Submatrix<MT,
aligned,false,true,CSAs...>&
8261 Submatrix<MT,
aligned,false,true,CSAs...>::scale( const Other& scalar )
8265 const size_t iend(
row() +
rows() );
8267 for(
size_t i=
row(); i<iend; ++i )
8269 const size_t jbegin( ( IsUpper_v<MT> )
8270 ?( ( IsStrictlyUpper_v<MT> )
8274 const size_t jend ( ( IsLower_v<MT> )
8275 ?( ( IsStrictlyLower_v<MT> )
8280 for(
size_t j=jbegin; j<jend; ++j )
8281 matrix_(i,j) *= scalar;
8309 template<
typename MT
8311 template<
typename Other >
8312 inline bool Submatrix<MT,aligned,false,true,CSAs...>::canAlias(
const Other* alias )
const noexcept
8314 return matrix_.isAliased( alias );
8331 template<
typename MT
8333 template<
typename MT2
8338 Submatrix<MT,aligned,false,true,CSAs...>::canAlias(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
8340 return ( matrix_.isAliased( &alias->matrix_ ) &&
8341 (
row() +
rows() > alias->row() ) &&
8342 (
row() < alias->row() + alias->rows() ) &&
8344 (
column() < alias->column() + alias->columns() ) );
8361 template<
typename MT
8363 template<
typename Other >
8364 inline bool Submatrix<MT,aligned,false,true,CSAs...>::isAliased(
const Other* alias )
const noexcept
8366 return matrix_.isAliased( alias );
8383 template<
typename MT
8385 template<
typename MT2
8390 Submatrix<MT,aligned,false,true,CSAs...>::isAliased(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
8392 return ( matrix_.isAliased( &alias->matrix_ ) &&
8393 (
row() +
rows() > alias->row() ) &&
8394 (
row() < alias->row() + alias->rows() ) &&
8396 (
column() < alias->column() + alias->columns() ) );
8412 template<
typename MT
8414 inline bool Submatrix<MT,aligned,false,true,CSAs...>::isAligned() const noexcept
8433 template<
typename MT
8435 inline bool Submatrix<MT,aligned,false,true,CSAs...>::canSMPAssign() const noexcept
8437 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
8459 template<
typename MT
8462 Submatrix<MT,aligned,false,true,CSAs...>::load(
size_t i,
size_t j )
const noexcept
8464 return loada( i, j );
8486 template<
typename MT
8498 return matrix_.loada(
row()+i,
column()+j );
8520 template<
typename MT
8532 return matrix_.loadu(
row()+i,
column()+j );
8555 template<
typename MT
8558 Submatrix<MT,aligned,false,true,CSAs...>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
8560 return storea( i, j, value );
8583 template<
typename MT
8595 return matrix_.storea(
row()+i,
column()+j, value );
8618 template<
typename MT
8630 matrix_.storeu(
row()+i,
column()+j, value );
8654 template<
typename MT
8666 matrix_.stream(
row()+i,
column()+j, value );
8684 template<
typename MT
8686 template<
typename MT2 >
8687 inline auto Submatrix<MT,aligned,false,true,CSAs...>::assign(
const DenseMatrix<MT2,false>& rhs )
8688 -> DisableIf_t< VectorizedAssign_v<MT2> >
8693 const size_t jpos(
columns() &
size_t(-2) );
8696 for(
size_t i=0UL; i<
rows(); ++i ) {
8697 for(
size_t j=0UL; j<jpos; j+=2UL ) {
8698 matrix_(
row()+i,
column()+j ) = (~rhs)(i,j );
8699 matrix_(
row()+i,
column()+j+1UL) = (~rhs)(i,j+1UL);
8702 matrix_(
row()+i,
column()+jpos) = (~rhs)(i,jpos);
8722 template<
typename MT
8724 template<
typename MT2 >
8725 inline auto Submatrix<MT,aligned,false,true,CSAs...>::assign(
const DenseMatrix<MT2,false>& rhs )
8726 -> EnableIf_t< VectorizedAssign_v<MT2> >
8733 const size_t jpos(
columns() &
size_t(-SIMDSIZE) );
8738 !(~rhs).isAliased( &matrix_ ) )
8740 for(
size_t i=0UL; i<
rows(); ++i )
8744 ConstIterator_t<MT2> right( (~rhs).
begin(i) );
8746 for( ; j<jpos; j+=SIMDSIZE ) {
8747 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8750 *left = *right; ++left; ++right;
8756 for(
size_t i=0UL; i<
rows(); ++i )
8760 ConstIterator_t<MT2> right( (~rhs).
begin(i) );
8762 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
8763 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8764 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8765 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8766 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8768 for( ; j<jpos; j+=SIMDSIZE ) {
8769 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8772 *left = *right; ++left; ++right;
8793 template<
typename MT
8795 template<
typename MT2 >
8796 inline void Submatrix<MT,aligned,false,true,CSAs...>::assign(
const DenseMatrix<MT2,true>& rhs )
8803 constexpr
size_t block( BLOCK_SIZE );
8805 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
8806 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
8807 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
8808 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
8809 for(
size_t i=ii; i<iend; ++i ) {
8810 for(
size_t j=jj; j<jend; ++j ) {
8811 matrix_(
row()+i,
column()+j) = (~rhs)(i,j);
8833 template<
typename MT
8835 template<
typename MT2 >
8836 inline void Submatrix<MT,aligned,false,true,CSAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
8841 for(
size_t i=0UL; i<
rows(); ++i )
8842 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
8843 matrix_(
row()+i,
column()+element->index()) = element->value();
8861 template<
typename MT
8863 template<
typename MT2 >
8864 inline void Submatrix<MT,aligned,false,true,CSAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
8871 for(
size_t j=0UL; j<
columns(); ++j )
8872 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
8873 matrix_(
row()+element->index(),
column()+j) = element->value();
8891 template<
typename MT
8893 template<
typename MT2 >
8894 inline auto Submatrix<MT,aligned,false,true,CSAs...>::addAssign(
const DenseMatrix<MT2,false>& rhs )
8895 -> DisableIf_t< VectorizedAddAssign_v<MT2> >
8900 const size_t jpos(
columns() &
size_t(-2) );
8903 for(
size_t i=0UL; i<
rows(); ++i )
8905 if( IsDiagonal_v<MT2> ) {
8906 matrix_(
row()+i,
column()+i) += (~rhs)(i,i);
8909 for(
size_t j=0UL; j<jpos; j+=2UL ) {
8910 matrix_(
row()+i,
column()+j ) += (~rhs)(i,j );
8911 matrix_(
row()+i,
column()+j+1UL) += (~rhs)(i,j+1UL);
8914 matrix_(
row()+i,
column()+jpos) += (~rhs)(i,jpos);
8935 template<
typename MT
8937 template<
typename MT2 >
8938 inline auto Submatrix<MT,aligned,false,true,CSAs...>::addAssign(
const DenseMatrix<MT2,false>& rhs )
8939 -> EnableIf_t< VectorizedAddAssign_v<MT2> >
8946 for(
size_t i=0UL; i<
rows(); ++i )
8948 const size_t jbegin( ( IsUpper_v<MT2> )
8949 ?( ( IsStrictlyUpper_v<MT2> ? i+1UL : i ) &
size_t(-SIMDSIZE) )
8951 const size_t jend ( ( IsLower_v<MT2> )
8952 ?( IsStrictlyLower_v<MT2> ? i : i+1UL )
8956 const size_t jpos( jend &
size_t(-SIMDSIZE) );
8961 ConstIterator_t<MT2> right( (~rhs).
begin(i) + jbegin );
8963 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
8964 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8965 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8966 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8967 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8969 for( ; j<jpos; j+=SIMDSIZE ) {
8970 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
8972 for( ; j<jend; ++j ) {
8973 *left += *right; ++left; ++right;
8993 template<
typename MT
8995 template<
typename MT2 >
8996 inline void Submatrix<MT,aligned,false,true,CSAs...>::addAssign(
const DenseMatrix<MT2,true>& rhs )
9003 constexpr
size_t block( BLOCK_SIZE );
9005 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
9006 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
9007 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
9008 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
9009 for(
size_t i=ii; i<iend; ++i ) {
9010 for(
size_t j=jj; j<jend; ++j ) {
9011 matrix_(
row()+i,
column()+j) += (~rhs)(i,j);
9033 template<
typename MT
9035 template<
typename MT2 >
9036 inline void Submatrix<MT,aligned,false,true,CSAs...>::addAssign(
const SparseMatrix<MT2,false>& rhs )
9041 for(
size_t i=0UL; i<
rows(); ++i )
9042 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
9043 matrix_(
row()+i,
column()+element->index()) += element->value();
9061 template<
typename MT
9063 template<
typename MT2 >
9064 inline void Submatrix<MT,aligned,false,true,CSAs...>::addAssign(
const SparseMatrix<MT2,true>& rhs )
9071 for(
size_t j=0UL; j<
columns(); ++j )
9072 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
9073 matrix_(
row()+element->index(),
column()+j) += element->value();
9091 template<
typename MT
9093 template<
typename MT2 >
9094 inline auto Submatrix<MT,aligned,false,true,CSAs...>::subAssign(
const DenseMatrix<MT2,false>& rhs )
9095 -> DisableIf_t< VectorizedSubAssign_v<MT2> >
9100 const size_t jpos(
columns() &
size_t(-2) );
9103 for(
size_t i=0UL; i<
rows(); ++i )
9105 if( IsDiagonal_v<MT2> ) {
9106 matrix_(
row()+i,
column()+i) -= (~rhs)(i,i);
9109 for(
size_t j=0UL; j<jpos; j+=2UL ) {
9110 matrix_(
row()+i,
column()+j ) -= (~rhs)(i,j );
9111 matrix_(
row()+i,
column()+j+1UL) -= (~rhs)(i,j+1UL);
9114 matrix_(
row()+i,
column()+jpos) -= (~rhs)(i,jpos);
9135 template<
typename MT
9137 template<
typename MT2 >
9138 inline auto Submatrix<MT,aligned,false,true,CSAs...>::subAssign(
const DenseMatrix<MT2,false>& rhs )
9139 -> EnableIf_t< VectorizedSubAssign_v<MT2> >
9146 for(
size_t i=0UL; i<
rows(); ++i )
9148 const size_t jbegin( ( IsUpper_v<MT2> )
9149 ?( ( IsStrictlyUpper_v<MT2> ? i+1UL : i ) &
size_t(-SIMDSIZE) )
9151 const size_t jend ( ( IsLower_v<MT2> )
9152 ?( IsStrictlyLower_v<MT2> ? i : i+1UL )
9156 const size_t jpos( jend &
size_t(-SIMDSIZE) );
9161 ConstIterator_t<MT2> right( (~rhs).
begin(i) + jbegin );
9163 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
9164 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9165 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9166 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9167 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9169 for( ; j<jpos; j+=SIMDSIZE ) {
9170 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9172 for( ; j<jend; ++j ) {
9173 *left -= *right; ++left; ++right;
9193 template<
typename MT
9195 template<
typename MT2 >
9196 inline void Submatrix<MT,aligned,false,true,CSAs...>::subAssign(
const DenseMatrix<MT2,true>& rhs )
9203 constexpr
size_t block( BLOCK_SIZE );
9205 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
9206 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
9207 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
9208 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
9209 for(
size_t i=ii; i<iend; ++i ) {
9210 for(
size_t j=jj; j<jend; ++j ) {
9211 matrix_(
row()+i,
column()+j) -= (~rhs)(i,j);
9233 template<
typename MT
9235 template<
typename MT2 >
9236 inline void Submatrix<MT,aligned,false,true,CSAs...>::subAssign(
const SparseMatrix<MT2,false>& rhs )
9241 for(
size_t i=0UL; i<
rows(); ++i )
9242 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
9243 matrix_(
row()+i,
column()+element->index()) -= element->value();
9261 template<
typename MT
9263 template<
typename MT2 >
9264 inline void Submatrix<MT,aligned,false,true,CSAs...>::subAssign(
const SparseMatrix<MT2,true>& rhs )
9271 for(
size_t j=0UL; j<
columns(); ++j )
9272 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
9273 matrix_(
row()+element->index(),
column()+j) -= element->value();
9291 template<
typename MT
9293 template<
typename MT2 >
9294 inline auto Submatrix<MT,aligned,false,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,false>& rhs )
9295 -> DisableIf_t< VectorizedSchurAssign_v<MT2> >
9300 const size_t jpos(
columns() &
size_t(-2) );
9303 for(
size_t i=0UL; i<
rows(); ++i ) {
9304 for(
size_t j=0UL; j<jpos; j+=2UL ) {
9305 matrix_(
row()+i,
column()+j ) *= (~rhs)(i,j );
9306 matrix_(
row()+i,
column()+j+1UL) *= (~rhs)(i,j+1UL);
9309 matrix_(
row()+i,
column()+jpos) *= (~rhs)(i,jpos);
9329 template<
typename MT
9331 template<
typename MT2 >
9332 inline auto Submatrix<MT,aligned,false,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,false>& rhs )
9333 -> EnableIf_t< VectorizedSchurAssign_v<MT2> >
9340 for(
size_t i=0UL; i<
rows(); ++i )
9342 const size_t jpos(
columns() &
size_t(-SIMDSIZE) );
9347 ConstIterator_t<MT2> right( (~rhs).
begin(i) );
9349 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
9350 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9351 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9352 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9353 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9355 for( ; j<jpos; j+=SIMDSIZE ) {
9356 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
9359 *left *= *right; ++left; ++right;
9379 template<
typename MT
9381 template<
typename MT2 >
9382 inline void Submatrix<MT,aligned,false,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,true>& rhs )
9389 constexpr
size_t block( BLOCK_SIZE );
9391 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
9392 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
9393 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
9394 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
9395 for(
size_t i=ii; i<iend; ++i ) {
9396 for(
size_t j=jj; j<jend; ++j ) {
9397 matrix_(
row()+i,
column()+j) *= (~rhs)(i,j);
9419 template<
typename MT
9421 template<
typename MT2 >
9422 inline void Submatrix<MT,aligned,false,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,false>& rhs )
9429 for(
size_t i=0UL; i<
rows(); ++i )
9433 for( ConstIterator_t<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
9434 for( ; j<element->index(); ++j )
9436 matrix_(
row()+i,
column()+j) *= element->value();
9461 template<
typename MT
9463 template<
typename MT2 >
9464 inline void Submatrix<MT,aligned,false,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,true>& rhs )
9473 for(
size_t j=0UL; j<
columns(); ++j )
9477 for( ConstIterator_t<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
9478 for( ; i<element->index(); ++i )
9480 matrix_(
row()+element->index(),
column()+j) *= element->value();
9484 for( ; i<
rows(); ++i ) {
9513 template<
typename MT
9515 class Submatrix<MT,
aligned,true,true,CSAs...>
9516 :
public View< DenseMatrix< Submatrix<MT,aligned,true,true,CSAs...>, true > >
9517 ,
private SubmatrixData<CSAs...>
9521 using DataType = SubmatrixData<CSAs...>;
9522 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
9527 template<
typename MT1,
typename MT2 >
9528 static constexpr
bool EnforceEvaluation_v =
9529 ( IsRestricted_v<MT1> && RequiresEvaluation_v<MT2> );
9535 using This = Submatrix<MT,
aligned,
true,
true,CSAs...>;
9537 using BaseType = DenseMatrix<This,true>;
9538 using ViewedType = MT;
9543 using SIMDType = SIMDTrait_t<ElementType>;
9554 using ConstPointer = ConstPointer_t<MT>;
9557 using Pointer = If_t< IsConst_v<MT> || !HasMutableDataAccess_v<MT>, ConstPointer, Pointer_t<MT> >;
9568 static constexpr
bool simdEnabled = MT::simdEnabled;
9577 template<
typename... RSAs >
9578 explicit inline Submatrix( MT& matrix, RSAs... args );
9580 Submatrix(
const Submatrix& ) =
default;
9587 ~Submatrix() =
default;
9594 inline Reference operator()(
size_t i,
size_t j );
9596 inline Reference at(
size_t i,
size_t j );
9598 inline Pointer
data () noexcept;
9599 inline ConstPointer
data () const noexcept;
9600 inline Pointer
data (
size_t j ) noexcept;
9601 inline ConstPointer
data (
size_t j ) const noexcept;
9614 inline Submatrix& operator=( const
ElementType& rhs );
9615 inline Submatrix& operator=( initializer_list< initializer_list<
ElementType> > list );
9616 inline Submatrix& operator=( const Submatrix& rhs );
9618 template< typename MT2,
bool SO >
9619 inline Submatrix& operator=( const Matrix<MT2,SO>& rhs );
9621 template< typename MT2,
bool SO >
9622 inline auto operator+=( const Matrix<MT2,SO>& rhs )
9623 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
9625 template< typename MT2,
bool SO >
9626 inline auto operator+=( const Matrix<MT2,SO>& rhs )
9627 ->
EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
9629 template< typename MT2,
bool SO >
9630 inline auto operator-=( const Matrix<MT2,SO>& rhs )
9631 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
9633 template< typename MT2,
bool SO >
9634 inline auto operator-=( const Matrix<MT2,SO>& rhs )
9635 ->
EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
9637 template< typename MT2,
bool SO >
9638 inline auto operator%=( const Matrix<MT2,SO>& rhs )
9639 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
9641 template< typename MT2,
bool SO >
9642 inline auto operator%=( const Matrix<MT2,SO>& rhs )
9643 ->
EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >;
9650 using DataType::
row;
9652 using DataType::
rows;
9655 inline MT& operand() noexcept;
9656 inline const MT& operand() const noexcept;
9658 inline
size_t spacing() const noexcept;
9659 inline
size_t capacity() const noexcept;
9660 inline
size_t capacity(
size_t i ) const noexcept;
9662 inline
size_t nonZeros(
size_t i ) const;
9663 inline
void reset();
9664 inline
void reset(
size_t i );
9674 template< typename Other > inline Submatrix& scale( const Other& scalar );
9681 template< typename MT2 >
9682 static constexpr
bool VectorizedAssign_v =
9683 ( useOptimizedKernels &&
9684 simdEnabled && MT2::simdEnabled &&
9690 template< typename MT2 >
9691 static constexpr
bool VectorizedAddAssign_v =
9692 ( useOptimizedKernels &&
9693 simdEnabled && MT2::simdEnabled &&
9701 template< typename MT2 >
9702 static constexpr
bool VectorizedSubAssign_v =
9703 ( useOptimizedKernels &&
9704 simdEnabled && MT2::simdEnabled &&
9712 template< typename MT2 >
9713 static constexpr
bool VectorizedSchurAssign_v =
9714 ( useOptimizedKernels &&
9715 simdEnabled && MT2::simdEnabled &&
9729 template< typename Other >
9730 inline
bool canAlias( const Other* alias ) const noexcept;
9732 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
9733 inline
bool canAlias( const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias ) const noexcept;
9735 template< typename Other >
9736 inline
bool isAliased( const Other* alias ) const noexcept;
9738 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
size_t... CSAs2 >
9739 inline
bool isAliased( const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias ) const noexcept;
9741 inline
bool isAligned () const noexcept;
9742 inline
bool canSMPAssign() const noexcept;
9753 template< typename MT2 >
9754 inline auto assign( const DenseMatrix<MT2,true>& rhs ) ->
DisableIf_t< VectorizedAssign_v<MT2> >;
9756 template< typename MT2 >
9757 inline auto assign( const DenseMatrix<MT2,true>& rhs ) ->
EnableIf_t< VectorizedAssign_v<MT2> >;
9759 template< typename MT2 > inline
void assign( const DenseMatrix<MT2,false>& rhs );
9760 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,true>& rhs );
9761 template< typename MT2 > inline
void assign( const SparseMatrix<MT2,false>& rhs );
9763 template< typename MT2 >
9764 inline auto addAssign( const DenseMatrix<MT2,true>& rhs ) ->
DisableIf_t< VectorizedAddAssign_v<MT2> >;
9766 template< typename MT2 >
9767 inline auto addAssign( const DenseMatrix<MT2,true>& rhs ) ->
EnableIf_t< VectorizedAddAssign_v<MT2> >;
9769 template< typename MT2 > inline
void addAssign( const DenseMatrix<MT2,false>& rhs );
9770 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,true>& rhs );
9771 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,false>& rhs );
9773 template< typename MT2 >
9774 inline auto subAssign( const DenseMatrix<MT2,true>& rhs ) ->
DisableIf_t< VectorizedSubAssign_v<MT2> >;
9776 template< typename MT2 >
9777 inline auto subAssign( const DenseMatrix<MT2,true>& rhs ) ->
EnableIf_t< VectorizedSubAssign_v<MT2> >;
9779 template< typename MT2 > inline
void subAssign( const DenseMatrix<MT2,false>& rhs );
9780 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,true>& rhs );
9781 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,false>& rhs );
9783 template< typename MT2 >
9784 inline auto schurAssign( const DenseMatrix<MT2,true>& rhs ) ->
DisableIf_t< VectorizedSchurAssign_v<MT2> >;
9786 template< typename MT2 >
9787 inline auto schurAssign( const DenseMatrix<MT2,true>& rhs ) ->
EnableIf_t< VectorizedSchurAssign_v<MT2> >;
9789 template< typename MT2 > inline
void schurAssign( const DenseMatrix<MT2,false>& rhs );
9790 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,true>& rhs );
9791 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,false>& rhs );
9799 inline
bool hasOverlap() const noexcept;
9811 template< typename MT2,
AlignmentFlag AF2,
bool SO2,
bool DF2,
size_t... CSAs2 > friend class Submatrix;
9849 template< typename MT
9851 template< typename... RSAs >
9852 inline Submatrix<MT,
aligned,true,true,CSAs...>::Submatrix( MT& matrix, RSAs... args )
9853 : DataType( args... )
9854 , matrix_ ( matrix )
9862 if( simdEnabled && IsContiguous_v<MT> &&
9864 (
columns() > 1UL && matrix_.spacing() % SIMDSIZE != 0UL ) ) ) {
9874 BLAZE_USER_ASSERT( !simdEnabled || !IsContiguous_v<MT> ||
columns() <= 1UL || matrix_.spacing() % SIMDSIZE == 0UL,
"Invalid submatrix alignment" );
9900 template<
typename MT
9903 Submatrix<MT,aligned,true,true,CSAs...>::operator()(
size_t i,
size_t j )
9925 template<
typename MT
9928 Submatrix<MT,aligned,true,true,CSAs...>::operator()(
size_t i,
size_t j )
const 9933 return const_cast<const MT&
>( matrix_ )(
row()+i,
column()+j);
9951 template<
typename MT
9954 Submatrix<MT,aligned,true,true,CSAs...>::at(
size_t i,
size_t j )
9962 return (*
this)(i,j);
9980 template<
typename MT
9983 Submatrix<MT,aligned,true,true,CSAs...>::at(
size_t i,
size_t j )
const 9991 return (*
this)(i,j);
10007 template<
typename MT
10009 inline typename Submatrix<MT,
aligned,
true,
true,CSAs...>::Pointer
10028 template<
typename MT
10030 inline typename Submatrix<MT,
aligned,
true,
true,CSAs...>::ConstPointer
10048 template<
typename MT
10050 inline typename Submatrix<MT,
aligned,
true,
true,CSAs...>::Pointer
10068 template<
typename MT
10070 inline typename Submatrix<MT,
aligned,
true,
true,CSAs...>::ConstPointer
10086 template<
typename MT
10092 return ( matrix_.begin(
column() + j ) +
row() );
10105 template<
typename MT
10111 return ( matrix_.cbegin(
column() + j ) +
row() );
10124 template<
typename MT
10130 return ( matrix_.cbegin(
column() + j ) +
row() );
10143 template<
typename MT
10162 template<
typename MT
10168 return ( matrix_.cbegin(
column() + j ) +
row() +
rows() );
10181 template<
typename MT
10187 return ( matrix_.cbegin(
column() + j ) +
row() +
rows() );
10212 template<
typename MT
10214 inline Submatrix<MT,
aligned,
true,
true,CSAs...>&
10215 Submatrix<MT,aligned,true,true,CSAs...>::operator=(
const ElementType& rhs )
10218 decltype(
auto) left( derestrict( matrix_ ) );
10220 for(
size_t j=
column(); j<jend; ++j )
10222 const size_t ibegin( ( IsLower_v<MT> )
10223 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
10224 ?(
max( j+1UL,
row() ) )
10227 const size_t iend ( ( IsUpper_v<MT> )
10228 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
10233 for(
size_t i=ibegin; i<iend; ++i ) {
10234 if( !IsRestricted_v<MT> || IsTriangular_v<MT> || trySet( matrix_, i, j, rhs ) )
10261 template<
typename MT
10263 inline Submatrix<MT,
aligned,
true,
true,CSAs...>&
10264 Submatrix<MT,aligned,true,true,CSAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
10268 if( list.size() !=
rows() ) {
10272 if( IsRestricted_v<MT> ) {
10273 const InitializerMatrix<ElementType> tmp( list,
columns() );
10274 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
10279 decltype(
auto) left( derestrict( *this ) );
10282 for( const auto& rowList : list ) {
10284 for(
const auto& element : rowList ) {
10285 left(i,j) = element;
10289 reset( left(i,j) );
10315 template<
typename MT
10317 inline Submatrix<MT,
aligned,
true,
true,CSAs...>&
10318 Submatrix<MT,aligned,true,true,CSAs...>::operator=(
const Submatrix& rhs )
10323 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ &&
row() == rhs.row() &&
column() == rhs.column() ) )
10326 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
10330 if( !tryAssign( matrix_, rhs,
row(),
column() ) ) {
10334 decltype(
auto) left( derestrict( *this ) );
10336 if( rhs.canAlias( &matrix_ ) ) {
10366 template<
typename MT
10368 template<
typename MT2
10370 inline Submatrix<MT,
aligned,
true,
true,CSAs...>&
10371 Submatrix<MT,aligned,true,true,CSAs...>::operator=(
const Matrix<MT2,SO>& rhs )
10379 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<MT2>,
const MT2& >;
10380 Right right( ~rhs );
10382 if( !tryAssign( matrix_, right,
row(),
column() ) ) {
10386 decltype(
auto) left( derestrict( *this ) );
10389 const ResultType_t<MT2> tmp( right );
10390 if( IsSparseMatrix_v<MT2> )
10395 if( IsSparseMatrix_v<MT2> )
10422 template<
typename MT
10424 template<
typename MT2
10427 -> DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
10433 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
10442 if( !tryAddAssign( matrix_, ~rhs,
row(),
column() ) ) {
10446 decltype(
auto) left( derestrict( *this ) );
10449 (~rhs).canAlias( &matrix_ ) ) {
10450 const AddType tmp( *
this + (~rhs) );
10479 template<
typename MT
10481 template<
typename MT2
10484 -> EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
10490 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
10499 const AddType tmp( *
this + (~rhs) );
10501 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
10505 decltype(
auto) left( derestrict( *this ) );
10531 template< typename MT
10533 template< typename MT2
10535 inline auto Submatrix<MT,
aligned,true,true,CSAs...>::operator-=( const Matrix<MT2,SO>& rhs )
10536 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
10542 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
10551 if( !trySubAssign( matrix_, ~rhs,
row(),
column() ) ) {
10555 decltype(
auto) left( derestrict( *this ) );
10558 (~rhs).canAlias( &matrix_ ) ) {
10559 const SubType tmp( *
this - (~rhs ) );
10588 template<
typename MT
10590 template<
typename MT2
10593 -> EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
10599 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
10608 const SubType tmp( *
this - (~rhs) );
10610 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
10614 decltype(
auto) left( derestrict( *this ) );
10640 template< typename MT
10642 template< typename MT2
10644 inline auto Submatrix<MT,
aligned,true,true,CSAs...>::operator%=( const Matrix<MT2,SO>& rhs )
10645 ->
DisableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
10651 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
10659 if( !trySchurAssign( matrix_, ~rhs,
row(),
column() ) ) {
10663 decltype(
auto) left( derestrict( *this ) );
10666 (~rhs).canAlias( &matrix_ ) ) {
10667 const SchurType tmp( *
this % (~rhs) );
10668 if( IsSparseMatrix_v<SchurType> )
10698 template<
typename MT
10700 template<
typename MT2
10702 inline auto Submatrix<MT,aligned,true,true,CSAs...>::operator%=(
const Matrix<MT2,SO>& rhs )
10703 -> EnableIf_t< EnforceEvaluation_v<MT,MT2>, Submatrix& >
10709 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
10717 const SchurType tmp( *
this % (~rhs) );
10719 if( !tryAssign( matrix_, tmp,
row(),
column() ) ) {
10723 decltype(
auto) left( derestrict( *this ) );
10753 template<
typename MT
10755 inline MT& Submatrix<MT,aligned,true,true,CSAs...>::operand() noexcept
10769 template<
typename MT
10771 inline const MT& Submatrix<MT,aligned,true,true,CSAs...>::operand() const noexcept
10788 template<
typename MT
10792 return matrix_.spacing();
10804 template<
typename MT
10821 template<
typename MT
10841 template<
typename MT
10845 const size_t iend(
row() +
rows() );
10847 size_t nonzeros( 0UL );
10849 for(
size_t j=
column(); j<jend; ++j )
10850 for(
size_t i=
row(); i<iend; ++i )
10867 template<
typename MT
10873 const size_t iend(
row() +
rows() );
10874 size_t nonzeros( 0UL );
10876 for(
size_t i=
row(); i<iend; ++i )
10892 template<
typename MT
10900 const size_t ibegin( ( IsLower_v<MT> )
10901 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
10902 ?(
max( j+1UL,
row() ) )
10905 const size_t iend ( ( IsUpper_v<MT> )
10906 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
10911 for(
size_t i=ibegin; i<iend; ++i )
10912 clear( matrix_(i,j) );
10926 template<
typename MT
10934 const size_t ibegin( ( IsLower_v<MT> )
10935 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
10936 ?(
max( j+1UL,
row() ) )
10939 const size_t iend ( ( IsUpper_v<MT> )
10940 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
10945 for(
size_t i=ibegin; i<iend; ++i )
10962 template<
typename MT
10964 inline bool Submatrix<MT,aligned,true,true,CSAs...>::hasOverlap() const noexcept
11002 template<
typename MT
11004 inline Submatrix<MT,
aligned,
true,
true,CSAs...>&
11015 decltype(
auto) left( derestrict( *this ) );
11044 template< typename MT
11046 inline Submatrix<MT,
aligned,true,true,CSAs...>&
11057 decltype(
auto) left( derestrict( *this ) );
11081 template< typename MT
11083 template< typename Other >
11084 inline Submatrix<MT,
aligned,true,true,CSAs...>&
11085 Submatrix<MT,
aligned,true,true,CSAs...>::scale( const Other& scalar )
11091 for(
size_t j=
column(); j<jend; ++j )
11093 const size_t ibegin( ( IsLower_v<MT> )
11094 ?( ( IsStrictlyLower_v<MT> )
11095 ?(
max( j+1UL,
row() ) )
11098 const size_t iend ( ( IsUpper_v<MT> )
11099 ?( ( IsStrictlyUpper_v<MT> )
11104 for(
size_t i=ibegin; i<iend; ++i )
11105 matrix_(i,j) *= scalar;
11133 template<
typename MT
11135 template<
typename Other >
11136 inline bool Submatrix<MT,aligned,true,true,CSAs...>::canAlias(
const Other* alias )
const noexcept
11138 return matrix_.isAliased( alias );
11155 template<
typename MT
11157 template<
typename MT2
11160 ,
size_t... CSAs2 >
11162 Submatrix<MT,aligned,true,true,CSAs...>::canAlias(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
11164 return ( matrix_.isAliased( &alias->matrix_ ) &&
11165 (
row() +
rows() > alias->row() ) &&
11166 (
row() < alias->row() + alias->rows() ) &&
11168 (
column() < alias->column() + alias->columns() ) );
11185 template<
typename MT
11187 template<
typename Other >
11188 inline bool Submatrix<MT,aligned,true,true,CSAs...>::isAliased(
const Other* alias )
const noexcept
11190 return matrix_.isAliased( alias );
11207 template<
typename MT
11209 template<
typename MT2
11212 ,
size_t... CSAs2 >
11214 Submatrix<MT,aligned,true,true,CSAs...>::isAliased(
const Submatrix<MT2,AF2,SO2,true,CSAs2...>* alias )
const noexcept
11216 return ( matrix_.isAliased( &alias->matrix_ ) &&
11217 (
row() +
rows() > alias->row() ) &&
11218 (
row() < alias->row() + alias->rows() ) &&
11220 (
column() < alias->column() + alias->columns() ) );
11236 template<
typename MT
11238 inline bool Submatrix<MT,aligned,true,true,CSAs...>::isAligned() const noexcept
11257 template<
typename MT
11259 inline bool Submatrix<MT,aligned,true,true,CSAs...>::canSMPAssign() const noexcept
11261 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
11282 template<
typename MT
11285 Submatrix<MT,aligned,true,true,CSAs...>::load(
size_t i,
size_t j )
const noexcept
11287 return loada( i, j );
11308 template<
typename MT
11320 return matrix_.loada(
row()+i,
column()+j );
11341 template<
typename MT
11353 return matrix_.loadu(
row()+i,
column()+j );
11375 template<
typename MT
11378 Submatrix<MT,aligned,true,true,CSAs...>::store(
size_t i,
size_t j,
const SIMDType& value ) noexcept
11402 template<
typename MT
11414 matrix_.storea(
row()+i,
column()+j, value );
11436 template<
typename MT
11448 matrix_.storeu(
row()+i,
column()+j, value );
11471 template<
typename MT
11483 matrix_.stream(
row()+i,
column()+j, value );
11501 template<
typename MT
11503 template<
typename MT2 >
11504 inline auto Submatrix<MT,aligned,true,true,CSAs...>::assign(
const DenseMatrix<MT2,true>& rhs )
11505 -> DisableIf_t< VectorizedAssign_v<MT2> >
11510 const size_t ipos(
rows() &
size_t(-2) );
11513 for(
size_t j=0UL; j<
columns(); ++j ) {
11514 for(
size_t i=0UL; i<ipos; i+=2UL ) {
11515 matrix_(
row()+i ,
column()+j) = (~rhs)(i ,j);
11516 matrix_(
row()+i+1UL,
column()+j) = (~rhs)(i+1UL,j);
11518 if( ipos <
rows() ) {
11519 matrix_(
row()+ipos,
column()+j) = (~rhs)(ipos,j);
11539 template<
typename MT
11541 template<
typename MT2 >
11542 inline auto Submatrix<MT,aligned,true,true,CSAs...>::assign(
const DenseMatrix<MT2,true>& rhs )
11543 -> EnableIf_t< VectorizedAssign_v<MT2> >
11550 const size_t ipos(
rows() &
size_t(-SIMDSIZE) );
11553 if( useStreaming &&
11555 !(~rhs).isAliased( &matrix_ ) )
11557 for(
size_t j=0UL; j<
columns(); ++j )
11561 ConstIterator_t<MT2> right( (~rhs).
begin(j) );
11563 for( ; i<ipos; i+=SIMDSIZE ) {
11564 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11566 for( ; i<
rows(); ++i ) {
11567 *left = *right; ++left; ++right;
11573 for(
size_t j=0UL; j<
columns(); ++j )
11577 ConstIterator_t<MT2> right( (~rhs).
begin(j) );
11579 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
11580 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11581 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11582 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11583 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11585 for( ; i<ipos; i+=SIMDSIZE ) {
11586 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11588 for( ; i<
rows(); ++i ) {
11589 *left = *right; ++left; ++right;
11610 template<
typename MT
11612 template<
typename MT2 >
11613 inline void Submatrix<MT,aligned,true,true,CSAs...>::assign(
const DenseMatrix<MT2,false>& rhs )
11620 constexpr
size_t block( BLOCK_SIZE );
11622 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
11623 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
11624 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
11625 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
11626 for(
size_t j=jj; j<jend; ++j ) {
11627 for(
size_t i=ii; i<iend; ++i ) {
11628 matrix_(
row()+i,
column()+j) = (~rhs)(i,j);
11650 template<
typename MT
11652 template<
typename MT2 >
11653 inline void Submatrix<MT,aligned,true,true,CSAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
11658 for(
size_t j=0UL; j<
columns(); ++j )
11659 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
11660 matrix_(
row()+element->index(),
column()+j) = element->value();
11678 template<
typename MT
11680 template<
typename MT2 >
11681 inline void Submatrix<MT,aligned,true,true,CSAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
11688 for(
size_t i=0UL; i<
rows(); ++i )
11689 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
11690 matrix_(
row()+i,
column()+element->index()) = element->value();
11708 template<
typename MT
11710 template<
typename MT2 >
11711 inline auto Submatrix<MT,aligned,true,true,CSAs...>::addAssign(
const DenseMatrix<MT2,true>& rhs )
11712 -> DisableIf_t< VectorizedAddAssign_v<MT2> >
11717 const size_t ipos(
rows() &
size_t(-2) );
11720 for(
size_t j=0UL; j<
columns(); ++j )
11722 if( IsDiagonal_v<MT2> ) {
11723 matrix_(
row()+j,
column()+j) += (~rhs)(j,j);
11726 for(
size_t i=0UL; i<ipos; i+=2UL ) {
11727 matrix_(
row()+i ,
column()+j) += (~rhs)(i ,j);
11728 matrix_(
row()+i+1UL,
column()+j) += (~rhs)(i+1UL,j);
11730 if( ipos <
rows() ) {
11731 matrix_(
row()+ipos,
column()+j) += (~rhs)(ipos,j);
11752 template<
typename MT
11754 template<
typename MT2 >
11755 inline auto Submatrix<MT,aligned,true,true,CSAs...>::addAssign(
const DenseMatrix<MT2,true>& rhs )
11756 -> EnableIf_t< VectorizedAddAssign_v<MT2> >
11763 for(
size_t j=0UL; j<
columns(); ++j )
11765 const size_t ibegin( ( IsLower_v<MT> )
11766 ?( ( IsStrictlyLower_v<MT> ? j+1UL : j ) &
size_t(-SIMDSIZE) )
11768 const size_t iend ( ( IsUpper_v<MT> )
11769 ?( IsStrictlyUpper_v<MT> ? j : j+1UL )
11773 const size_t ipos( iend &
size_t(-SIMDSIZE) );
11776 size_t i( ibegin );
11778 ConstIterator_t<MT2> right( (~rhs).
begin(j) + ibegin );
11780 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
11781 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11782 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11783 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11784 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11786 for( ; i<ipos; i+=SIMDSIZE ) {
11787 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11789 for( ; i<iend; ++i ) {
11790 *left += *right; ++left; ++right;
11810 template<
typename MT
11812 template<
typename MT2 >
11813 inline void Submatrix<MT,aligned,true,true,CSAs...>::addAssign(
const DenseMatrix<MT2,false>& rhs )
11820 constexpr
size_t block( BLOCK_SIZE );
11822 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
11823 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
11824 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
11825 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
11826 for(
size_t j=jj; j<jend; ++j ) {
11827 for(
size_t i=ii; i<iend; ++i ) {
11828 matrix_(
row()+i,
column()+j) += (~rhs)(i,j);
11850 template<
typename MT
11852 template<
typename MT2 >
11853 inline void Submatrix<MT,aligned,true,true,CSAs...>::addAssign(
const SparseMatrix<MT2,true>& rhs )
11858 for(
size_t j=0UL; j<
columns(); ++j )
11859 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
11860 matrix_(
row()+element->index(),
column()+j) += element->value();
11878 template<
typename MT
11880 template<
typename MT2 >
11881 inline void Submatrix<MT,aligned,true,true,CSAs...>::addAssign(
const SparseMatrix<MT2,false>& rhs )
11888 for(
size_t i=0UL; i<
rows(); ++i )
11889 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
11890 matrix_(
row()+i,
column()+element->index()) += element->value();
11908 template<
typename MT
11910 template<
typename MT2 >
11911 inline auto Submatrix<MT,aligned,true,true,CSAs...>::subAssign(
const DenseMatrix<MT2,true>& rhs )
11912 -> DisableIf_t< VectorizedSubAssign_v<MT2> >
11917 const size_t ipos(
rows() &
size_t(-2) );
11920 for(
size_t j=0UL; j<
columns(); ++j )
11922 if( IsDiagonal_v<MT2> ) {
11923 matrix_(
row()+j,
column()+j) -= (~rhs)(j,j);
11926 for(
size_t i=0UL; i<ipos; i+=2UL ) {
11927 matrix_(
row()+i ,
column()+j) -= (~rhs)(i ,j);
11928 matrix_(
row()+i+1UL,
column()+j) -= (~rhs)(i+1UL,j);
11930 if( ipos <
rows() ) {
11931 matrix_(
row()+ipos,
column()+j) -= (~rhs)(ipos,j);
11952 template<
typename MT
11954 template<
typename MT2 >
11955 inline auto Submatrix<MT,aligned,true,true,CSAs...>::subAssign(
const DenseMatrix<MT2,true>& rhs )
11956 -> EnableIf_t< VectorizedSubAssign_v<MT2> >
11963 for(
size_t j=0UL; j<
columns(); ++j )
11965 const size_t ibegin( ( IsLower_v<MT> )
11966 ?( ( IsStrictlyLower_v<MT> ? j+1UL : j ) &
size_t(-SIMDSIZE) )
11968 const size_t iend ( ( IsUpper_v<MT> )
11969 ?( IsStrictlyUpper_v<MT> ? j : j+1UL )
11973 const size_t ipos( iend &
size_t(-SIMDSIZE) );
11976 size_t i( ibegin );
11978 ConstIterator_t<MT2> right( (~rhs).
begin(j) + ibegin );
11980 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
11981 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11982 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11983 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11984 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11986 for( ; i<ipos; i+=SIMDSIZE ) {
11987 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
11989 for( ; i<iend; ++i ) {
11990 *left -= *right; ++left; ++right;
12010 template<
typename MT
12012 template<
typename MT2 >
12013 inline void Submatrix<MT,aligned,true,true,CSAs...>::subAssign(
const DenseMatrix<MT2,false>& rhs )
12020 constexpr
size_t block( BLOCK_SIZE );
12022 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
12023 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
12024 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
12025 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
12026 for(
size_t j=jj; j<jend; ++j ) {
12027 for(
size_t i=ii; i<iend; ++i ) {
12028 matrix_(
row()+i,
column()+j) -= (~rhs)(i,j);
12050 template<
typename MT
12052 template<
typename MT2 >
12053 inline void Submatrix<MT,aligned,true,true,CSAs...>::subAssign(
const SparseMatrix<MT2,true>& rhs )
12058 for(
size_t j=0UL; j<
columns(); ++j )
12059 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
12060 matrix_(
row()+element->index(),
column()+j) -= element->value();
12078 template<
typename MT
12080 template<
typename MT2 >
12081 inline void Submatrix<MT,aligned,true,true,CSAs...>::subAssign(
const SparseMatrix<MT2,false>& rhs )
12088 for(
size_t i=0UL; i<
rows(); ++i )
12089 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
12090 matrix_(
row()+i,
column()+element->index()) -= element->value();
12108 template<
typename MT
12110 template<
typename MT2 >
12111 inline auto Submatrix<MT,aligned,true,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,true>& rhs )
12112 -> DisableIf_t< VectorizedSchurAssign_v<MT2> >
12117 const size_t ipos(
rows() &
size_t(-2) );
12120 for(
size_t j=0UL; j<
columns(); ++j ) {
12121 for(
size_t i=0UL; i<ipos; i+=2UL ) {
12122 matrix_(
row()+i ,
column()+j) *= (~rhs)(i ,j);
12123 matrix_(
row()+i+1UL,
column()+j) *= (~rhs)(i+1UL,j);
12125 if( ipos <
rows() ) {
12126 matrix_(
row()+ipos,
column()+j) *= (~rhs)(ipos,j);
12147 template<
typename MT
12149 template<
typename MT2 >
12150 inline auto Submatrix<MT,aligned,true,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,true>& rhs )
12151 -> EnableIf_t< VectorizedSchurAssign_v<MT2> >
12158 for(
size_t j=0UL; j<
columns(); ++j )
12160 const size_t ipos(
rows() &
size_t(-SIMDSIZE) );
12165 ConstIterator_t<MT2> right( (~rhs).
begin(j) );
12167 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
12168 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
12169 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
12170 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
12171 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
12173 for( ; i<ipos; i+=SIMDSIZE ) {
12174 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
12176 for( ; i<
rows(); ++i ) {
12177 *left *= *right; ++left; ++right;
12197 template<
typename MT
12199 template<
typename MT2 >
12200 inline void Submatrix<MT,aligned,true,true,CSAs...>::schurAssign(
const DenseMatrix<MT2,false>& rhs )
12207 constexpr
size_t block( BLOCK_SIZE );
12209 for(
size_t jj=0UL; jj<
columns(); jj+=block ) {
12210 const size_t jend( (
columns()<(jj+block) )?(
columns() ):( jj+block ) );
12211 for(
size_t ii=0UL; ii<
rows(); ii+=block ) {
12212 const size_t iend( (
rows()<(ii+block) )?(
rows() ):( ii+block ) );
12213 for(
size_t j=jj; j<jend; ++j ) {
12214 for(
size_t i=ii; i<iend; ++i ) {
12215 matrix_(
row()+i,
column()+j) *= (~rhs)(i,j);
12237 template<
typename MT
12239 template<
typename MT2 >
12240 inline void Submatrix<MT,aligned,true,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,true>& rhs )
12247 for(
size_t j=0UL; j<
columns(); ++j )
12251 for( ConstIterator_t<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
12252 for( ; i<element->index(); ++i )
12254 matrix_(
row()+i,
column()+j) *= element->value();
12258 for( ; i<
rows(); ++i ) {
12279 template<
typename MT
12281 template<
typename MT2 >
12282 inline void Submatrix<MT,aligned,true,true,CSAs...>::schurAssign(
const SparseMatrix<MT2,false>& rhs )
12291 for(
size_t i=0UL; i<
rows(); ++i )
12295 for( ConstIterator_t<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
12296 for( ; j<element->index(); ++j )
12298 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:133
Headerfile for the generic min algorithm.
Header file for the blaze::checked and blaze::unchecked instances.
constexpr bool IsContiguous_v
Auxiliary variable template for the IsContiguous type trait.The IsContiguous_v variable template prov...
Definition: IsContiguous.h:145
Header file for kernel specific block sizes.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3078
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
constexpr bool IsSparseMatrix_v
Auxiliary variable template for the IsSparseMatrix type trait.The IsSparseMatrix_v variable template ...
Definition: IsSparseMatrix.h:139
Header file for the alignment flag values.
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
Header file for the subtraction trait.
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
constexpr const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:750
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:169
Header file for the View base class.
constexpr bool HasSIMDSub_v
Auxiliary variable template for the HasSIMDSub type trait.The HasSIMDSub_v variable template provides...
Definition: HasSIMDSub.h:188
Header file for the IsSparseMatrix type trait.
Header file for the IsDiagonal type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:61
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:332
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:76
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3079
#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
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
#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
constexpr bool IsHermitian_v
Auxiliary variable template for the IsHermitian type trait.The IsHermitian_v variable template provid...
Definition: IsHermitian.h:171
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
constexpr bool IsReference_v
Auxiliary variable template for the IsReference type trait.The IsReference_v variable template provid...
Definition: IsReference.h:95
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Header file for the reset shim.
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
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
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition: Storeu.h:75
Header file for the RequiresEvaluation type trait.
Header file for the extended initializer_list functionality.
System settings for performance optimizations.
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the IsUniLower type trait.
typename SubmatrixTrait< MT, CSAs... >::Type SubmatrixTrait_t
Auxiliary alias declaration for the SubmatrixTrait type trait.The SubmatrixTrait_t alias declaration ...
Definition: SubmatrixTrait.h:171
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:482
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:416
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Constraint on the data type.
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:252
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.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
Headerfile for the generic max algorithm.
Header file for the DisableIf class template.
Header file for the IsStrictlyUpper type trait.
constexpr bool IsSIMDCombinable_v
Auxiliary variable template for the IsSIMDCombinable type trait.The IsSIMDCombinable_v variable templ...
Definition: IsSIMDCombinable.h:137
Header file for the IsSymmetric type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#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:1364
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
constexpr bool HasSIMDMult_v
Auxiliary variable template for the HasSIMDMult type trait.The HasSIMDMult_v variable template provid...
Definition: HasSIMDMult.h:189
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3080
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
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:370
constexpr bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:446
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:253
Header file for all SIMD functionality.
constexpr bool Contains_v
Auxiliary variable template for the Contains type trait.The Contains_v variable template provides a c...
Definition: Contains.h:139
Header file for the IsLower type trait.
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:78
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
constexpr bool IsSymmetric_v
Auxiliary variable template for the IsSymmetric type trait.The IsSymmetric_v variable template provid...
Definition: IsSymmetric.h:171
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1179
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
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:8908
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
Constraint on the data type.
Flag for aligned vectors and matrices.
Definition: AlignmentFlag.h:65
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.
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
Header file for the Unique class template.
Header file for the submatrix trait.
Header file for the IsContiguous type 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:133
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.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
Constraint on the data type.
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:408
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.
auto smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:194
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
constexpr bool IsDiagonal_v
Auxiliary variable template for the IsDiagonal type trait.The IsDiagonal_v variable template provides...
Definition: IsDiagonal.h:148
constexpr const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:718
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:79
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< 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:74
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
Flag for unaligned vectors and matrices.
Definition: AlignmentFlag.h:64
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3082
Header file for the alignment check function.
constexpr bool HasSIMDAdd_v
Auxiliary variable template for the HasSIMDAdd type trait.The HasSIMDAdd_v variable template provides...
Definition: HasSIMDAdd.h:188
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
#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.
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
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 clear shim.
Header file for the IsExpression type trait class.
Constraint on the data type.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825