35 #ifndef _BLAZE_MATH_VIEWS_SUBMATRIX_SPARSE_H_ 36 #define _BLAZE_MATH_VIEWS_SUBMATRIX_SPARSE_H_ 112 template<
typename MT
114 class Submatrix<MT,AF,false,false>
115 :
public View< SparseMatrix< Submatrix<MT,AF,false,false>, false > >
120 using Operand = If_< IsExpression<MT>, MT, MT& >;
125 using This = Submatrix<MT,AF,false,false>;
126 using BaseType = SparseMatrix<This,false>;
144 template<
typename MatrixType
145 ,
typename IteratorType >
146 class SubmatrixElement
147 :
private SparseElement
156 inline SubmatrixElement( IteratorType pos,
size_t offset )
168 template<
typename T >
inline SubmatrixElement& operator=(
const T& v ) {
180 template<
typename T >
inline SubmatrixElement&
operator+=(
const T& v ) {
192 template<
typename T >
inline SubmatrixElement&
operator-=(
const T& v ) {
204 template<
typename T >
inline SubmatrixElement&
operator*=(
const T& v ) {
216 template<
typename T >
inline SubmatrixElement&
operator/=(
const T& v ) {
227 inline const SubmatrixElement* operator->()
const {
237 inline decltype(
auto) value()
const {
238 return pos_->value();
247 inline size_t index()
const {
248 return pos_->index() - offset_;
263 template<
typename MatrixType
264 ,
typename IteratorType >
265 class SubmatrixIterator
269 using IteratorCategory = std::forward_iterator_tag;
270 using ValueType = SubmatrixElement<MatrixType,IteratorType>;
271 using PointerType = ValueType;
272 using ReferenceType = ValueType;
273 using DifferenceType = ptrdiff_t;
276 using iterator_category = IteratorCategory;
277 using value_type = ValueType;
278 using pointer = PointerType;
279 using reference = ReferenceType;
280 using difference_type = DifferenceType;
286 inline SubmatrixIterator()
298 inline SubmatrixIterator( IteratorType iterator,
size_t index )
309 template<
typename MatrixType2,
typename IteratorType2 >
310 inline SubmatrixIterator(
const SubmatrixIterator<MatrixType2,IteratorType2>& it )
312 , offset_( it.offset() )
321 inline SubmatrixIterator& operator++() {
332 inline const SubmatrixIterator operator++(
int ) {
333 const SubmatrixIterator tmp( *
this );
345 return ReferenceType( pos_, offset_ );
354 inline PointerType operator->()
const {
355 return PointerType( pos_, offset_ );
365 template<
typename MatrixType2,
typename IteratorType2 >
366 inline bool operator==(
const SubmatrixIterator<MatrixType2,IteratorType2>& rhs )
const {
367 return base() == rhs.base();
377 template<
typename MatrixType2,
typename IteratorType2 >
378 inline bool operator!=(
const SubmatrixIterator<MatrixType2,IteratorType2>& rhs )
const {
379 return !( *
this == rhs );
389 inline DifferenceType
operator-(
const SubmatrixIterator& rhs )
const {
390 return pos_ - rhs.pos_;
399 inline IteratorType base()
const {
409 inline size_t offset() const noexcept {
424 using ConstIterator = SubmatrixIterator< const MT, ConstIterator_<MT> >;
432 enum :
bool { smpAssignable = MT::smpAssignable };
438 explicit inline Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n );
450 inline Reference operator()(
size_t i,
size_t j );
451 inline ConstReference operator()(
size_t i,
size_t j )
const;
452 inline Reference at(
size_t i,
size_t j );
453 inline ConstReference at(
size_t i,
size_t j )
const;
455 inline ConstIterator
begin (
size_t i )
const;
456 inline ConstIterator
cbegin(
size_t i )
const;
458 inline ConstIterator
end (
size_t i )
const;
459 inline ConstIterator
cend (
size_t i )
const;
466 inline Submatrix& operator=(
const Submatrix& rhs );
468 template<
typename MT2,
bool SO >
inline Submatrix& operator= (
const Matrix<MT2,SO>& rhs );
469 template<
typename MT2,
bool SO >
inline Submatrix&
operator+=(
const Matrix<MT2,SO>& rhs );
470 template<
typename MT2,
bool SO >
inline Submatrix&
operator-=(
const Matrix<MT2,SO>& rhs );
471 template<
typename MT2,
bool SO >
inline Submatrix& operator%=(
const Matrix<MT2,SO>& rhs );
472 template<
typename MT2,
bool SO >
inline Submatrix&
operator*=(
const Matrix<MT2,SO>& rhs );
474 template<
typename Other >
475 inline EnableIf_<IsNumeric<Other>, Submatrix >&
operator*=( Other rhs );
477 template<
typename Other >
478 inline EnableIf_<IsNumeric<Other>, Submatrix >&
operator/=( Other rhs );
485 inline Operand operand() const noexcept;
486 inline
size_t row() const noexcept;
487 inline
size_t column() const noexcept;
488 inline
size_t rows() const noexcept;
489 inline
size_t columns() const noexcept;
490 inline
size_t capacity() const noexcept;
491 inline
size_t capacity(
size_t i ) const noexcept;
493 inline
size_t nonZeros(
size_t i ) const;
495 inline
void reset(
size_t i );
496 inline
void reserve(
size_t nonzeros );
497 void reserve(
size_t i,
size_t nonzeros );
499 inline
void trim(
size_t i );
508 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
509 inline
void finalize(
size_t i );
516 inline
void erase(
size_t i,
size_t j );
520 template< typename Pred >
521 inline
void erase( Pred predicate );
523 template< typename Pred >
524 inline
void erase(
size_t i,
Iterator first,
Iterator last, Pred predicate );
531 inline
Iterator find (
size_t i,
size_t j );
532 inline ConstIterator find (
size_t i,
size_t j ) const;
533 inline
Iterator lowerBound(
size_t i,
size_t j );
534 inline ConstIterator lowerBound(
size_t i,
size_t j ) const;
535 inline
Iterator upperBound(
size_t i,
size_t j );
536 inline ConstIterator upperBound(
size_t i,
size_t j ) const;
546 template< typename Other > inline Submatrix& scale( const Other& scalar );
553 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
554 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
556 inline
bool canSMPAssign() const noexcept;
558 template< typename MT2,
bool SO > inline
void assign ( const DenseMatrix<MT2,SO>& rhs );
559 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,false>& rhs );
560 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,true>& rhs );
561 template< typename MT2,
bool SO > inline
void addAssign ( const Matrix<MT2,SO>& rhs );
562 template< typename MT2,
bool SO > inline
void subAssign ( const Matrix<MT2,SO>& rhs );
563 template< typename MT2,
bool SO > inline
void schurAssign( const Matrix<MT2,SO>& rhs );
571 inline
bool hasOverlap() const noexcept;
580 const
size_t column_;
622 template< typename MT
624 inline Submatrix<MT,AF,false,false>::Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n )
631 if( ( row_ + m_ > matrix_.rows() ) || ( column_ + n_ > matrix_.columns() ) ) {
658 template<
typename MT
661 Submatrix<MT,AF,false,false>::operator()(
size_t i,
size_t j )
666 return matrix_(row_+i,column_+j);
683 template<
typename MT
686 Submatrix<MT,AF,false,false>::operator()(
size_t i,
size_t j )
const 691 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
709 template<
typename MT
712 Submatrix<MT,AF,false,false>::at(
size_t i,
size_t j )
738 template<
typename MT
741 Submatrix<MT,AF,false,false>::at(
size_t i,
size_t j )
const 767 template<
typename MT
775 return Iterator( matrix_.begin( i + row_ ), column_ );
777 return Iterator( matrix_.lowerBound( i + row_, column_ ), column_ );
795 template<
typename MT
805 return ConstIterator( matrix_.lowerBound( i + row_, column_ ), column_ );
823 template<
typename MT
833 return ConstIterator( matrix_.lowerBound( i + row_, column_ ), column_ );
851 template<
typename MT
858 if( matrix_.columns() == column_ +
n_ )
859 return Iterator( matrix_.end( i + row_ ), column_ );
861 return Iterator( matrix_.lowerBound( i + row_, column_ + n_ ), column_ );
879 template<
typename MT
886 if( matrix_.columns() == column_ +
n_ )
889 return ConstIterator( matrix_.lowerBound( i + row_, column_ + n_ ), column_ );
907 template<
typename MT
914 if( matrix_.columns() == column_ +
n_ )
917 return ConstIterator( matrix_.lowerBound( i + row_, column_ + n_ ), column_ );
946 template<
typename MT
948 inline Submatrix<MT,AF,false,false>&
949 Submatrix<MT,AF,false,false>::operator=(
const Submatrix& rhs )
956 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
959 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
963 if( !tryAssign( matrix_, rhs, row_, column_ ) ) {
967 decltype(
auto) left( derestrict( *this ) );
969 if( rhs.canAlias( &matrix_ ) ) {
1002 template<
typename MT
1004 template<
typename MT2
1006 inline Submatrix<MT,AF,false,false>&
1007 Submatrix<MT,AF,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1009 using blaze::assign;
1017 using Right = CompositeType_<MT2>;
1018 Right right( ~rhs );
1020 if( !tryAssign( matrix_, right, row_, column_ ) ) {
1024 decltype(
auto) left( derestrict( *this ) );
1026 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1027 const ResultType_<MT2> tmp( right );
1029 assign( left, tmp );
1033 assign( left, right );
1058 template<
typename MT
1060 template<
typename MT2
1062 inline Submatrix<MT,AF,false,false>&
1065 using blaze::assign;
1071 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
1079 const AddType tmp( *
this + (~rhs) );
1081 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
1085 decltype(
auto) left( derestrict( *this ) );
1088 assign( left, tmp );
1112 template< typename MT
1114 template< typename MT2
1116 inline Submatrix<MT,AF,false,false>&
1117 Submatrix<MT,AF,false,false>::operator-=( const Matrix<MT2,SO>& rhs )
1119 using blaze::assign;
1125 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
1133 const SubType tmp( *
this - (~rhs) );
1135 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
1139 decltype(
auto) left( derestrict( *this ) );
1142 assign( left, tmp );
1166 template< typename MT
1168 template< typename MT2
1170 inline Submatrix<MT,AF,false,false>&
1171 Submatrix<MT,AF,false,false>::operator%=( const Matrix<MT2,SO>& rhs )
1173 using blaze::assign;
1179 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
1187 const SchurType tmp( *
this % (~rhs) );
1189 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
1193 decltype(
auto) left( derestrict( *this ) );
1196 assign( left, tmp );
1220 template< typename MT
1222 template< typename MT2
1224 inline Submatrix<MT,AF,false,false>&
1225 Submatrix<MT,AF,false,false>::operator*=( const Matrix<MT2,SO>& rhs )
1227 using blaze::assign;
1233 using MultType = MultTrait_< ResultType, ResultType_<MT2> >;
1242 const MultType tmp( *
this * (~rhs) );
1244 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
1248 decltype(
auto) left( derestrict( *this ) );
1251 assign( left, tmp );
1276 template< typename MT
1278 template< typename Other >
1279 inline
EnableIf_<IsNumeric<Other>, Submatrix<MT,AF,false,false> >&
1280 Submatrix<MT,AF,false,false>::operator*=( Other rhs )
1284 for(
size_t i=0UL; i<
rows(); ++i ) {
1287 element->value() *= rhs;
1314 template<
typename MT
1316 template<
typename Other >
1317 inline EnableIf_<IsNumeric<Other>, Submatrix<MT,AF,false,false> >&
1324 using DT = DivTrait_<ElementType,Other>;
1325 using Tmp = If_< IsNumeric<DT>, DT, Other >;
1329 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
1330 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1331 for(
size_t i=0UL; i<
rows(); ++i ) {
1334 element->value() *= tmp;
1338 for(
size_t i=0UL; i<
rows(); ++i ) {
1341 element->value() /= rhs;
1365 template<
typename MT
1367 inline typename Submatrix<MT,AF,false,false>::Operand
1368 Submatrix<MT,AF,false,false>::operand() const noexcept
1382 template<
typename MT
1398 template<
typename MT
1414 template<
typename MT
1430 template<
typename MT
1446 template<
typename MT
1450 return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
1468 template<
typename MT
1473 return nonZeros( i ) + matrix_.capacity( row_+i ) - matrix_.nonZeros( row_+i );
1485 template<
typename MT
1489 size_t nonzeros( 0UL );
1491 for(
size_t i=0UL; i<
rows(); ++i )
1512 template<
typename MT
1529 template<
typename MT
1533 for(
size_t i=row_; i<row_+
m_; ++i )
1535 const size_t jbegin( ( IsUpper<MT>::value )
1536 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
1537 ?(
max( i+1UL, column_ ) )
1538 :(
max( i, column_ ) ) )
1540 const size_t jend ( ( IsLower<MT>::value )
1541 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
1542 ?(
min( i, column_+n_ ) )
1543 :(
min( i+1UL, column_+n_ ) ) )
1546 matrix_.erase( i, matrix_.lowerBound( i, jbegin ), matrix_.lowerBound( i, jend ) );
1565 template<
typename MT
1571 const size_t index( row_ + i );
1573 const size_t jbegin( ( IsUpper<MT>::value )
1574 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
1575 ?(
max( i+1UL, column_ ) )
1576 :(
max( i, column_ ) ) )
1578 const size_t jend ( ( IsLower<MT>::value )
1579 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
1580 ?(
min( i, column_+n_ ) )
1581 :(
min( i+1UL, column_+n_ ) ) )
1584 matrix_.erase( index, matrix_.lowerBound( index, jbegin ), matrix_.lowerBound( index, jend ) );
1601 template<
typename MT
1603 inline void Submatrix<MT,AF,false,false>::reserve(
size_t nonzeros )
1605 const size_t current(
capacity() );
1607 if( nonzeros > current ) {
1608 matrix_.reserve( matrix_.capacity() + nonzeros - current );
1631 template<
typename MT
1633 void Submatrix<MT,AF,false,false>::reserve(
size_t i,
size_t nonzeros )
1635 const size_t current(
capacity( i ) );
1636 const size_t index ( row_ + i );
1638 if( nonzeros > current ) {
1639 matrix_.reserve( index, matrix_.capacity( index ) + nonzeros - current );
1657 template<
typename MT
1659 void Submatrix<MT,AF,false,false>::trim()
1661 for(
size_t i=0UL; i<
rows(); ++i )
1680 template<
typename MT
1682 void Submatrix<MT,AF,false,false>::trim(
size_t i )
1685 matrix_.trim( row_ + i );
1701 template<
typename MT
1703 inline bool Submatrix<MT,AF,false,false>::hasOverlap() const noexcept
1705 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
1707 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
1736 template<
typename MT
1741 return Iterator( matrix_.set( row_+i, column_+j, value ), column_ );
1761 template<
typename MT
1764 Submatrix<MT,AF,false,false>::insert(
size_t i,
size_t j,
const ElementType& value )
1766 return Iterator( matrix_.insert( row_+i, column_+j, value ), column_ );
1821 template<
typename MT
1823 inline void Submatrix<MT,AF,false,false>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
1825 if( column_ + n_ == matrix_.columns() ) {
1826 matrix_.append( row_ + i, column_ + j, value, check );
1828 else if( !check || !
isDefault( value ) ) {
1829 matrix_.insert( row_ + i, column_ + j, value );
1850 template<
typename MT
1852 inline void Submatrix<MT,AF,false,false>::finalize(
size_t i )
1854 matrix_.trim( row_ + i );
1878 template<
typename MT
1880 inline void Submatrix<MT,AF,false,false>::erase(
size_t i,
size_t j )
1885 matrix_.erase( row_ + i, column_ + j );
1903 template<
typename MT
1906 Submatrix<MT,AF,false,false>::erase(
size_t i,
Iterator pos )
1909 return Iterator( matrix_.erase( row_+i, pos.base() ), column_ );
1929 template<
typename MT
1932 Submatrix<MT,AF,false,false>::erase(
size_t i,
Iterator first,
Iterator last )
1935 return Iterator( matrix_.erase( row_+i, first.base(), last.base() ), column_ );
1964 template<
typename MT
1966 template<
typename Pred >
1967 inline void Submatrix<MT,AF,false,false>::erase( Pred predicate )
1969 for(
size_t i=0UL; i<
rows(); ++i ) {
1970 matrix_.erase( row_+i,
begin(i).base(),
end(i).base(), predicate );
2006 template<
typename MT
2008 template<
typename Pred >
2009 inline void Submatrix<MT,AF,false,false>::erase(
size_t i,
Iterator first,
Iterator last, Pred predicate )
2012 matrix_.erase( row_+i, first.base(), last.base(), predicate );
2042 template<
typename MT
2045 Submatrix<MT,AF,false,false>::find(
size_t i,
size_t j )
2047 const Iterator_<MT> pos( matrix_.find( row_ + i, column_ + j ) );
2049 if( pos != matrix_.end( row_ + i ) )
2074 template<
typename MT
2077 Submatrix<MT,AF,false,false>::find(
size_t i,
size_t j )
const 2079 const ConstIterator_<MT> pos( matrix_.find( row_ + i, column_ + j ) );
2081 if( pos != matrix_.end( row_ + i ) )
2106 template<
typename MT
2109 Submatrix<MT,AF,false,false>::lowerBound(
size_t i,
size_t j )
2111 return Iterator( matrix_.lowerBound( row_ + i, column_ + j ), column_ );
2133 template<
typename MT
2136 Submatrix<MT,AF,false,false>::lowerBound(
size_t i,
size_t j )
const 2138 return ConstIterator( matrix_.lowerBound( row_ + i, column_ + j ), column_ );
2160 template<
typename MT
2163 Submatrix<MT,AF,false,false>::upperBound(
size_t i,
size_t j )
2165 return Iterator( matrix_.upperBound( row_ + i, column_ + j ), column_ );
2187 template<
typename MT
2190 Submatrix<MT,AF,false,false>::upperBound(
size_t i,
size_t j )
const 2192 return ConstIterator( matrix_.upperBound( row_ + i, column_ + j ), column_ );
2224 template<
typename MT
2228 using blaze::assign;
2234 if( !tryAssign( matrix_,
trans( *
this ), row_, column_ ) ) {
2238 decltype(
auto) left( derestrict( *this ) );
2241 assign( left, tmp );
2267 template< typename MT
2269 inline Submatrix<MT,AF,false,false>& Submatrix<MT,AF,false,false>::ctranspose()
2271 using blaze::assign;
2277 if( !tryAssign( matrix_,
trans( *
this ), row_, column_ ) ) {
2281 decltype(
auto) left( derestrict( *this ) );
2284 assign( left, tmp );
2305 template< typename MT
2307 template< typename Other >
2308 inline Submatrix<MT,AF,false,false>& Submatrix<MT,AF,false,false>::scale( const Other& scalar )
2312 for(
size_t i=0UL; i<
rows(); ++i ) {
2315 element->value() *= scalar;
2343 template<
typename MT
2345 template<
typename Other >
2346 inline bool Submatrix<MT,AF,false,false>::canAlias(
const Other* alias )
const noexcept
2348 return matrix_.isAliased( alias );
2365 template<
typename MT
2367 template<
typename Other >
2368 inline bool Submatrix<MT,AF,false,false>::isAliased(
const Other* alias )
const noexcept
2370 return matrix_.isAliased( alias );
2387 template<
typename MT
2389 inline bool Submatrix<MT,AF,false,false>::canSMPAssign() const noexcept
2409 template<
typename MT
2411 template<
typename MT2
2413 inline void Submatrix<MT,AF,false,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
2420 for(
size_t i=0UL; i<
rows(); ++i ) {
2421 for(
size_t j=0UL; j<
columns(); ++j ) {
2422 if( IsSymmetric<MT>::value || IsHermitian<MT>::value ) {
2424 if( !isDefault<strict>( value ) )
2428 append( i, j, (~rhs)(i,j),
true );
2450 template<
typename MT
2452 template<
typename MT2 >
2453 inline void Submatrix<MT,AF,false,false>::assign(
const SparseMatrix<MT2,false>& rhs )
2460 for(
size_t i=0UL; i<(~rhs).
rows(); ++i ) {
2461 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element ) {
2462 if( IsSymmetric<MT>::value || IsHermitian<MT>::value ) {
2464 if( !isDefault<strict>( value ) )
2465 set( i, element->index(), value );
2468 append( i, element->index(), element->value(), true );
2490 template<
typename MT
2492 template<
typename MT2 >
2493 inline void Submatrix<MT,AF,false,false>::assign(
const SparseMatrix<MT2,true>& rhs )
2500 using RhsIterator = ConstIterator_<MT2>;
2503 std::vector<size_t> rowLengths( m_, 0UL );
2504 for(
size_t j=0UL; j<
n_; ++j ) {
2505 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2506 ++rowLengths[element->index()];
2510 for(
size_t i=0UL; i<
m_; ++i ) {
2511 reserve( i, rowLengths[i] );
2515 for(
size_t j=0UL; j<
n_; ++j ) {
2516 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2517 if( IsSymmetric<MT>::value || IsHermitian<MT>::value ) {
2519 if( !isDefault<strict>( value ) )
2520 set( element->index(), j, value );
2523 append( element->index(), j, element->value(), true );
2543 template<
typename MT
2545 template<
typename MT2
2547 inline void Submatrix<MT,AF,false,false>::addAssign(
const Matrix<MT2,SO>& rhs )
2549 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
2556 const AddType tmp(
serial( *
this + (~rhs) ) );
2576 template<
typename MT
2578 template<
typename MT2
2580 inline void Submatrix<MT,AF,false,false>::subAssign(
const Matrix<MT2,SO>& rhs )
2582 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
2589 const SubType tmp(
serial( *
this - (~rhs) ) );
2609 template<
typename MT
2611 template<
typename MT2
2613 inline void Submatrix<MT,AF,false,false>::schurAssign(
const Matrix<MT2,SO>& rhs )
2615 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
2623 const SchurType tmp(
serial( *
this % (~rhs) ) );
2651 template<
typename MT
2653 class Submatrix<MT,AF,true,false>
2654 :
public View< SparseMatrix< Submatrix<MT,AF,true,false>, true > >
2659 using Operand = If_< IsExpression<MT>, MT, MT& >;
2664 using This = Submatrix<MT,AF,true,false>;
2665 using BaseType = SparseMatrix<This,true>;
2674 using ConstReference = ConstReference_<MT>;
2683 template<
typename MatrixType
2684 ,
typename IteratorType >
2685 class SubmatrixElement
2686 :
private SparseElement
2695 inline SubmatrixElement( IteratorType pos,
size_t offset )
2707 template<
typename T >
inline SubmatrixElement& operator=(
const T& v ) {
2719 template<
typename T >
inline SubmatrixElement&
operator+=(
const T& v ) {
2731 template<
typename T >
inline SubmatrixElement&
operator-=(
const T& v ) {
2743 template<
typename T >
inline SubmatrixElement&
operator*=(
const T& v ) {
2755 template<
typename T >
inline SubmatrixElement&
operator/=(
const T& v ) {
2766 inline const SubmatrixElement* operator->()
const {
2776 inline decltype(
auto) value()
const {
2777 return pos_->value();
2786 inline size_t index()
const {
2787 return pos_->index() - offset_;
2802 template<
typename MatrixType
2803 ,
typename IteratorType >
2804 class SubmatrixIterator
2808 using IteratorCategory = std::forward_iterator_tag;
2809 using ValueType = SubmatrixElement<MatrixType,IteratorType>;
2810 using PointerType = ValueType;
2811 using ReferenceType = ValueType;
2812 using DifferenceType = ptrdiff_t;
2815 using iterator_category = IteratorCategory;
2816 using value_type = ValueType;
2817 using pointer = PointerType;
2818 using reference = ReferenceType;
2819 using difference_type = DifferenceType;
2825 inline SubmatrixIterator()
2837 inline SubmatrixIterator( IteratorType iterator,
size_t index )
2848 template<
typename MatrixType2,
typename IteratorType2 >
2849 inline SubmatrixIterator(
const SubmatrixIterator<MatrixType2,IteratorType2>& it )
2850 : pos_ ( it.base() )
2851 , offset_( it.offset() )
2860 inline SubmatrixIterator& operator++() {
2871 inline const SubmatrixIterator operator++(
int ) {
2872 const SubmatrixIterator tmp( *
this );
2883 inline ReferenceType
operator*()
const {
2884 return ReferenceType( pos_, offset_ );
2893 inline PointerType operator->()
const {
2894 return PointerType( pos_, offset_ );
2904 template<
typename MatrixType2,
typename IteratorType2 >
2905 inline bool operator==(
const SubmatrixIterator<MatrixType2,IteratorType2>& rhs )
const {
2906 return base() == rhs.base();
2916 template<
typename MatrixType2,
typename IteratorType2 >
2917 inline bool operator!=(
const SubmatrixIterator<MatrixType2,IteratorType2>& rhs )
const {
2918 return !( *
this == rhs );
2928 inline DifferenceType
operator-(
const SubmatrixIterator& rhs )
const {
2929 return pos_ - rhs.pos_;
2938 inline IteratorType base()
const {
2948 inline size_t offset() const noexcept {
2963 using ConstIterator = SubmatrixIterator< const MT, ConstIterator_<MT> >;
2971 enum :
bool { smpAssignable = MT::smpAssignable };
2977 explicit inline Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n );
2989 inline Reference operator()(
size_t i,
size_t j );
2990 inline ConstReference operator()(
size_t i,
size_t j )
const;
2991 inline Reference at(
size_t i,
size_t j );
2992 inline ConstReference at(
size_t i,
size_t j )
const;
2994 inline ConstIterator
begin (
size_t i )
const;
2995 inline ConstIterator
cbegin(
size_t i )
const;
2997 inline ConstIterator
end (
size_t i )
const;
2998 inline ConstIterator
cend (
size_t i )
const;
3005 inline Submatrix& operator=(
const Submatrix& rhs );
3007 template<
typename MT2,
bool SO >
inline Submatrix& operator= (
const Matrix<MT2,SO>& rhs );
3008 template<
typename MT2,
bool SO >
inline Submatrix&
operator+=(
const Matrix<MT2,SO>& rhs );
3009 template<
typename MT2,
bool SO >
inline Submatrix&
operator-=(
const Matrix<MT2,SO>& rhs );
3010 template<
typename MT2,
bool SO >
inline Submatrix& operator%=(
const Matrix<MT2,SO>& rhs );
3011 template<
typename MT2,
bool SO >
inline Submatrix&
operator*=(
const Matrix<MT2,SO>& rhs );
3013 template<
typename Other >
3014 inline EnableIf_<IsNumeric<Other>, Submatrix >&
operator*=( Other rhs );
3016 template<
typename Other >
3017 inline EnableIf_<IsNumeric<Other>, Submatrix >&
operator/=( Other rhs );
3024 inline Operand operand() const noexcept;
3025 inline
size_t row() const noexcept;
3026 inline
size_t column() const noexcept;
3027 inline
size_t rows() const noexcept;
3028 inline
size_t columns() const noexcept;
3029 inline
size_t capacity() const noexcept;
3030 inline
size_t capacity(
size_t i ) const noexcept;
3032 inline
size_t nonZeros(
size_t i ) const;
3033 inline
void reset();
3034 inline
void reset(
size_t i );
3035 inline
void reserve(
size_t nonzeros );
3036 void reserve(
size_t i,
size_t nonzeros );
3038 inline
void trim(
size_t j );
3047 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
3048 inline
void finalize(
size_t i );
3055 inline
void erase(
size_t i,
size_t j );
3059 template< typename Pred >
3060 inline
void erase( Pred predicate );
3062 template< typename Pred >
3063 inline
void erase(
size_t i,
Iterator first,
Iterator last, Pred predicate );
3070 inline
Iterator find (
size_t i,
size_t j );
3071 inline ConstIterator find (
size_t i,
size_t j ) const;
3072 inline
Iterator lowerBound(
size_t i,
size_t j );
3073 inline ConstIterator lowerBound(
size_t i,
size_t j ) const;
3074 inline
Iterator upperBound(
size_t i,
size_t j );
3075 inline ConstIterator upperBound(
size_t i,
size_t j ) const;
3082 inline Submatrix& transpose();
3083 inline Submatrix& ctranspose();
3085 template< typename Other > inline Submatrix& scale( const Other& scalar );
3092 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
3093 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
3095 inline
bool canSMPAssign() const noexcept;
3097 template< typename MT2,
bool SO > inline
void assign ( const DenseMatrix<MT2,SO>& rhs );
3098 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,true>& rhs );
3099 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,false>& rhs );
3100 template< typename MT2,
bool SO > inline
void addAssign ( const Matrix<MT2,SO>& rhs );
3101 template< typename MT2,
bool SO > inline
void subAssign ( const Matrix<MT2,SO>& rhs );
3102 template< typename MT2,
bool SO > inline
void schurAssign( const Matrix<MT2,SO>& rhs );
3110 inline
bool hasOverlap() const noexcept;
3119 const
size_t column_;
3161 template< typename MT
3163 inline Submatrix<MT,AF,true,false>::Submatrix( Operand matrix,
size_t rindex,
size_t cindex,
size_t m,
size_t n )
3170 if( ( row_ + m_ > matrix_.rows() ) || ( column_ + n_ > matrix_.columns() ) ) {
3197 template<
typename MT
3200 Submatrix<MT,AF,true,false>::operator()(
size_t i,
size_t j )
3205 return matrix_(row_+i,column_+j);
3222 template<
typename MT
3225 Submatrix<MT,AF,true,false>::operator()(
size_t i,
size_t j )
const 3230 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
3248 template<
typename MT
3251 Submatrix<MT,AF,true,false>::at(
size_t i,
size_t j )
3259 return (*
this)(i,j);
3277 template<
typename MT
3280 Submatrix<MT,AF,true,false>::at(
size_t i,
size_t j )
const 3288 return (*
this)(i,j);
3301 template<
typename MT
3309 return Iterator( matrix_.begin( j + column_ ), row_ );
3311 return Iterator( matrix_.lowerBound( row_, j + column_ ), row_ );
3324 template<
typename MT
3332 return ConstIterator( matrix_.cbegin( j + column_ ), row_ );
3334 return ConstIterator( matrix_.lowerBound( row_, j + column_ ), row_ );
3347 template<
typename MT
3355 return ConstIterator( matrix_.cbegin( j + column_ ), row_ );
3357 return ConstIterator( matrix_.lowerBound( row_, j + column_ ), row_ );
3370 template<
typename MT
3377 if( matrix_.rows() == row_ +
m_ )
3378 return Iterator( matrix_.end( j + column_ ), row_ );
3380 return Iterator( matrix_.lowerBound( row_ + m_, j + column_ ), row_ );
3393 template<
typename MT
3400 if( matrix_.rows() == row_ +
m_ )
3403 return ConstIterator( matrix_.lowerBound( row_ + m_, j + column_ ), row_ );
3416 template<
typename MT
3423 if( matrix_.rows() == row_ +
m_ )
3426 return ConstIterator( matrix_.lowerBound( row_ + m_, j + column_ ), row_ );
3455 template<
typename MT
3457 inline Submatrix<MT,AF,true,false>&
3458 Submatrix<MT,AF,true,false>::operator=(
const Submatrix& rhs )
3460 using blaze::assign;
3465 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
3468 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
3472 if( !tryAssign( matrix_, rhs, row_, column_ ) ) {
3476 decltype(
auto) left( derestrict( *this ) );
3478 if( rhs.canAlias( &matrix_ ) ) {
3481 assign( left, tmp );
3485 assign( left, rhs );
3511 template<
typename MT
3513 template<
typename MT2
3515 inline Submatrix<MT,AF,true,false>&
3516 Submatrix<MT,AF,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
3518 using blaze::assign;
3526 using Right = CompositeType_<MT2>;
3527 Right right( ~rhs );
3529 if( !tryAssign( matrix_, right, row_, column_ ) ) {
3533 decltype(
auto) left( derestrict( *this ) );
3535 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3536 const ResultType_<MT2> tmp( right );
3538 assign( left, tmp );
3542 assign( left, right );
3567 template<
typename MT
3569 template<
typename MT2
3571 inline Submatrix<MT,AF,true,false>&
3574 using blaze::assign;
3580 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
3588 const AddType tmp( *
this + (~rhs) );
3590 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
3594 decltype(
auto) left( derestrict( *this ) );
3597 assign( left, tmp );
3621 template< typename MT
3623 template< typename MT2
3625 inline Submatrix<MT,AF,true,false>&
3626 Submatrix<MT,AF,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
3628 using blaze::assign;
3634 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
3642 const SubType tmp( *
this - (~rhs) );
3644 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
3648 decltype(
auto) left( derestrict( *this ) );
3651 assign( left, tmp );
3675 template< typename MT
3677 template< typename MT2
3679 inline Submatrix<MT,AF,true,false>&
3680 Submatrix<MT,AF,true,false>::operator%=( const Matrix<MT2,SO>& rhs )
3682 using blaze::assign;
3688 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
3696 const SchurType tmp( *
this % (~rhs) );
3698 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
3702 decltype(
auto) left( derestrict( *this ) );
3705 assign( left, tmp );
3729 template< typename MT
3731 template< typename MT2
3733 inline Submatrix<MT,AF,true,false>&
3734 Submatrix<MT,AF,true,false>::operator*=( const Matrix<MT2,SO>& rhs )
3736 using blaze::assign;
3742 using MultType = MultTrait_< ResultType, ResultType_<MT2> >;
3751 const MultType tmp( *
this * (~rhs) );
3753 if( !tryAssign( matrix_, tmp, row_, column_ ) ) {
3757 decltype(
auto) left( derestrict( *this ) );
3760 assign( left, tmp );
3785 template< typename MT
3787 template< typename Other >
3788 inline
EnableIf_<IsNumeric<Other>, Submatrix<MT,AF,true,false> >&
3789 Submatrix<MT,AF,true,false>::operator*=( Other rhs )
3793 for(
size_t i=0UL; i<
columns(); ++i ) {
3796 element->value() *= rhs;
3823 template<
typename MT
3825 template<
typename Other >
3826 inline EnableIf_<IsNumeric<Other>, Submatrix<MT,AF,true,false> >&
3833 using DT = DivTrait_<ElementType,Other>;
3834 using Tmp = If_< IsNumeric<DT>, DT, Other >;
3838 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
3839 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
3840 for(
size_t i=0UL; i<
columns(); ++i ) {
3843 element->value() *= tmp;
3847 for(
size_t i=0UL; i<
columns(); ++i ) {
3850 element->value() /= rhs;
3874 template<
typename MT
3876 inline typename Submatrix<MT,AF,true,false>::Operand
3877 Submatrix<MT,AF,true,false>::operand() const noexcept
3891 template<
typename MT
3907 template<
typename MT
3923 template<
typename MT
3939 template<
typename MT
3955 template<
typename MT
3959 return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
3972 template<
typename MT
3977 return nonZeros( j ) + matrix_.capacity( column_+j ) - matrix_.nonZeros( column_+j );
3989 template<
typename MT
3993 size_t nonzeros( 0UL );
3995 for(
size_t i=0UL; i<
columns(); ++i )
4011 template<
typename MT
4028 template<
typename MT
4032 for(
size_t j=column_; j<column_+
n_; ++j )
4034 const size_t ibegin( ( IsLower<MT>::value )
4035 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4036 ?(
max( j+1UL, row_ ) )
4037 :(
max( j, row_ ) ) )
4039 const size_t iend ( ( IsUpper<MT>::value )
4040 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4041 ?(
min( j, row_+m_ ) )
4042 :(
min( j+1UL, row_+m_ ) ) )
4045 matrix_.erase( j, matrix_.lowerBound( ibegin, j ), matrix_.lowerBound( iend, j ) );
4059 template<
typename MT
4065 const size_t index( column_ + j );
4067 const size_t ibegin( ( IsLower<MT>::value )
4068 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4069 ?(
max( j+1UL, row_ ) )
4070 :(
max( j, row_ ) ) )
4072 const size_t iend ( ( IsUpper<MT>::value )
4073 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4074 ?(
min( j, row_+m_ ) )
4075 :(
min( j+1UL, row_+m_ ) ) )
4078 matrix_.erase( index, matrix_.lowerBound( ibegin, index ), matrix_.lowerBound( iend, index ) );
4095 template<
typename MT
4097 inline void Submatrix<MT,AF,true,false>::reserve(
size_t nonzeros )
4099 const size_t current(
capacity() );
4101 if( nonzeros > current ) {
4102 matrix_.reserve( matrix_.capacity() + nonzeros - current );
4121 template<
typename MT
4123 void Submatrix<MT,AF,true,false>::reserve(
size_t j,
size_t nonzeros )
4125 const size_t current(
capacity( j ) );
4126 const size_t index ( column_ + j );
4128 if( nonzeros > current ) {
4129 matrix_.reserve( index, matrix_.capacity( index ) + nonzeros - current );
4146 template<
typename MT
4148 void Submatrix<MT,AF,true,false>::trim()
4150 for(
size_t j=0UL; j<
columns(); ++j )
4168 template<
typename MT
4170 void Submatrix<MT,AF,true,false>::trim(
size_t j )
4173 matrix_.trim( column_ + j );
4189 template<
typename MT
4191 inline bool Submatrix<MT,AF,true,false>::hasOverlap() const noexcept
4193 BLAZE_INTERNAL_ASSERT( IsSymmetric<MT>::value || IsHermitian<MT>::value,
"Invalid matrix detected" );
4195 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
4224 template<
typename MT
4229 return Iterator( matrix_.set( row_+i, column_+j, value ), row_ );
4249 template<
typename MT
4252 Submatrix<MT,AF,true,false>::insert(
size_t i,
size_t j,
const ElementType& value )
4254 return Iterator( matrix_.insert( row_+i, column_+j, value ), row_ );
4309 template<
typename MT
4311 inline void Submatrix<MT,AF,true,false>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
4313 if( row_ + m_ == matrix_.rows() ) {
4314 matrix_.append( row_ + i, column_ + j, value, check );
4316 else if( !check || !
isDefault( value ) ) {
4317 matrix_.insert( row_ + i, column_ + j, value );
4338 template<
typename MT
4340 inline void Submatrix<MT,AF,true,false>::finalize(
size_t j )
4342 matrix_.trim( column_ + j );
4366 template<
typename MT
4368 inline void Submatrix<MT,AF,true,false>::erase(
size_t i,
size_t j )
4373 matrix_.erase( row_ + i, column_ + j );
4389 template<
typename MT
4392 Submatrix<MT,AF,true,false>::erase(
size_t j,
Iterator pos )
4395 return Iterator( matrix_.erase( column_+j, pos.base() ), row_ );
4412 template<
typename MT
4415 Submatrix<MT,AF,true,false>::erase(
size_t j,
Iterator first,
Iterator last )
4418 return Iterator( matrix_.erase( column_+j, first.base(), last.base() ), row_ );
4447 template<
typename MT
4449 template<
typename Pred >
4450 inline void Submatrix<MT,AF,true,false>::erase( Pred predicate )
4452 for(
size_t j=0UL; j<
columns(); ++j ) {
4453 matrix_.erase( column_+j,
begin(j).base(),
end(j).base(), predicate );
4486 template<
typename MT
4488 template<
typename Pred >
4489 inline void Submatrix<MT,AF,true,false>::erase(
size_t j,
Iterator first,
Iterator last, Pred predicate )
4492 matrix_.erase( column_+j, first.base(), last.base(), predicate );
4522 template<
typename MT
4525 Submatrix<MT,AF,true,false>::find(
size_t i,
size_t j )
4527 const Iterator_<MT> pos( matrix_.find( row_ + i, column_ + j ) );
4529 if( pos != matrix_.end( column_ + j ) )
4554 template<
typename MT
4557 Submatrix<MT,AF,true,false>::find(
size_t i,
size_t j )
const 4559 const ConstIterator_<MT> pos( matrix_.find( row_ + i, column_ + j ) );
4561 if( pos != matrix_.end( column_ + j ) )
4586 template<
typename MT
4589 Submatrix<MT,AF,true,false>::lowerBound(
size_t i,
size_t j )
4591 return Iterator( matrix_.lowerBound( row_ + i, column_ + j ), row_ );
4613 template<
typename MT
4616 Submatrix<MT,AF,true,false>::lowerBound(
size_t i,
size_t j )
const 4618 return ConstIterator( matrix_.lowerBound( row_ + i, column_ + j ), row_ );
4640 template<
typename MT
4643 Submatrix<MT,AF,true,false>::upperBound(
size_t i,
size_t j )
4645 return Iterator( matrix_.upperBound( row_ + i, column_ + j ), row_ );
4667 template<
typename MT
4670 Submatrix<MT,AF,true,false>::upperBound(
size_t i,
size_t j )
const 4672 return ConstIterator( matrix_.upperBound( row_ + i, column_ + j ), row_ );
4704 template<
typename MT
4708 using blaze::assign;
4714 if( !tryAssign( matrix_,
trans( *
this ), row_, column_ ) ) {
4718 decltype(
auto) left( derestrict( *this ) );
4721 assign( left, tmp );
4747 template< typename MT
4749 inline Submatrix<MT,AF,true,false>& Submatrix<MT,AF,true,false>::ctranspose()
4751 using blaze::assign;
4757 if( !tryAssign( matrix_,
ctrans( *
this ), row_, column_ ) ) {
4761 decltype(
auto) left( derestrict( *this ) );
4764 assign( left, tmp );
4785 template< typename MT
4787 template< typename Other >
4788 inline Submatrix<MT,AF,true,false>& Submatrix<MT,AF,true,false>::scale( const Other& scalar )
4792 for(
size_t i=0UL; i<
columns(); ++i ) {
4795 element->value() *= scalar;
4823 template<
typename MT
4825 template<
typename Other >
4826 inline bool Submatrix<MT,AF,true,false>::canAlias(
const Other* alias )
const noexcept
4828 return matrix_.isAliased( alias );
4845 template<
typename MT
4847 template<
typename Other >
4848 inline bool Submatrix<MT,AF,true,false>::isAliased(
const Other* alias )
const noexcept
4850 return matrix_.isAliased( alias );
4867 template<
typename MT
4869 inline bool Submatrix<MT,AF,true,false>::canSMPAssign() const noexcept
4889 template<
typename MT
4891 template<
typename MT2
4893 inline void Submatrix<MT,AF,true,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
4900 for(
size_t j=0UL; j<
columns(); ++j ) {
4901 for(
size_t i=0UL; i<
rows(); ++i ) {
4902 if( IsSymmetric<MT>::value || IsHermitian<MT>::value ) {
4904 if( !isDefault<strict>( value ) )
4908 append( i, j, (~rhs)(i,j),
true );
4930 template<
typename MT
4932 template<
typename MT2 >
4933 inline void Submatrix<MT,AF,true,false>::assign(
const SparseMatrix<MT2,true>& rhs )
4940 for(
size_t j=0UL; j<(~rhs).
columns(); ++j ) {
4941 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element ) {
4942 if( IsSymmetric<MT>::value || IsHermitian<MT>::value ) {
4944 if( !isDefault<strict>( value ) )
4945 set( element->index(), j, value );
4948 append( element->index(), j, element->value(), true );
4969 template<
typename MT
4971 template<
typename MT2 >
4972 inline void Submatrix<MT,AF,true,false>::assign(
const SparseMatrix<MT2,false>& rhs )
4979 using RhsIterator = ConstIterator_<MT2>;
4982 std::vector<size_t> columnLengths( n_, 0UL );
4983 for(
size_t i=0UL; i<
m_; ++i ) {
4984 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
4985 ++columnLengths[element->index()];
4989 for(
size_t j=0UL; j<
n_; ++j ) {
4990 reserve( j, columnLengths[j] );
4994 for(
size_t i=0UL; i<
m_; ++i ) {
4995 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
4996 if( IsSymmetric<MT>::value || IsHermitian<MT>::value ) {
4998 if( !isDefault<strict>( value ) )
4999 set( i, element->index(), value );
5002 append( i, element->index(), element->value(), true );
5022 template<
typename MT
5024 template<
typename MT2
5026 inline void Submatrix<MT,AF,true,false>::addAssign(
const Matrix<MT2,SO>& rhs )
5028 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
5035 const AddType tmp(
serial( *
this + (~rhs) ) );
5055 template<
typename MT
5057 template<
typename MT2
5059 inline void Submatrix<MT,AF,true,false>::subAssign(
const Matrix<MT2,SO>& rhs )
5061 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
5068 const SubType tmp(
serial( *
this - (~rhs) ) );
5088 template<
typename MT
5090 template<
typename MT2
5092 inline void Submatrix<MT,AF,true,false>::schurAssign(
const Matrix<MT2,SO>& rhs )
5094 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
5101 const SchurType tmp(
serial( *
this % (~rhs) ) );
#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.
Headerfile for the generic min algorithm.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3079
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the alignment flag values.
Header file for the IsUniUpper type trait.
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:356
Header file for basic type definitions.
Header file for the View base class.
Header file for the serial shim.
#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
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1411
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3078
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:198
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
size_t m_
The current number of rows of the compressed matrix.
Definition: CompressedMatrix.h:3287
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3080
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1762
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SUBMATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a submatrix type (i.e. a dense or sparse submatrix), a compilation error is created.
Definition: Submatrix.h:81
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:661
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3085
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:394
Column< MT > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:124
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3086
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 T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1393
Header file for the IsUniLower type trait.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1809
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:308
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:242
Constraint on the data type.
Header file for the SparseMatrix base class.
Row< MT > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:124
Constraint on the data type.
Header file for the matrix storage order types.
Constraint on the data type.
Headerfile for the generic max algorithm.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3084
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
decltype(auto) ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatMapExpr.h:1359
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3077
#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:3081
Constraint on the data type.
#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.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Header file for the IsLower type trait.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:340
Header file for the SparseElement base class.
Constraint on the data type.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:264
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8893
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Constraint on the data type.
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
#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 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 relaxation flag types.
Header file for the addition trait.
Header file for the division trait.
Header file for the submatrix trait.
Header file for the reset shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
Constraints on the storage order of matrix types.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:819
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the IsReference type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:324
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:790
size_t n_
The current number of columns of the compressed matrix.
Definition: CompressedMatrix.h:3288
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3083
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:252
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
#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
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a N-dimensional matrix type...
Definition: Matrix.h:61
Header file for the IsUpper type trait.
Header file for the IsHermitian type trait.
#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
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Header file for the IsExpression type trait class.
Constraint on the data type.
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:635