35 #ifndef _BLAZE_MATH_VIEWS_SPARSESUBMATRIX_H_
36 #define _BLAZE_MATH_VIEWS_SPARSESUBMATRIX_H_
453 template<
typename MT
455 ,
bool SO = IsColumnMajorMatrix<MT>::value >
456 class SparseSubmatrix :
public SparseMatrix< SparseSubmatrix<MT,AF,SO>, SO >
497 ,
typename IteratorType >
513 typedef typename std::iterator_traits<IteratorType>::value_type
SET;
615 return pos_->value();
641 ,
typename IteratorType >
686 template<
typename MatrixType2,
typename IteratorType2 >
742 template<
typename MatrixType2,
typename IteratorType2 >
754 template<
typename MatrixType2,
typename IteratorType2 >
756 return !( *
this == rhs );
776 inline IteratorType
base()
const {
809 enum { smpAssignable = MT::smpAssignable };
848 template<
typename Other >
850 operator*=( Other rhs );
852 template<
typename Other >
854 operator/=( Other rhs );
861 inline size_t rows()
const;
864 inline size_t capacity(
size_t i )
const;
866 inline size_t nonZeros(
size_t i )
const;
868 inline void reset(
size_t i );
871 inline void erase(
size_t i,
size_t j );
874 inline void reserve(
size_t nonzeros );
875 void reserve(
size_t i,
size_t nonzeros );
877 inline void trim(
size_t i );
879 template<
typename Other >
inline SparseSubmatrix& scale(
const Other& scalar );
898 inline void append (
size_t i,
size_t j,
const ElementType& value,
bool check=
false );
906 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
907 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
942 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
946 template<
typename MT2,
bool AF2,
bool SO2 >
949 template<
typename MT2,
bool AF2,
bool SO2 >
952 template<
typename MT2,
bool AF2,
bool SO2 >
991 template<
typename MT
1001 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
1002 throw std::invalid_argument(
"Invalid submatrix specification" );
1022 template<
typename MT
1031 return matrix_(row_+i,column_+j);
1043 template<
typename MT
1052 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
1068 template<
typename MT
1076 if( column_ == 0UL )
1077 return Iterator( matrix_.begin( i + row_ ), column_ );
1079 return Iterator( matrix_.lowerBound( i + row_, column_ ), column_ );
1095 template<
typename MT
1103 if( column_ == 0UL )
1104 return ConstIterator( matrix_.cbegin( i + row_ ), column_ );
1106 return ConstIterator( matrix_.lowerBound( i + row_, column_ ), column_ );
1122 template<
typename MT
1130 if( column_ == 0UL )
1131 return ConstIterator( matrix_.cbegin( i + row_ ), column_ );
1133 return ConstIterator( matrix_.lowerBound( i + row_, column_ ), column_ );
1149 template<
typename MT
1157 if( matrix_.columns() == column_ +
n_ )
1158 return Iterator( matrix_.end( i + row_ ), column_ );
1160 return Iterator( matrix_.lowerBound( i + row_, column_ +
n_ ), column_ );
1176 template<
typename MT
1184 if( matrix_.columns() == column_ +
n_ )
1187 return ConstIterator( matrix_.lowerBound( i + row_, column_ +
n_ ), column_ );
1203 template<
typename MT
1211 if( matrix_.columns() == column_ +
n_ )
1214 return ConstIterator( matrix_.lowerBound( i + row_, column_ +
n_ ), column_ );
1240 template<
typename MT
1251 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
1254 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
1255 throw std::invalid_argument(
"Submatrix sizes do not match" );
1258 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1260 if( rhs.canAlias( &matrix_ ) ) {
1288 template<
typename MT
1291 template<
typename MT2
1302 throw std::invalid_argument(
"Matrix sizes do not match" );
1305 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1335 template<
typename MT
1338 template<
typename MT2
1349 throw std::invalid_argument(
"Matrix sizes do not match" );
1352 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1381 template<
typename MT
1384 template<
typename MT2
1392 throw std::invalid_argument(
"Matrix sizes do not match" );
1395 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1416 template<
typename MT
1419 template<
typename MT2
1427 throw std::invalid_argument(
"Matrix sizes do not match" );
1430 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1451 template<
typename MT
1454 template<
typename MT2
1460 throw std::invalid_argument(
"Matrix sizes do not match" );
1468 const MultType tmp( *
this * (~rhs) );
1471 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1488 template<
typename MT
1491 template<
typename Other >
1495 for(
size_t i=0UL; i<
rows(); ++i ) {
1498 element->value() *= rhs;
1513 template<
typename MT
1516 template<
typename Other >
1528 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1529 for(
size_t i=0UL; i<
rows(); ++i ) {
1532 element->value() *= tmp;
1536 for(
size_t i=0UL; i<
rows(); ++i ) {
1539 element->value() /= rhs;
1561 template<
typename MT
1576 template<
typename MT
1591 template<
typename MT
1596 return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
1612 template<
typename MT
1618 return nonZeros( i ) + matrix_.capacity( row_+i ) - matrix_.nonZeros( row_+i );
1628 template<
typename MT
1633 size_t nonzeros( 0UL );
1635 for(
size_t i=0UL; i<
rows(); ++i )
1654 template<
typename MT
1670 template<
typename MT
1675 for(
size_t i=row_; i<row_+
m_; ++i ) {
1676 matrix_.erase( i, matrix_.lowerBound( i, column_ ), matrix_.lowerBound( i, column_+
n_ ) );
1693 template<
typename MT
1699 const size_t index( row_ + i );
1700 matrix_.erase( index, matrix_.lowerBound( index, column_ ), matrix_.lowerBound( index, column_+
n_ ) );
1717 template<
typename MT
1723 return Iterator( matrix_.set( row_+i, column_+j, value ), column_ );
1741 template<
typename MT
1747 return Iterator( matrix_.insert( row_+i, column_+j, value ), column_ );
1761 template<
typename MT
1769 matrix_.erase( row_ + i, column_ + j );
1785 template<
typename MT
1792 return Iterator( matrix_.erase( row_+i, pos.base() ), column_ );
1810 template<
typename MT
1817 return Iterator( matrix_.erase( row_+i, first.base(), last.base() ), column_ );
1832 template<
typename MT
1837 const size_t current(
capacity() );
1839 if( nonzeros > current ) {
1840 matrix_.reserve( matrix_.capacity() + nonzeros - current );
1861 template<
typename MT
1866 const size_t current(
capacity( i ) );
1867 const size_t index ( row_ + i );
1869 if( nonzeros > current ) {
1870 matrix_.reserve( index, matrix_.capacity( index ) + nonzeros - current );
1886 template<
typename MT
1891 for(
size_t i=0UL; i<
rows(); ++i )
1908 template<
typename MT
1914 matrix_.trim( row_ + i );
1930 template<
typename MT
1938 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
1954 template<
typename MT
1957 template<
typename Other >
1960 for(
size_t i=0UL; i<
rows(); ++i ) {
1963 element->value() *= scalar;
1981 template<
typename MT
1984 template<
typename MT2
1988 if( ( row_ +
m_ <= column_ ) || ( column_ +
n_ <= row_ ) )
1991 const bool lower( row_ > column_ );
1992 const size_t size (
min( row_ +
m_, column_ +
n_ ) - ( lower ? row_ : column_ ) );
1997 const size_t row ( lower ? 0UL : column_ - row_ );
1998 const size_t column( lower ? row_ - column_ : 0UL );
2028 template<
typename MT
2034 const typename MT::Iterator pos( matrix_.find( row_ + i, column_ + j ) );
2036 if( pos != matrix_.end( row_ + i ) )
2059 template<
typename MT
2067 if( pos != matrix_.end( row_ + i ) )
2090 template<
typename MT
2096 return Iterator( matrix_.lowerBound( row_ + i, column_ + j ), column_ );
2116 template<
typename MT
2122 return ConstIterator( matrix_.lowerBound( row_ + i, column_ + j ), column_ );
2142 template<
typename MT
2148 return Iterator( matrix_.upperBound( row_ + i, column_ + j ), column_ );
2168 template<
typename MT
2174 return ConstIterator( matrix_.upperBound( row_ + i, column_ + j ), column_ );
2234 template<
typename MT
2239 if( column_ +
n_ == matrix_.columns() ) {
2240 matrix_.append( row_ + i, column_ + j, value, check );
2242 else if( !check || !
isDefault( value ) ) {
2243 matrix_.insert( row_ + i, column_ + j, value );
2262 template<
typename MT
2267 matrix_.trim( row_ + i );
2290 template<
typename MT
2293 template<
typename Other >
2296 return matrix_.isAliased( alias );
2311 template<
typename MT
2314 template<
typename Other >
2317 return matrix_.isAliased( alias );
2332 template<
typename MT
2353 template<
typename MT
2356 template<
typename MT2
2365 for(
size_t i=0UL; i<
rows(); ++i ) {
2366 for(
size_t j=0UL; j<
columns(); ++j ) {
2368 set( i, j, (~rhs)(i,j) );
2370 append( i, j, (~rhs)(i,j),
true );
2389 template<
typename MT
2392 template<
typename MT2 >
2400 for(
size_t i=0UL; i<(~rhs).
rows(); ++i ) {
2403 set( i, element->index(), element->value() );
2405 append( i, element->index(), element->value(), true );
2424 template<
typename MT
2427 template<
typename MT2 >
2438 std::vector<size_t> rowLengths(
m_, 0UL );
2439 for(
size_t j=0UL; j<
n_; ++j ) {
2440 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2441 ++rowLengths[element->index()];
2445 for(
size_t i=0UL; i<
m_; ++i ) {
2446 reserve( i, rowLengths[i] );
2450 for(
size_t j=0UL; j<
n_; ++j ) {
2451 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2453 set( element->index(), j, element->value() );
2455 append( element->index(), j, element->value() );
2472 template<
typename MT
2475 template<
typename MT2
2487 const AddType tmp(
serial( *
this + (~rhs) ) );
2505 template<
typename MT
2508 template<
typename MT2
2520 const AddType tmp(
serial( *
this + (~rhs) ) );
2538 template<
typename MT
2541 template<
typename MT2
2553 const SubType tmp(
serial( *
this - (~rhs) ) );
2571 template<
typename MT
2574 template<
typename MT2
2586 const SubType tmp(
serial( *
this - (~rhs) ) );
2613 template<
typename MT
2637 typedef SparseSubmatrix<MT,AF,true>
This;
2638 typedef typename SubmatrixTrait<MT>::Type
ResultType;
2649 typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type
Reference;
2656 ,
typename IteratorType >
2657 class SubmatrixElement :
private SparseElement
2667 enum { returnConst = IsConst<MatrixType>::value };
2672 typedef typename std::iterator_traits<IteratorType>::value_type
SET;
2680 typedef typename SET::ValueType
ValueType;
2682 typedef typename SelectType<returnConst,CRT,RT>::Type
Reference;
2774 return pos_->value();
2800 ,
typename IteratorType >
2801 class SubmatrixIterator
2806 typedef SubmatrixElement<MatrixType,IteratorType>
ValueType;
2845 template<
typename MatrixType2,
typename IteratorType2 >
2846 inline SubmatrixIterator(
const SubmatrixIterator<MatrixType2,IteratorType2>& it )
2901 template<
typename MatrixType2,
typename IteratorType2 >
2902 inline bool operator==(
const SubmatrixIterator<MatrixType2,IteratorType2>& rhs )
const {
2903 return base() == rhs.base();
2913 template<
typename MatrixType2,
typename IteratorType2 >
2914 inline bool operator!=(
const SubmatrixIterator<MatrixType2,IteratorType2>& rhs )
const {
2915 return !( *
this == rhs );
2926 return pos_ - rhs.pos_;
2935 inline IteratorType
base()
const {
2945 inline size_t offset()
const {
2960 typedef SubmatrixIterator<const MT,typename MT::ConstIterator>
ConstIterator;
2963 typedef typename SelectType< useConst, ConstIterator, SubmatrixIterator<MT,typename MT::Iterator> >::Type
Iterator;
2968 enum { smpAssignable = MT::smpAssignable };
3003 template<
typename MT2,
bool SO >
inline SparseSubmatrix& operator+=(
const Matrix<MT2,SO>& rhs );
3004 template<
typename MT2,
bool SO >
inline SparseSubmatrix& operator-=(
const Matrix<MT2,SO>& rhs );
3005 template<
typename MT2,
bool SO >
inline SparseSubmatrix& operator*=(
const Matrix<MT2,SO>& rhs );
3007 template<
typename Other >
3009 operator*=( Other rhs );
3011 template<
typename Other >
3013 operator/=( Other rhs );
3020 inline size_t rows()
const;
3021 inline size_t columns()
const;
3023 inline size_t capacity(
size_t i )
const;
3025 inline size_t nonZeros(
size_t i )
const;
3026 inline void reset();
3027 inline void reset(
size_t i );
3030 inline void erase(
size_t i,
size_t j );
3033 inline void reserve(
size_t nonzeros );
3034 void reserve(
size_t i,
size_t nonzeros );
3036 inline void trim(
size_t j );
3038 template<
typename Other >
inline SparseSubmatrix& scale(
const Other& scalar );
3057 inline void append (
size_t i,
size_t j,
const ElementType& value,
bool check=
false );
3065 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
3066 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
3070 template<
typename MT2,
bool SO >
inline void assign (
const DenseMatrix<MT2,SO>& rhs );
3071 template<
typename MT2 >
inline void assign (
const SparseMatrix<MT2,false>& rhs );
3072 template<
typename MT2 >
inline void assign (
const SparseMatrix<MT2,true>& rhs );
3073 template<
typename MT2,
bool SO >
inline void addAssign(
const DenseMatrix<MT2,SO>& rhs );
3074 template<
typename MT2,
bool SO >
inline void addAssign(
const SparseMatrix<MT2,SO>& rhs );
3075 template<
typename MT2,
bool SO >
inline void subAssign(
const DenseMatrix<MT2,SO>& rhs );
3076 template<
typename MT2,
bool SO >
inline void subAssign(
const SparseMatrix<MT2,SO>& rhs );
3084 template<
typename MT2,
bool SO2 >
inline bool preservesSymmetry(
const Matrix<MT2,SO2>& rhs );
3100 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
3101 friend const SparseSubmatrix<MT2,AF1,SO2>
3102 submatrix(
const SparseSubmatrix<MT2,AF2,SO2>& sm,
size_t row,
size_t column,
size_t m,
size_t n );
3104 template<
typename MT2,
bool AF2,
bool SO2 >
3105 friend bool isSame(
const SparseSubmatrix<MT2,AF2,SO2>& a,
const SparseMatrix<MT2,SO2>& b );
3107 template<
typename MT2,
bool AF2,
bool SO2 >
3108 friend bool isSame(
const SparseMatrix<MT2,SO2>& a,
const SparseSubmatrix<MT2,AF2,SO2>& b );
3110 template<
typename MT2,
bool AF2,
bool SO2 >
3111 friend bool isSame(
const SparseSubmatrix<MT2,AF2,SO2>& a,
const SparseSubmatrix<MT2,AF2,SO2>& b );
3148 template<
typename MT
3157 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
3158 throw std::invalid_argument(
"Invalid submatrix specification" );
3180 template<
typename MT
3188 return matrix_(row_+i,column_+j);
3202 template<
typename MT
3210 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
3223 template<
typename MT
3231 return Iterator( matrix_.begin( j + column_ ), row_ );
3233 return Iterator( matrix_.lowerBound( row_, j + column_ ), row_ );
3246 template<
typename MT
3254 return ConstIterator( matrix_.cbegin( j + column_ ), row_ );
3256 return ConstIterator( matrix_.lowerBound( row_, j + column_ ), row_ );
3269 template<
typename MT
3277 return ConstIterator( matrix_.cbegin( j + column_ ), row_ );
3279 return ConstIterator( matrix_.lowerBound( row_, j + column_ ), row_ );
3292 template<
typename MT
3299 if( matrix_.rows() == row_ +
m_ )
3300 return Iterator( matrix_.end( j + column_ ), row_ );
3302 return Iterator( matrix_.lowerBound( row_ +
m_, j + column_ ), row_ );
3315 template<
typename MT
3322 if( matrix_.rows() == row_ +
m_ )
3325 return ConstIterator( matrix_.lowerBound( row_ +
m_, j + column_ ), row_ );
3338 template<
typename MT
3345 if( matrix_.rows() == row_ +
m_ )
3348 return ConstIterator( matrix_.lowerBound( row_ +
m_, j + column_ ), row_ );
3376 template<
typename MT
3378 inline SparseSubmatrix<MT,AF,true>&
3386 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
3389 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
3390 throw std::invalid_argument(
"Submatrix sizes do not match" );
3392 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
3393 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
3395 if( rhs.canAlias( &matrix_ ) ) {
3425 template<
typename MT
3427 template<
typename MT2
3429 inline SparseSubmatrix<MT,AF,true>&
3437 throw std::invalid_argument(
"Matrix sizes do not match" );
3439 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
3440 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
3442 if( RequiresEvaluation<MT2>::value || (~rhs).canAlias( &matrix_ ) ) {
3472 template<
typename MT
3474 template<
typename MT2
3476 inline SparseSubmatrix<MT,AF,true>&
3485 throw std::invalid_argument(
"Matrix sizes do not match" );
3487 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
3488 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
3490 if( RequiresEvaluation<MT2>::value || (~rhs).canAlias( &matrix_ ) ) {
3519 template<
typename MT
3521 template<
typename MT2
3523 inline SparseSubmatrix<MT,AF,true>&
3524 SparseSubmatrix<MT,AF,true>::operator+=(
const Matrix<MT2,SO>& rhs )
3529 throw std::invalid_argument(
"Matrix sizes do not match" );
3531 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
3532 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
3555 template<
typename MT
3557 template<
typename MT2
3559 inline SparseSubmatrix<MT,AF,true>&
3560 SparseSubmatrix<MT,AF,true>::operator-=(
const Matrix<MT2,SO>& rhs )
3565 throw std::invalid_argument(
"Matrix sizes do not match" );
3567 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
3568 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
3591 template<
typename MT
3593 template<
typename MT2
3595 inline SparseSubmatrix<MT,AF,true>&
3596 SparseSubmatrix<MT,AF,true>::operator*=(
const Matrix<MT2,SO>& rhs )
3599 throw std::invalid_argument(
"Matrix sizes do not match" );
3601 typedef typename MultTrait<ResultType,typename MT2::ResultType>::Type MultType;
3607 const MultType tmp( *
this * (~rhs) );
3609 if( IsSymmetric<MT>::value && !preservesSymmetry( tmp ) )
3610 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
3629 template<
typename MT
3631 template<
typename Other >
3632 inline typename EnableIf< IsNumeric<Other>, SparseSubmatrix<MT,AF,true> >::Type&
3633 SparseSubmatrix<MT,AF,true>::operator*=( Other rhs )
3635 for(
size_t i=0UL; i<
columns(); ++i ) {
3638 element->value() *= rhs;
3655 template<
typename MT
3657 template<
typename Other >
3658 inline typename EnableIf< IsNumeric<Other>, SparseSubmatrix<MT,AF,true> >::Type&
3659 SparseSubmatrix<MT,AF,true>::operator/=( Other rhs )
3663 typedef typename DivTrait<ElementType,Other>::Type DT;
3664 typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
3668 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
3669 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
3670 for(
size_t i=0UL; i<
columns(); ++i ) {
3673 element->value() *= tmp;
3677 for(
size_t i=0UL; i<
columns(); ++i ) {
3680 element->value() /= rhs;
3704 template<
typename MT
3720 template<
typename MT
3736 template<
typename MT
3740 return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
3753 template<
typename MT
3758 return nonZeros( j ) + matrix_.capacity( column_+j ) - matrix_.nonZeros( column_+j );
3770 template<
typename MT
3774 size_t nonzeros( 0UL );
3776 for(
size_t i=0UL; i<
columns(); ++i )
3792 template<
typename MT
3809 template<
typename MT
3813 for(
size_t j=column_; j<column_+
n_; ++j ) {
3814 matrix_.erase( j, matrix_.lowerBound( row_, j ), matrix_.lowerBound( row_+
m_, j ) );
3828 template<
typename MT
3833 const size_t index( column_ + j );
3834 matrix_.erase( index, matrix_.lowerBound( row_, index ), matrix_.lowerBound( row_+
m_, index ) );
3853 template<
typename MT
3858 return Iterator( matrix_.set( row_+i, column_+j, value ), row_ );
3878 template<
typename MT
3883 return Iterator( matrix_.insert( row_+i, column_+j, value ), row_ );
3899 template<
typename MT
3906 matrix_.erase( row_ + i, column_ + j );
3922 template<
typename MT
3928 return Iterator( matrix_.erase( column_+j, pos.base() ), row_ );
3945 template<
typename MT
3951 return Iterator( matrix_.erase( column_+j, first.base(), last.base() ), row_ );
3968 template<
typename MT
3972 const size_t current(
capacity() );
3974 if( nonzeros > current ) {
3975 matrix_.reserve( matrix_.capacity() + nonzeros - current );
3994 template<
typename MT
3998 const size_t current(
capacity( j ) );
3999 const size_t index ( column_ + j );
4001 if( nonzeros > current ) {
4002 matrix_.reserve( index, matrix_.capacity( index ) + nonzeros - current );
4019 template<
typename MT
4023 for(
size_t j=0UL; j<
columns(); ++j )
4041 template<
typename MT
4046 matrix_.trim( column_ + j );
4064 template<
typename MT
4071 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
4089 template<
typename MT
4091 template<
typename Other >
4092 inline SparseSubmatrix<MT,AF,true>& SparseSubmatrix<MT,AF,true>::scale(
const Other& scalar )
4094 for(
size_t i=0UL; i<
columns(); ++i ) {
4097 element->value() *= scalar;
4117 template<
typename MT
4119 template<
typename MT2
4123 if( ( row_ +
m_ <= column_ ) || ( column_ + n_ <= row_ ) )
4126 const bool lower( row_ > column_ );
4127 const size_t size (
min( row_ +
m_, column_ + n_ ) - ( lower ? row_ : column_ ) );
4132 const size_t row ( lower ? 0UL : column_ - row_ );
4133 const size_t column( lower ? row_ - column_ : 0UL );
4165 template<
typename MT
4170 const typename MT::Iterator pos( matrix_.find( row_ + i, column_ + j ) );
4172 if( pos != matrix_.end( column_ + j ) )
4197 template<
typename MT
4204 if( pos != matrix_.end( column_ + j ) )
4229 template<
typename MT
4234 return Iterator( matrix_.lowerBound( row_ + i, column_ + j ), row_ );
4256 template<
typename MT
4261 return ConstIterator( matrix_.lowerBound( row_ + i, column_ + j ), row_ );
4283 template<
typename MT
4288 return Iterator( matrix_.upperBound( row_ + i, column_ + j ), row_ );
4310 template<
typename MT
4315 return ConstIterator( matrix_.upperBound( row_ + i, column_ + j ), row_ );
4377 template<
typename MT
4381 if( row_ +
m_ == matrix_.rows() ) {
4382 matrix_.append( row_ + i, column_ + j, value, check );
4384 else if( !check || !
isDefault( value ) ) {
4385 matrix_.insert( row_ + i, column_ + j, value );
4406 template<
typename MT
4410 matrix_.trim( column_ + j );
4435 template<
typename MT
4437 template<
typename Other >
4440 return matrix_.isAliased( alias );
4457 template<
typename MT
4459 template<
typename Other >
4462 return matrix_.isAliased( alias );
4479 template<
typename MT
4501 template<
typename MT
4503 template<
typename MT2
4512 for(
size_t j=0UL; j<
columns(); ++j ) {
4513 for(
size_t i=0UL; i<
rows(); ++i ) {
4514 if( IsSymmetric<MT>::value )
4515 set( i, j, (~rhs)(i,j) );
4517 append( i, j, (~rhs)(i,j),
true );
4538 template<
typename MT
4540 template<
typename MT2 >
4551 std::vector<size_t> columnLengths( n_, 0UL );
4552 for(
size_t i=0UL; i<
m_; ++i ) {
4553 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
4554 ++columnLengths[element->index()];
4558 for(
size_t j=0UL; j<
n_; ++j ) {
4559 reserve( j, columnLengths[j] );
4563 for(
size_t i=0UL; i<
m_; ++i ) {
4564 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
4565 if( IsSymmetric<MT>::value )
4566 set( i, element->index(), element->value() );
4568 append( i, element->index(), element->value() );
4587 template<
typename MT
4589 template<
typename MT2 >
4597 for(
size_t j=0UL; j<(~rhs).
columns(); ++j ) {
4599 if( IsSymmetric<MT>::value )
4600 set( element->index(), j, element->value() );
4602 append( element->index(), j, element->value(), true );
4623 template<
typename MT
4625 template<
typename MT2
4629 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
4637 const AddType tmp(
serial( *
this + (~rhs) ) );
4657 template<
typename MT
4659 template<
typename MT2
4663 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
4671 const AddType tmp(
serial( *
this + (~rhs) ) );
4691 template<
typename MT
4693 template<
typename MT2
4697 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
4705 const SubType tmp(
serial( *
this - (~rhs) ) );
4725 template<
typename MT
4727 template<
typename MT2
4731 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
4739 const SubType tmp(
serial( *
this - (~rhs) ) );
4762 template<
typename MT,
bool AF,
bool SO >
4763 inline void reset( SparseSubmatrix<MT,AF,SO>& sm );
4765 template<
typename MT,
bool AF,
bool SO >
4766 inline void reset( SparseSubmatrix<MT,AF,SO>& sm,
size_t i );
4768 template<
typename MT,
bool AF,
bool SO >
4769 inline void clear( SparseSubmatrix<MT,AF,SO>& sm );
4771 template<
typename MT,
bool AF,
bool SO >
4772 inline bool isDefault(
const SparseSubmatrix<MT,AF,SO>& sm );
4774 template<
typename MT,
bool AF,
bool SO >
4775 inline bool isSame(
const SparseSubmatrix<MT,AF,SO>& a,
const SparseMatrix<MT,SO>& b );
4777 template<
typename MT,
bool AF,
bool SO >
4778 inline bool isSame(
const SparseMatrix<MT,SO>& a,
const SparseSubmatrix<MT,AF,SO>& b );
4780 template<
typename MT,
bool AF,
bool SO >
4781 inline bool isSame(
const SparseSubmatrix<MT,AF,SO>& a,
const SparseSubmatrix<MT,AF,SO>& b );
4793 template<
typename MT
4816 template<
typename MT
4835 template<
typename MT
4863 template<
typename MT
4872 const size_t iend( ( SO ==
rowMajor)?( sm.rows() ):( sm.columns() ) );
4874 for(
size_t i=0UL; i<iend; ++i ) {
4875 for( ConstIterator element=sm.begin(i); element!=sm.end(i); ++element )
4876 if( !
isDefault( element->value() ) )
return false;
4896 template<
typename MT,
bool AF,
bool SO >
4899 return (
isSame( a.matrix_, ~b ) && ( a.rows() == (~b).
rows() ) && ( a.columns() == (~b).
columns() ) );
4916 template<
typename MT,
bool AF,
bool SO >
4919 return (
isSame( ~a, b.matrix_ ) && ( (~a).rows() == b.rows() ) && ( (~a).columns() == b.columns() ) );
4936 template<
typename MT,
bool AF,
bool SO >
4939 return (
isSame( a.matrix_, b.matrix_ ) &&
4940 ( a.row_ == b.row_ ) && ( a.column_ == b.column_ ) &&
4941 ( a.m_ == b.m_ ) && ( a.n_ == b.n_ ) );
4973 inline const SparseSubmatrix<MT,AF1,SO>
4974 submatrix(
const SparseSubmatrix<MT,AF2,SO>& sm,
size_t row,
size_t column,
size_t m,
size_t n )
4978 if( ( row + m > sm.rows() ) || ( column + n > sm.columns() ) )
4979 throw std::invalid_argument(
"Invalid submatrix specification" );
4981 return SparseSubmatrix<MT,AF1,SO>( sm.matrix_, sm.row_ +
row, sm.column_ +
column, m, n );
4997 template<
typename MT,
bool AF,
bool SO >
4998 struct SubmatrixTrait< SparseSubmatrix<MT,AF,SO> >
5016 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
5017 struct SubmatrixExprTrait< SparseSubmatrix<MT,AF1,SO>, AF2 >
5019 typedef SparseSubmatrix<MT,AF2,SO> Type;
5027 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
5028 struct SubmatrixExprTrait< const SparseSubmatrix<MT,AF1,SO>, AF2 >
5030 typedef SparseSubmatrix<MT,AF2,SO> Type;
5038 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
5039 struct SubmatrixExprTrait< volatile SparseSubmatrix<MT,AF1,SO>, AF2 >
5041 typedef SparseSubmatrix<MT,AF2,SO> Type;
5049 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
5050 struct SubmatrixExprTrait< const volatile SparseSubmatrix<MT,AF1,SO>, AF2 >
5052 typedef SparseSubmatrix<MT,AF2,SO> Type;
5068 template<
typename MT,
bool AF,
bool SO >
5069 struct RowTrait< SparseSubmatrix<MT,AF,SO> >
5087 template<
typename MT,
bool AF,
bool SO >
5088 struct ColumnTrait< SparseSubmatrix<MT,AF,SO> >
MT MatrixType
Type of the matrix.
Definition: Matrix.h:84
const size_t m_
The number of rows of the submatrix.
Definition: SparseSubmatrix.h:935
Constraint on the data type.
Pointer difference type of the Blaze library.
SubmatrixIterator(const SubmatrixIterator< MatrixType2, IteratorType2 > &it)
Conversion constructor from different SubmatrixIterator instances.
Definition: SparseSubmatrix.h:687
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SparseSubmatrix.h:650
IteratorType pos_
Iterator to the current position within the sparse submatrix.
Definition: SparseSubmatrix.h:631
SparseSubmatrix< MT, AF, SO > This
Type of this SparseSubmatrix instance.
Definition: SparseSubmatrix.h:478
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
Header file for mathematical functions.
size_t columns() const
Returns the number of columns of the sparse submatrix.
Definition: SparseSubmatrix.h:1579
#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
Iterator lowerBound(size_t i, size_t j)
Returns an iterator to the first index not less then the given index.
Definition: SparseSubmatrix.h:2094
Header file for the subvector/submatrix alignment flag values.
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
Header file for the subtraction trait.
ConstIterator cbegin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: SparseSubmatrix.h:1126
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:258
Header file for the row trait.
void reserve(size_t nonzeros)
Setting the minimum capacity of the sparse submatrix.
Definition: SparseSubmatrix.h:1835
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:258
Base template for the SubmatrixTrait class.
Definition: SubmatrixTrait.h:118
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
SubmatrixTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: SparseSubmatrix.h:479
#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:118
size_t offset() const
Access to the offset of the submatrix iterator.
Definition: SparseSubmatrix.h:786
#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:79
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:946
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:731
IteratorType pos_
Iterator to the current sparse element.
Definition: SparseSubmatrix.h:793
Reference operator()(size_t i, size_t j)
2D-access to the sparse submatrix elements.
Definition: SparseSubmatrix.h:1026
Header file for the IsColumnMajorMatrix type trait.
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2636
void addAssign(const DenseMatrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a dense matrix.
Definition: SparseSubmatrix.h:2477
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:348
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
void reset()
Reset to the default initial values.
Definition: SparseSubmatrix.h:1673
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:103
#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:118
CompressedMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:255
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:695
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:386
Access proxy for sparse, matrices.The MatrixAccessProxy provides safe access to the elements of a no...
Definition: MatrixAccessProxy.h:95
#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:118
Header file for the RequiresEvaluation type trait.
CRT ConstReference
Reference-to-const return type.
Definition: SparseSubmatrix.h:524
Iterator find(size_t i, size_t j)
Searches for a specific submatrix element.
Definition: SparseSubmatrix.h:2032
ValueType value_type
Type of the underlying elements.
Definition: SparseSubmatrix.h:654
DifferenceType operator-(const SubmatrixIterator &rhs) const
Calculating the number of elements between two submatrix iterators.
Definition: SparseSubmatrix.h:766
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SparseSubmatrix.h:646
ReferenceType operator*() const
Direct access to the current sparse submatrix element.
Definition: SparseSubmatrix.h:721
Base class for all submatrices.The Submatrix class serves as a tag for all submatrices (i...
Definition: Submatrix.h:64
size_t IndexType
The index type of the row element.
Definition: SparseSubmatrix.h:522
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
Iterator end(size_t i)
Returns an iterator just past the last non-zero element of row/column i.
Definition: SparseSubmatrix.h:1153
size_t capacity() const
Returns the maximum capacity of the sparse submatrix.
Definition: SparseSubmatrix.h:1594
Header file for the SparseMatrix base class.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse submatrix.
Definition: SparseSubmatrix.h:1631
SET::Reference RT
Reference type of the underlying sparse element.
Definition: SparseSubmatrix.h:515
Constraint on the data type.
Header file for the matrix storage order types.
Constraint on the data type.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
ValueType ReferenceType
Reference return type.
Definition: SparseSubmatrix.h:649
Operand matrix_
The sparse matrix containing the submatrix.
Definition: SparseSubmatrix.h:932
size_t offset_
Offset within the according row/column of the sparse matrix.
Definition: SparseSubmatrix.h:632
ConstIterator cend(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: SparseSubmatrix.h:1207
size_t rows() const
Returns the number of rows of the sparse submatrix.
Definition: SparseSubmatrix.h:1564
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
SubmatrixElement< MatrixType, IteratorType > ValueType
Type of the underlying elements.
Definition: SparseSubmatrix.h:647
PointerType operator->() const
Direct access to the current sparse submatrix element.
Definition: SparseSubmatrix.h:731
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
SubmatrixElement(IteratorType pos, size_t offset)
Constructor for the SubmatrixElement class.
Definition: SparseSubmatrix.h:533
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: StorageOrder.h:161
SparseSubmatrix & operator=(const SparseSubmatrix &rhs)
Copy assignment operator for SparseSubmatrix.
Definition: SparseSubmatrix.h:1244
SubmatrixElement & operator-=(const T &v)
Subtraction assignment to the accessed sparse submatrix element.
Definition: SparseSubmatrix.h:569
void append(size_t i, size_t j, const ElementType &value, bool check=false)
Appending an element to the specified row/column of the sparse submatrix.
Definition: SparseSubmatrix.h:2237
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
Header file for the Or class template.
Constraint on the data type.
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:947
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
Access proxy for a specific element of the sparse submatrix.
Definition: SparseSubmatrix.h:498
bool isAliased(const Other *alias) const
Returns whether the submatrix is aliased with the given address alias.
Definition: SparseSubmatrix.h:2315
SubmatrixIterator(IteratorType iterator, size_t index)
Constructor for the SubmatrixIterator class.
Definition: SparseSubmatrix.h:675
Iterator begin(size_t i)
Returns an iterator to the first non-zero element of row/column i.
Definition: SparseSubmatrix.h:1072
Iterator upperBound(size_t i, size_t j)
Returns an iterator to the first index greater then the given index.
Definition: SparseSubmatrix.h:2146
Iterator set(size_t i, size_t j, const ElementType &value)
Setting an element of the sparse submatrix.
Definition: SparseSubmatrix.h:1721
SelectType< returnConst, CRT, RT >::Type Reference
Reference return type.
Definition: SparseSubmatrix.h:523
const size_t row_
The first row of the submatrix.
Definition: SparseSubmatrix.h:933
Header file for the SparseElement base class.
void erase(size_t i, size_t j)
Erasing an element from the sparse submatrix.
Definition: SparseSubmatrix.h:1764
Constraint on the data type.
Constraints on the storage order of matrix types.
MT::ConstReference ConstReference
Reference to a constant submatrix value.
Definition: SparseSubmatrix.h:487
Iterator insert(size_t i, size_t j, const ElementType &value)
Inserting an element into the sparse submatrix.
Definition: SparseSubmatrix.h:1745
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:195
Compile time check for floating point data types.This type trait tests whether or not the given templ...
Definition: IsFloatingPoint.h:94
SubmatrixElement & operator/=(const T &v)
Division assignment to the accessed sparse submatrix element.
Definition: SparseSubmatrix.h:593
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2476
Constraint on the data type.
Header file for the SelectType class template.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2480
size_t offset_
The offset of the according row/column of the sparse matrix.
Definition: SparseSubmatrix.h:794
Header file for the EnableIf class template.
SubmatrixIterator & operator++()
Pre-increment operator.
Definition: SparseSubmatrix.h:698
SubmatrixIterator()
Default constructor for the SubmatrixIterator class.
Definition: SparseSubmatrix.h:663
Header file for the serial shim.
const size_t n_
The number of columns of the submatrix.
Definition: SparseSubmatrix.h:936
SET::ValueType ValueType
The value type of the row element.
Definition: SparseSubmatrix.h:521
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant submatrix value.
Definition: SparseSubmatrix.h:490
bool canSMPAssign() const
Returns whether the submatrix can be used in SMP assignments.
Definition: SparseSubmatrix.h:2335
const bool unaligned
Alignment flag for unaligned subvectors and submatrices.
Definition: AlignmentFlag.h:63
Header file for the IsNumeric type trait.
std::iterator_traits< IteratorType >::value_type SET
Type of the underlying sparse elements.
Definition: SparseSubmatrix.h:513
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:103
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Set< T, sizeof(T)> >::Type::Type set(T value)
Sets all values in the vector to the given integral value.
Definition: Set.h:211
ValueType PointerType
Pointer return type.
Definition: SparseSubmatrix.h:648
#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:116
Header file for the SubmatrixExprTrait class template.
#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: StorageOrder.h:81
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2477
Header file for the IsConst type trait.
SelectType< IsExpression< MT >::value, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
Definition: SparseSubmatrix.h:462
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:142
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SparseSubmatrix.h:480
Base template for the MultTrait class.
Definition: MultTrait.h:142
Header file for the addition trait.
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
Header file for the division trait.
Header file for the submatrix trait.
const SubmatrixIterator operator++(int)
Post-increment operator.
Definition: SparseSubmatrix.h:709
bool operator==(const SubmatrixIterator< MatrixType2, IteratorType2 > &rhs) const
Equality comparison between two SubmatrixIterator objects.
Definition: SparseSubmatrix.h:743
bool operator!=(const SubmatrixIterator< MatrixType2, IteratorType2 > &rhs) const
Inequality comparison between two SubmatrixIterator objects.
Definition: SparseSubmatrix.h:755
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
View on a specific submatrix of a sparse matrix.The SparseSubmatrix template represents a view on a s...
Definition: Forward.h:53
void assign(const DenseMatrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a dense matrix.
Definition: SparseSubmatrix.h:2358
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2481
IteratorType base() const
Access to the current position of the submatrix iterator.
Definition: SparseSubmatrix.h:776
Header file for the column trait.
Header file for the isDefault shim.
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:87
SelectType< useConst, ConstIterator, SubmatrixIterator< MT, typename MT::Iterator > >::Type Iterator
Iterator over non-constant elements.
Definition: SparseSubmatrix.h:804
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
Constraint on the data type.
SparseSubmatrix & transpose()
Transposing the submatrix.
Definition: SparseSubmatrix.h:1933
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
Base class for all sparse element types.The SparseElement class is the base class for all sparse elem...
Definition: SparseElement.h:57
SubmatrixElement & operator*=(const T &v)
Multiplication assignment to the accessed sparse submatrix element.
Definition: SparseSubmatrix.h:581
SET::ConstReference CRT
Reference-to-const type of the underlying sparse element.
Definition: SparseSubmatrix.h:516
#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:118
Iterator over the elements of the sparse submatrix.
Definition: SparseSubmatrix.h:642
const size_t column_
The first column of the submatrix.
Definition: SparseSubmatrix.h:934
Compile time check for constant data types.The IsConst type trait tests whether or not the given temp...
Definition: IsConst.h:94
Base template for the DivTrait class.
Definition: DivTrait.h:142
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2637
SubmatrixExprTrait< MT, unaligned >::Type submatrix(Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:137
MT::ElementType ElementType
Type of the submatrix elements.
Definition: SparseSubmatrix.h:482
ReferenceType reference
Reference return type.
Definition: SparseSubmatrix.h:656
bool preservesSymmetry(const Matrix< MT2, SO2 > &rhs)
Checking whether the given matrix would violate the symmetry of the underlying matrix.
Definition: SparseSubmatrix.h:1986
void subAssign(const DenseMatrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a dense matrix.
Definition: SparseSubmatrix.h:2543
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SparseSubmatrix.h:481
PointerType pointer
Pointer return type.
Definition: SparseSubmatrix.h:655
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:932
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:256
IndexType index() const
Access to the current index of the sparse element.
Definition: SparseSubmatrix.h:624
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2473
void finalize(size_t i)
Finalizing the element insertion of a row/column.
Definition: SparseSubmatrix.h:2265
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
Header file for basic type definitions.
const SubmatrixElement * operator->() const
Direct access to the sparse submatrix element at the current iterator position.
Definition: SparseSubmatrix.h:604
SubmatrixIterator< const MT, typename MT::ConstIterator > ConstIterator
Iterator over constant elements.
Definition: SparseSubmatrix.h:801
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2479
Base template for the SubTrait class.
Definition: SubTrait.h:142
Header file for the Submatrix base class.
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: SparseSubmatrix.h:483
#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:79
Reference value() const
Access to the current value of the sparse submatrix element.
Definition: SparseSubmatrix.h:614
Size type of the Blaze library.
SubmatrixElement & operator=(const T &v)
Assignment to the accessed sparse submatrix element.
Definition: SparseSubmatrix.h:545
SubmatrixElement & operator+=(const T &v)
Addition assignment to the accessed sparse submatrix element.
Definition: SparseSubmatrix.h:557
#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:79
SparseSubmatrix(Operand matrix, size_t row, size_t column, size_t m, size_t n)
The constructor for SparseSubmatrix.
Definition: SparseSubmatrix.h:994
const SparseSubmatrix & CompositeType
Data type for composite expression templates.
Definition: SparseSubmatrix.h:484
Header file for the IsExpression type trait class.
IteratorCategory iterator_category
The iterator category.
Definition: SparseSubmatrix.h:653
Constraint on the data type.
Header file for the FunctionTrace class.
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849
bool canAlias(const Other *alias) const
Returns whether the submatrix can alias with the given address alias.
Definition: SparseSubmatrix.h:2294
DifferenceType difference_type
Difference between two iterators.
Definition: SparseSubmatrix.h:657
void trim()
Removing all excessive capacity from all rows/columns.
Definition: SparseSubmatrix.h:1889