35 #ifndef _BLAZE_MATH_VIEWS_ROW_SPARSE_H_ 36 #define _BLAZE_MATH_VIEWS_ROW_SPARSE_H_ 111 template<
typename MT
113 class Row<MT,true,false,SF>
114 :
public SparseVector< Row<MT,true,false,SF>, true >
120 typedef If_< IsExpression<MT>, MT, MT& > Operand;
125 typedef Row<MT,true,false,SF>
This;
126 typedef SparseVector<This,true>
BaseType;
148 enum :
bool { smpAssignable =
false };
154 explicit inline Row( Operand matrix,
size_t index );
166 inline Reference operator[](
size_t index );
167 inline ConstReference operator[](
size_t index )
const;
168 inline Reference at(
size_t index );
169 inline ConstReference at(
size_t index )
const;
170 inline Iterator
begin ();
171 inline ConstIterator
begin ()
const;
172 inline ConstIterator
cbegin()
const;
173 inline Iterator
end ();
174 inline ConstIterator
end ()
const;
175 inline ConstIterator
cend ()
const;
182 inline Row& operator=(
const Row& rhs );
184 template<
typename VT >
inline Row& operator= (
const DenseVector<VT,true>& rhs );
185 template<
typename VT >
inline Row& operator= (
const SparseVector<VT,true>& rhs );
186 template<
typename VT >
inline Row&
operator+=(
const DenseVector<VT,true>& rhs );
187 template<
typename VT >
inline Row&
operator+=(
const SparseVector<VT,true>& rhs );
188 template<
typename VT >
inline Row&
operator-=(
const DenseVector<VT,true>& rhs );
189 template<
typename VT >
inline Row&
operator-=(
const SparseVector<VT,true>& rhs );
190 template<
typename VT >
inline Row&
operator*=(
const Vector<VT,true>& rhs );
191 template<
typename VT >
inline Row&
operator/=(
const DenseVector<VT,true>& rhs );
193 template<
typename Other >
194 inline EnableIf_<IsNumeric<Other>, Row >&
operator*=( Other rhs );
196 template<
typename Other >
197 inline EnableIf_<IsNumeric<Other>, Row >&
operator/=( Other rhs );
204 inline size_t size() const noexcept;
205 inline
size_t capacity() const noexcept;
208 inline
void reserve(
size_t n );
215 inline Iterator
set (
size_t index, const ElementType& value );
216 inline Iterator insert(
size_t index, const ElementType& value );
217 inline
void append(
size_t index, const ElementType& value,
bool check=false );
224 inline
void erase(
size_t index );
225 inline Iterator erase( Iterator pos );
226 inline Iterator erase( Iterator first, Iterator last );
228 template< typename Pred, typename =
DisableIf_< IsIntegral<Pred> > >
229 inline
void erase( Pred predicate );
231 template< typename Pred >
232 inline
void erase( Iterator first, Iterator last, Pred predicate );
239 inline Iterator find (
size_t index );
240 inline ConstIterator find (
size_t index ) const;
241 inline Iterator lowerBound(
size_t index );
242 inline ConstIterator lowerBound(
size_t index ) const;
243 inline Iterator upperBound(
size_t index );
244 inline ConstIterator upperBound(
size_t index ) const;
251 template< typename Other > inline Row& scale( const Other& scalar );
258 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
259 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
261 template< typename VT > inline
void assign ( const DenseVector <VT,true>& rhs );
262 template< typename VT > inline
void assign ( const SparseVector<VT,true>& rhs );
263 template< typename VT > inline
void addAssign( const DenseVector <VT,true>& rhs );
264 template< typename VT > inline
void addAssign( const SparseVector<VT,true>& rhs );
265 template< typename VT > inline
void subAssign( const DenseVector <VT,true>& rhs );
266 template< typename VT > inline
void subAssign( const SparseVector<VT,true>& rhs );
274 inline
size_t extendCapacity() const noexcept;
287 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
288 friend
bool isIntact( const Row<MT2,SO2,DF2,SF2>&
row ) noexcept;
290 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
291 friend
bool isSame( const Row<MT2,SO2,DF2,SF2>& a, const Row<MT2,SO2,DF2,SF2>& b ) noexcept;
293 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
294 friend
bool tryAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
296 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
297 friend
bool tryAddAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
299 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
300 friend
bool trySubAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
302 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
303 friend
bool tryMultAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
305 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
338 template< typename MT
340 inline Row<MT,true,false,SF>::Row( Operand matrix,
size_t index )
344 if( matrix_.rows() <= index ) {
370 template<
typename MT
375 return matrix_(row_,index);
391 template<
typename MT
394 Row<MT,true,false,SF>::operator[](
size_t index )
const 397 return const_cast<const MT&
>( matrix_ )(row_,index);
414 template<
typename MT
418 if( index >=
size() ) {
421 return (*
this)[index];
438 template<
typename MT
442 if( index >=
size() ) {
445 return (*
this)[index];
459 template<
typename MT
463 return matrix_.begin( row_ );
477 template<
typename MT
481 return matrix_.cbegin( row_ );
495 template<
typename MT
499 return matrix_.cbegin( row_ );
513 template<
typename MT
517 return matrix_.end( row_ );
531 template<
typename MT
535 return matrix_.cend( row_ );
549 template<
typename MT
553 return matrix_.cend( row_ );
581 template<
typename MT
583 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator=(
const Row& rhs )
591 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
594 if(
size() != rhs.size() ) {
598 if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
602 DerestrictTrait_<This> left( derestrict( *
this ) );
604 if( rhs.canAlias( &matrix_ ) ) {
605 const ResultType tmp( rhs );
607 left.reserve( tmp.nonZeros() );
612 left.reserve( rhs.nonZeros() );
638 template<
typename MT
640 template<
typename VT >
641 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator=(
const DenseVector<VT,true>& rhs )
653 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
656 if( !tryAssign( matrix_, right, row_, 0UL ) ) {
660 DerestrictTrait_<This> left( derestrict( *
this ) );
662 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
663 const ResultType_<VT> tmp( right );
669 assign( left, right );
694 template<
typename MT
696 template<
typename VT >
697 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator=(
const SparseVector<VT,true>& rhs )
709 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
712 if( !tryAssign( matrix_, right, row_, 0UL ) ) {
716 DerestrictTrait_<This> left( derestrict( *
this ) );
718 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
719 const ResultType_<VT> tmp( right );
721 left.reserve( tmp.nonZeros() );
726 left.reserve( right.nonZeros() );
727 assign( left, right );
752 template<
typename MT
754 template<
typename VT >
766 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
776 const AddType tmp( *
this + (~rhs) );
778 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
782 DerestrictTrait_<This> left( derestrict( *
this ) );
809 template<
typename MT
811 template<
typename VT >
823 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
833 const AddType tmp( *
this + (~rhs) );
835 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
839 DerestrictTrait_<This> left( derestrict( *
this ) );
842 left.reserve( tmp.nonZeros() );
868 template<
typename MT
870 template<
typename VT >
882 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
892 const SubType tmp( *
this - (~rhs) );
894 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
898 DerestrictTrait_<This> left( derestrict( *
this ) );
926 template<
typename MT
928 template<
typename VT >
940 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
950 const SubType tmp( *
this - (~rhs) );
952 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
956 DerestrictTrait_<This> left( derestrict( *
this ) );
959 left.reserve( tmp.nonZeros() );
983 template<
typename MT
985 template<
typename VT >
996 typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
1005 const MultType tmp( *
this * (~rhs) );
1007 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
1011 DerestrictTrait_<This> left( derestrict( *
this ) );
1014 assign( left, tmp );
1036 template<
typename MT
1038 template<
typename VT >
1041 using blaze::assign;
1050 typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
1060 const DivType tmp( *
this / (~rhs) );
1062 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
1066 DerestrictTrait_<This> left( derestrict( *
this ) );
1069 assign( left, tmp );
1094 template<
typename MT
1096 template<
typename Other >
1097 inline EnableIf_<IsNumeric<Other>, Row<MT,true,false,SF> >&
1102 for( Iterator element=
begin(); element!=
end(); ++element )
1103 element->value() *= rhs;
1128 template<
typename MT
1130 template<
typename Other >
1131 inline EnableIf_<IsNumeric<Other>, Row<MT,true,false,SF> >&
1138 typedef DivTrait_<ElementType,Other> DT;
1139 typedef If_< IsNumeric<DT>, DT, Other > Tmp;
1143 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
1144 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1145 for( Iterator element=
begin(); element!=
end(); ++element )
1146 element->value() *= tmp;
1149 for( Iterator element=
begin(); element!=
end(); ++element )
1150 element->value() /= rhs;
1173 template<
typename MT
1177 return matrix_.columns();
1189 template<
typename MT
1193 return matrix_.capacity( row_ );
1208 template<
typename MT
1212 return matrix_.nonZeros( row_ );
1224 template<
typename MT
1228 matrix_.reset( row_ );
1244 template<
typename MT
1246 void Row<MT,true,false,SF>::reserve(
size_t n )
1248 matrix_.reserve( row_, n );
1263 template<
typename MT
1265 inline size_t Row<MT,true,false,SF>::extendCapacity() const noexcept
1270 size_t nonzeros( 2UL*
capacity()+1UL );
1271 nonzeros =
max( nonzeros, 7UL );
1272 nonzeros =
min( nonzeros,
size() );
1302 template<
typename MT
1307 return matrix_.set( row_, index, value );
1326 template<
typename MT
1329 Row<MT,true,false,SF>::insert(
size_t index,
const ElementType& value )
1331 return matrix_.insert( row_, index, value );
1362 template<
typename MT
1364 inline void Row<MT,true,false,SF>::append(
size_t index,
const ElementType& value,
bool check )
1366 matrix_.append( row_, index, value, check );
1389 template<
typename MT
1391 inline void Row<MT,true,false,SF>::erase(
size_t index )
1393 matrix_.erase( row_, index );
1408 template<
typename MT
1412 return matrix_.erase( row_, pos );
1428 template<
typename MT
1431 Row<MT,true,false,SF>::erase( Iterator first, Iterator last )
1433 return matrix_.erase( row_, first, last );
1462 template<
typename MT
1464 template<
typename Pred
1466 inline void Row<MT,true,false,SF>::erase( Pred predicate )
1468 matrix_.erase( row_,
begin(),
end(), predicate );
1499 template<
typename MT
1501 template<
typename Pred >
1502 inline void Row<MT,true,false,SF>::erase( Iterator first, Iterator last, Pred predicate )
1504 matrix_.erase( row_, first, last, predicate );
1532 template<
typename MT
1536 return matrix_.find( row_, index );
1556 template<
typename MT
1560 return matrix_.find( row_, index );
1579 template<
typename MT
1583 return matrix_.lowerBound( row_, index );
1602 template<
typename MT
1606 return matrix_.lowerBound( row_, index );
1625 template<
typename MT
1629 return matrix_.upperBound( row_, index );
1648 template<
typename MT
1652 return matrix_.upperBound( row_, index );
1677 template<
typename MT
1679 template<
typename Other >
1680 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::scale(
const Other& scalar )
1684 for( Iterator element=
begin(); element!=
end(); ++element )
1685 element->value() *= scalar;
1711 template<
typename MT
1713 template<
typename Other >
1714 inline bool Row<MT,true,false,SF>::canAlias(
const Other* alias )
const noexcept
1716 return matrix_.isAliased( alias );
1733 template<
typename MT
1735 template<
typename Other >
1736 inline bool Row<MT,true,false,SF>::isAliased(
const Other* alias )
const noexcept
1738 return matrix_.isAliased( alias );
1756 template<
typename MT
1758 template<
typename VT >
1759 inline void Row<MT,true,false,SF>::assign(
const DenseVector<VT,true>& rhs )
1764 for(
size_t j=0UL; j<
size(); ++j )
1766 if( matrix_.nonZeros( row_ ) == matrix_.capacity( row_ ) )
1767 matrix_.reserve( row_, extendCapacity() );
1769 matrix_.append( row_, j, (~rhs)[j],
true );
1788 template<
typename MT
1790 template<
typename VT >
1791 inline void Row<MT,true,false,SF>::assign(
const SparseVector<VT,true>& rhs )
1796 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1797 matrix_.append( row_, element->index(), element->value(), true );
1816 template<
typename MT
1818 template<
typename VT >
1819 inline void Row<MT,true,false,SF>::addAssign(
const DenseVector<VT,true>& rhs )
1821 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
1829 const AddType tmp(
serial( *
this + (~rhs) ) );
1830 matrix_.reset( row_ );
1849 template<
typename MT
1851 template<
typename VT >
1852 inline void Row<MT,true,false,SF>::addAssign(
const SparseVector<VT,true>& rhs )
1854 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
1862 const AddType tmp(
serial( *
this + (~rhs) ) );
1863 matrix_.reset( row_ );
1864 matrix_.reserve( row_, tmp.nonZeros() );
1883 template<
typename MT
1885 template<
typename VT >
1886 inline void Row<MT,true,false,SF>::subAssign(
const DenseVector<VT,true>& rhs )
1888 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
1896 const SubType tmp(
serial( *
this - (~rhs) ) );
1897 matrix_.reset( row_ );
1916 template<
typename MT
1918 template<
typename VT >
1919 inline void Row<MT,true,false,SF>::subAssign(
const SparseVector<VT,true>& rhs )
1921 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
1929 const SubType tmp(
serial( *
this - (~rhs) ) );
1930 matrix_.reset( row_ );
1931 matrix_.reserve( row_, tmp.nonZeros() );
1958 template<
typename MT >
1959 class Row<MT,false,false,false>
1960 :
public SparseVector< Row<MT,false,false,false>, true >
1966 typedef If_< IsExpression<MT>, MT, MT& > Operand;
1971 typedef Row<MT,false,false,false>
This;
1972 typedef SparseVector<This,true>
BaseType;
1989 template<
typename MatrixType
1990 ,
typename IteratorType >
1991 class RowElement :
private SparseElement
2001 enum :
bool { returnConst = IsConst<MatrixType>::value };
2006 typedef typename std::iterator_traits<IteratorType>::value_type SET;
2008 typedef Reference_<SET> RT;
2009 typedef ConstReference_<SET> CRT;
2014 typedef ValueType_<SET> ValueType;
2015 typedef size_t IndexType;
2016 typedef IfTrue_<returnConst,CRT,RT>
Reference;
2026 inline RowElement( IteratorType pos,
size_t column )
2038 template<
typename T >
inline RowElement& operator=(
const T& v ) {
2050 template<
typename T >
inline RowElement&
operator+=(
const T& v ) {
2062 template<
typename T >
inline RowElement&
operator-=(
const T& v ) {
2074 template<
typename T >
inline RowElement&
operator*=(
const T& v ) {
2086 template<
typename T >
inline RowElement&
operator/=(
const T& v ) {
2097 inline const RowElement* operator->()
const {
2107 inline Reference value()
const {
2108 return pos_->value();
2117 inline IndexType index()
const {
2133 template<
typename MatrixType
2134 ,
typename IteratorType >
2139 typedef std::forward_iterator_tag IteratorCategory;
2140 typedef RowElement<MatrixType,IteratorType> ValueType;
2141 typedef ValueType PointerType;
2142 typedef ValueType ReferenceType;
2143 typedef ptrdiff_t DifferenceType;
2146 typedef IteratorCategory iterator_category;
2147 typedef ValueType value_type;
2148 typedef PointerType pointer;
2149 typedef ReferenceType reference;
2150 typedef DifferenceType difference_type;
2156 inline RowIterator()
2157 : matrix_( nullptr )
2171 inline RowIterator( MatrixType& matrix,
size_t row,
size_t column )
2172 : matrix_( &matrix )
2177 for( ; column_<matrix_->columns(); ++column_ ) {
2178 pos_ = matrix_->find( row_, column_ );
2179 if( pos_ != matrix_->end( column_ ) )
break;
2192 inline RowIterator( MatrixType& matrix,
size_t row,
size_t column, IteratorType pos )
2193 : matrix_( &matrix )
2207 template<
typename MatrixType2,
typename IteratorType2 >
2208 inline RowIterator(
const RowIterator<MatrixType2,IteratorType2>& it )
2209 : matrix_( it.matrix_ )
2211 , column_( it.column_ )
2221 inline RowIterator& operator++() {
2223 for( ; column_<matrix_->columns(); ++column_ ) {
2224 pos_ = matrix_->find( row_, column_ );
2225 if( pos_ != matrix_->end( column_ ) )
break;
2237 inline const RowIterator operator++(
int ) {
2238 const RowIterator tmp( *
this );
2249 inline ReferenceType
operator*()
const {
2250 return ReferenceType( pos_, column_ );
2259 inline PointerType operator->()
const {
2260 return PointerType( pos_, column_ );
2270 template<
typename MatrixType2,
typename IteratorType2 >
2271 inline bool operator==(
const RowIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2272 return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
2282 template<
typename MatrixType2,
typename IteratorType2 >
2283 inline bool operator!=(
const RowIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2284 return !( *
this == rhs );
2294 inline DifferenceType
operator-(
const RowIterator& rhs )
const {
2295 size_t counter( 0UL );
2296 for(
size_t j=rhs.column_; j<column_; ++j ) {
2297 if( matrix_->find( row_, j ) != matrix_->end( j ) )
2306 MatrixType* matrix_;
2313 template<
typename MatrixType2,
typename IteratorType2 >
friend class RowIterator;
2314 template<
typename MT2,
bool SO2,
bool DF2,
bool SF2 >
friend class Row;
2321 typedef RowIterator< const MT, ConstIterator_<MT> >
ConstIterator;
2329 enum :
bool { smpAssignable =
false };
2335 explicit inline Row( Operand matrix,
size_t index );
2347 inline Reference operator[](
size_t index );
2348 inline ConstReference operator[](
size_t index )
const;
2349 inline Reference at(
size_t index );
2350 inline ConstReference at(
size_t index )
const;
2351 inline Iterator
begin ();
2352 inline ConstIterator
begin ()
const;
2353 inline ConstIterator
cbegin()
const;
2354 inline Iterator
end ();
2355 inline ConstIterator
end ()
const;
2356 inline ConstIterator
cend ()
const;
2363 inline Row& operator= (
const Row& rhs );
2364 template<
typename VT >
inline Row& operator= (
const Vector<VT,true>& rhs );
2365 template<
typename VT >
inline Row&
operator+=(
const Vector<VT,true>& rhs );
2366 template<
typename VT >
inline Row&
operator-=(
const Vector<VT,true>& rhs );
2367 template<
typename VT >
inline Row&
operator*=(
const Vector<VT,true>& rhs );
2368 template<
typename VT >
inline Row&
operator/=(
const DenseVector<VT,true>& rhs );
2370 template<
typename Other >
2371 inline EnableIf_<IsNumeric<Other>, Row >&
operator*=( Other rhs );
2373 template<
typename Other >
2374 inline EnableIf_<IsNumeric<Other>, Row >&
operator/=( Other rhs );
2381 inline size_t size() const noexcept;
2382 inline
size_t capacity() const noexcept;
2384 inline
void reset();
2385 inline
void reserve(
size_t n );
2392 inline Iterator
set (
size_t index, const ElementType& value );
2393 inline Iterator insert(
size_t index, const ElementType& value );
2394 inline
void append(
size_t index, const ElementType& value,
bool check=false );
2401 inline
void erase(
size_t index );
2402 inline Iterator erase( Iterator pos );
2403 inline Iterator erase( Iterator first, Iterator last );
2405 template< typename Pred, typename =
DisableIf_< IsIntegral<Pred> > >
2406 inline
void erase( Pred predicate );
2408 template< typename Pred >
2409 inline
void erase( Iterator first, Iterator last, Pred predicate );
2416 inline Iterator find (
size_t index );
2417 inline ConstIterator find (
size_t index ) const;
2418 inline Iterator lowerBound(
size_t index );
2419 inline ConstIterator lowerBound(
size_t index ) const;
2420 inline Iterator upperBound(
size_t index );
2421 inline ConstIterator upperBound(
size_t index ) const;
2428 template< typename Other > inline Row& scale( const Other& scalar );
2435 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
2436 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
2438 template< typename VT > inline
void assign ( const DenseVector <VT,true>& rhs );
2439 template< typename VT > inline
void assign ( const SparseVector<VT,true>& rhs );
2440 template< typename VT > inline
void addAssign( const Vector<VT,true>& rhs );
2441 template< typename VT > inline
void subAssign( const Vector<VT,true>& rhs );
2455 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
2456 friend
bool isIntact( const Row<MT2,SO2,DF2,SF2>& row ) noexcept;
2458 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
2459 friend
bool isSame( const Row<MT2,SO2,DF2,SF2>& a, const Row<MT2,SO2,DF2,SF2>& b ) noexcept;
2461 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2462 friend
bool tryAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
2464 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2465 friend
bool tryAddAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
2467 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2468 friend
bool trySubAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
2470 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2471 friend
bool tryMultAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
2473 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
2474 friend
DerestrictTrait_< Row<MT2,SO2,DF2,SF2> > derestrict( Row<MT2,SO2,DF2,SF2>& row );
2507 template< typename MT >
2508 inline Row<MT,false,false,false>::Row( Operand matrix,
size_t index )
2512 if( matrix_.rows() <= index ) {
2538 template<
typename MT >
2540 Row<MT,false,false,false>::operator[](
size_t index )
2543 return matrix_(row_,index);
2559 template<
typename MT >
2561 Row<MT,false,false,false>::operator[](
size_t index )
const 2564 return const_cast<const MT&
>( matrix_ )(row_,index);
2581 template<
typename MT >
2583 Row<MT,false,false,false>::at(
size_t index )
2585 if( index >=
size() ) {
2588 return (*
this)[index];
2605 template<
typename MT >
2607 Row<MT,false,false,false>::at(
size_t index )
const 2609 if( index >=
size() ) {
2612 return (*
this)[index];
2626 template<
typename MT >
2629 return Iterator( matrix_, row_, 0UL );
2643 template<
typename MT >
2660 template<
typename MT >
2677 template<
typename MT >
2694 template<
typename MT >
2711 template<
typename MT >
2742 template<
typename MT >
2743 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator=(
const Row& rhs )
2745 using blaze::assign;
2751 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
2754 if(
size() != rhs.size() ) {
2758 if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
2762 DerestrictTrait_<This> left( derestrict( *
this ) );
2764 if( rhs.canAlias( &matrix_ ) ) {
2765 const ResultType tmp( rhs );
2766 assign( left, tmp );
2769 assign( left, rhs );
2794 template<
typename MT >
2795 template<
typename VT >
2796 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator=(
const Vector<VT,true>& rhs )
2798 using blaze::assign;
2804 const CompositeType_<VT> tmp( ~rhs );
2806 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2810 DerestrictTrait_<This> left( derestrict( *
this ) );
2812 assign( left, tmp );
2836 template<
typename MT >
2837 template<
typename VT >
2840 using blaze::assign;
2848 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
2857 const AddType tmp( *
this + (~rhs) );
2859 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2863 DerestrictTrait_<This> left( derestrict( *
this ) );
2865 assign( left, tmp );
2889 template<
typename MT >
2890 template<
typename VT >
2893 using blaze::assign;
2901 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
2910 const SubType tmp( *
this - (~rhs) );
2912 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2916 DerestrictTrait_<This> left( derestrict( *
this ) );
2918 assign( left, tmp );
2941 template<
typename MT >
2942 template<
typename VT >
2945 using blaze::assign;
2953 typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
2962 const MultType tmp( *
this * (~rhs) );
2964 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2968 DerestrictTrait_<This> left( derestrict( *
this ) );
2970 assign( left, tmp );
2992 template<
typename MT >
2993 template<
typename VT >
2994 inline Row<MT,false,false,false>&
2997 using blaze::assign;
3006 typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
3016 const DivType tmp( *
this / (~rhs) );
3018 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
3022 DerestrictTrait_<This> left( derestrict( *
this ) );
3024 assign( left, tmp );
3049 template<
typename MT >
3050 template<
typename Other >
3051 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,false> >&
3056 for( Iterator element=
begin(); element!=
end(); ++element )
3057 element->value() *= rhs;
3082 template<
typename MT >
3083 template<
typename Other >
3084 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,false> >&
3091 typedef DivTrait_<ElementType,Other> DT;
3092 typedef If_< IsNumeric<DT>, DT, Other > Tmp;
3096 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
3097 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
3098 for( Iterator element=
begin(); element!=
end(); ++element )
3099 element->value() *= tmp;
3102 for( Iterator element=
begin(); element!=
end(); ++element )
3103 element->value() /= rhs;
3126 template<
typename MT >
3129 return matrix_.columns();
3141 template<
typename MT >
3144 return matrix_.columns();
3159 template<
typename MT >
3162 size_t counter( 0UL );
3163 for( ConstIterator element=
begin(); element!=
end(); ++element ) {
3178 template<
typename MT >
3181 const size_t jbegin( ( IsUpper<MT>::value )
3182 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3186 const size_t jend ( ( IsLower<MT>::value )
3187 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3192 for(
size_t j=jbegin; j<jend; ++j ) {
3193 matrix_.erase( row_, j );
3210 template<
typename MT >
3211 void Row<MT,false,false,false>::reserve(
size_t n )
3241 template<
typename MT >
3245 return Iterator( matrix_, row_, index, matrix_.set( row_, index, value ) );
3264 template<
typename MT >
3266 Row<MT,false,false,false>::insert(
size_t index,
const ElementType& value )
3268 return Iterator( matrix_, row_, index, matrix_.insert( row_, index, value ) );
3299 template<
typename MT >
3300 inline void Row<MT,false,false,false>::append(
size_t index,
const ElementType& value,
bool check )
3303 matrix_.insert( row_, index, value );
3326 template<
typename MT >
3327 inline void Row<MT,false,false,false>::erase(
size_t index )
3329 matrix_.erase( row_, index );
3344 template<
typename MT >
3347 const size_t column( pos.column_ );
3349 if( column ==
size() )
3352 matrix_.erase( column, pos.pos_ );
3353 return Iterator( matrix_, row_, column+1UL );
3369 template<
typename MT >
3371 Row<MT,false,false,false>::erase( Iterator first, Iterator last )
3373 for( ; first!=last; ++first ) {
3374 matrix_.erase( first.column_, first.pos_ );
3405 template<
typename MT >
3406 template<
typename Pred
3408 inline void Row<MT,false,false,false>::erase( Pred predicate )
3410 for( Iterator element=
begin(); element!=
end(); ++element ) {
3411 if( predicate( element->value() ) )
3412 matrix_.erase( element.column_, element.pos_ );
3444 template<
typename MT >
3445 template<
typename Pred >
3446 inline void Row<MT,false,false,false>::erase( Iterator first, Iterator last, Pred predicate )
3448 for( ; first!=last; ++first ) {
3449 if( predicate( first->value() ) )
3450 matrix_.erase( first.column_, first.pos_ );
3479 template<
typename MT >
3482 const Iterator_<MT> pos( matrix_.find( row_, index ) );
3484 if( pos != matrix_.end( index ) )
3485 return Iterator( matrix_, row_, index, pos );
3507 template<
typename MT >
3509 Row<MT,false,false,false>::find(
size_t index )
const 3511 const ConstIterator_<MT> pos( matrix_.find( row_, index ) );
3513 if( pos != matrix_.end( index ) )
3535 template<
typename MT >
3537 Row<MT,false,false,false>::lowerBound(
size_t index )
3539 for(
size_t i=index; i<
size(); ++i )
3541 const Iterator_<MT> pos( matrix_.find( row_, i ) );
3543 if( pos != matrix_.end( i ) )
3544 return Iterator( matrix_, row_, i, pos );
3566 template<
typename MT >
3568 Row<MT,false,false,false>::lowerBound(
size_t index )
const 3570 for(
size_t i=index; i<
size(); ++i )
3572 const ConstIterator_<MT> pos( matrix_.find( row_, i ) );
3574 if( pos != matrix_.end( i ) )
3597 template<
typename MT >
3599 Row<MT,false,false,false>::upperBound(
size_t index )
3601 for(
size_t i=index+1UL; i<
size(); ++i )
3603 const Iterator_<MT> pos( matrix_.find( row_, i ) );
3605 if( pos != matrix_.end( i ) )
3606 return Iterator( matrix_, row_, i, pos );
3628 template<
typename MT >
3630 Row<MT,false,false,false>::upperBound(
size_t index )
const 3632 for(
size_t i=index+1UL; i<
size(); ++i )
3634 const ConstIterator_<MT> pos( matrix_.find( row_, i ) );
3636 if( pos != matrix_.end( i ) )
3665 template<
typename MT >
3666 template<
typename Other >
3667 inline Row<MT,false,false,false>& Row<MT,false,false,false>::scale(
const Other& scalar )
3671 for( Iterator element=
begin(); element!=
end(); ++element )
3672 element->value() *= scalar;
3698 template<
typename MT >
3699 template<
typename Other >
3700 inline bool Row<MT,false,false,false>::canAlias(
const Other* alias )
const noexcept
3702 return matrix_.isAliased( alias );
3715 template<
typename MT >
3716 template<
typename Other >
3717 inline bool Row<MT,false,false,false>::isAliased(
const Other* alias )
const noexcept
3719 return matrix_.isAliased( alias );
3737 template<
typename MT >
3738 template<
typename VT >
3739 inline void Row<MT,false,false,false>::assign(
const DenseVector<VT,true>& rhs )
3743 for(
size_t j=0UL; j<(~rhs).
size(); ++j ) {
3744 matrix_(row_,j) = (~rhs)[j];
3763 template<
typename MT >
3764 template<
typename VT >
3765 inline void Row<MT,false,false,false>::assign(
const SparseVector<VT,true>& rhs )
3771 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
3772 for( ; j<element->index(); ++j )
3773 matrix_.erase( row_, j );
3774 matrix_(row_,j++) = element->value();
3776 for( ; j<
size(); ++j ) {
3777 matrix_.erase( row_, j );
3796 template<
typename MT >
3797 template<
typename VT >
3798 inline void Row<MT,false,false,false>::addAssign(
const Vector<VT,true>& rhs )
3800 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
3807 const AddType tmp(
serial( *
this + (~rhs) ) );
3826 template<
typename MT >
3827 template<
typename VT >
3828 inline void Row<MT,false,false,false>::subAssign(
const Vector<VT,true>& rhs )
3830 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
3837 const SubType tmp(
serial( *
this - (~rhs) ) );
3864 template<
typename MT >
3865 class Row<MT,false,false,true>
3866 :
public SparseVector< Row<MT,false,false,true>, true >
3872 typedef If_< IsExpression<MT>, MT, MT& > Operand;
3877 typedef Row<MT,false,false,true>
This;
3878 typedef SparseVector<This,true>
BaseType;
3900 enum :
bool { smpAssignable =
false };
3906 explicit inline Row( Operand matrix,
size_t index );
3918 inline Reference operator[](
size_t index );
3919 inline ConstReference operator[](
size_t index )
const;
3920 inline Reference at(
size_t index );
3921 inline ConstReference at(
size_t index )
const;
3922 inline Iterator
begin ();
3923 inline ConstIterator
begin ()
const;
3924 inline ConstIterator
cbegin()
const;
3925 inline Iterator
end ();
3926 inline ConstIterator
end ()
const;
3927 inline ConstIterator
cend ()
const;
3934 inline Row& operator=(
const Row& rhs );
3936 template<
typename VT >
inline Row& operator= (
const DenseVector<VT,true>& rhs );
3937 template<
typename VT >
inline Row& operator= (
const SparseVector<VT,true>& rhs );
3938 template<
typename VT >
inline Row&
operator+=(
const DenseVector<VT,true>& rhs );
3939 template<
typename VT >
inline Row&
operator+=(
const SparseVector<VT,true>& rhs );
3940 template<
typename VT >
inline Row&
operator-=(
const DenseVector<VT,true>& rhs );
3941 template<
typename VT >
inline Row&
operator-=(
const SparseVector<VT,true>& rhs );
3942 template<
typename VT >
inline Row&
operator*=(
const Vector<VT,true>& rhs );
3943 template<
typename VT >
inline Row&
operator/=(
const DenseVector<VT,true>& rhs );
3945 template<
typename Other >
3946 inline EnableIf_<IsNumeric<Other>, Row >&
operator*=( Other rhs );
3948 template<
typename Other >
3949 inline EnableIf_<IsNumeric<Other>, Row >&
operator/=( Other rhs );
3956 inline size_t size() const noexcept;
3957 inline
size_t capacity() const noexcept;
3959 inline
void reset();
3960 inline
void reserve(
size_t n );
3967 inline Iterator
set (
size_t index, const ElementType& value );
3968 inline Iterator insert(
size_t index, const ElementType& value );
3969 inline
void append(
size_t index, const ElementType& value,
bool check=false );
3976 inline
void erase(
size_t index );
3977 inline Iterator erase( Iterator pos );
3978 inline Iterator erase( Iterator first, Iterator last );
3980 template< typename Pred, typename =
DisableIf_< IsIntegral<Pred> > >
3981 inline
void erase( Pred predicate );
3983 template< typename Pred >
3984 inline
void erase( Iterator first, Iterator last, Pred predicate );
3991 inline Iterator find (
size_t index );
3992 inline ConstIterator find (
size_t index ) const;
3993 inline Iterator lowerBound(
size_t index );
3994 inline ConstIterator lowerBound(
size_t index ) const;
3995 inline Iterator upperBound(
size_t index );
3996 inline ConstIterator upperBound(
size_t index ) const;
4003 template< typename Other > inline Row& scale( const Other& scalar );
4010 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
4011 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
4013 template< typename VT > inline
void assign ( const DenseVector <VT,true>& rhs );
4014 template< typename VT > inline
void assign ( const SparseVector<VT,true>& rhs );
4015 template< typename VT > inline
void addAssign( const DenseVector <VT,true>& rhs );
4016 template< typename VT > inline
void addAssign( const SparseVector<VT,true>& rhs );
4017 template< typename VT > inline
void subAssign( const DenseVector <VT,true>& rhs );
4018 template< typename VT > inline
void subAssign( const SparseVector<VT,true>& rhs );
4026 inline
size_t extendCapacity() const;
4039 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
4040 friend
bool isIntact( const Row<MT2,SO2,DF2,SF2>& row ) noexcept;
4042 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
4043 friend
bool isSame( const Row<MT2,SO2,DF2,SF2>& a, const Row<MT2,SO2,DF2,SF2>& b ) noexcept;
4045 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
4046 friend
bool tryAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
4048 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
4049 friend
bool tryAddAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
4051 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
4052 friend
bool trySubAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
4054 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
4055 friend
bool tryMultAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
4057 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
4058 friend
DerestrictTrait_< Row<MT2,SO2,DF2,SF2> > derestrict( Row<MT2,SO2,DF2,SF2>& row );
4091 template< typename MT >
4092 inline Row<MT,false,false,true>::Row( Operand matrix,
size_t index )
4096 if( matrix_.rows() <= index ) {
4122 template<
typename MT >
4124 Row<MT,false,false,true>::operator[](
size_t index )
4127 return matrix_(index,row_);
4143 template<
typename MT >
4145 Row<MT,false,false,true>::operator[](
size_t index )
const 4148 return const_cast<const MT&
>( matrix_ )(index,row_);
4165 template<
typename MT >
4167 Row<MT,false,false,true>::at(
size_t index )
4169 if( index >=
size() ) {
4172 return (*
this)[index];
4189 template<
typename MT >
4191 Row<MT,false,false,true>::at(
size_t index )
const 4193 if( index >=
size() ) {
4196 return (*
this)[index];
4210 template<
typename MT >
4213 return matrix_.begin( row_ );
4227 template<
typename MT >
4230 return matrix_.cbegin( row_ );
4244 template<
typename MT >
4247 return matrix_.cbegin( row_ );
4261 template<
typename MT >
4264 return matrix_.end( row_ );
4278 template<
typename MT >
4281 return matrix_.cend( row_ );
4295 template<
typename MT >
4298 return matrix_.cend( row_ );
4326 template<
typename MT >
4327 inline Row<MT,false,false,true>& Row<MT,false,false,true>::operator=(
const Row& rhs )
4329 using blaze::assign;
4335 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
4338 if(
size() != rhs.size() ) {
4342 if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
4346 DerestrictTrait_<This> left( derestrict( *
this ) );
4348 if( rhs.canAlias( &matrix_ ) ) {
4349 const ResultType tmp( rhs );
4351 left.reserve( tmp.nonZeros() );
4352 assign( left, tmp );
4356 left.reserve( rhs.nonZeros() );
4357 assign( left, rhs );
4382 template<
typename MT >
4383 template<
typename VT >
4384 inline Row<MT,false,false,true>&
4385 Row<MT,false,false,true>::operator=(
const DenseVector<VT,true>& rhs )
4387 using blaze::assign;
4397 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
4398 Right right( ~rhs );
4400 if( !tryAssign( matrix_, right, row_, 0UL ) ) {
4404 DerestrictTrait_<This> left( derestrict( *
this ) );
4406 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4407 const ResultType_<VT> tmp( right );
4409 assign( left, tmp );
4413 assign( left, right );
4438 template<
typename MT >
4439 template<
typename VT >
4440 inline Row<MT,false,false,true>&
4441 Row<MT,false,false,true>::operator=(
const SparseVector<VT,true>& rhs )
4443 using blaze::assign;
4453 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
4454 Right right( ~rhs );
4456 if( !tryAssign( matrix_, right, row_, 0UL ) ) {
4460 DerestrictTrait_<This> left( derestrict( *
this ) );
4462 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4463 const ResultType_<VT> tmp( right );
4465 left.reserve( tmp.nonZeros() );
4466 assign( left, tmp );
4470 left.reserve( right.nonZeros() );
4471 assign( left, right );
4496 template<
typename MT >
4497 template<
typename VT >
4498 inline Row<MT,false,false,true>&
4501 using blaze::assign;
4510 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
4520 const AddType tmp( *
this + (~rhs) );
4522 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4526 DerestrictTrait_<This> left( derestrict( *
this ) );
4529 assign( left, tmp );
4553 template<
typename MT >
4554 template<
typename VT >
4555 inline Row<MT,false,false,true>&
4558 using blaze::assign;
4567 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
4577 const AddType tmp( *
this + (~rhs) );
4579 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4583 DerestrictTrait_<This> left( derestrict( *
this ) );
4586 left.reserve( tmp.nonZeros() );
4587 assign( left, tmp );
4612 template<
typename MT >
4613 template<
typename VT >
4614 inline Row<MT,false,false,true>&
4617 using blaze::assign;
4626 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
4636 const SubType tmp( *
this - (~rhs) );
4638 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4642 DerestrictTrait_<This> left( derestrict( *
this ) );
4645 assign( left, tmp );
4670 template<
typename MT >
4671 template<
typename VT >
4672 inline Row<MT,false,false,true>&
4675 using blaze::assign;
4684 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
4694 const SubType tmp( *
this - (~rhs) );
4696 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4700 DerestrictTrait_<This> left( derestrict( *
this ) );
4703 left.reserve( tmp.nonZeros() );
4704 assign( left, tmp );
4727 template<
typename MT >
4728 template<
typename VT >
4729 inline Row<MT,false,false,true>&
4732 using blaze::assign;
4740 typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
4749 const MultType tmp( *
this * (~rhs) );
4751 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4755 DerestrictTrait_<This> left( derestrict( *
this ) );
4758 assign( left, tmp );
4780 template<
typename MT >
4781 template<
typename VT >
4782 inline Row<MT,false,false,true>&
4785 using blaze::assign;
4794 typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
4804 const DivType tmp( *
this / (~rhs) );
4806 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4810 DerestrictTrait_<This> left( derestrict( *
this ) );
4813 assign( left, tmp );
4838 template<
typename MT >
4839 template<
typename Other >
4840 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,true> >&
4845 for( Iterator element=
begin(); element!=
end(); ++element )
4846 element->value() *= rhs;
4871 template<
typename MT >
4872 template<
typename Other >
4873 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,true> >&
4880 typedef DivTrait_<ElementType,Other> DT;
4881 typedef If_< IsNumeric<DT>, DT, Other > Tmp;
4885 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
4886 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
4887 for( Iterator element=
begin(); element!=
end(); ++element )
4888 element->value() *= tmp;
4891 for( Iterator element=
begin(); element!=
end(); ++element )
4892 element->value() /= rhs;
4915 template<
typename MT >
4918 return matrix_.columns();
4930 template<
typename MT >
4933 return matrix_.capacity( row_ );
4948 template<
typename MT >
4951 return matrix_.nonZeros( row_ );
4963 template<
typename MT >
4966 matrix_.reset( row_ );
4982 template<
typename MT >
4983 void Row<MT,false,false,true>::reserve(
size_t n )
4985 matrix_.reserve( row_, n );
5000 template<
typename MT >
5001 inline size_t Row<MT,false,false,true>::extendCapacity()
const 5006 size_t nonzeros( 2UL*
capacity()+1UL );
5007 nonzeros =
max( nonzeros, 7UL );
5008 nonzeros =
min( nonzeros,
size() );
5038 template<
typename MT >
5042 return matrix_.set( index, row_, value );
5061 template<
typename MT >
5063 Row<MT,false,false,true>::insert(
size_t index,
const ElementType& value )
5065 return matrix_.insert( index, row_, value );
5096 template<
typename MT >
5097 inline void Row<MT,false,false,true>::append(
size_t index,
const ElementType& value,
bool check )
5099 matrix_.append( index, row_, value, check );
5122 template<
typename MT >
5123 inline void Row<MT,false,false,true>::erase(
size_t index )
5125 matrix_.erase( index, row_ );
5140 template<
typename MT >
5142 Row<MT,false,false,true>::erase( Iterator pos )
5144 return matrix_.erase( row_, pos );
5160 template<
typename MT >
5162 Row<MT,false,false,true>::erase( Iterator first, Iterator last )
5164 return matrix_.erase( row_, first, last );
5193 template<
typename MT >
5194 template<
typename Pred
5196 inline void Row<MT,false,false,true>::erase( Pred predicate )
5198 matrix_.erase( row_,
begin(),
end(), predicate );
5229 template<
typename MT >
5230 template<
typename Pred >
5231 inline void Row<MT,false,false,true>::erase( Iterator first, Iterator last, Pred predicate )
5233 matrix_.erase( row_, first, last, predicate );
5261 template<
typename MT >
5263 Row<MT,false,false,true>::find(
size_t index )
5265 return matrix_.find( index, row_ );
5285 template<
typename MT >
5287 Row<MT,false,false,true>::find(
size_t index )
const 5289 return matrix_.find( index, row_ );
5308 template<
typename MT >
5310 Row<MT,false,false,true>::lowerBound(
size_t index )
5312 return matrix_.lowerBound( index, row_ );
5331 template<
typename MT >
5333 Row<MT,false,false,true>::lowerBound(
size_t index )
const 5335 return matrix_.lowerBound( index, row_ );
5354 template<
typename MT >
5356 Row<MT,false,false,true>::upperBound(
size_t index )
5358 return matrix_.upperBound( index, row_ );
5377 template<
typename MT >
5379 Row<MT,false,false,true>::upperBound(
size_t index )
const 5381 return matrix_.upperBound( index, row_ );
5406 template<
typename MT >
5407 template<
typename Other >
5408 inline Row<MT,false,false,true>& Row<MT,false,false,true>::scale(
const Other& scalar )
5412 for( Iterator element=
begin(); element!=
end(); ++element )
5413 element->value() *= scalar;
5439 template<
typename MT >
5440 template<
typename Other >
5441 inline bool Row<MT,false,false,true>::canAlias(
const Other* alias )
const noexcept
5443 return matrix_.isAliased( alias );
5460 template<
typename MT >
5461 template<
typename Other >
5462 inline bool Row<MT,false,false,true>::isAliased(
const Other* alias )
const noexcept
5464 return matrix_.isAliased( alias );
5482 template<
typename MT >
5483 template<
typename VT >
5484 inline void Row<MT,false,false,true>::assign(
const DenseVector<VT,true>& rhs )
5489 for(
size_t i=0UL; i<
size(); ++i )
5491 if( matrix_.nonZeros( row_ ) == matrix_.capacity( row_ ) )
5492 matrix_.reserve( row_, extendCapacity() );
5494 matrix_.append( i, row_, (~rhs)[i],
true );
5513 template<
typename MT >
5514 template<
typename VT >
5515 inline void Row<MT,false,false,true>::assign(
const SparseVector<VT,true>& rhs )
5520 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
5521 matrix_.append( element->index(), row_, element->value(), true );
5540 template<
typename MT >
5541 template<
typename VT >
5542 inline void Row<MT,false,false,true>::addAssign(
const DenseVector<VT,true>& rhs )
5544 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
5552 const AddType tmp(
serial( *
this + (~rhs) ) );
5553 matrix_.reset( row_ );
5572 template<
typename MT >
5573 template<
typename VT >
5574 inline void Row<MT,false,false,true>::addAssign(
const SparseVector<VT,true>& rhs )
5576 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
5584 const AddType tmp(
serial( *
this + (~rhs) ) );
5585 matrix_.reset( row_ );
5586 matrix_.reserve( row_, tmp.nonZeros() );
5605 template<
typename MT >
5606 template<
typename VT >
5607 inline void Row<MT,false,false,true>::subAssign(
const DenseVector<VT,true>& rhs )
5609 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
5617 const SubType tmp(
serial( *
this - (~rhs) ) );
5618 matrix_.reset( row_ );
5637 template<
typename MT >
5638 template<
typename VT >
5639 inline void Row<MT,false,false,true>::subAssign(
const SparseVector<VT,true>& rhs )
5641 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
5649 const SubType tmp(
serial( *
this - (~rhs) ) );
5650 matrix_.reset( row_ );
5651 matrix_.reserve( row_, tmp.nonZeros() );
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
Header file for mathematical functions.
typename DerestrictTrait< T >::Type DerestrictTrait_
Auxiliary alias declaration for the DerestrictTrait type trait.The DerestrictTrait_ alias declaration...
Definition: DerestrictTrait.h:110
#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.
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:352
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:721
Header file for basic type definitions.
Header file for the SparseVector base class.
Header file for the View base class.
Header file for the row trait.
Header file for the serial shim.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:261
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
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:194
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2935
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
Header file for the IsIntegral type trait.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1755
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2928
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
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:390
#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:60
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Header file for the IsUniLower type trait.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1802
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:304
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:238
Constraint on the data type.
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the implementation of the Row base template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Header file for the IsLower type trait.
#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:61
Header file for the SparseElement base class.
Constraint on the data type.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:128
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2932
Constraint on the data type.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:260
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:2933
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Constraint on the data type.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2937
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:128
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the DerestrictTrait class template.
Constraint on the data type.
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2934
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the division trait.
Header file for the reset shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2938
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the IsReference type trait.
Header file for the RemoveReference type trait.
#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:61
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2929
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2930
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:249
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: RowVector.h:61
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2936
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
Header file for the IsUpper type trait.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the IsRestricted type trait.
const DMatDMatMultExpr< T1, T2, false, false, false, false > 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:7505
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Constraint on the transpose flag of vector types.
Header file for the IsExpression type trait class.