35 #ifndef _BLAZE_MATH_VIEWS_SPARSECOLUMN_H_
36 #define _BLAZE_MATH_VIEWS_SPARSECOLUMN_H_
351 template<
typename MT
352 ,
bool SO = IsColumnMajorMatrix<MT>::value
353 ,
bool SF = IsSymmetric<MT>::value >
354 class SparseColumn :
public SparseVector< SparseColumn<MT,SO,SF>, false >
398 enum { smpAssignable = 0 };
404 explicit inline SparseColumn( MT& matrix,
size_t index );
437 template<
typename Other >
439 operator*=( Other rhs );
441 template<
typename Other >
443 operator/=( Other rhs );
450 inline size_t size()
const;
456 inline void erase (
size_t index );
459 inline void reserve(
size_t n );
460 template<
typename Other >
inline SparseColumn& scale (
const Other& scalar );
486 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
487 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
516 template<
typename MT2,
bool SO2,
bool SF2 >
548 template<
typename MT
555 if(
matrix_.columns() <= index )
556 throw std::invalid_argument(
"Invalid column access index" );
575 template<
typename MT
582 return matrix_(index,col_);
593 template<
typename MT
600 return const_cast<const MT&
>( matrix_ )(index,col_);
612 template<
typename MT
617 return matrix_.begin( col_ );
629 template<
typename MT
634 return matrix_.cbegin( col_ );
646 template<
typename MT
651 return matrix_.cbegin( col_ );
663 template<
typename MT
668 return matrix_.end( col_ );
680 template<
typename MT
685 return matrix_.cend( col_ );
697 template<
typename MT
702 return matrix_.cend( col_ );
725 template<
typename MT
736 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
739 if(
size() != rhs.size() )
740 throw std::invalid_argument(
"Column sizes do not match" );
742 if( rhs.canAlias( &matrix_ ) ) {
744 matrix_.reset ( col_ );
745 matrix_.reserve( col_, tmp.nonZeros() );
749 matrix_.reset ( col_ );
750 matrix_.reserve( col_, rhs.nonZeros() );
769 template<
typename MT
772 template<
typename VT >
782 throw std::invalid_argument(
"Vector sizes do not match" );
784 if( (~rhs).canAlias( &matrix_ ) ) {
786 matrix_.reset( col_ );
790 matrix_.reset( col_ );
809 template<
typename MT
812 template<
typename VT >
818 throw std::invalid_argument(
"Vector sizes do not match" );
824 if( (~rhs).canAlias( &matrix_ ) ) {
826 matrix_.reset ( col_ );
827 matrix_.reserve( col_, tmp.nonZeros() );
831 matrix_.reset ( col_ );
832 matrix_.reserve( col_, (~rhs).
nonZeros() );
851 template<
typename MT
854 template<
typename VT >
860 throw std::invalid_argument(
"Vector sizes do not match" );
879 template<
typename MT
882 template<
typename VT >
888 throw std::invalid_argument(
"Vector sizes do not match" );
908 template<
typename MT
911 template<
typename VT >
915 throw std::invalid_argument(
"Vector sizes do not match" );
922 const MultType tmp( *
this * (~rhs) );
923 matrix_.reset( col_ );
942 template<
typename MT
945 template<
typename Other >
950 element->value() *= rhs;
968 template<
typename MT
971 template<
typename Other >
983 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
985 element->value() *= tmp;
989 element->value() /= rhs;
1010 template<
typename MT
1015 return matrix_.rows();
1025 template<
typename MT
1030 return matrix_.capacity( col_ );
1043 template<
typename MT
1048 return matrix_.nonZeros( col_ );
1058 template<
typename MT
1063 matrix_.reset( col_ );
1079 template<
typename MT
1085 return matrix_.set( index, col_, value );
1102 template<
typename MT
1108 return matrix_.insert( index, col_, value );
1121 template<
typename MT
1126 matrix_.erase( index, col_ );
1139 template<
typename MT
1144 return matrix_.erase( col_, pos );
1158 template<
typename MT
1164 return matrix_.erase( col_, first, last );
1178 template<
typename MT
1183 matrix_.reserve( col_, n );
1194 template<
typename MT
1197 template<
typename Other >
1201 element->value() *= scalar;
1215 template<
typename MT
1223 size_t nonzeros( 2UL*
capacity()+1UL );
1224 nonzeros =
max( nonzeros, 7UL );
1225 nonzeros =
min( nonzeros,
size() );
1255 template<
typename MT
1260 return matrix_.find( index, col_ );
1278 template<
typename MT
1284 return matrix_.find( index, col_ );
1301 template<
typename MT
1306 return matrix_.lowerBound( index, col_ );
1323 template<
typename MT
1329 return matrix_.lowerBound( index, col_ );
1346 template<
typename MT
1351 return matrix_.upperBound( index, col_ );
1368 template<
typename MT
1374 return matrix_.upperBound( index, col_ );
1411 template<
typename MT
1416 matrix_.append( index, col_, value, check );
1439 template<
typename MT
1442 template<
typename Other >
1445 return matrix_.isAliased( alias );
1460 template<
typename MT
1463 template<
typename Other >
1466 return matrix_.isAliased( alias );
1482 template<
typename MT
1485 template<
typename VT >
1491 for(
size_t i=0UL; i<
size(); ++i )
1493 if( matrix_.nonZeros( col_ ) == matrix_.capacity( col_ ) )
1494 matrix_.reserve( col_, extendCapacity() );
1496 matrix_.append( i, col_, (~rhs)[i],
true );
1513 template<
typename MT
1516 template<
typename VT >
1523 matrix_.append( element->index(), col_, element->value() );
1540 template<
typename MT
1543 template<
typename VT >
1554 const AddType tmp(
serial( *
this + (~rhs) ) );
1555 matrix_.reset( col_ );
1572 template<
typename MT
1575 template<
typename VT >
1586 const AddType tmp(
serial( *
this + (~rhs) ) );
1587 matrix_.reset ( col_ );
1588 matrix_.reserve( col_, tmp.nonZeros() );
1605 template<
typename MT
1608 template<
typename VT >
1619 const SubType tmp(
serial( *
this - (~rhs) ) );
1620 matrix_.reset( col_ );
1637 template<
typename MT
1640 template<
typename VT >
1651 const SubType tmp(
serial( *
this - (~rhs) ) );
1652 matrix_.reset ( col_ );
1653 matrix_.reserve( col_, tmp.nonZeros() );
1679 template<
typename MT >
1702 typedef SparseColumn<MT,false,false>
This;
1703 typedef typename ColumnTrait<MT>::Type
ResultType;
1713 typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type
Reference;
1719 template<
typename MatrixType
1720 ,
typename IteratorType >
1721 class ColumnElement :
private SparseElement
1731 enum { returnConst = IsConst<MatrixType>::value };
1736 typedef typename std::iterator_traits<IteratorType>::value_type SET;
1744 typedef typename SET::ValueType ValueType;
1745 typedef size_t IndexType;
1746 typedef typename SelectType<returnConst,CRT,RT>::Type
Reference;
1756 inline ColumnElement( IteratorType pos,
size_t row )
1768 template<
typename T >
inline ColumnElement&
operator=(
const T& v ) {
1780 template<
typename T >
inline ColumnElement& operator+=(
const T& v ) {
1792 template<
typename T >
inline ColumnElement& operator-=(
const T& v ) {
1804 template<
typename T >
inline ColumnElement& operator*=(
const T& v ) {
1816 template<
typename T >
inline ColumnElement& operator/=(
const T& v ) {
1827 inline const ColumnElement* operator->()
const {
1838 return pos_->value();
1847 inline IndexType index()
const {
1863 template<
typename MatrixType
1864 ,
typename IteratorType >
1865 class ColumnIterator
1869 typedef std::forward_iterator_tag IteratorCategory;
1870 typedef ColumnElement<MatrixType,IteratorType> ValueType;
1871 typedef ValueType PointerType;
1872 typedef ValueType ReferenceType;
1873 typedef ptrdiff_t DifferenceType;
1876 typedef IteratorCategory iterator_category;
1877 typedef ValueType value_type;
1878 typedef PointerType pointer;
1879 typedef ReferenceType reference;
1880 typedef DifferenceType difference_type;
1886 inline ColumnIterator()
1901 inline ColumnIterator( MatrixType& matrix,
size_t row,
size_t column )
1907 for( ; row_<
matrix_->rows(); ++row_ ) {
1908 pos_ =
matrix_->find( row_, column_ );
1909 if( pos_ !=
matrix_->end( row_ ) )
break;
1922 inline ColumnIterator( MatrixType& matrix,
size_t row,
size_t column, IteratorType pos )
1937 template<
typename MatrixType2,
typename IteratorType2 >
1938 inline ColumnIterator(
const ColumnIterator<MatrixType2,IteratorType2>& it )
1941 , column_( it.column_ )
1951 inline ColumnIterator& operator++() {
1953 for( ; row_<
matrix_->rows(); ++row_ ) {
1954 pos_ =
matrix_->find( row_, column_ );
1955 if( pos_ !=
matrix_->end( row_ ) )
break;
1967 inline const ColumnIterator operator++(
int ) {
1968 const ColumnIterator tmp( *
this );
1979 inline ReferenceType
operator*()
const {
1980 return ReferenceType( pos_, row_ );
1989 inline PointerType operator->()
const {
1990 return PointerType( pos_, row_ );
2000 template<
typename MatrixType2,
typename IteratorType2 >
2001 inline bool operator==(
const ColumnIterator<MatrixType2,IteratorType2>& rhs )
const {
2002 return (
matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
2012 template<
typename MatrixType2,
typename IteratorType2 >
2013 inline bool operator!=(
const ColumnIterator<MatrixType2,IteratorType2>& rhs )
const {
2014 return !( *
this == rhs );
2024 inline DifferenceType
operator-(
const ColumnIterator& rhs )
const {
2025 size_t counter( 0UL );
2026 for(
size_t i=rhs.row_; i<row_; ++i ) {
2043 template<
typename MatrixType2,
typename IteratorType2 >
friend class ColumnIterator;
2044 template<
typename MT2,
bool SO2,
bool SF2 >
friend class SparseColumn;
2051 typedef ColumnIterator<const MT,typename MT::ConstIterator>
ConstIterator;
2054 typedef typename SelectType< useConst, ConstIterator, ColumnIterator<MT,typename MT::Iterator> >::Type
Iterator;
2059 enum { smpAssignable = 0 };
2065 explicit inline SparseColumn( MT& matrix,
size_t index );
2093 template<
typename VT >
inline SparseColumn& operator+=(
const Vector<VT,false>& rhs );
2094 template<
typename VT >
inline SparseColumn& operator-=(
const Vector<VT,false>& rhs );
2095 template<
typename VT >
inline SparseColumn& operator*=(
const Vector<VT,false>& rhs );
2097 template<
typename Other >
2098 inline typename EnableIf< IsNumeric<Other>,
SparseColumn >::Type&
2099 operator*=( Other rhs );
2101 template<
typename Other >
2102 inline typename EnableIf< IsNumeric<Other>,
SparseColumn >::Type&
2103 operator/=( Other rhs );
2110 inline size_t size()
const;
2113 inline void reset();
2116 inline void erase (
size_t index );
2119 inline void reserve(
size_t n );
2120 template<
typename Other >
inline SparseColumn& scale (
const Other& scalar );
2146 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2147 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2149 template<
typename VT >
inline void assign (
const DenseVector <VT,false>& rhs );
2150 template<
typename VT >
inline void assign (
const SparseVector<VT,false>& rhs );
2151 template<
typename VT >
inline void addAssign(
const Vector<VT,false>& rhs );
2152 template<
typename VT >
inline void subAssign(
const Vector<VT,false>& rhs );
2166 template<
typename MT2,
bool SO2,
bool SF2 >
2167 friend bool isSame(
const SparseColumn<MT2,SO2,SF2>& a,
const SparseColumn<MT2,SO2,SF2>& b );
2198 template<
typename MT >
2203 if(
matrix_.columns() <= index )
2204 throw std::invalid_argument(
"Invalid column access index" );
2225 template<
typename MT >
2230 return matrix_(index,col_);
2243 template<
typename MT >
2248 return const_cast<const MT&
>( matrix_ )(index,col_);
2262 template<
typename MT >
2265 return Iterator( matrix_, 0UL, col_ );
2279 template<
typename MT >
2297 template<
typename MT >
2315 template<
typename MT >
2332 template<
typename MT >
2350 template<
typename MT >
2379 template<
typename MT >
2380 inline SparseColumn<MT,false,false>&
2389 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
2392 if(
size() != rhs.size() )
2393 throw std::invalid_argument(
"Column sizes do not match" );
2395 if( rhs.canAlias( &matrix_ ) ) {
2420 template<
typename MT >
2421 template<
typename VT >
2422 inline SparseColumn<MT,false,false>&
2428 throw std::invalid_argument(
"Vector sizes do not match" );
2450 template<
typename MT >
2451 template<
typename VT >
2452 inline SparseColumn<MT,false,false>&
2453 SparseColumn<MT,false,false>::operator+=(
const Vector<VT,false>& rhs )
2458 throw std::invalid_argument(
"Vector sizes do not match" );
2479 template<
typename MT >
2480 template<
typename VT >
2481 inline SparseColumn<MT,false,false>&
2482 SparseColumn<MT,false,false>::operator-=(
const Vector<VT,false>& rhs )
2487 throw std::invalid_argument(
"Vector sizes do not match" );
2509 template<
typename MT >
2510 template<
typename VT >
2511 inline SparseColumn<MT,false,false>&
2512 SparseColumn<MT,false,false>::operator*=(
const Vector<VT,false>& rhs )
2515 throw std::invalid_argument(
"Vector sizes do not match" );
2517 typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
2522 const MultType tmp( *
this * (~rhs) );
2543 template<
typename MT >
2544 template<
typename Other >
2545 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false,false> >::Type&
2546 SparseColumn<MT,false,false>::operator*=( Other rhs )
2549 element->value() *= rhs;
2569 template<
typename MT >
2570 template<
typename Other >
2571 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false,false> >::Type&
2572 SparseColumn<MT,false,false>::operator/=( Other rhs )
2576 typedef typename DivTrait<ElementType,Other>::Type DT;
2577 typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
2581 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2582 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2584 element->value() *= tmp;
2588 element->value() /= rhs;
2611 template<
typename MT >
2614 return matrix_.rows();
2626 template<
typename MT >
2629 return matrix_.rows();
2644 template<
typename MT >
2647 size_t counter( 0UL );
2663 template<
typename MT >
2666 for(
size_t i=0UL; i<
size(); ++i ) {
2667 matrix_.erase( i, col_ );
2686 template<
typename MT >
2690 return Iterator( matrix_, index, col_, matrix_.set( index, col_, value ) );
2709 template<
typename MT >
2713 return Iterator( matrix_, index, col_, matrix_.insert( index, col_, value ) );
2728 template<
typename MT >
2731 matrix_.erase( index, col_ );
2746 template<
typename MT >
2750 const size_t row( pos.row_ );
2755 matrix_.erase( row, pos.pos_ );
2756 return Iterator( matrix_, row+1UL, col_ );
2772 template<
typename MT >
2776 for( ; first!=last; ++first ) {
2777 matrix_.erase( first.row_, first.pos_ );
2795 template<
typename MT >
2812 template<
typename MT >
2813 template<
typename Other >
2814 inline SparseColumn<MT,false,false>& SparseColumn<MT,false,false>::scale(
const Other& scalar )
2817 element->value() *= scalar;
2846 template<
typename MT >
2850 const typename MT::Iterator pos( matrix_.find( index, col_ ) );
2852 if( pos != matrix_.end( index ) )
2853 return Iterator( matrix_, index, col_, pos );
2875 template<
typename MT >
2881 if( pos != matrix_.end( index ) )
2903 template<
typename MT >
2907 for(
size_t i=index; i<
size(); ++i )
2909 const typename MT::Iterator pos( matrix_.find( i, col_ ) );
2911 if( pos != matrix_.end( i ) )
2912 return Iterator( matrix_, i, col_, pos );
2934 template<
typename MT >
2938 for(
size_t i=index; i<
size(); ++i )
2942 if( pos != matrix_.end( i ) )
2965 template<
typename MT >
2969 for(
size_t i=index+1UL; i<
size(); ++i )
2971 const typename MT::Iterator pos( matrix_.find( i, col_ ) );
2973 if( pos != matrix_.end( i ) )
2974 return Iterator( matrix_, i, col_, pos );
2996 template<
typename MT >
3000 for(
size_t i=index+1UL; i<
size(); ++i )
3004 if( pos != matrix_.end( i ) )
3047 template<
typename MT >
3051 matrix_.insert( index, col_, value );
3076 template<
typename MT >
3077 template<
typename Other >
3080 return matrix_.isAliased( alias );
3093 template<
typename MT >
3094 template<
typename Other >
3097 return matrix_.isAliased( alias );
3115 template<
typename MT >
3116 template<
typename VT >
3121 for(
size_t i=0UL; i<(~rhs).
size(); ++i ) {
3122 matrix_(i,col_) = (~rhs)[i];
3141 template<
typename MT >
3142 template<
typename VT >
3150 for( ; i<element->index(); ++i )
3151 matrix_.erase( i, col_ );
3152 matrix_(i++,col_) = element->value();
3154 for( ; i<
size(); ++i ) {
3155 matrix_.erase( i, col_ );
3174 template<
typename MT >
3175 template<
typename VT >
3178 typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
3185 const AddType tmp(
serial( *
this + (~rhs) ) );
3204 template<
typename MT >
3205 template<
typename VT >
3208 typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
3215 const SubType tmp(
serial( *
this - (~rhs) ) );
3242 template<
typename MT >
3243 class SparseColumn<MT,false,true> :
public SparseVector< SparseColumn<MT,false,true>, false >
3249 typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type
Operand;
3260 enum { useConst = IsConst<MT>::value };
3265 typedef SparseColumn<MT,false,true>
This;
3266 typedef typename ColumnTrait<MT>::Type
ResultType;
3276 typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type
Reference;
3282 typedef typename SelectType< useConst, ConstIterator, typename MT::Iterator >::Type
Iterator;
3287 enum { smpAssignable = 0 };
3293 explicit inline SparseColumn( MT& matrix,
size_t index );
3322 template<
typename VT >
inline SparseColumn& operator+=(
const Vector<VT,false>& rhs );
3323 template<
typename VT >
inline SparseColumn& operator-=(
const Vector<VT,false>& rhs );
3324 template<
typename VT >
inline SparseColumn& operator*=(
const Vector<VT,false>& rhs );
3326 template<
typename Other >
3327 inline typename EnableIf< IsNumeric<Other>,
SparseColumn >::Type&
3328 operator*=( Other rhs );
3330 template<
typename Other >
3331 inline typename EnableIf< IsNumeric<Other>,
SparseColumn >::Type&
3332 operator/=( Other rhs );
3339 inline size_t size()
const;
3342 inline void reset();
3345 inline void erase (
size_t index );
3348 inline void reserve(
size_t n );
3349 template<
typename Other >
inline SparseColumn& scale (
const Other& scalar );
3375 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
3376 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
3378 template<
typename VT >
inline void assign (
const DenseVector <VT,false>& rhs );
3379 template<
typename VT >
inline void assign (
const SparseVector<VT,false>& rhs );
3380 template<
typename VT >
inline void addAssign(
const DenseVector <VT,false>& rhs );
3381 template<
typename VT >
inline void addAssign(
const SparseVector<VT,false>& rhs );
3382 template<
typename VT >
inline void subAssign(
const DenseVector <VT,false>& rhs );
3383 template<
typename VT >
inline void subAssign(
const SparseVector<VT,false>& rhs );
3404 template<
typename MT2,
bool SO2,
bool SF2 >
3405 friend bool isSame(
const SparseColumn<MT2,SO2,SF2>& a,
const SparseColumn<MT2,SO2,SF2>& b );
3436 template<
typename MT >
3441 if(
matrix_.columns() <= index )
3442 throw std::invalid_argument(
"Invalid column access index" );
3463 template<
typename MT >
3468 return matrix_(col_,index);
3481 template<
typename MT >
3486 return const_cast<const MT&
>( matrix_ )(col_,index);
3500 template<
typename MT >
3503 return matrix_.begin( col_ );
3517 template<
typename MT >
3521 return matrix_.cbegin( col_ );
3535 template<
typename MT >
3539 return matrix_.cbegin( col_ );
3553 template<
typename MT >
3556 return matrix_.end( col_ );
3570 template<
typename MT >
3574 return matrix_.cend( col_ );
3588 template<
typename MT >
3592 return matrix_.cend( col_ );
3617 template<
typename MT >
3626 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
3629 if(
size() != rhs.size() )
3630 throw std::invalid_argument(
"Column sizes do not match" );
3632 if( rhs.canAlias( &matrix_ ) ) {
3634 matrix_.reset ( col_ );
3635 matrix_.reserve( col_, tmp.nonZeros() );
3639 matrix_.reset ( col_ );
3640 matrix_.reserve( col_, rhs.nonZeros() );
3661 template<
typename MT >
3662 template<
typename VT >
3663 inline SparseColumn<MT,false,true>&
3673 throw std::invalid_argument(
"Vector sizes do not match" );
3675 if( (~rhs).canAlias( &matrix_ ) ) {
3677 matrix_.reset( col_ );
3681 matrix_.reset( col_ );
3702 template<
typename MT >
3703 template<
typename VT >
3704 inline SparseColumn<MT,false,true>&
3710 throw std::invalid_argument(
"Vector sizes do not match" );
3716 if( (~rhs).canAlias( &matrix_ ) ) {
3718 matrix_.reset ( col_ );
3719 matrix_.reserve( col_, tmp.nonZeros() );
3723 matrix_.reset ( col_ );
3724 matrix_.reserve( col_, (~rhs).
nonZeros() );
3745 template<
typename MT >
3746 template<
typename VT >
3747 inline SparseColumn<MT,false,true>&
3748 SparseColumn<MT,false,true>::operator+=(
const Vector<VT,false>& rhs )
3753 throw std::invalid_argument(
"Vector sizes do not match" );
3774 template<
typename MT >
3775 template<
typename VT >
3776 inline SparseColumn<MT,false,true>&
3777 SparseColumn<MT,false,true>::operator-=(
const Vector<VT,false>& rhs )
3782 throw std::invalid_argument(
"Vector sizes do not match" );
3804 template<
typename MT >
3805 template<
typename VT >
3806 inline SparseColumn<MT,false,true>&
3807 SparseColumn<MT,false,true>::operator*=(
const Vector<VT,false>& rhs )
3810 throw std::invalid_argument(
"Vector sizes do not match" );
3812 typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
3817 const MultType tmp( *
this * (~rhs) );
3818 matrix_.reset( col_ );
3839 template<
typename MT >
3840 template<
typename Other >
3841 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false,true> >::Type&
3842 SparseColumn<MT,false,true>::operator*=( Other rhs )
3845 element->value() *= rhs;
3865 template<
typename MT >
3866 template<
typename Other >
3867 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false,true> >::Type&
3868 SparseColumn<MT,false,true>::operator/=( Other rhs )
3872 typedef typename DivTrait<ElementType,Other>::Type DT;
3873 typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
3877 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
3878 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
3880 element->value() *= tmp;
3884 element->value() /= rhs;
3907 template<
typename MT >
3910 return matrix_.rows();
3922 template<
typename MT >
3925 return matrix_.capacity( col_ );
3940 template<
typename MT >
3943 return matrix_.nonZeros( col_ );
3955 template<
typename MT >
3958 matrix_.reset( col_ );
3976 template<
typename MT >
3980 return matrix_.set( col_, index, value );
3999 template<
typename MT >
4003 return matrix_.insert( col_, index, value );
4018 template<
typename MT >
4021 matrix_.erase( col_, index );
4036 template<
typename MT >
4040 return matrix_.erase( col_, pos );
4056 template<
typename MT >
4060 return matrix_.erase( col_, first, last );
4076 template<
typename MT >
4079 matrix_.reserve( col_, n );
4092 template<
typename MT >
4093 template<
typename Other >
4094 inline SparseColumn<MT,false,true>& SparseColumn<MT,false,true>::scale(
const Other& scalar )
4097 element->value() *= scalar;
4113 template<
typename MT >
4119 size_t nonzeros( 2UL*
capacity()+1UL );
4120 nonzeros =
max( nonzeros, 7UL );
4121 nonzeros =
min( nonzeros,
size() );
4153 template<
typename MT >
4157 return matrix_.find( col_, index );
4177 template<
typename MT >
4181 return matrix_.find( col_, index );
4200 template<
typename MT >
4204 return matrix_.lowerBound( col_, index );
4223 template<
typename MT >
4227 return matrix_.lowerBound( col_, index );
4246 template<
typename MT >
4250 return matrix_.upperBound( col_, index );
4269 template<
typename MT >
4273 return matrix_.upperBound( col_, index );
4312 template<
typename MT >
4315 matrix_.append( col_, index, value, check );
4340 template<
typename MT >
4341 template<
typename Other >
4344 return matrix_.isAliased( alias );
4361 template<
typename MT >
4362 template<
typename Other >
4365 return matrix_.isAliased( alias );
4383 template<
typename MT >
4384 template<
typename VT >
4390 for(
size_t i=0UL; i<
size(); ++i )
4392 if( matrix_.nonZeros( col_ ) == matrix_.capacity( col_ ) )
4393 matrix_.reserve( col_, extendCapacity() );
4395 matrix_.append( col_, i, (~rhs)[i],
true );
4414 template<
typename MT >
4415 template<
typename VT >
4422 matrix_.append( col_, element->index(), element->value() );
4441 template<
typename MT >
4442 template<
typename VT >
4445 typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
4453 const AddType tmp(
serial( *
this + (~rhs) ) );
4454 matrix_.reset( col_ );
4473 template<
typename MT >
4474 template<
typename VT >
4477 typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
4485 const AddType tmp(
serial( *
this + (~rhs) ) );
4486 matrix_.reset ( col_ );
4487 matrix_.reserve( col_, tmp.nonZeros() );
4506 template<
typename MT >
4507 template<
typename VT >
4510 typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
4518 const SubType tmp(
serial( *
this - (~rhs) ) );
4519 matrix_.reset( col_ );
4538 template<
typename MT >
4539 template<
typename VT >
4542 typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
4550 const SubType tmp(
serial( *
this - (~rhs) ) );
4551 matrix_.reset ( col_ );
4552 matrix_.reserve( col_, tmp.nonZeros() );
4574 template<
typename MT,
bool SO,
bool SF >
4575 inline void reset( SparseColumn<MT,SO,SF>& column );
4577 template<
typename MT,
bool SO,
bool SF >
4578 inline void clear( SparseColumn<MT,SO,SF>& column );
4580 template<
typename MT,
bool SO,
bool SF >
4581 inline bool isDefault(
const SparseColumn<MT,SO,SF>& column );
4583 template<
typename MT,
bool SO,
bool SF >
4584 inline bool isSame(
const SparseColumn<MT,SO,SF>& a,
const SparseColumn<MT,SO,SF>& b );
4596 template<
typename MT
4615 template<
typename MT
4643 template<
typename MT
4650 const ConstIterator
end( column.end() );
4651 for( ConstIterator element=column.begin(); element!=
end; ++element )
4652 if( !
isDefault( element->value() ) )
return false;
4670 template<
typename MT
4675 return (
isSame( a.matrix_, b.matrix_ ) && ( a.col_ == b.col_ ) );
4690 template<
typename MT,
bool SO,
bool SF >
4691 struct SubvectorTrait< SparseColumn<MT,SO,SF> >
Iterator upperBound(size_t index)
Returns an iterator to the first index greater then the given index.
Definition: SparseColumn.h:1349
Constraint on the data type.
bool canAlias(const Other *alias) const
Returns whether the sparse column can alias with the given address alias.
Definition: SparseColumn.h:1443
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:994
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.
ConstIterator cbegin() const
Returns an iterator to the first element of the column.
Definition: SparseColumn.h:649
#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 UNUSED_PARAMETER function template.
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:4838
Header file for the subtraction trait.
MT::ElementType ElementType
Type of the column elements.
Definition: SparseColumn.h:379
Iterator insert(size_t index, const ElementType &value)
Inserting an element into the sparse column.
Definition: SparseColumn.h:1106
Iterator find(size_t index)
Searches for a specific column element.
Definition: SparseColumn.h:1258
Header file for the SparseVector base class.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:258
void subAssign(const DenseVector< VT, false > &rhs)
Default implementation of the subtraction assignment of a dense vector.
Definition: SparseColumn.h:1609
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 ColumnTrait class.
Definition: ColumnTrait.h:115
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a column dense or sparse vector type...
Definition: TransposeFlag.h:159
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
#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
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
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: SparseColumn.h:390
void reserve(size_t n)
Setting the minimum capacity of the sparse column.
Definition: SparseColumn.h:1181
size_t capacity() const
Returns the maximum capacity of the sparse column.
Definition: SparseColumn.h:1028
Header file for the IsColumnMajorMatrix type trait.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2478
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:348
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
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
SelectType< useConst, ConstIterator, typename MT::Iterator >::Type Iterator
Iterator over non-constant elements.
Definition: SparseColumn.h:393
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_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a symmetric matrix type...
Definition: Symmetric.h:78
#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
Operand matrix_
The sparse matrix containing the column.
Definition: SparseColumn.h:509
void append(size_t index, const ElementType &value, bool check=false)
Appending an element to the sparse column.
Definition: SparseColumn.h:1414
Header file for the column base class.
Constraint on the data type.
ConstIterator cend() const
Returns an iterator just past the last element of the column.
Definition: SparseColumn.h:700
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.
Header file for the IsSymmetric type trait.
SparseColumn< MT, SO, SF > This
Type of this SparseColumn instance.
Definition: SparseColumn.h:376
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
Iterator lowerBound(size_t index)
Returns an iterator to the first index not less then the given index.
Definition: SparseColumn.h:1304
const size_t col_
The index of the column in the matrix.
Definition: SparseColumn.h:510
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
Header file for the Or class template.
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
Iterator set(size_t index, const ElementType &value)
Setting an element of the sparse column.
Definition: SparseColumn.h:1083
Base class for all columns.The Column class serves as a tag for all columns (i.e. dense and sparse co...
Definition: Column.h:64
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
Header file for the subvector trait.
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:79
Constraint on the data type.
Header file for the SparseElement base class.
Constraint on the data type.
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant column value.
Definition: SparseColumn.h:387
void reset()
Reset to the default initial values.
Definition: SparseColumn.h:1061
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SparseColumn.h:378
void erase(size_t index)
Erasing an element from the sparse column.
Definition: SparseColumn.h:1124
Constraints on the storage order of matrix types.
Constraint on the data type.
void assign(const DenseVector< VT, false > &rhs)
Default implementation of the assignment of a dense vector.
Definition: SparseColumn.h:1486
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
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2476
size_t nonZeros() const
Returns the number of non-zero elements in the column.
Definition: SparseColumn.h:1046
Constraint on the data type.
Header file for the SelectType class template.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2480
Header file for the EnableIf class template.
Header file for the serial shim.
bool isAliased(const Other *alias) const
Returns whether the sparse column is aliased with the given address alias.
Definition: SparseColumn.h:1464
Header file for the IsNumeric type trait.
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
#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
#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.
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:142
Base template for the MultTrait class.
Definition: MultTrait.h:142
MT::ConstReference ConstReference
Reference to a constant column value.
Definition: SparseColumn.h:384
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.
const DenseIterator< Type > operator-(const DenseIterator< Type > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:585
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Header file for the reset shim.
SparseColumn & operator=(const SparseColumn &rhs)
Copy assignment operator for SparseColumn.
Definition: SparseColumn.h:728
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2481
Header file for the column trait.
Header file for the isDefault shim.
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.
const SparseColumn & CompositeType
Data type for composite expression templates.
Definition: SparseColumn.h:381
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
#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
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
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:79
void addAssign(const DenseVector< VT, false > &rhs)
Default implementation of the addition assignment of a dense vector.
Definition: SparseColumn.h:1544
Iterator end()
Returns an iterator just past the last element of the column.
Definition: SparseColumn.h:666
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:151
Iterator begin()
Returns an iterator to the first element of the column.
Definition: SparseColumn.h:615
Reference operator[](size_t index)
Subscript operator for the direct access to the column elements.
Definition: SparseColumn.h:579
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:256
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: SparseColumn.h:380
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2473
ColumnTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: SparseColumn.h:377
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
Header file for basic type definitions.
size_t extendCapacity() const
Calculating a new sparse column capacity.
Definition: SparseColumn.h:1218
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2479
Base template for the SubTrait class.
Definition: SubTrait.h:142
#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
SelectType< IsExpression< MT >::value, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
Definition: SparseColumn.h:360
#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 to a specific column of a sparse matrix.The SparseColumn template represents a reference to...
Definition: Forward.h:51
Header file for the IsExpression type trait class.
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
size_t size() const
Returns the current size/dimension of the sparse column.
Definition: SparseColumn.h:1013
SparseColumn(MT &matrix, size_t index)
The constructor for SparseColumn.
Definition: SparseColumn.h:551
Header file for a safe C++ NULL pointer implementation.