35 #ifndef _BLAZE_MATH_VIEWS_SPARSESUBMATRIX_H_
36 #define _BLAZE_MATH_VIEWS_SPARSESUBMATRIX_H_
320 template<
typename MT
321 ,
bool SO = IsColumnMajorMatrix<MT>::value >
322 class SparseSubmatrix :
public SparseMatrix< SparseSubmatrix<MT,SO>, SO >
363 ,
typename IteratorType >
471 return pos_->value();
497 ,
typename IteratorType >
542 template<
typename MatrixType2,
typename IteratorType2 >
598 template<
typename MatrixType2,
typename IteratorType2 >
610 template<
typename MatrixType2,
typename IteratorType2 >
612 return !( *
this == rhs );
635 template<
typename MatrixType2,
typename IteratorType2 >
friend class SubmatrixIterator;
686 template<
typename Other >
688 operator*=( Other rhs );
690 template<
typename Other >
692 operator/=( Other rhs );
699 inline size_t rows()
const;
702 inline size_t capacity(
size_t i )
const;
704 inline size_t nonZeros(
size_t i )
const;
706 inline void reset(
size_t i );
708 inline void erase(
size_t i,
size_t j );
711 inline void reserve(
size_t nonzeros );
712 void reserve(
size_t i,
size_t nonzeros );
714 inline void trim(
size_t i );
715 template<
typename Other >
inline SparseSubmatrix& scale( Other scalar );
734 inline void append (
size_t i,
size_t j,
const ElementType& value,
bool check=
false );
742 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
743 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
768 template<
typename MT2,
bool SO2 >
807 template<
typename MT
816 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
817 throw std::invalid_argument(
"Invalid submatrix specification" );
837 template<
typename MT
857 template<
typename MT
881 template<
typename MT
906 template<
typename MT
931 template<
typename MT
956 template<
typename MT
981 template<
typename MT
1006 template<
typename MT
1039 template<
typename MT
1048 if(
this == &rhs || ( &
matrix_ == &rhs.matrix_ &&
row_ == rhs.row_ &&
column_ == rhs.column_ ) )
1051 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
1052 throw std::invalid_argument(
"Submatrix sizes do not match" );
1054 if( rhs.canAlias( &
matrix_ ) ) {
1079 template<
typename MT
1081 template<
typename MT2
1091 throw std::invalid_argument(
"Matrix sizes do not match" );
1118 template<
typename MT
1120 template<
typename MT2
1130 throw std::invalid_argument(
"Matrix sizes do not match" );
1157 template<
typename MT
1159 template<
typename MT2
1166 throw std::invalid_argument(
"Matrix sizes do not match" );
1185 template<
typename MT
1187 template<
typename MT2
1194 throw std::invalid_argument(
"Matrix sizes do not match" );
1213 template<
typename MT
1215 template<
typename MT2
1220 throw std::invalid_argument(
"Matrix sizes do not match" );
1228 const MultType tmp( *
this * (~rhs) );
1244 template<
typename MT
1246 template<
typename Other >
1250 for(
size_t i=0UL; i<
rows(); ++i ) {
1252 for(
Iterator element=begin(i); element!=last; ++element )
1253 element->value() *= rhs;
1268 template<
typename MT
1270 template<
typename Other >
1282 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1283 for(
size_t i=0UL; i<
rows(); ++i ) {
1285 for(
Iterator element=begin(i); element!=last; ++element )
1286 element->value() *= tmp;
1290 for(
size_t i=0UL; i<
rows(); ++i ) {
1292 for(
Iterator element=begin(i); element!=last; ++element )
1293 element->value() /= rhs;
1315 template<
typename MT
1329 template<
typename MT
1343 template<
typename MT
1363 template<
typename MT
1378 template<
typename MT
1382 size_t nonzeros( 0UL );
1384 for(
size_t i=0UL; i<
rows(); ++i )
1385 nonzeros += nonZeros( i );
1403 template<
typename MT
1408 return end(i) - begin(i);
1418 template<
typename MT
1440 template<
typename MT
1445 const size_t index(
row_ + i );
1464 template<
typename MT
1483 template<
typename MT
1506 template<
typename MT
1530 template<
typename MT
1551 template<
typename MT
1555 const size_t current( capacity() );
1557 if( nonzeros > current ) {
1579 template<
typename MT
1583 const size_t current( capacity( i ) );
1584 const size_t index (
row_ + i );
1586 if( nonzeros > current ) {
1587 matrix_.reserve( index,
matrix_.capacity( index ) + nonzeros - current );
1603 template<
typename MT
1607 for(
size_t i=0UL; i<
rows(); ++i )
1624 template<
typename MT
1640 template<
typename MT
1642 template<
typename Other >
1645 for(
size_t i=0UL; i<
rows(); ++i ) {
1647 for(
Iterator element=begin(i); element!=last; ++element )
1648 element->value() *= scalar;
1679 template<
typename MT
1709 template<
typename MT
1739 template<
typename MT
1764 template<
typename MT
1789 template<
typename MT
1814 template<
typename MT
1879 template<
typename MT
1886 else if( !check || !
isDefault( value ) ) {
1906 template<
typename MT
1933 template<
typename MT
1935 template<
typename Other >
1938 return static_cast<const void*
>( &
matrix_ ) == static_cast<const void*>( alias );
1953 template<
typename MT
1955 template<
typename Other >
1958 return static_cast<const void*
>( &
matrix_ ) == static_cast<const void*>( alias );
1974 template<
typename MT
1976 template<
typename MT2
1985 for(
size_t i=0UL; i<
rows(); ++i ) {
1986 for(
size_t j=0UL; j<
columns(); ++j ) {
1987 append( i, j, (~rhs)(i,j),
true );
2006 template<
typename MT
2008 template<
typename MT2 >
2014 reserve( 0UL, (~rhs).nonZeros() );
2016 for(
size_t i=0UL; i<(~rhs).
rows(); ++i ) {
2017 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element ) {
2018 append( i, element->index(), element->value(), true );
2037 template<
typename MT
2039 template<
typename MT2 >
2048 std::vector<size_t> rowLengths(
m_, 0UL );
2049 for(
size_t j=0UL; j<
n_; ++j ) {
2050 for( RhsIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2051 ++rowLengths[element->index()];
2055 for(
size_t i=0UL; i<
m_; ++i ) {
2056 reserve( i, rowLengths[i] );
2060 for(
size_t j=0UL; j<
n_; ++j ) {
2061 for( RhsIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2062 append( element->index(), j, element->value() );
2079 template<
typename MT
2081 template<
typename MT2
2093 const AddType tmp( *
this + (~rhs) );
2111 template<
typename MT
2113 template<
typename MT2
2125 const AddType tmp( *
this + (~rhs) );
2143 template<
typename MT
2145 template<
typename MT2
2157 const SubType tmp( *
this - (~rhs) );
2175 template<
typename MT
2177 template<
typename MT2
2189 const SubType tmp( *
this - (~rhs) );
2216 template<
typename MT >
2239 typedef SparseSubmatrix<MT,true>
This;
2240 typedef typename SubmatrixTrait<MT>::Type
ResultType;
2251 typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type
Reference;
2258 ,
typename IteratorType >
2259 class SubmatrixElement :
private SparseElement
2269 enum { returnConst = IsConst<MatrixType>::value };
2274 typedef typename SelectType< returnConst, const ElementType&, ElementType& >::Type
ReferenceType;
2365 return pos_->value();
2374 inline size_t index()
const {
2391 ,
typename IteratorType >
2392 class SubmatrixIterator
2397 typedef SubmatrixElement<MatrixType,IteratorType>
ValueType;
2436 template<
typename MatrixType2,
typename IteratorType2 >
2437 inline SubmatrixIterator(
const SubmatrixIterator<MatrixType2,IteratorType2>& it )
2492 template<
typename MatrixType2,
typename IteratorType2 >
2493 inline bool operator==(
const SubmatrixIterator<MatrixType2,IteratorType2>& rhs )
const {
2494 return pos_ == rhs.pos_;
2504 template<
typename MatrixType2,
typename IteratorType2 >
2505 inline bool operator!=(
const SubmatrixIterator<MatrixType2,IteratorType2>& rhs )
const {
2506 return !( *
this == rhs );
2517 return pos_ - rhs.pos_;
2529 template<
typename MatrixType2,
typename IteratorType2 >
friend class SubmatrixIterator;
2538 typedef SubmatrixIterator<const MT,typename MT::ConstIterator>
ConstIterator;
2541 typedef typename SelectType< useConst, ConstIterator, SubmatrixIterator<MT,typename MT::Iterator> >::Type
Iterator;
2576 template<
typename MT2,
bool SO >
inline SparseSubmatrix& operator+=(
const Matrix<MT2,SO>& rhs );
2577 template<
typename MT2,
bool SO >
inline SparseSubmatrix& operator-=(
const Matrix<MT2,SO>& rhs );
2578 template<
typename MT2,
bool SO >
inline SparseSubmatrix& operator*=(
const Matrix<MT2,SO>& rhs );
2580 template<
typename Other >
2582 operator*=( Other rhs );
2584 template<
typename Other >
2586 operator/=( Other rhs );
2593 inline size_t rows()
const;
2594 inline size_t columns()
const;
2596 inline size_t capacity(
size_t i )
const;
2598 inline size_t nonZeros(
size_t i )
const;
2599 inline void reset();
2600 inline void reset(
size_t i );
2602 inline void erase(
size_t i,
size_t j );
2605 inline void reserve(
size_t nonzeros );
2606 void reserve(
size_t i,
size_t nonzeros );
2608 inline void trim(
size_t j );
2609 template<
typename Other >
inline SparseSubmatrix& scale( Other scalar );
2628 inline void append (
size_t i,
size_t j,
const ElementType& value,
bool check=
false );
2636 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2637 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2638 template<
typename MT2,
bool SO >
inline void assign (
const DenseMatrix<MT2,SO>& rhs );
2639 template<
typename MT2 >
inline void assign (
const SparseMatrix<MT2,false>& rhs );
2640 template<
typename MT2 >
inline void assign (
const SparseMatrix<MT2,true>& rhs );
2641 template<
typename MT2,
bool SO >
inline void addAssign(
const DenseMatrix<MT2,SO>& rhs );
2642 template<
typename MT2,
bool SO >
inline void addAssign(
const SparseMatrix<MT2,SO>& rhs );
2643 template<
typename MT2,
bool SO >
inline void subAssign(
const DenseMatrix<MT2,SO>& rhs );
2644 template<
typename MT2,
bool SO >
inline void subAssign(
const SparseMatrix<MT2,SO>& rhs );
2662 template<
typename MT2,
bool SO2 >
2663 friend SparseSubmatrix<MT2,SO2>
2664 submatrix(
const SparseSubmatrix<MT2,SO2>& sm,
size_t row,
size_t column,
size_t m,
size_t n );
2703 template<
typename MT >
2711 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
2712 throw std::invalid_argument(
"Invalid submatrix specification" );
2734 template<
typename MT >
2736 SparseSubmatrix<MT,true>::operator()(
size_t i,
size_t j )
2755 template<
typename MT >
2757 SparseSubmatrix<MT,true>::operator()(
size_t i,
size_t j )
const
2775 template<
typename MT >
2796 template<
typename MT >
2817 template<
typename MT >
2838 template<
typename MT >
2859 template<
typename MT >
2880 template<
typename MT >
2914 template<
typename MT >
2915 inline SparseSubmatrix<MT,true>& SparseSubmatrix<MT,true>::operator=(
const SparseSubmatrix& rhs )
2922 if(
this == &rhs || ( &
matrix_ == &rhs.matrix_ &&
row_ == rhs.row_ &&
column_ == rhs.column_ ) )
2925 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
2926 throw std::invalid_argument(
"Submatrix sizes do not match" );
2928 if( rhs.canAlias( &
matrix_ ) ) {
2955 template<
typename MT >
2956 template<
typename MT2
2958 inline SparseSubmatrix<MT,true>& SparseSubmatrix<MT,true>::operator=(
const DenseMatrix<MT2,SO>& rhs )
2965 throw std::invalid_argument(
"Matrix sizes do not match" );
2967 if( RequiresEvaluation<MT2>::value || (~rhs).canAlias( &
matrix_ ) ) {
2994 template<
typename MT >
2995 template<
typename MT2
2997 inline SparseSubmatrix<MT,true>& SparseSubmatrix<MT,true>::operator=(
const SparseMatrix<MT2,SO>& rhs )
3005 throw std::invalid_argument(
"Matrix sizes do not match" );
3007 if( RequiresEvaluation<MT2>::value || (~rhs).canAlias( &
matrix_ ) ) {
3034 template<
typename MT >
3035 template<
typename MT2
3037 inline SparseSubmatrix<MT,true>& SparseSubmatrix<MT,true>::operator+=(
const Matrix<MT2,SO>& rhs )
3042 throw std::invalid_argument(
"Matrix sizes do not match" );
3063 template<
typename MT >
3064 template<
typename MT2
3066 inline SparseSubmatrix<MT,true>& SparseSubmatrix<MT,true>::operator-=(
const Matrix<MT2,SO>& rhs )
3071 throw std::invalid_argument(
"Matrix sizes do not match" );
3092 template<
typename MT >
3093 template<
typename MT2
3095 inline SparseSubmatrix<MT,true>& SparseSubmatrix<MT,true>::operator*=(
const Matrix<MT2,SO>& rhs )
3098 throw std::invalid_argument(
"Matrix sizes do not match" );
3100 typedef typename MultTrait<ResultType,typename MT2::ResultType>::Type MultType;
3106 const MultType tmp( *
this * (~rhs) );
3124 template<
typename MT >
3125 template<
typename Other >
3126 inline typename EnableIf< IsNumeric<Other>, SparseSubmatrix<MT,true> >::Type&
3127 SparseSubmatrix<MT,true>::operator*=( Other rhs )
3129 for(
size_t i=0UL; i<
columns(); ++i ) {
3131 for(
Iterator element=begin(i); element!=last; ++element )
3132 element->value() *= rhs;
3149 template<
typename MT >
3150 template<
typename Other >
3151 inline typename EnableIf< IsNumeric<Other>, SparseSubmatrix<MT,true> >::Type&
3152 SparseSubmatrix<MT,true>::operator/=( Other rhs )
3156 typedef typename DivTrait<ElementType,Other>::Type DT;
3157 typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
3161 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
3162 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
3163 for(
size_t i=0UL; i<
columns(); ++i ) {
3165 for(
Iterator element=begin(i); element!=last; ++element )
3166 element->value() *= tmp;
3170 for(
size_t i=0UL; i<
columns(); ++i ) {
3172 for(
Iterator element=begin(i); element!=last; ++element )
3173 element->value() /= rhs;
3197 template<
typename MT >
3212 template<
typename MT >
3227 template<
typename MT >
3228 inline size_t SparseSubmatrix<MT,true>::capacity()
const
3243 template<
typename MT >
3244 inline size_t SparseSubmatrix<MT,true>::capacity(
size_t j )
const
3259 template<
typename MT >
3260 inline size_t SparseSubmatrix<MT,true>::nonZeros()
const
3262 size_t nonzeros( 0UL );
3264 for(
size_t i=0UL; i<
columns(); ++i )
3265 nonzeros += nonZeros( i );
3280 template<
typename MT >
3281 inline size_t SparseSubmatrix<MT,true>::nonZeros(
size_t j )
const
3284 return end(j) - begin(j);
3296 template<
typename MT >
3314 template<
typename MT >
3318 const size_t index(
column_ + j );
3339 template<
typename MT >
3341 SparseSubmatrix<MT,true>::insert(
size_t i,
size_t j,
const ElementType& value )
3359 template<
typename MT >
3360 inline void SparseSubmatrix<MT,true>::erase(
size_t i,
size_t j )
3381 template<
typename MT >
3383 SparseSubmatrix<MT,true>::erase(
size_t j,
Iterator pos )
3403 template<
typename MT >
3425 template<
typename MT >
3426 inline void SparseSubmatrix<MT,true>::reserve(
size_t nonzeros )
3428 const size_t current( capacity() );
3430 if( nonzeros > current ) {
3450 template<
typename MT >
3451 void SparseSubmatrix<MT,true>::reserve(
size_t j,
size_t nonzeros )
3453 const size_t current( capacity( j ) );
3454 const size_t index (
column_ + j );
3456 if( nonzeros > current ) {
3457 matrix_.reserve( index,
matrix_.capacity( index ) + nonzeros - current );
3474 template<
typename MT >
3475 void SparseSubmatrix<MT,true>::trim()
3477 for(
size_t j=0UL; j<
columns(); ++j )
3495 template<
typename MT >
3496 void SparseSubmatrix<MT,true>::trim(
size_t j )
3512 template<
typename MT >
3513 template<
typename Other >
3514 inline SparseSubmatrix<MT,true>& SparseSubmatrix<MT,true>::scale( Other scalar )
3516 for(
size_t i=0UL; i<
columns(); ++i ) {
3518 for(
Iterator element=begin(i); element!=last; ++element )
3519 element->value() *= scalar;
3552 template<
typename MT >
3554 SparseSubmatrix<MT,true>::find(
size_t i,
size_t j )
3583 template<
typename MT >
3585 SparseSubmatrix<MT,true>::find(
size_t i,
size_t j )
const
3614 template<
typename MT >
3616 SparseSubmatrix<MT,true>::lowerBound(
size_t i,
size_t j )
3640 template<
typename MT >
3642 SparseSubmatrix<MT,true>::lowerBound(
size_t i,
size_t j )
const
3666 template<
typename MT >
3668 SparseSubmatrix<MT,true>::upperBound(
size_t i,
size_t j )
3692 template<
typename MT >
3694 SparseSubmatrix<MT,true>::upperBound(
size_t i,
size_t j )
const
3758 template<
typename MT >
3759 inline void SparseSubmatrix<MT,true>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
3764 else if( !check || !
isDefault( value ) ) {
3786 template<
typename MT >
3787 inline void SparseSubmatrix<MT,true>::finalize(
size_t j )
3814 template<
typename MT >
3815 template<
typename Other >
3816 inline bool SparseSubmatrix<MT,true>::canAlias(
const Other* alias )
const
3818 return static_cast<const void*
>( &
matrix_ ) == static_cast<const void*>( alias );
3835 template<
typename MT >
3836 template<
typename Other >
3837 inline bool SparseSubmatrix<MT,true>::isAliased(
const Other* alias )
const
3839 return static_cast<const void*
>( &
matrix_ ) == static_cast<const void*>( alias );
3857 template<
typename MT >
3858 template<
typename MT2
3867 for(
size_t j=0UL; j<
columns(); ++j ) {
3868 for(
size_t i=0UL; i<
rows(); ++i ) {
3869 append( i, j, (~rhs)(i,j),
true );
3890 template<
typename MT >
3891 template<
typename MT2 >
3900 std::vector<size_t> columnLengths( n_, 0UL );
3901 for(
size_t i=0UL; i<
m_; ++i ) {
3902 for( RhsIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
3903 ++columnLengths[element->index()];
3907 for(
size_t j=0UL; j<
n_; ++j ) {
3908 reserve( j, columnLengths[j] );
3912 for(
size_t i=0UL; i<
m_; ++i ) {
3913 for( RhsIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
3914 append( i, element->index(), element->value() );
3933 template<
typename MT >
3934 template<
typename MT2 >
3940 reserve( 0UL, (~rhs).nonZeros() );
3942 for(
size_t j=0UL; j<(~rhs).
columns(); ++j ) {
3943 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element ) {
3944 append( element->index(), j, element->value(), true );
3965 template<
typename MT >
3966 template<
typename MT2
3970 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
3978 const AddType tmp( *
this + (~rhs) );
3998 template<
typename MT >
3999 template<
typename MT2
4003 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
4011 const AddType tmp( *
this + (~rhs) );
4031 template<
typename MT >
4032 template<
typename MT2
4036 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
4044 const SubType tmp( *
this - (~rhs) );
4064 template<
typename MT >
4065 template<
typename MT2
4069 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
4077 const SubType tmp( *
this - (~rhs) );
4100 template<
typename MT,
bool SO >
4101 inline void reset( SparseSubmatrix<MT,SO>& sm );
4103 template<
typename MT,
bool SO >
4104 inline void clear( SparseSubmatrix<MT,SO>& sm );
4106 template<
typename MT,
bool SO >
4107 inline bool isDefault(
const SparseSubmatrix<MT,SO>& sm );
4119 template<
typename MT
4121 inline void reset( SparseSubmatrix<MT,SO>& sm )
4137 template<
typename MT
4139 inline void clear( SparseSubmatrix<MT,SO>& sm )
4164 template<
typename MT
4172 const size_t iend( ( SO ==
rowMajor)?( sm.rows() ):( sm.columns() ) );
4174 for(
size_t i=0UL; i<iend; ++i ) {
4175 for( ConstIterator element=sm.begin(i); element!=sm.end(i); ++element )
4176 if( !
isDefault( element->value() ) )
return false;
4221 template<
typename MT
4223 inline typename DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> >, SparseSubmatrix<MT> >::Type
4224 submatrix( SparseMatrix<MT,SO>& sm,
size_t row,
size_t column,
size_t m,
size_t n )
4228 return SparseSubmatrix<MT>( ~sm,
row,
column, m, n );
4262 template<
typename MT
4264 inline typename DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> >, SparseSubmatrix<const MT> >::Type
4265 submatrix(
const SparseMatrix<MT,SO>& sm,
size_t row,
size_t column,
size_t m,
size_t n )
4269 return SparseSubmatrix<const MT>( ~sm,
row,
column, m, n );
4297 template<
typename MT
4299 inline SparseSubmatrix<MT,SO>
4300 submatrix(
const SparseSubmatrix<MT,SO>& sm,
size_t row,
size_t column,
size_t m,
size_t n )
4304 return SparseSubmatrix<MT,SO>( sm.matrix_, sm.row_ +
row, sm.column_ +
column, m, n );
4320 template<
typename MT,
bool SO >
4321 struct SubmatrixTrait< SparseSubmatrix<MT,SO> >
4339 template<
typename MT,
bool SO >
4340 struct SubmatrixExprTrait< SparseSubmatrix<MT,SO> >
4342 typedef SparseSubmatrix<MT,SO> Type;
4350 template<
typename MT,
bool SO >
4351 struct SubmatrixExprTrait< const SparseSubmatrix<MT,SO> >
4353 typedef SparseSubmatrix<MT,SO> Type;
4361 template<
typename MT,
bool SO >
4362 struct SubmatrixExprTrait< volatile SparseSubmatrix<MT,SO> >
4364 typedef SparseSubmatrix<MT,SO> Type;
4372 template<
typename MT,
bool SO >
4373 struct SubmatrixExprTrait< const volatile SparseSubmatrix<MT,SO> >
4375 typedef SparseSubmatrix<MT,SO> Type;
4391 template<
typename MT,
bool SO >
4392 struct RowTrait< SparseSubmatrix<MT,SO> >
4410 template<
typename MT,
bool SO >
4411 struct ColumnTrait< SparseSubmatrix<MT,SO> >
MT MatrixType
Type of the matrix.
Definition: Matrix.h:71
Constraint on the data type.
Pointer difference type of the Blaze library.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, DenseColumn< MT > >::Type column(DenseMatrix< MT, SO > &dm, size_t index)
Creating a view on a specific column of the given dense matrix.
Definition: DenseColumn.h:3026
const size_t n_
The number of columns of the submatrix.
Definition: SparseSubmatrix.h:762
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
const SubmatrixElement * operator->() const
Direct access to the sparse submatrix element at the current iterator position.
Definition: SparseSubmatrix.h:460
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4512
#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
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.
void trim()
Removing all excessive capacity from all rows/columns.
Definition: SparseSubmatrix.h:1605
void reset()
Reset to the default initial values.
Definition: SparseSubmatrix.h:1420
DifferenceType difference_type
Difference between two iterators.
Definition: SparseSubmatrix.h:513
IteratorCategory iterator_category
The iterator category.
Definition: SparseSubmatrix.h:509
Header file for the View base class.
const size_t row_
The first row of the submatrix.
Definition: SparseSubmatrix.h:759
Header file for the row trait.
Base template for the SubmatrixTrait class.
Definition: SubmatrixTrait.h:117
ReferenceType reference
Reference return type.
Definition: SparseSubmatrix.h:512
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4555
size_t offset_
Offset within the according row/column of the sparse matrix.
Definition: SparseSubmatrix.h:488
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:196
#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
#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
Header file for the IsColumnMajorMatrix type trait.
PointerType pointer
Pointer return type.
Definition: SparseSubmatrix.h:511
void subAssign(const DenseMatrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a dense matrix.
Definition: SparseSubmatrix.h:2147
ConstIterator cbegin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: SparseSubmatrix.h:933
const SparseSubmatrix & CompositeType
Data type for composite expression templates.
Definition: SparseSubmatrix.h:350
void reserve(size_t nonzeros)
Setting the minimum capacity of the sparse submatrix.
Definition: SparseSubmatrix.h:1553
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant submatrix value.
Definition: SparseSubmatrix.h:356
CompressedMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:246
Header file for the IsTransExpr type trait class.
const size_t row_
The first row of the submatrix.
Definition: DenseSubmatrix.h:2793
#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.
Operand matrix_
The sparse matrix containing the submatrix.
Definition: SparseSubmatrix.h:758
MT::ElementType ElementType
Type of the submatrix elements.
Definition: SparseSubmatrix.h:348
ValueType value_type
Type of the underlying elements.
Definition: SparseSubmatrix.h:510
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4528
void finalize(size_t i)
Finalizing the element insertion of a row/column.
Definition: SparseSubmatrix.h:1908
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
SparseSubmatrix(MT &matrix, size_t row, size_t column, size_t m, size_t n)
The constructor for SparseSubmatrix.
Definition: SparseSubmatrix.h:809
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:104
Header file for the SparseMatrix base class.
Constraint on the data type.
Header file for the matrix storage order types.
Constraint on the data type.
SubmatrixElement< MatrixType, IteratorType > ValueType
Type of the underlying elements.
Definition: SparseSubmatrix.h:503
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
const size_t column_
The first column of the submatrix.
Definition: SparseSubmatrix.h:2654
SubmatrixIterator & operator++()
Pre-increment operator.
Definition: SparseSubmatrix.h:554
SelectType< IsExpression< MT >::value, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
Definition: SparseSubmatrix.h:328
Iterator insert(size_t i, size_t j, const ElementType &value)
Inserting an element into the sparse submatrix.
Definition: SparseSubmatrix.h:1467
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the DisableIf class template.
Header file for the multiplication trait.
Iterator lowerBound(size_t i, size_t j)
Returns an iterator to the first index not less then the given index.
Definition: SparseSubmatrix.h:1742
Header file for the If class template.
void erase(size_t i, size_t j)
Erasing an element from the sparse submatrix.
Definition: SparseSubmatrix.h:1485
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
size_t index() const
Access to the current index of the sparse element.
Definition: SparseSubmatrix.h:480
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
Header file for the Or class template.
Constraint on the data type.
ReferenceType operator*() const
Direct access to the current sparse submatrix element.
Definition: SparseSubmatrix.h:577
PointerType operator->() const
Direct access to the current sparse submatrix element.
Definition: SparseSubmatrix.h:587
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:179
ValueType ReferenceType
Reference return type.
Definition: SparseSubmatrix.h:505
Access proxy for a specific element of the sparse submatrix.
Definition: SparseSubmatrix.h:364
SubmatrixTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: SparseSubmatrix.h:345
Iterator begin(size_t i)
Returns an iterator to the first non-zero element of row/column i.
Definition: SparseSubmatrix.h:883
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2512
const SubmatrixIterator operator++(int)
Post-increment operator.
Definition: SparseSubmatrix.h:565
SubmatrixElement & operator-=(const T &v)
Subtraction assignment to the accessed sparse submatrix element.
Definition: SparseSubmatrix.h:425
SubmatrixIterator(IteratorType pos, size_t offset)
Constructor for the SubmatrixIterator class.
Definition: SparseSubmatrix.h:531
Header file for the SparseElement base class.
Constraint on the data type.
Operand matrix_
The dense matrix containing the column.
Definition: DenseColumn.h:2069
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SparseSubmatrix.h:502
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SparseSubmatrix.h:346
Constraints on the storage order of matrix types.
size_t rows() const
Returns the number of rows of the sparse submatrix.
Definition: SparseSubmatrix.h:1317
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SparseSubmatrix.h:506
Iterator find(size_t i, size_t j)
Searches for a specific submatrix element.
Definition: SparseSubmatrix.h:1682
Compile time check for floating point data types.This type trait tests whether or not the given templ...
Definition: IsFloatingPoint.h:94
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2373
SubmatrixIterator(const SubmatrixIterator< MatrixType2, IteratorType2 > &it)
Conversion constructor from different SubmatrixIterator instances.
Definition: SparseSubmatrix.h:543
SubmatrixElement & operator=(const T &v)
Assignment to the accessed sparse submatrix element.
Definition: SparseSubmatrix.h:401
Constraint on the data type.
Header file for the SelectType class template.
const size_t column_
The first column of the submatrix.
Definition: DenseSubmatrix.h:2794
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2377
ValueType PointerType
Pointer return type.
Definition: SparseSubmatrix.h:504
const size_t m_
The number of rows of the submatrix.
Definition: SparseSubmatrix.h:2655
bool canAlias(const Other *alias) const
Returns whether the submatrix can alias with the given address alias.
Definition: SparseSubmatrix.h:1936
Header file for the EnableIf class template.
SelectType< useConst, ConstIterator, SubmatrixIterator< MT, typename MT::Iterator > >::Type Iterator
Iterator over non-constant elements.
Definition: SparseSubmatrix.h:647
ColumnIterator< const MT > ConstIterator
Iterator over constant elements.
Definition: DenseColumn.h:1972
SubmatrixElement(IteratorType pos, size_t offset)
Constructor for the SubmatrixElement class.
Definition: SparseSubmatrix.h:389
Header file for the IsNumeric type trait.
const size_t row_
The index of the row in the matrix.
Definition: DenseRow.h:2069
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:2374
size_t offset_
The offset of the according row/column of the sparse matrix.
Definition: SparseSubmatrix.h:630
Header file for the IsConst type trait.
bool operator!=(const SubmatrixIterator< MatrixType2, IteratorType2 > &rhs) const
Inequality comparison between two SubmatrixIterator objects.
Definition: SparseSubmatrix.h:611
SparseSubmatrix< MT, SO > This
Type of this SparseSubmatrix instance.
Definition: SparseSubmatrix.h:344
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:141
SparseSubmatrix & operator=(const SparseSubmatrix &rhs)
Copy assignment operator for SparseSubmatrix.
Definition: SparseSubmatrix.h:1041
Base template for the MultTrait class.
Definition: MultTrait.h:141
const size_t column_
The first column of the submatrix.
Definition: SparseSubmatrix.h:760
Header file for the addition trait.
Header file for the division trait.
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: SparseSubmatrix.h:349
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:209
Header file for the submatrix trait.
void assign(const DenseMatrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a dense matrix.
Definition: SparseSubmatrix.h:1978
void addAssign(const DenseMatrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a dense matrix.
Definition: SparseSubmatrix.h:2083
bool operator==(const SubmatrixIterator< MatrixType2, IteratorType2 > &rhs) const
Equality comparison between two SubmatrixIterator objects.
Definition: SparseSubmatrix.h:599
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
SelectType< returnConst, const ElementType &, ElementType & >::Type ReferenceType
Return type of the value member function.
Definition: SparseSubmatrix.h:380
Iterator upperBound(size_t i, size_t j)
Returns an iterator to the first index greater then the given index.
Definition: SparseSubmatrix.h:1792
IteratorType pos_
Iterator to the current position within the sparse submatrix.
Definition: SparseSubmatrix.h:487
View on a specific submatrix of a sparse matrix.The SparseSubmatrix template represents a view on a s...
Definition: Forward.h:53
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, DenseRow< MT > >::Type row(DenseMatrix< MT, SO > &dm, size_t index)
Creating a view on a specific row of the given dense matrix.
Definition: DenseRow.h:3025
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:239
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2378
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:85
Base class for all sparse element types.The SparseElement class is the base class for all sparse elem...
Definition: SparseElement.h:57
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2511
#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:498
Compile time check for constant data types.The IsConst type trait tests whether or not the given temp...
Definition: IsConst.h:94
size_t columns() const
Returns the number of columns of the sparse submatrix.
Definition: SparseSubmatrix.h:1331
Base template for the DivTrait class.
Definition: DivTrait.h:141
ReferenceType value() const
Access to the current value of the sparse submatrix element.
Definition: SparseSubmatrix.h:470
SubmatrixIterator< const MT, typename MT::ConstIterator > ConstIterator
Iterator over constant elements.
Definition: SparseSubmatrix.h:644
IteratorType pos_
Iterator to the current sparse element.
Definition: SparseSubmatrix.h:629
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SparseSubmatrix.h:347
Base class for all views.The View class serves as a tag for all views (subvectors, submatrices, rows, columns, ...). All classes that represent a view and that are used within the expression template environment of the Blaze library have to derive from this class in order to qualify as a view. Only in case a class is derived from the View base class, the IsView type trait recognizes the class as valid view.
Definition: View.h:64
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
Header file for the IsComputation type trait class.
Iterator end(size_t i)
Returns an iterator just past the last non-zero element of row/column i.
Definition: SparseSubmatrix.h:958
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:247
SubmatrixElement & operator+=(const T &v)
Addition assignment to the accessed sparse submatrix element.
Definition: SparseSubmatrix.h:413
ConstIterator cend(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: SparseSubmatrix.h:1008
#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:2370
const size_t n_
The number of columns of the submatrix.
Definition: SparseSubmatrix.h:2656
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:154
Header file for basic type definitions.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2376
Base template for the SubTrait class.
Definition: SubTrait.h:141
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, DenseSubmatrix< MT > >::Type submatrix(DenseMatrix< MT, SO > &dm, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given dense matrix.
Definition: DenseSubmatrix.h:4412
#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
SubmatrixIterator()
Default constructor for the SubmatrixIterator class.
Definition: SparseSubmatrix.h:519
SelectType< useConst, ConstIterator, ColumnIterator< MT > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseColumn.h:1980
MT::ConstReference ConstReference
Reference to a constant submatrix value.
Definition: SparseSubmatrix.h:353
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:1881
size_t nonZeros() const
Returns the number of non-zero elements in the sparse submatrix.
Definition: SparseSubmatrix.h:1380
SubmatrixElement & operator/=(const T &v)
Division assignment to the accessed sparse submatrix element.
Definition: SparseSubmatrix.h:449
bool isAliased(const Other *alias) const
Returns whether the submatrix is aliased with the given address alias.
Definition: SparseSubmatrix.h:1956
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:138
#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
Operand matrix_
The dense matrix containing the submatrix.
Definition: DenseSubmatrix.h:2792
const size_t m_
The number of rows of the submatrix.
Definition: SparseSubmatrix.h:761
#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
Reference operator()(size_t i, size_t j)
2D-access to the sparse submatrix elements.
Definition: SparseSubmatrix.h:840
SubmatrixElement & operator*=(const T &v)
Multiplication assignment to the accessed sparse submatrix element.
Definition: SparseSubmatrix.h:437
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
DifferenceType operator-(const SubmatrixIterator &rhs) const
Calculating the number of elements between two submatrix iterators.
Definition: SparseSubmatrix.h:622
size_t capacity() const
Returns the maximum capacity of the sparse submatrix.
Definition: SparseSubmatrix.h:1345