35 #ifndef _BLAZE_MATH_VIEWS_SPARSECOLUMN_H_
36 #define _BLAZE_MATH_VIEWS_SPARSECOLUMN_H_
371 template<
typename MT
372 ,
bool SO = IsColumnMajorMatrix<MT>::value
373 ,
bool SF = IsSymmetric<MT>::value >
374 class SparseColumn :
public SparseVector< SparseColumn<MT,SO,SF>, false >
418 enum { smpAssignable = 0 };
424 explicit inline SparseColumn( MT& matrix,
size_t index );
437 inline ConstReference
operator[](
size_t index )
const;
438 inline Iterator
begin ();
439 inline ConstIterator
begin ()
const;
440 inline ConstIterator
cbegin()
const;
441 inline Iterator
end ();
442 inline ConstIterator
end ()
const;
443 inline ConstIterator
cend ()
const;
460 template<
typename Other >
462 operator*=( Other rhs );
464 template<
typename Other >
466 operator/=( Other rhs );
473 inline size_t size()
const;
477 inline Iterator
set (
size_t index,
const ElementType& value );
478 inline Iterator
insert (
size_t index,
const ElementType& value );
479 inline void erase (
size_t index );
480 inline Iterator
erase ( Iterator pos );
481 inline Iterator
erase ( Iterator first, Iterator last );
482 inline void reserve(
size_t n );
483 template<
typename Other >
inline SparseColumn& scale (
const Other& scalar );
490 inline Iterator
find (
size_t index );
491 inline ConstIterator
find (
size_t index )
const;
493 inline ConstIterator
lowerBound(
size_t index )
const;
495 inline ConstIterator
upperBound(
size_t index )
const;
502 inline void append(
size_t index,
const ElementType& value,
bool check=
false );
509 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
510 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
527 template<
typename MT2,
bool SO2,
typename VT >
531 template<
typename MT2,
bool SO2,
typename VT >
535 template<
typename MT2,
bool SO2,
typename VT >
536 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
539 template<
typename MT2,
bool SO2,
typename VT >
543 template<
typename MT2,
bool SO2,
typename VT >
544 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
547 template<
typename MT2,
bool SO2,
typename VT >
551 template<
typename MT2,
bool SO2,
typename VT >
552 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
567 template<
typename MT2,
bool SO2,
bool SF2 >
570 template<
typename MT2,
bool SO2,
bool SF2 >
606 template<
typename MT
613 if(
matrix_.columns() <= index )
614 throw std::invalid_argument(
"Invalid column access index" );
633 template<
typename MT
640 return matrix_(index,col_);
651 template<
typename MT
658 return const_cast<const MT&
>( matrix_ )(index,col_);
670 template<
typename MT
675 return matrix_.begin( col_ );
687 template<
typename MT
692 return matrix_.cbegin( col_ );
704 template<
typename MT
709 return matrix_.cbegin( col_ );
721 template<
typename MT
726 return matrix_.end( col_ );
738 template<
typename MT
743 return matrix_.cend( col_ );
755 template<
typename MT
760 return matrix_.cend( col_ );
786 template<
typename MT
797 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
800 if(
size() != rhs.size() )
801 throw std::invalid_argument(
"Column sizes do not match" );
803 if( !preservesInvariant( matrix_, rhs ) )
804 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
808 if( rhs.canAlias( &matrix_ ) ) {
811 left.reserve( tmp.nonZeros() );
816 left.reserve( rhs.nonZeros() );
841 template<
typename MT
844 template<
typename VT >
854 throw std::invalid_argument(
"Vector sizes do not match" );
859 if( !preservesInvariant( matrix_, right ) )
860 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
895 template<
typename MT
898 template<
typename VT >
908 throw std::invalid_argument(
"Vector sizes do not match" );
913 if( !preservesInvariant( matrix_, right ) )
914 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
921 left.reserve( tmp.nonZeros() );
926 left.reserve( right.nonZeros() );
951 template<
typename MT
954 template<
typename VT >
973 throw std::invalid_argument(
"Vector sizes do not match" );
975 const AddType tmp( *
this + (~rhs) );
977 if( !preservesInvariant( matrix_, tmp ) )
978 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
1006 template<
typename MT
1009 template<
typename VT >
1028 throw std::invalid_argument(
"Vector sizes do not match" );
1030 const AddType tmp( *
this + (~rhs) );
1032 if( !preservesInvariant( matrix_, tmp ) )
1033 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
1038 left.reserve( tmp.nonZeros() );
1063 template<
typename MT
1066 template<
typename VT >
1085 throw std::invalid_argument(
"Vector sizes do not match" );
1087 const SubType tmp( *
this - (~rhs) );
1089 if( !preservesInvariant( matrix_, tmp ) )
1090 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
1119 template<
typename MT
1122 template<
typename VT >
1141 throw std::invalid_argument(
"Vector sizes do not match" );
1143 const SubType tmp( *
this - (~rhs) );
1145 if( !preservesInvariant( matrix_, tmp ) )
1146 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
1151 left.reserve( tmp.nonZeros() );
1173 template<
typename MT
1176 template<
typename VT >
1193 throw std::invalid_argument(
"Vector sizes do not match" );
1197 const MultType tmp( *
this * (~rhs) );
1223 template<
typename MT
1226 template<
typename Other >
1233 element->value() *= rhs;
1256 template<
typename MT
1259 template<
typename Other >
1273 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1275 element->value() *= tmp;
1279 element->value() /= rhs;
1300 template<
typename MT
1305 return matrix_.rows();
1315 template<
typename MT
1320 return matrix_.capacity( col_ );
1333 template<
typename MT
1338 return matrix_.nonZeros( col_ );
1348 template<
typename MT
1353 matrix_.reset( col_ );
1369 template<
typename MT
1375 return matrix_.set( index, col_, value );
1392 template<
typename MT
1398 return matrix_.insert( index, col_, value );
1411 template<
typename MT
1416 matrix_.erase( index, col_ );
1429 template<
typename MT
1434 return matrix_.erase( col_, pos );
1448 template<
typename MT
1454 return matrix_.erase( col_, first, last );
1468 template<
typename MT
1473 matrix_.reserve( col_, n );
1488 template<
typename MT
1491 template<
typename Other >
1497 element->value() *= scalar;
1511 template<
typename MT
1519 size_t nonzeros( 2UL*
capacity()+1UL );
1520 nonzeros =
max( nonzeros, 7UL );
1521 nonzeros =
min( nonzeros,
size() );
1541 template<
typename MT
1544 template<
typename MT2
1568 template<
typename MT
1571 template<
typename MT2
1583 for(
size_t i=0UL; i<iend; ++i ) {
1607 template<
typename MT
1610 template<
typename MT2
1613 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
1627 for( RhsIterator element=(~rhs).begin(); element!=last; ++element ) {
1648 template<
typename MT
1651 template<
typename MT2
1666 for(
size_t i=ibegin; i<
size(); ++i ) {
1687 template<
typename MT
1690 template<
typename MT2
1693 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
1703 const RhsIterator last( (~rhs).
end() );
1704 RhsIterator element( (~rhs).lowerBound( ( checkDiagonal )?( col_ ):( col_+1UL ) ) );
1707 if( element == last || element->index() != col_ || !
isOne( element->value() ) )
1712 for( ; element!=last; ++element ) {
1733 template<
typename MT
1736 template<
typename MT2
1746 for(
size_t i=0UL; i<col_; ++i ) {
1751 for(
size_t i=col_+1UL; i<
size(); ++i ) {
1772 template<
typename MT
1775 template<
typename MT2
1778 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
1787 for( RhsIterator element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1788 if( element->index() != col_ && !
isDefault( element->value() ) )
1818 template<
typename MT
1823 return matrix_.find( index, col_ );
1841 template<
typename MT
1847 return matrix_.find( index, col_ );
1864 template<
typename MT
1869 return matrix_.lowerBound( index, col_ );
1886 template<
typename MT
1892 return matrix_.lowerBound( index, col_ );
1909 template<
typename MT
1914 return matrix_.upperBound( index, col_ );
1931 template<
typename MT
1937 return matrix_.upperBound( index, col_ );
1974 template<
typename MT
1979 matrix_.append( index, col_, value, check );
2002 template<
typename MT
2005 template<
typename Other >
2008 return matrix_.isAliased( alias );
2023 template<
typename MT
2026 template<
typename Other >
2029 return matrix_.isAliased( alias );
2045 template<
typename MT
2048 template<
typename VT >
2056 for(
size_t i=0UL; i<
size(); ++i )
2058 if( matrix_.nonZeros( col_ ) == matrix_.capacity( col_ ) )
2059 matrix_.reserve( col_, extendCapacity() );
2061 matrix_.append( i, col_, (~rhs)[i],
true );
2078 template<
typename MT
2081 template<
typename VT >
2090 matrix_.append( element->index(), col_, element->value(), true );
2107 template<
typename MT
2110 template<
typename VT >
2123 const AddType tmp(
serial( *
this + (~rhs) ) );
2124 matrix_.reset( col_ );
2141 template<
typename MT
2144 template<
typename VT >
2157 const AddType tmp(
serial( *
this + (~rhs) ) );
2158 matrix_.reset( col_ );
2159 matrix_.reserve( col_, tmp.nonZeros() );
2176 template<
typename MT
2179 template<
typename VT >
2192 const SubType tmp(
serial( *
this - (~rhs) ) );
2193 matrix_.reset( col_ );
2210 template<
typename MT
2213 template<
typename VT >
2226 const SubType tmp(
serial( *
this - (~rhs) ) );
2227 matrix_.reset( col_ );
2228 matrix_.reserve( col_, tmp.nonZeros() );
2254 template<
typename MT >
2277 typedef SparseColumn<MT,false,false>
This;
2278 typedef typename ColumnTrait<MT>::Type
ResultType;
2288 typedef typename IfTrue< useConst, ConstReference, typename MT::Reference >::Type
Reference;
2294 template<
typename MatrixType
2295 ,
typename IteratorType >
2296 class ColumnElement :
private SparseElement
2306 enum { returnConst = IsConst<MatrixType>::value };
2311 typedef typename std::iterator_traits<IteratorType>::value_type SET;
2319 typedef typename SET::ValueType ValueType;
2320 typedef size_t IndexType;
2321 typedef typename IfTrue<returnConst,CRT,RT>::Type
Reference;
2331 inline ColumnElement( IteratorType pos,
size_t row )
2343 template<
typename T >
inline ColumnElement&
operator=(
const T& v ) {
2355 template<
typename T >
inline ColumnElement& operator+=(
const T& v ) {
2367 template<
typename T >
inline ColumnElement& operator-=(
const T& v ) {
2379 template<
typename T >
inline ColumnElement& operator*=(
const T& v ) {
2391 template<
typename T >
inline ColumnElement& operator/=(
const T& v ) {
2402 inline const ColumnElement* operator->()
const {
2412 inline Reference value()
const {
2413 return pos_->value();
2422 inline IndexType index()
const {
2438 template<
typename MatrixType
2439 ,
typename IteratorType >
2440 class ColumnIterator
2444 typedef std::forward_iterator_tag IteratorCategory;
2445 typedef ColumnElement<MatrixType,IteratorType> ValueType;
2446 typedef ValueType PointerType;
2447 typedef ValueType ReferenceType;
2448 typedef ptrdiff_t DifferenceType;
2451 typedef IteratorCategory iterator_category;
2452 typedef ValueType value_type;
2453 typedef PointerType pointer;
2454 typedef ReferenceType reference;
2455 typedef DifferenceType difference_type;
2461 inline ColumnIterator()
2476 inline ColumnIterator( MatrixType& matrix,
size_t row,
size_t column )
2482 for( ; row_<
matrix_->rows(); ++row_ ) {
2483 pos_ =
matrix_->find( row_, column_ );
2484 if( pos_ !=
matrix_->end( row_ ) )
break;
2497 inline ColumnIterator( MatrixType& matrix,
size_t row,
size_t column, IteratorType pos )
2512 template<
typename MatrixType2,
typename IteratorType2 >
2513 inline ColumnIterator(
const ColumnIterator<MatrixType2,IteratorType2>& it )
2516 , column_( it.column_ )
2526 inline ColumnIterator& operator++() {
2528 for( ; row_<
matrix_->rows(); ++row_ ) {
2529 pos_ =
matrix_->find( row_, column_ );
2530 if( pos_ !=
matrix_->end( row_ ) )
break;
2542 inline const ColumnIterator operator++(
int ) {
2543 const ColumnIterator tmp( *
this );
2554 inline ReferenceType
operator*()
const {
2555 return ReferenceType( pos_, row_ );
2564 inline PointerType operator->()
const {
2565 return PointerType( pos_, row_ );
2575 template<
typename MatrixType2,
typename IteratorType2 >
2576 inline bool operator==(
const ColumnIterator<MatrixType2,IteratorType2>& rhs )
const {
2577 return (
matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
2587 template<
typename MatrixType2,
typename IteratorType2 >
2588 inline bool operator!=(
const ColumnIterator<MatrixType2,IteratorType2>& rhs )
const {
2589 return !( *
this == rhs );
2599 inline DifferenceType
operator-(
const ColumnIterator& rhs )
const {
2600 size_t counter( 0UL );
2601 for(
size_t i=rhs.row_; i<row_; ++i ) {
2618 template<
typename MatrixType2,
typename IteratorType2 >
friend class ColumnIterator;
2619 template<
typename MT2,
bool SO2,
bool SF2 >
friend class SparseColumn;
2626 typedef ColumnIterator<const MT,typename MT::ConstIterator>
ConstIterator;
2629 typedef typename IfTrue< useConst, ConstIterator, ColumnIterator<MT,typename MT::Iterator> >::Type
Iterator;
2634 enum { smpAssignable = 0 };
2640 explicit inline SparseColumn( MT& matrix,
size_t index );
2653 inline ConstReference
operator[](
size_t index )
const;
2654 inline Iterator
begin ();
2655 inline ConstIterator
begin ()
const;
2656 inline ConstIterator
cbegin()
const;
2657 inline Iterator
end ();
2658 inline ConstIterator
end ()
const;
2659 inline ConstIterator
cend ()
const;
2668 template<
typename VT >
inline SparseColumn& operator+=(
const Vector<VT,false>& rhs );
2669 template<
typename VT >
inline SparseColumn& operator-=(
const Vector<VT,false>& rhs );
2670 template<
typename VT >
inline SparseColumn& operator*=(
const Vector<VT,false>& rhs );
2672 template<
typename Other >
2673 inline typename EnableIf< IsNumeric<Other>,
SparseColumn >::Type&
2674 operator*=( Other rhs );
2676 template<
typename Other >
2677 inline typename EnableIf< IsNumeric<Other>,
SparseColumn >::Type&
2678 operator/=( Other rhs );
2685 inline size_t size()
const;
2688 inline void reset();
2689 inline Iterator
set (
size_t index,
const ElementType& value );
2690 inline Iterator
insert (
size_t index,
const ElementType& value );
2691 inline void erase (
size_t index );
2692 inline Iterator
erase ( Iterator pos );
2693 inline Iterator
erase ( Iterator first, Iterator last );
2694 inline void reserve(
size_t n );
2695 template<
typename Other >
inline SparseColumn& scale (
const Other& scalar );
2702 inline Iterator
find (
size_t index );
2703 inline ConstIterator
find (
size_t index )
const;
2705 inline ConstIterator
lowerBound(
size_t index )
const;
2707 inline ConstIterator
upperBound(
size_t index )
const;
2714 inline void append(
size_t index,
const ElementType& value,
bool check=
false );
2721 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2722 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2724 template<
typename VT >
inline void assign (
const DenseVector <VT,false>& rhs );
2725 template<
typename VT >
inline void assign (
const SparseVector<VT,false>& rhs );
2726 template<
typename VT >
inline void addAssign(
const Vector<VT,false>& rhs );
2727 template<
typename VT >
inline void subAssign(
const Vector<VT,false>& rhs );
2735 template<
typename MT2,
bool SO2,
typename VT >
2736 inline typename EnableIf< Not< IsRestricted<MT2> >,
bool >::Type
2737 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const Vector<VT,false>& rhs );
2739 template<
typename MT2,
bool SO2,
typename VT >
2740 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
2741 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const DenseVector<VT,false>& rhs );
2743 template<
typename MT2,
bool SO2,
typename VT >
2744 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
2745 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const SparseVector<VT,false>& rhs );
2747 template<
typename MT2,
bool SO2,
typename VT >
2748 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
2749 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const DenseVector<VT,false>& rhs );
2751 template<
typename MT2,
bool SO2,
typename VT >
2752 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
2753 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const SparseVector<VT,false>& rhs );
2755 template<
typename MT2,
bool SO2,
typename VT >
2756 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
2757 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const DenseVector<VT,false>& rhs );
2759 template<
typename MT2,
bool SO2,
typename VT >
2760 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
2761 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const SparseVector<VT,false>& rhs );
2774 template<
typename MT2,
bool SO2,
bool SF2 >
2775 friend bool isSame(
const SparseColumn<MT2,SO2,SF2>& a,
const SparseColumn<MT2,SO2,SF2>& b );
2777 template<
typename MT2,
bool SO2,
bool SF2 >
2778 friend typename DerestrictTrait< SparseColumn<MT2,SO2,SF2> >::Type
2779 derestrict( SparseColumn<MT2,SO2,SF2>& dm );
2790 BLAZE_STATIC_ASSERT( !IsRestricted<MT>::value || IsLower<MT>::value || IsUpper<MT>::value );
2813 template<
typename MT >
2818 if(
matrix_.columns() <= index )
2819 throw std::invalid_argument(
"Invalid column access index" );
2840 template<
typename MT >
2845 return matrix_(index,col_);
2858 template<
typename MT >
2863 return const_cast<const MT&
>( matrix_ )(index,col_);
2877 template<
typename MT >
2880 return Iterator( matrix_, 0UL, col_ );
2894 template<
typename MT >
2912 template<
typename MT >
2930 template<
typename MT >
2947 template<
typename MT >
2965 template<
typename MT >
2997 template<
typename MT >
2998 inline SparseColumn<MT,false,false>&
3007 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
3010 if(
size() != rhs.size() )
3011 throw std::invalid_argument(
"Column sizes do not match" );
3013 if( !preservesInvariant( matrix_, rhs ) )
3014 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
3016 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
3018 if( rhs.canAlias( &matrix_ ) ) {
3019 const ResultType tmp( rhs );
3049 template<
typename MT >
3050 template<
typename VT >
3051 inline SparseColumn<MT,false,false>&
3057 throw std::invalid_argument(
"Vector sizes do not match" );
3061 if( !preservesInvariant( matrix_, tmp ) )
3062 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
3064 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
3091 template<
typename MT >
3092 template<
typename VT >
3093 inline SparseColumn<MT,false,false>&
3094 SparseColumn<MT,false,false>::operator+=(
const Vector<VT,false>& rhs )
3104 typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
3110 throw std::invalid_argument(
"Vector sizes do not match" );
3112 const AddType tmp( *
this + (~rhs) );
3114 if( !preservesInvariant( matrix_, tmp ) )
3115 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
3117 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
3144 template<
typename MT >
3145 template<
typename VT >
3146 inline SparseColumn<MT,false,false>&
3147 SparseColumn<MT,false,false>::operator-=(
const Vector<VT,false>& rhs )
3157 typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
3163 throw std::invalid_argument(
"Vector sizes do not match" );
3165 const SubType tmp( *
this - (~rhs) );
3167 if( !preservesInvariant( matrix_, tmp ) )
3168 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
3170 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
3195 template<
typename MT >
3196 template<
typename VT >
3197 inline SparseColumn<MT,false,false>&
3198 SparseColumn<MT,false,false>::operator*=(
const Vector<VT,false>& rhs )
3208 typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
3214 throw std::invalid_argument(
"Vector sizes do not match" );
3216 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
3218 const MultType tmp( *
this * (~rhs) );
3245 template<
typename MT >
3246 template<
typename Other >
3247 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false,false> >::Type&
3248 SparseColumn<MT,false,false>::operator*=( Other rhs )
3253 element->value() *= rhs;
3278 template<
typename MT >
3279 template<
typename Other >
3280 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false,false> >::Type&
3281 SparseColumn<MT,false,false>::operator/=( Other rhs )
3287 typedef typename DivTrait<ElementType,Other>::Type DT;
3288 typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
3292 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
3293 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
3295 element->value() *= tmp;
3299 element->value() /= rhs;
3322 template<
typename MT >
3325 return matrix_.rows();
3337 template<
typename MT >
3340 return matrix_.rows();
3355 template<
typename MT >
3358 size_t counter( 0UL );
3374 template<
typename MT >
3377 const size_t ibegin( ( IsLower<MT>::value )
3378 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3382 const size_t iend ( ( IsUpper<MT>::value )
3383 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3388 for(
size_t i=ibegin; i<iend; ++i ) {
3389 matrix_.erase( i, col_ );
3408 template<
typename MT >
3412 return Iterator( matrix_, index, col_, matrix_.set( index, col_, value ) );
3431 template<
typename MT >
3435 return Iterator( matrix_, index, col_, matrix_.insert( index, col_, value ) );
3450 template<
typename MT >
3453 matrix_.erase( index, col_ );
3468 template<
typename MT >
3472 const size_t row( pos.row_ );
3477 matrix_.erase( row, pos.pos_ );
3478 return Iterator( matrix_, row+1UL, col_ );
3494 template<
typename MT >
3498 for( ; first!=last; ++first ) {
3499 matrix_.erase( first.row_, first.pos_ );
3517 template<
typename MT >
3539 template<
typename MT >
3540 template<
typename Other >
3541 inline SparseColumn<MT,false,false>& SparseColumn<MT,false,false>::scale(
const Other& scalar )
3546 element->value() *= scalar;
3565 template<
typename MT >
3566 template<
typename MT2
3569 inline typename EnableIf< Not< IsRestricted<MT2> >,
bool >::Type
3570 SparseColumn<MT,false,false>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const Vector<VT,false>& rhs )
3592 template<
typename MT >
3593 template<
typename MT2
3596 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
3597 SparseColumn<MT,false,false>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const DenseVector<VT,false>& rhs )
3603 const size_t iend( ( IsStrictlyLower<MT2>::value )?( col_+1UL ):( col_ ) );
3605 for(
size_t i=0UL; i<iend; ++i ) {
3610 if( IsUniLower<MT2>::value && !
isOne( (~rhs)[col_] ) )
3631 template<
typename MT >
3632 template<
typename MT2
3635 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
3636 SparseColumn<MT,false,false>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const SparseVector<VT,false>& rhs )
3644 const RhsIterator last( (~rhs).lowerBound( ( IsStrictlyLower<MT2>::value )?( col_+1UL ):( col_ ) ) );
3646 if( IsUniLower<MT2>::value && ( last == (~rhs).
end() || last->index() != col_ || !
isOne( last->value() ) ) )
3649 for( RhsIterator element=(~rhs).begin(); element!=last; ++element ) {
3672 template<
typename MT >
3673 template<
typename MT2
3676 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
3677 SparseColumn<MT,false,false>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const DenseVector<VT,false>& rhs )
3683 if( IsUniUpper<MT2>::value && !
isOne( (~rhs)[col_] ) )
3686 const size_t ibegin( ( IsStrictlyUpper<MT2>::value )?( col_ ):( col_+1UL ) );
3688 for(
size_t i=ibegin; i<
size(); ++i ) {
3711 template<
typename MT >
3712 template<
typename MT2
3715 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
3716 SparseColumn<MT,false,false>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const SparseVector<VT,false>& rhs )
3724 const bool checkDiagonal( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value );
3725 const RhsIterator last( (~rhs).
end() );
3726 RhsIterator element( (~rhs).lowerBound( ( checkDiagonal )?( col_ ):( col_+1UL ) ) );
3728 if( IsUniUpper<MT2>::value ) {
3729 if( element == last || element->index() != col_ || !
isOne( element->value() ) )
3734 for( ; element!=last; ++element ) {
3757 template<
typename MT >
3758 template<
typename MT2
3761 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
3762 SparseColumn<MT,false,false>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const DenseVector<VT,false>& rhs )
3768 for(
size_t i=0UL; i<col_; ++i ) {
3773 for(
size_t i=col_+1UL; i<
size(); ++i ) {
3796 template<
typename MT >
3797 template<
typename MT2
3800 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
3801 SparseColumn<MT,false,false>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const SparseVector<VT,false>& rhs )
3809 for( RhsIterator element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
3810 if( element->index() != col_ && !
isDefault( element->value() ) )
3842 template<
typename MT >
3846 const typename MT::Iterator pos( matrix_.find( index, col_ ) );
3848 if( pos != matrix_.end( index ) )
3849 return Iterator( matrix_, index, col_, pos );
3871 template<
typename MT >
3877 if( pos != matrix_.end( index ) )
3899 template<
typename MT >
3903 for(
size_t i=index; i<
size(); ++i )
3905 const typename MT::Iterator pos( matrix_.find( i, col_ ) );
3907 if( pos != matrix_.end( i ) )
3908 return Iterator( matrix_, i, col_, pos );
3930 template<
typename MT >
3934 for(
size_t i=index; i<
size(); ++i )
3938 if( pos != matrix_.end( i ) )
3961 template<
typename MT >
3965 for(
size_t i=index+1UL; i<
size(); ++i )
3967 const typename MT::Iterator pos( matrix_.find( i, col_ ) );
3969 if( pos != matrix_.end( i ) )
3970 return Iterator( matrix_, i, col_, pos );
3992 template<
typename MT >
3996 for(
size_t i=index+1UL; i<
size(); ++i )
4000 if( pos != matrix_.end( i ) )
4043 template<
typename MT >
4047 matrix_.insert( index, col_, value );
4072 template<
typename MT >
4073 template<
typename Other >
4076 return matrix_.isAliased( alias );
4089 template<
typename MT >
4090 template<
typename Other >
4093 return matrix_.isAliased( alias );
4111 template<
typename MT >
4112 template<
typename VT >
4119 for(
size_t i=0UL; i<(~rhs).
size(); ++i ) {
4120 matrix_(i,col_) = (~rhs)[i];
4139 template<
typename MT >
4140 template<
typename VT >
4150 for( ; i<element->index(); ++i )
4151 matrix_.erase( i, col_ );
4152 matrix_(i++,col_) = element->value();
4154 for( ; i<
size(); ++i ) {
4155 matrix_.erase( i, col_ );
4174 template<
typename MT >
4175 template<
typename VT >
4180 typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
4187 const AddType tmp(
serial( *
this + (~rhs) ) );
4206 template<
typename MT >
4207 template<
typename VT >
4212 typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
4219 const SubType tmp(
serial( *
this - (~rhs) ) );
4246 template<
typename MT >
4247 class SparseColumn<MT,false,true> :
public SparseVector< SparseColumn<MT,false,true>, false >
4253 typedef typename If< IsExpression<MT>, MT, MT& >::Type
Operand;
4264 enum { useConst = IsConst<MT>::value };
4269 typedef SparseColumn<MT,false,true>
This;
4270 typedef typename ColumnTrait<MT>::Type
ResultType;
4280 typedef typename IfTrue< useConst, ConstReference, typename MT::Reference >::Type
Reference;
4286 typedef typename IfTrue< useConst, ConstIterator, typename MT::Iterator >::Type
Iterator;
4291 enum { smpAssignable = 0 };
4297 explicit inline SparseColumn( MT& matrix,
size_t index );
4310 inline ConstReference
operator[](
size_t index )
const;
4311 inline Iterator
begin ();
4312 inline ConstIterator
begin ()
const;
4313 inline ConstIterator
cbegin()
const;
4314 inline Iterator
end ();
4315 inline ConstIterator
end ()
const;
4316 inline ConstIterator
cend ()
const;
4327 template<
typename VT >
inline SparseColumn& operator+=(
const DenseVector<VT,false>& rhs );
4328 template<
typename VT >
inline SparseColumn& operator+=(
const SparseVector<VT,false>& rhs );
4329 template<
typename VT >
inline SparseColumn& operator-=(
const DenseVector<VT,false>& rhs );
4330 template<
typename VT >
inline SparseColumn& operator-=(
const SparseVector<VT,false>& rhs );
4331 template<
typename VT >
inline SparseColumn& operator*=(
const Vector<VT,false>& rhs );
4333 template<
typename Other >
4334 inline typename EnableIf< IsNumeric<Other>,
SparseColumn >::Type&
4335 operator*=( Other rhs );
4337 template<
typename Other >
4338 inline typename EnableIf< IsNumeric<Other>,
SparseColumn >::Type&
4339 operator/=( Other rhs );
4346 inline size_t size()
const;
4349 inline void reset();
4350 inline Iterator
set (
size_t index,
const ElementType& value );
4351 inline Iterator
insert (
size_t index,
const ElementType& value );
4352 inline void erase (
size_t index );
4353 inline Iterator
erase ( Iterator pos );
4354 inline Iterator
erase ( Iterator first, Iterator last );
4355 inline void reserve(
size_t n );
4356 template<
typename Other >
inline SparseColumn& scale (
const Other& scalar );
4363 inline Iterator
find (
size_t index );
4364 inline ConstIterator
find (
size_t index )
const;
4366 inline ConstIterator
lowerBound(
size_t index )
const;
4368 inline ConstIterator
upperBound(
size_t index )
const;
4375 inline void append(
size_t index,
const ElementType& value,
bool check=
false );
4382 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
4383 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
4385 template<
typename VT >
inline void assign (
const DenseVector <VT,false>& rhs );
4386 template<
typename VT >
inline void assign (
const SparseVector<VT,false>& rhs );
4387 template<
typename VT >
inline void addAssign(
const DenseVector <VT,false>& rhs );
4388 template<
typename VT >
inline void addAssign(
const SparseVector<VT,false>& rhs );
4389 template<
typename VT >
inline void subAssign(
const DenseVector <VT,false>& rhs );
4390 template<
typename VT >
inline void subAssign(
const SparseVector<VT,false>& rhs );
4400 template<
typename MT2,
bool SO2,
typename VT >
4401 inline typename EnableIf< Not< IsRestricted<MT2> >,
bool >::Type
4402 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const Vector<VT,false>& rhs );
4404 template<
typename MT2,
bool SO2,
typename VT >
4405 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4406 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const DenseVector<VT,false>& rhs );
4408 template<
typename MT2,
bool SO2,
typename VT >
4409 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4410 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const SparseVector<VT,false>& rhs );
4412 template<
typename MT2,
bool SO2,
typename VT >
4413 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4414 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const DenseVector<VT,false>& rhs );
4416 template<
typename MT2,
bool SO2,
typename VT >
4417 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4418 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const SparseVector<VT,false>& rhs );
4420 template<
typename MT2,
bool SO2,
typename VT >
4421 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
4422 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const DenseVector<VT,false>& rhs );
4424 template<
typename MT2,
bool SO2,
typename VT >
4425 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
4426 preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const SparseVector<VT,false>& rhs );
4439 template<
typename MT2,
bool SO2,
bool SF2 >
4440 friend bool isSame(
const SparseColumn<MT2,SO2,SF2>& a,
const SparseColumn<MT2,SO2,SF2>& b );
4442 template<
typename MT2,
bool SO2,
bool SF2 >
4443 friend typename DerestrictTrait< SparseColumn<MT2,SO2,SF2> >::Type
4444 derestrict( SparseColumn<MT2,SO2,SF2>& dm );
4455 BLAZE_STATIC_ASSERT( !IsRestricted<MT>::value || IsLower<MT>::value || IsUpper<MT>::value );
4478 template<
typename MT >
4483 if(
matrix_.columns() <= index )
4484 throw std::invalid_argument(
"Invalid column access index" );
4505 template<
typename MT >
4510 return matrix_(col_,index);
4523 template<
typename MT >
4528 return const_cast<const MT&
>( matrix_ )(col_,index);
4542 template<
typename MT >
4545 return matrix_.begin( col_ );
4559 template<
typename MT >
4563 return matrix_.cbegin( col_ );
4577 template<
typename MT >
4581 return matrix_.cbegin( col_ );
4595 template<
typename MT >
4598 return matrix_.end( col_ );
4612 template<
typename MT >
4616 return matrix_.cend( col_ );
4630 template<
typename MT >
4634 return matrix_.cend( col_ );
4662 template<
typename MT >
4671 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
4674 if(
size() != rhs.size() )
4675 throw std::invalid_argument(
"Column sizes do not match" );
4677 if( !preservesInvariant( matrix_, rhs ) )
4678 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
4680 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
4682 if( rhs.canAlias( &matrix_ ) ) {
4683 const ResultType tmp( rhs );
4685 left.reserve( tmp.nonZeros() );
4690 left.reserve( rhs.nonZeros() );
4717 template<
typename MT >
4718 template<
typename VT >
4719 inline SparseColumn<MT,false,true>&
4729 throw std::invalid_argument(
"Vector sizes do not match" );
4731 typedef typename If< IsRestricted<MT>,
typename VT::CompositeType,
const VT& >::Type Right;
4732 Right right( ~rhs );
4734 if( !preservesInvariant( matrix_, right ) )
4735 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
4737 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
4739 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4772 template<
typename MT >
4773 template<
typename VT >
4774 inline SparseColumn<MT,false,true>&
4784 throw std::invalid_argument(
"Vector sizes do not match" );
4786 typedef typename If< IsRestricted<MT>,
typename VT::CompositeType,
const VT& >::Type Right;
4787 Right right( ~rhs );
4789 if( !preservesInvariant( matrix_, right ) )
4790 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
4792 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
4794 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4797 left.reserve( tmp.nonZeros() );
4802 left.reserve( right.nonZeros() );
4829 template<
typename MT >
4830 template<
typename VT >
4831 inline SparseColumn<MT,false,true>&
4832 SparseColumn<MT,false,true>::operator+=(
const DenseVector<VT,false>& rhs )
4843 typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
4850 throw std::invalid_argument(
"Vector sizes do not match" );
4852 const AddType tmp( *
this + (~rhs) );
4854 if( !preservesInvariant( matrix_, tmp ) )
4855 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
4857 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
4885 template<
typename MT >
4886 template<
typename VT >
4887 inline SparseColumn<MT,false,true>&
4888 SparseColumn<MT,false,true>::operator+=(
const SparseVector<VT,false>& rhs )
4899 typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
4906 throw std::invalid_argument(
"Vector sizes do not match" );
4908 const AddType tmp( *
this + (~rhs) );
4910 if( !preservesInvariant( matrix_, tmp ) )
4911 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
4913 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
4916 left.reserve( tmp.nonZeros() );
4943 template<
typename MT >
4944 template<
typename VT >
4945 inline SparseColumn<MT,false,true>&
4946 SparseColumn<MT,false,true>::operator-=(
const DenseVector<VT,false>& rhs )
4957 typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
4964 throw std::invalid_argument(
"Vector sizes do not match" );
4966 const SubType tmp( *
this - (~rhs) );
4968 if( !preservesInvariant( matrix_, tmp ) )
4969 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
4971 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
5000 template<
typename MT >
5001 template<
typename VT >
5002 inline SparseColumn<MT,false,true>&
5003 SparseColumn<MT,false,true>::operator-=(
const SparseVector<VT,false>& rhs )
5014 typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
5021 throw std::invalid_argument(
"Vector sizes do not match" );
5023 const SubType tmp( *
this - (~rhs) );
5025 if( !preservesInvariant( matrix_, tmp ) )
5026 throw std::invalid_argument(
"Invalid assignment to restricted matrix" );
5028 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
5031 left.reserve( tmp.nonZeros() );
5055 template<
typename MT >
5056 template<
typename VT >
5057 inline SparseColumn<MT,false,true>&
5058 SparseColumn<MT,false,true>::operator*=(
const Vector<VT,false>& rhs )
5068 typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
5074 throw std::invalid_argument(
"Vector sizes do not match" );
5076 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
5078 const MultType tmp( *
this * (~rhs) );
5106 template<
typename MT >
5107 template<
typename Other >
5108 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false,true> >::Type&
5109 SparseColumn<MT,false,true>::operator*=( Other rhs )
5114 element->value() *= rhs;
5139 template<
typename MT >
5140 template<
typename Other >
5141 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false,true> >::Type&
5142 SparseColumn<MT,false,true>::operator/=( Other rhs )
5148 typedef typename DivTrait<ElementType,Other>::Type DT;
5149 typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
5153 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
5154 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
5156 element->value() *= tmp;
5160 element->value() /= rhs;
5183 template<
typename MT >
5186 return matrix_.rows();
5198 template<
typename MT >
5201 return matrix_.capacity( col_ );
5216 template<
typename MT >
5219 return matrix_.nonZeros( col_ );
5231 template<
typename MT >
5234 matrix_.reset( col_ );
5252 template<
typename MT >
5256 return matrix_.set( col_, index, value );
5275 template<
typename MT >
5279 return matrix_.insert( col_, index, value );
5294 template<
typename MT >
5297 matrix_.erase( col_, index );
5312 template<
typename MT >
5316 return matrix_.erase( col_, pos );
5332 template<
typename MT >
5336 return matrix_.erase( col_, first, last );
5352 template<
typename MT >
5355 matrix_.reserve( col_, n );
5372 template<
typename MT >
5373 template<
typename Other >
5374 inline SparseColumn<MT,false,true>& SparseColumn<MT,false,true>::scale(
const Other& scalar )
5379 element->value() *= scalar;
5395 template<
typename MT >
5401 size_t nonzeros( 2UL*
capacity()+1UL );
5402 nonzeros =
max( nonzeros, 7UL );
5403 nonzeros =
min( nonzeros,
size() );
5425 template<
typename MT >
5426 template<
typename MT2
5429 inline typename EnableIf< Not< IsRestricted<MT2> >,
bool >::Type
5430 SparseColumn<MT,false,true>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const Vector<VT,false>& rhs )
5452 template<
typename MT >
5453 template<
typename MT2
5456 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
5457 SparseColumn<MT,false,true>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const DenseVector<VT,false>& rhs )
5463 const size_t iend( ( IsStrictlyLower<MT2>::value )?( col_+1UL ):( col_ ) );
5465 for(
size_t i=0UL; i<iend; ++i ) {
5470 if( IsUniLower<MT2>::value && !
isOne( (~rhs)[col_] ) )
5491 template<
typename MT >
5492 template<
typename MT2
5495 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
5496 SparseColumn<MT,false,true>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const SparseVector<VT,false>& rhs )
5504 const RhsIterator last( (~rhs).lowerBound( ( IsStrictlyLower<MT2>::value )?( col_+1UL ):( col_ ) ) );
5506 if( IsUniLower<MT2>::value && ( last == (~rhs).
end() || last->index() != col_ || !
isOne( last->value() ) ) )
5509 for( RhsIterator element=(~rhs).begin(); element!=last; ++element ) {
5532 template<
typename MT >
5533 template<
typename MT2
5536 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
5537 SparseColumn<MT,false,true>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const DenseVector<VT,false>& rhs )
5543 if( IsUniUpper<MT2>::value && !
isOne( (~rhs)[col_] ) )
5546 const size_t ibegin( ( IsStrictlyUpper<MT2>::value )?( col_ ):( col_+1UL ) );
5548 for(
size_t i=ibegin; i<
size(); ++i ) {
5571 template<
typename MT >
5572 template<
typename MT2
5575 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
5576 SparseColumn<MT,false,true>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const SparseVector<VT,false>& rhs )
5584 const bool checkDiagonal( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value );
5585 const RhsIterator last( (~rhs).
end() );
5586 RhsIterator element( (~rhs).lowerBound( ( checkDiagonal )?( col_ ):( col_+1UL ) ) );
5588 if( IsUniUpper<MT2>::value ) {
5589 if( element == last || element->index() != col_ || !
isOne( element->value() ) )
5594 for( ; element!=last; ++element ) {
5617 template<
typename MT >
5618 template<
typename MT2
5621 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
5622 SparseColumn<MT,false,true>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const DenseVector<VT,false>& rhs )
5628 for(
size_t i=0UL; i<col_; ++i ) {
5633 for(
size_t i=col_+1UL; i<
size(); ++i ) {
5656 template<
typename MT >
5657 template<
typename MT2
5660 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
5661 SparseColumn<MT,false,true>::preservesInvariant(
const SparseMatrix<MT2,SO2>& lhs,
const SparseVector<VT,false>& rhs )
5669 for( RhsIterator element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
5670 if( element->index() != col_ && !
isDefault( element->value() ) )
5702 template<
typename MT >
5706 return matrix_.find( col_, index );
5726 template<
typename MT >
5730 return matrix_.find( col_, index );
5749 template<
typename MT >
5753 return matrix_.lowerBound( col_, index );
5772 template<
typename MT >
5776 return matrix_.lowerBound( col_, index );
5795 template<
typename MT >
5799 return matrix_.upperBound( col_, index );
5818 template<
typename MT >
5822 return matrix_.upperBound( col_, index );
5861 template<
typename MT >
5864 matrix_.append( col_, index, value, check );
5889 template<
typename MT >
5890 template<
typename Other >
5893 return matrix_.isAliased( alias );
5910 template<
typename MT >
5911 template<
typename Other >
5914 return matrix_.isAliased( alias );
5932 template<
typename MT >
5933 template<
typename VT >
5941 for(
size_t i=0UL; i<
size(); ++i )
5943 if( matrix_.nonZeros( col_ ) == matrix_.capacity( col_ ) )
5944 matrix_.reserve( col_, extendCapacity() );
5946 matrix_.append( col_, i, (~rhs)[i],
true );
5965 template<
typename MT >
5966 template<
typename VT >
5975 matrix_.append( col_, element->index(), element->value(), true );
5994 template<
typename MT >
5995 template<
typename VT >
6000 typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
6008 const AddType tmp(
serial( *
this + (~rhs) ) );
6009 matrix_.reset( col_ );
6028 template<
typename MT >
6029 template<
typename VT >
6034 typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
6042 const AddType tmp(
serial( *
this + (~rhs) ) );
6043 matrix_.reset( col_ );
6044 matrix_.reserve( col_, tmp.nonZeros() );
6063 template<
typename MT >
6064 template<
typename VT >
6069 typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
6077 const SubType tmp(
serial( *
this - (~rhs) ) );
6078 matrix_.reset( col_ );
6097 template<
typename MT >
6098 template<
typename VT >
6103 typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
6111 const SubType tmp(
serial( *
this - (~rhs) ) );
6112 matrix_.reset( col_ );
6113 matrix_.reserve( col_, tmp.nonZeros() );
6135 template<
typename MT,
bool SO,
bool SF >
6136 inline void reset( SparseColumn<MT,SO,SF>& column );
6138 template<
typename MT,
bool SO,
bool SF >
6139 inline void clear( SparseColumn<MT,SO,SF>& column );
6141 template<
typename MT,
bool SO,
bool SF >
6142 inline bool isDefault(
const SparseColumn<MT,SO,SF>& column );
6144 template<
typename MT,
bool SO,
bool SF >
6145 inline bool isSame(
const SparseColumn<MT,SO,SF>& a,
const SparseColumn<MT,SO,SF>& b );
6157 template<
typename MT
6176 template<
typename MT
6204 template<
typename MT
6211 const ConstIterator
end( column.end() );
6212 for( ConstIterator element=column.begin(); element!=
end; ++element )
6213 if( !
isDefault( element->value() ) )
return false;
6231 template<
typename MT
6236 return (
isSame( a.matrix_, b.matrix_ ) && ( a.col_ == b.col_ ) );
6258 template<
typename MT
6261 inline typename DerestrictTrait< SparseColumn<MT,SO,SF> >::Type
6262 derestrict( SparseColumn<MT,SO,SF>& column )
6264 typedef typename DerestrictTrait< SparseColumn<MT,SO,SF> >::Type
ReturnType;
6265 return ReturnType( derestrict( column.matrix_ ), column.col_ );
6281 template<
typename MT,
bool SO,
bool SF >
6282 struct IsRestricted< SparseColumn<MT,SO,SF> > :
public If< IsRestricted<MT>, TrueType, FalseType >::Type
6284 enum { value = IsRestricted<MT>::value };
6301 template<
typename MT,
bool SO,
bool SF >
6302 struct DerestrictTrait< SparseColumn<MT,SO,SF> >
6304 typedef SparseColumn< typename RemoveReference< typename DerestrictTrait<MT>::Type >::Type > Type;
6320 template<
typename MT,
bool SO,
bool SF >
6321 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:1912
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:2006
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1649
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:707
#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.
Header file for the IsUniUpper type trait.
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:8247
Header file for the subtraction trait.
Header file for basic type definitions.
Iterator insert(size_t index, const ElementType &value)
Inserting an element into the sparse column.
Definition: SparseColumn.h:1396
Iterator find(size_t index)
Searches for a specific column element.
Definition: SparseColumn.h:1821
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:264
void subAssign(const DenseVector< VT, false > &rhs)
Default implementation of the subtraction assignment of a dense vector.
Definition: SparseColumn.h:2180
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:209
Header file for the IsDiagonal type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h: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
void reserve(size_t n)
Setting the minimum capacity of the sparse column.
Definition: SparseColumn.h:1471
size_t capacity() const
Returns the maximum capacity of the sparse column.
Definition: SparseColumn.h:1318
Header file for the IsColumnMajorMatrix type trait.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:821
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
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
Header file for the And class template.
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:90
IfTrue< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant column value.
Definition: SparseColumn.h:407
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:118
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: SparseColumn.h:410
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:699
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
#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
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:90
#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.
Header file for the IsUniLower type trait.
void append(size_t index, const ElementType &value, bool check=false)
Appending an element to the sparse column.
Definition: SparseColumn.h:1977
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:964
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Constraint on the data type.
Header file for the column base class.
Compile time check for data types with restricted data access.This type trait tests whether the given...
Definition: IsRestricted.h:82
const size_t col_
The index of the column in the matrix.
Definition: SparseColumn.h:561
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SparseColumn.h:398
Constraint on the data type.
Compile time check for upper unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniUpper.h:85
ConstIterator cend() const
Returns an iterator just past the last element of the column.
Definition: SparseColumn.h:758
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
Constraint on the data type.
IfTrue< useConst, ConstIterator, typename MT::Iterator >::Type Iterator
Iterator over non-constant elements.
Definition: SparseColumn.h:413
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:1867
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:116
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:1602
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:1373
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
ColumnTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: SparseColumn.h:397
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
Header file for the IsLower type trait.
#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.
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: SparseColumn.h:400
Constraint on the data type.
void reset()
Reset to the default initial values.
Definition: SparseColumn.h:1351
void erase(size_t index)
Erasing an element from the sparse column.
Definition: SparseColumn.h:1414
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1197
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:2049
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 strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
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:2505
size_t nonZeros() const
Returns the number of non-zero elements in the column.
Definition: SparseColumn.h:1336
Constraint on the data type.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2509
const SparseColumn & CompositeType
Data type for composite expression templates.
Definition: SparseColumn.h:401
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:841
Header file for the IsAdaptor type trait.
Header file for the serial shim.
Header file for the isOne shim.
bool isAliased(const Other *alias) const
Returns whether the sparse column is aliased with the given address alias.
Definition: SparseColumn.h:2027
Compile time check for lower unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniLower.h:85
Header file for the DerestrictTrait class template.
Constraint on the data type.
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:2506
Header file for the IsConst type trait.
MT::ElementType ElementType
Type of the column elements.
Definition: SparseColumn.h:399
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:150
Base template for the MultTrait class.
Definition: MultTrait.h:150
Header file for the addition trait.
Header file for the division trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESTRICTED(T)
Constraint on the data type.In case the given data type T does have a restricted data access...
Definition: Restricted.h:118
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:789
Compile time type negation.The Not class template negates the given compile time condition. In case the given condition would evaluate to true, the nested member enumeration is set to false and vice versa:
Definition: Not.h:70
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2510
Header file for the column trait.
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
#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
Evaluation of the return type of the derestrict function.Via this type trait it is possible to evalua...
Definition: DerestrictTrait.h:74
Header file for the IsReference type trait.
Header file for the RemoveReference type trait.
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:150
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
#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:2111
Iterator end()
Returns an iterator just past the last element of the column.
Definition: SparseColumn.h:724
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:673
Reference operator[](size_t index)
Subscript operator for the direct access to the column elements.
Definition: SparseColumn.h:637
boost::false_type FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: FalseType.h:61
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:260
If< IsExpression< MT >, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
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:2502
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
size_t extendCapacity() const
Calculating a new sparse column capacity.
Definition: SparseColumn.h:1514
Compile time type check.This class tests whether the given template parameter T is a reference type (...
Definition: IsReference.h:94
SparseColumn< MT, SO, SF > This
Type of this SparseColumn instance.
Definition: SparseColumn.h:396
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2508
Base template for the SubTrait class.
Definition: SubTrait.h:150
Header file for the IsUpper type trait.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:143
EnableIf< IsNumeric< Type >, bool >::Type isOne(const Type &v)
Returns whether the given value/object represents the numeric value 1.
Definition: IsOne.h:80
Header file for the IsRestricted type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:79
Reference to a specific column of a sparse matrix.The SparseColumn template represents a reference to...
Definition: Forward.h:51
Compile time type selection.The IfTrue class template selects one of the two given types T1 and T2 de...
Definition: If.h:59
MT::ConstReference ConstReference
Reference to a constant column value.
Definition: SparseColumn.h:404
Operand matrix_
The sparse matrix containing the column.
Definition: SparseColumn.h:560
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
size_t size() const
Returns the current size/dimension of the sparse column.
Definition: SparseColumn.h:1303
SparseColumn(MT &matrix, size_t index)
The constructor for SparseColumn.
Definition: SparseColumn.h:609
Header file for a safe C++ NULL pointer implementation.