35 #ifndef _BLAZE_MATH_VIEWS_ROWS_SPARSE_H_ 36 #define _BLAZE_MATH_VIEWS_ROWS_SPARSE_H_ 112 template<
typename MT
115 class Rows<MT,true,false,SF,CRAs...>
116 :
public View< SparseMatrix< Rows<MT,true,false,SF,CRAs...>, false > >
117 ,
private RowsData<CRAs...>
121 using DataType = RowsData<CRAs...>;
122 using Operand = If_< IsExpression<MT>, MT, MT& >;
128 using This = Rows<MT,
true,
false,SF,CRAs...>;
130 using BaseType = SparseMatrix<This,false>;
131 using ViewedType = MT;
154 enum :
bool { smpAssignable = MT::smpAssignable };
160 template<
typename... RRAs >
161 explicit inline Rows( MT& matrix, RRAs... args );
163 inline Rows(
const Rows& ) =
default;
164 inline Rows( Rows&& ) =
default;
175 inline Reference operator()(
size_t i,
size_t j );
176 inline ConstReference operator()(
size_t i,
size_t j )
const;
177 inline Reference at(
size_t i,
size_t j );
178 inline ConstReference at(
size_t i,
size_t j )
const;
180 inline ConstIterator
begin (
size_t i )
const;
181 inline ConstIterator
cbegin(
size_t i )
const;
183 inline ConstIterator
end (
size_t i )
const;
184 inline ConstIterator
cend (
size_t i )
const;
191 inline Rows& operator=( initializer_list< initializer_list<ElementType> > list );
192 inline Rows& operator=(
const Rows& rhs );
194 template<
typename MT2,
bool SO >
inline Rows& operator= (
const Matrix<MT2,SO>& rhs );
195 template<
typename MT2,
bool SO >
inline Rows&
operator+=(
const Matrix<MT2,SO>& rhs );
196 template<
typename MT2,
bool SO >
inline Rows&
operator-=(
const Matrix<MT2,SO>& rhs );
197 template<
typename MT2,
bool SO >
inline Rows& operator%=(
const Matrix<MT2,SO>& rhs );
205 using DataType::idces;
208 inline MT& operand() noexcept;
209 inline const MT& operand() const noexcept;
211 inline
size_t columns() const noexcept;
212 inline
size_t capacity() const noexcept;
213 inline
size_t capacity(
size_t i ) const noexcept;
215 inline
size_t nonZeros(
size_t i ) const;
217 inline
void reset(
size_t i );
218 inline
void reserve(
size_t nonzeros );
219 void reserve(
size_t i,
size_t nonzeros );
221 inline
void trim(
size_t i );
230 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
231 inline
void finalize(
size_t i );
238 inline
void erase(
size_t i,
size_t j );
242 template< typename Pred >
243 inline
void erase( Pred predicate );
245 template< typename Pred >
246 inline
void erase(
size_t i,
Iterator first,
Iterator last, Pred predicate );
253 inline
Iterator find (
size_t i,
size_t j );
254 inline ConstIterator find (
size_t i,
size_t j ) const;
255 inline
Iterator lowerBound(
size_t i,
size_t j );
256 inline ConstIterator lowerBound(
size_t i,
size_t j ) const;
257 inline
Iterator upperBound(
size_t i,
size_t j );
258 inline ConstIterator upperBound(
size_t i,
size_t j ) const;
268 template< typename Other > inline Rows& scale( const Other& scalar );
275 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
276 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
278 inline
bool canSMPAssign() const noexcept;
280 template< typename MT2,
bool SO > inline
void assign ( const DenseMatrix<MT2,SO>& rhs );
281 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,false>& rhs );
282 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,true>& rhs );
283 template< typename MT2,
bool SO > inline
void addAssign ( const Matrix<MT2,SO>& rhs );
284 template< typename MT2,
bool SO > inline
void subAssign ( const Matrix<MT2,SO>& rhs );
285 template< typename MT2,
bool SO > inline
void schurAssign( const Matrix<MT2,SO>& rhs );
293 inline
size_t extendCapacity(
size_t i ) const noexcept;
340 template< typename MT
343 template< typename... RRAs >
344 inline Rows<MT,true,false,SF,CRAs...>::Rows( MT& matrix, RRAs... args )
345 : DataType( args... )
348 if( !Contains< TypeList<RRAs...>,
Unchecked >::value ) {
349 for(
size_t i=0UL; i<
rows(); ++i ) {
350 if( matrix_.rows() <= idx(i) ) {
379 template<
typename MT
382 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Reference 383 Rows<MT,true,false,SF,CRAs...>::operator()(
size_t i,
size_t j )
388 return matrix_(idx(i),j);
405 template<
typename MT
409 Rows<MT,true,false,SF,CRAs...>::operator()(
size_t i,
size_t j )
const 414 return const_cast<const MT&
>( matrix_ )(idx(i),j);
432 template<
typename MT
435 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Reference 436 Rows<MT,true,false,SF,CRAs...>::at(
size_t i,
size_t j )
462 template<
typename MT
466 Rows<MT,true,false,SF,CRAs...>::at(
size_t i,
size_t j )
const 489 template<
typename MT
492 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 497 return matrix_.begin( idx(i) );
512 template<
typename MT
520 return matrix_.cbegin( idx(i) );
535 template<
typename MT
543 return matrix_.cbegin( idx(i) );
558 template<
typename MT
561 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 566 return matrix_.end( idx(i) );
581 template<
typename MT
589 return matrix_.cend( idx(i) );
604 template<
typename MT
612 return matrix_.cend( idx(i) );
642 template<
typename MT
645 inline Rows<MT,
true,
false,SF,CRAs...>&
646 Rows<MT,true,false,SF,CRAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
651 if( list.size() !=
rows() ) {
655 const InitializerMatrix<ElementType> tmp( list,
columns() );
657 if( IsRestricted<MT>::value ) {
658 for(
size_t i=0UL; i<
rows(); ++i ) {
659 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), i, 0UL ) ) {
665 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
691 template<
typename MT
694 inline Rows<MT,
true,
false,SF,CRAs...>&
695 Rows<MT,true,false,SF,CRAs...>::operator=(
const Rows& rhs )
703 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && idces() == rhs.idces() ) )
706 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
710 if( IsRestricted<MT>::value ) {
711 for(
size_t i=0UL; i<
rows(); ++i ) {
712 if( !tryAssign( matrix_,
row( rhs, i,
unchecked ), idx(i), 0UL ) ) {
718 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
720 if( rhs.canAlias( &matrix_ ) ) {
753 template<
typename MT
756 template<
typename MT2
758 inline Rows<MT,
true,
false,SF,CRAs...>&
759 Rows<MT,true,false,SF,CRAs...>::operator=(
const Matrix<MT2,SO>& rhs )
770 using Right = CompositeType_<MT2>;
773 if( IsRestricted<MT>::value ) {
774 for(
size_t i=0UL; i<
rows(); ++i ) {
775 if( !tryAssign( matrix_,
row( right, i,
unchecked ), idx(i), 0UL ) ) {
781 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
783 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
784 const ResultType_<MT2> tmp( right );
815 template<
typename MT
818 template<
typename MT2
820 inline Rows<MT,
true,
false,SF,CRAs...>&
830 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
838 const AddType tmp( *
this + (~rhs) );
840 if( IsRestricted<MT>::value ) {
841 for(
size_t i=0UL; i<
rows(); ++i ) {
842 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
848 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
875 template<
typename MT
878 template<
typename MT2
880 inline Rows<MT,
true,
false,SF,CRAs...>&
890 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
898 const SubType tmp( *
this - (~rhs) );
900 if( IsRestricted<MT>::value ) {
901 for(
size_t i=0UL; i<
rows(); ++i ) {
902 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
908 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
935 template<
typename MT
938 template<
typename MT2
940 inline Rows<MT,
true,
false,SF,CRAs...>&
941 Rows<MT,true,false,SF,CRAs...>::operator%=(
const Matrix<MT2,SO>& rhs )
950 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
958 const SchurType tmp( *
this % (~rhs) );
960 if( IsRestricted<MT>::value ) {
961 for(
size_t i=0UL; i<
rows(); ++i ) {
962 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
968 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
995 template<
typename MT
998 inline MT& Rows<MT,true,false,SF,CRAs...>::operand() noexcept
1012 template<
typename MT
1015 inline const MT& Rows<MT,true,false,SF,CRAs...>::operand() const noexcept
1029 template<
typename MT
1034 return matrix_.columns();
1046 template<
typename MT
1051 return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
1066 template<
typename MT
1073 return matrix_.capacity( idx(i) );
1085 template<
typename MT
1090 size_t nonzeros( 0UL );
1092 for(
size_t i=0UL; i<
rows(); ++i )
1110 template<
typename MT
1117 return matrix_.nonZeros( idx(i) );
1129 template<
typename MT
1134 for(
size_t i=0UL; i<
rows(); ++i ) {
1135 matrix_.reset( idx(i) );
1152 template<
typename MT
1157 matrix_.reset( idx(i) );
1174 template<
typename MT
1177 inline void Rows<MT,true,false,SF,CRAs...>::reserve(
size_t nonzeros )
1179 const size_t current(
capacity() );
1181 if( nonzeros > current ) {
1182 matrix_.reserve( matrix_.capacity() + nonzeros - current );
1202 template<
typename MT
1205 void Rows<MT,true,false,SF,CRAs...>::reserve(
size_t i,
size_t nonzeros )
1207 matrix_.reserve( idx(i), nonzeros );
1223 template<
typename MT
1226 void Rows<MT,true,false,SF,CRAs...>::trim()
1228 for(
size_t i=0UL; i<
rows(); ++i ) {
1247 template<
typename MT
1250 void Rows<MT,true,false,SF,CRAs...>::trim(
size_t i )
1254 matrix_.trim( idx(i) );
1270 template<
typename MT
1273 inline size_t Rows<MT,true,false,SF,CRAs...>::extendCapacity(
size_t i )
const noexcept
1278 size_t nonzeros( 2UL*
capacity( i )+1UL );
1279 nonzeros =
max( nonzeros, 7UL );
1311 template<
typename MT
1314 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1317 return matrix_.set( idx(i), j, value );
1337 template<
typename MT
1340 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1341 Rows<MT,true,false,SF,CRAs...>::insert(
size_t i,
size_t j,
const ElementType& value )
1343 return matrix_.insert( idx(i), j, value );
1393 template<
typename MT
1396 inline void Rows<MT,true,false,SF,CRAs...>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
1398 if( !check || !isDefault<strict>( value ) )
1399 matrix_.insert( idx(i), j, value );
1419 template<
typename MT
1422 inline void Rows<MT,true,false,SF,CRAs...>::finalize(
size_t i )
1450 template<
typename MT
1453 inline void Rows<MT,true,false,SF,CRAs...>::erase(
size_t i,
size_t j )
1458 matrix_.erase( idx(i), j );
1474 template<
typename MT
1477 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1478 Rows<MT,true,false,SF,CRAs...>::erase(
size_t i,
Iterator pos )
1482 return matrix_.erase( idx(i), pos );
1499 template<
typename MT
1502 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1503 Rows<MT,true,false,SF,CRAs...>::erase(
size_t i,
Iterator first,
Iterator last )
1507 return matrix_.erase( idx(i), first, last );
1536 template<
typename MT
1539 template<
typename Pred >
1540 inline void Rows<MT,true,false,SF,CRAs...>::erase( Pred predicate )
1542 for(
size_t i=0UL; i<
rows(); ++i ) {
1543 matrix_.erase( idx(i),
begin(i),
end(i), predicate );
1577 template<
typename MT
1580 template<
typename Pred >
1581 inline void Rows<MT,true,false,SF,CRAs...>::erase(
size_t i,
Iterator first,
Iterator last, Pred predicate )
1585 matrix_.erase( idx(i), first, last, predicate );
1614 template<
typename MT
1617 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1618 Rows<MT,true,false,SF,CRAs...>::find(
size_t i,
size_t j )
1620 return matrix_.find( idx(i), j );
1641 template<
typename MT
1645 Rows<MT,true,false,SF,CRAs...>::find(
size_t i,
size_t j )
const 1647 return matrix_.find( idx(i), j );
1667 template<
typename MT
1670 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1671 Rows<MT,true,false,SF,CRAs...>::lowerBound(
size_t i,
size_t j )
1673 return matrix_.lowerBound( idx(i), j );
1693 template<
typename MT
1697 Rows<MT,true,false,SF,CRAs...>::lowerBound(
size_t i,
size_t j )
const 1699 return matrix_.lowerBound( idx(i), j );
1719 template<
typename MT
1722 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1723 Rows<MT,true,false,SF,CRAs...>::upperBound(
size_t i,
size_t j )
1725 return matrix_.upperBound( idx(i), j );
1745 template<
typename MT
1749 Rows<MT,true,false,SF,CRAs...>::upperBound(
size_t i,
size_t j )
const 1751 return matrix_.upperBound( idx(i), j );
1778 template<
typename MT
1781 inline Rows<MT,
true,
false,SF,CRAs...>&
1793 if( IsRestricted<MT>::value ) {
1794 for(
size_t i=0UL; i<
rows(); ++i ) {
1795 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
1801 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1825 template<
typename MT
1828 inline Rows<MT,
true,
false,SF,CRAs...>&
1840 if( IsRestricted<MT>::value ) {
1841 for(
size_t i=0UL; i<
rows(); ++i ) {
1842 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
1848 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1872 template<
typename MT
1875 template<
typename Other >
1876 inline Rows<MT,
true,
false,SF,CRAs...>&
1877 Rows<MT,true,false,SF,CRAs...>::scale(
const Other& scalar )
1883 for(
size_t i=0UL; i<
rows(); ++i ) {
1886 element->value() *= scalar;
1914 template<
typename MT
1917 template<
typename Other >
1918 inline bool Rows<MT,true,false,SF,CRAs...>::canAlias(
const Other* alias )
const noexcept
1920 return matrix_.isAliased( alias );
1937 template<
typename MT
1940 template<
typename Other >
1941 inline bool Rows<MT,true,false,SF,CRAs...>::isAliased(
const Other* alias )
const noexcept
1943 return matrix_.isAliased( alias );
1960 template<
typename MT
1963 inline bool Rows<MT,true,false,SF,CRAs...>::canSMPAssign() const noexcept
1983 template<
typename MT
1986 template<
typename MT2
1988 inline void Rows<MT,true,false,SF,CRAs...>::assign(
const DenseMatrix<MT2,SO>& rhs )
1997 for(
size_t i=0UL; i<
rows(); ++i )
1999 const size_t index( idx(i) );
2000 size_t remaining( matrix_.capacity( index ) );
2002 for(
size_t j=0UL; j<
columns(); ++j )
2004 if( remaining == 0UL ) {
2005 matrix_.reserve( index, extendCapacity( i ) );
2006 remaining = matrix_.capacity( index ) - matrix_.nonZeros( index );
2009 matrix_.append( index, j, (~rhs)(i,j),
true );
2030 template<
typename MT
2033 template<
typename MT2 >
2034 inline void Rows<MT,true,false,SF,CRAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
2043 for(
size_t i=0UL; i<
rows(); ++i )
2045 const size_t index( idx(i) );
2046 size_t remaining( matrix_.capacity( index ) );
2048 for( ConstIterator_<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
2050 if( remaining == 0UL ) {
2051 matrix_.reserve( index, extendCapacity( i ) );
2052 remaining = matrix_.capacity( index ) - matrix_.nonZeros( index );
2055 matrix_.append( index, element->index(), element->value(), true );
2076 template<
typename MT
2079 template<
typename MT2 >
2080 inline void Rows<MT,true,false,SF,CRAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
2091 using RhsIterator = ConstIterator_<MT2>;
2094 std::vector<size_t> rowLengths(
rows(), 0UL );
2095 for(
size_t j=0UL; j<
columns(); ++j ) {
2096 for( RhsIterator element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
2097 ++rowLengths[element->index()];
2101 for(
size_t i=0UL; i<
rows(); ++i ) {
2102 reserve( i, rowLengths[i] );
2106 for(
size_t j=0UL; j<
columns(); ++j ) {
2107 for( RhsIterator element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
2108 append( element->index(), j, element->value(), true );
2127 template<
typename MT
2130 template<
typename MT2
2132 inline void Rows<MT,true,false,SF,CRAs...>::addAssign(
const Matrix<MT2,SO>& rhs )
2137 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
2144 const AddType tmp(
serial( *
this + (~rhs) ) );
2164 template<
typename MT
2167 template<
typename MT2
2169 inline void Rows<MT,true,false,SF,CRAs...>::subAssign(
const Matrix<MT2,SO>& rhs )
2174 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
2181 const SubType tmp(
serial( *
this - (~rhs) ) );
2201 template<
typename MT
2204 template<
typename MT2
2206 inline void Rows<MT,true,false,SF,CRAs...>::schurAssign(
const Matrix<MT2,SO>& rhs )
2211 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
2219 const SchurType tmp(
serial( *
this % (~rhs) ) );
2247 template<
typename MT
2249 class Rows<MT,false,false,false,CRAs...>
2250 :
public View< SparseMatrix< Rows<MT,false,false,false,CRAs...>, false > >
2251 ,
private RowsData<CRAs...>
2255 using DataType = RowsData<CRAs...>;
2256 using Operand = If_< IsExpression<MT>, MT, MT& >;
2262 using This = Rows<MT,
false,
false,
false,CRAs...>;
2264 using BaseType = SparseMatrix<This,false>;
2265 using ViewedType = MT;
2274 using ConstReference = ConstReference_<MT>;
2283 template<
typename MatrixType
2284 ,
typename IteratorType >
2286 :
private SparseElement
2295 inline RowsElement( IteratorType pos,
size_t column )
2307 template<
typename T >
inline RowsElement& operator=(
const T& v ) {
2319 template<
typename T >
inline RowsElement&
operator+=(
const T& v ) {
2331 template<
typename T >
inline RowsElement&
operator-=(
const T& v ) {
2343 template<
typename T >
inline RowsElement&
operator*=(
const T& v ) {
2355 template<
typename T >
inline RowsElement&
operator/=(
const T& v ) {
2366 inline const RowsElement* operator->()
const {
2376 inline decltype(
auto) value()
const {
2377 return pos_->value();
2386 inline size_t index()
const {
2402 template<
typename MatrixType
2403 ,
typename IteratorType >
2408 using IteratorCategory = std::forward_iterator_tag;
2409 using ValueType = RowsElement<MatrixType,IteratorType>;
2410 using PointerType = ValueType;
2411 using ReferenceType = ValueType;
2412 using DifferenceType = ptrdiff_t;
2415 using iterator_category = IteratorCategory;
2416 using value_type = ValueType;
2417 using pointer = PointerType;
2418 using reference = ReferenceType;
2419 using difference_type = DifferenceType;
2425 inline RowsIterator()
2426 : matrix_( nullptr )
2440 inline RowsIterator( MatrixType& matrix,
size_t row,
size_t column )
2441 : matrix_( &matrix )
2446 for( ; column_<matrix_->columns(); ++column_ ) {
2447 pos_ = matrix_->find( row_, column_ );
2448 if( pos_ != matrix_->end( column_ ) )
break;
2461 inline RowsIterator( MatrixType& matrix,
size_t row,
size_t column, IteratorType pos )
2462 : matrix_( &matrix )
2476 template<
typename MatrixType2,
typename IteratorType2 >
2477 inline RowsIterator(
const RowsIterator<MatrixType2,IteratorType2>& it )
2478 : matrix_( it.matrix_ )
2480 , column_( it.column_ )
2490 inline RowsIterator& operator++() {
2492 for( ; column_<matrix_->columns(); ++column_ ) {
2493 pos_ = matrix_->find( row_, column_ );
2494 if( pos_ != matrix_->end( column_ ) )
break;
2506 inline const RowsIterator operator++(
int ) {
2507 const RowsIterator tmp( *
this );
2518 inline ReferenceType
operator*()
const {
2519 return ReferenceType( pos_, column_ );
2528 inline PointerType operator->()
const {
2529 return PointerType( pos_, column_ );
2539 template<
typename MatrixType2,
typename IteratorType2 >
2540 inline bool operator==(
const RowsIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2541 return column_ == rhs.column_;
2551 template<
typename MatrixType2,
typename IteratorType2 >
2552 inline bool operator!=(
const RowsIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2553 return !( *
this == rhs );
2563 inline DifferenceType
operator-(
const RowsIterator& rhs )
const {
2564 size_t counter( 0UL );
2565 for(
size_t j=rhs.column_; j<column_; ++j ) {
2566 if( matrix_->find( row_, j ) != matrix_->end( j ) )
2575 MatrixType* matrix_;
2582 template<
typename MatrixType2,
typename IteratorType2 >
friend class RowsIterator;
2583 template<
typename MT2,
bool SO2,
bool DF2,
bool SF2,
size_t... CRAs2 >
friend class Rows;
2590 using ConstIterator = RowsIterator< const MT, ConstIterator_<MT> >;
2598 enum :
bool { smpAssignable = MT::smpAssignable };
2604 template<
typename... RRAs >
2605 explicit inline Rows( MT& matrix, RRAs... args );
2607 inline Rows(
const Rows& ) =
default;
2608 inline Rows( Rows&& ) =
default;
2619 inline Reference operator()(
size_t i,
size_t j );
2620 inline ConstReference operator()(
size_t i,
size_t j )
const;
2621 inline Reference at(
size_t i,
size_t j );
2622 inline ConstReference at(
size_t i,
size_t j )
const;
2624 inline ConstIterator
begin (
size_t i )
const;
2625 inline ConstIterator
cbegin(
size_t i )
const;
2627 inline ConstIterator
end (
size_t i )
const;
2628 inline ConstIterator
cend (
size_t i )
const;
2635 inline Rows& operator=( initializer_list< initializer_list<ElementType> > list );
2636 inline Rows& operator=(
const Rows& rhs );
2638 template<
typename MT2,
bool SO >
inline Rows& operator= (
const Matrix<MT2,SO>& rhs );
2639 template<
typename MT2,
bool SO >
inline Rows&
operator+=(
const Matrix<MT2,SO>& rhs );
2640 template<
typename MT2,
bool SO >
inline Rows&
operator-=(
const Matrix<MT2,SO>& rhs );
2641 template<
typename MT2,
bool SO >
inline Rows& operator%=(
const Matrix<MT2,SO>& rhs );
2648 using DataType::idx;
2649 using DataType::idces;
2652 inline MT& operand() noexcept;
2653 inline const MT& operand() const noexcept;
2655 inline
size_t columns() const noexcept;
2656 inline
size_t capacity() const noexcept;
2657 inline
size_t capacity(
size_t i ) const noexcept;
2659 inline
size_t nonZeros(
size_t i ) const;
2660 inline
void reset();
2661 inline
void reset(
size_t i );
2662 inline
void reserve(
size_t nonzeros );
2663 void reserve(
size_t i,
size_t nonzeros );
2665 inline
void trim(
size_t j );
2674 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
2675 inline
void finalize(
size_t i );
2682 inline
void erase(
size_t i,
size_t j );
2686 template< typename Pred >
2687 inline
void erase( Pred predicate );
2689 template< typename Pred >
2690 inline
void erase(
size_t i,
Iterator first,
Iterator last, Pred predicate );
2697 inline
Iterator find (
size_t i,
size_t j );
2698 inline ConstIterator find (
size_t i,
size_t j ) const;
2699 inline
Iterator lowerBound(
size_t i,
size_t j );
2700 inline ConstIterator lowerBound(
size_t i,
size_t j ) const;
2701 inline
Iterator upperBound(
size_t i,
size_t j );
2702 inline ConstIterator upperBound(
size_t i,
size_t j ) const;
2709 inline Rows& transpose();
2710 inline Rows& ctranspose();
2712 template< typename Other > inline Rows& scale( const Other& scalar );
2719 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
2720 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
2722 inline
bool canSMPAssign() const noexcept;
2724 template< typename MT2,
bool SO > inline
void assign ( const DenseMatrix<MT2,SO>& rhs );
2725 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,true>& rhs );
2726 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,false>& rhs );
2727 template< typename MT2,
bool SO > inline
void addAssign ( const Matrix<MT2,SO>& rhs );
2728 template< typename MT2,
bool SO > inline
void subAssign ( const Matrix<MT2,SO>& rhs );
2729 template< typename MT2,
bool SO > inline
void schurAssign( const Matrix<MT2,SO>& rhs );
2778 template< typename MT
2780 template< typename... RRAs >
2781 inline Rows<MT,false,false,false,CRAs...>::Rows( MT& matrix, RRAs... args )
2782 : DataType( args... )
2783 , matrix_ ( matrix )
2785 if( !Contains< TypeList<RRAs...>,
Unchecked >::value ) {
2786 for(
size_t i=0UL; i<
rows(); ++i ) {
2787 if( matrix_.rows() <= idx(i) ) {
2816 template<
typename MT
2818 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Reference 2819 Rows<MT,false,false,false,CRAs...>::operator()(
size_t i,
size_t j )
2824 return matrix_(idx(i),j);
2841 template<
typename MT
2844 Rows<MT,false,false,false,CRAs...>::operator()(
size_t i,
size_t j )
const 2849 return const_cast<const MT&
>( matrix_ )(idx(i),j);
2867 template<
typename MT
2869 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Reference 2870 Rows<MT,false,false,false,CRAs...>::at(
size_t i,
size_t j )
2878 return (*
this)(i,j);
2896 template<
typename MT
2899 Rows<MT,false,false,false,CRAs...>::at(
size_t i,
size_t j )
const 2907 return (*
this)(i,j);
2922 template<
typename MT
2924 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 2929 return Iterator( matrix_, idx(i), 0UL );
2944 template<
typename MT
2966 template<
typename MT
2988 template<
typename MT
2990 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 3010 template<
typename MT
3032 template<
typename MT
3069 template<
typename MT
3071 inline Rows<MT,
false,
false,
false,CRAs...>&
3072 Rows<MT,false,false,false,CRAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
3077 if( list.size() !=
rows() ) {
3081 const InitializerMatrix<ElementType> tmp( list,
columns() );
3083 if( IsRestricted<MT>::value ) {
3084 for(
size_t i=0UL; i<
rows(); ++i ) {
3085 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), i, 0UL ) ) {
3091 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3116 template<
typename MT
3118 inline Rows<MT,
false,
false,
false,CRAs...>&
3119 Rows<MT,false,false,false,CRAs...>::operator=(
const Rows& rhs )
3127 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && idces() == rhs.idces() ) )
3130 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
3134 if( IsRestricted<MT>::value ) {
3135 for(
size_t i=0UL; i<
rows(); ++i ) {
3136 if( !tryAssign( matrix_,
row( rhs, i,
unchecked ), idx(i), 0UL ) ) {
3142 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3144 if( rhs.canAlias( &matrix_ ) ) {
3177 template<
typename MT
3179 template<
typename MT2
3181 inline Rows<MT,
false,
false,
false,CRAs...>&
3182 Rows<MT,false,false,false,CRAs...>::operator=(
const Matrix<MT2,SO>& rhs )
3193 using Right = CompositeType_<MT2>;
3194 Right right( ~rhs );
3196 if( IsRestricted<MT>::value ) {
3197 for(
size_t i=0UL; i<
rows(); ++i ) {
3198 if( !tryAssign( matrix_,
row( right, i,
unchecked ), idx(i), 0UL ) ) {
3204 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3206 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3207 const ResultType_<MT2> tmp( right );
3208 if( IsSparseMatrix< ResultType_<MT2> >::value )
3213 if( IsSparseMatrix<MT2>::value )
3240 template<
typename MT
3242 template<
typename MT2
3244 inline Rows<MT,
false,
false,
false,CRAs...>&
3254 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
3262 const AddType tmp( *
this + (~rhs) );
3264 if( IsRestricted<MT>::value ) {
3265 for(
size_t i=0UL; i<
rows(); ++i ) {
3266 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
3272 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3274 if( IsSparseMatrix<AddType>::value ) {
3302 template<
typename MT
3304 template<
typename MT2
3306 inline Rows<MT,
false,
false,
false,CRAs...>&
3316 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
3324 const SubType tmp( *
this - (~rhs) );
3326 if( IsRestricted<MT>::value ) {
3327 for(
size_t i=0UL; i<
rows(); ++i ) {
3328 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
3334 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3336 if( IsSparseMatrix<SubType>::value ) {
3364 template<
typename MT
3366 template<
typename MT2
3368 inline Rows<MT,
false,
false,
false,CRAs...>&
3369 Rows<MT,false,false,false,CRAs...>::operator%=(
const Matrix<MT2,SO>& rhs )
3378 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
3386 const SchurType tmp( *
this % (~rhs) );
3388 if( IsRestricted<MT>::value ) {
3389 for(
size_t i=0UL; i<
rows(); ++i ) {
3390 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
3396 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3398 if( IsSparseMatrix<SchurType>::value ) {
3426 template<
typename MT
3428 inline MT& Rows<MT,false,false,false,CRAs...>::operand() noexcept
3442 template<
typename MT
3444 inline const MT& Rows<MT,false,false,false,CRAs...>::operand() const noexcept
3458 template<
typename MT
3462 return matrix_.columns();
3474 template<
typename MT
3493 template<
typename MT
3513 template<
typename MT
3517 size_t nonzeros( 0UL );
3519 for(
size_t j=0UL; j<
columns(); ++j ) {
3520 const auto end( matrix_.end( j ) );
3521 for(
size_t i=0UL; i<
rows(); ++i ) {
3522 auto pos = matrix_.find( idx(i), j );
3544 template<
typename MT
3550 size_t counter( 0UL );
3552 const ConstIterator last(
end(i) );
3553 for( ConstIterator element=
begin(i); element!=last; ++element ) {
3569 template<
typename MT
3573 for(
size_t i=0UL; i<
rows(); ++i ) {
3591 template<
typename MT
3595 const size_t index( idx(i) );
3597 const size_t jbegin( ( IsUpper<MT>::value )
3598 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3602 const size_t jend ( ( IsLower<MT>::value )
3603 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3608 for(
size_t j=jbegin; j<jend; ++j ) {
3609 matrix_.erase( index, j );
3627 template<
typename MT
3629 inline void Rows<MT,false,false,false,CRAs...>::reserve(
size_t nonzeros )
3652 template<
typename MT
3654 void Rows<MT,false,false,false,CRAs...>::reserve(
size_t i,
size_t nonzeros )
3674 template<
typename MT
3676 void Rows<MT,false,false,false,CRAs...>::trim()
3695 template<
typename MT
3697 void Rows<MT,false,false,false,CRAs...>::trim(
size_t i )
3730 template<
typename MT
3732 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 3735 return Iterator( matrix_, idx(i), j, matrix_.set( idx(i), j, value ) );
3755 template<
typename MT
3757 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 3758 Rows<MT,false,false,false,CRAs...>::insert(
size_t i,
size_t j,
const ElementType& value )
3760 return Iterator( matrix_, idx(i), j, matrix_.insert( idx(i), j, value ) );
3810 template<
typename MT
3812 inline void Rows<MT,false,false,false,CRAs...>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
3814 if( !check || !isDefault<strict>( value ) )
3815 matrix_.insert( idx(i), j, value );
3835 template<
typename MT
3837 inline void Rows<MT,false,false,false,CRAs...>::finalize(
size_t i )
3865 template<
typename MT
3867 inline void Rows<MT,false,false,false,CRAs...>::erase(
size_t i,
size_t j )
3872 matrix_.erase( idx(i), j );
3888 template<
typename MT
3890 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 3891 Rows<MT,false,false,false,CRAs...>::erase(
size_t i,
Iterator pos )
3893 const size_t column( pos.column_ );
3898 matrix_.erase( column, pos.pos_ );
3899 return Iterator( matrix_, idx(i), column+1UL );
3916 template<
typename MT
3918 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 3919 Rows<MT,false,false,false,CRAs...>::erase(
size_t i,
Iterator first,
Iterator last )
3925 for( ; first!=last; ++first ) {
3926 matrix_.erase( first.column_, first.pos_ );
3958 template<
typename MT
3960 template<
typename Pred >
3961 inline void Rows<MT,false,false,false,CRAs...>::erase( Pred predicate )
3963 for(
size_t i=0UL; i<
rows(); ++i ) {
3965 if( predicate( element->value() ) )
3966 matrix_.erase( element.column_, element.pos_ );
4001 template<
typename MT
4003 template<
typename Pred >
4004 inline void Rows<MT,false,false,false,CRAs...>::erase(
size_t i,
Iterator first,
Iterator last, Pred predicate )
4010 for( ; first!=last; ++first ) {
4011 if( predicate( first->value() ) )
4012 matrix_.erase( first.column_, first.pos_ );
4042 template<
typename MT
4044 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 4045 Rows<MT,false,false,false,CRAs...>::find(
size_t i,
size_t j )
4047 const size_t index( idx(i) );
4048 const Iterator_<MT> pos( matrix_.find( index, j ) );
4050 if( pos != matrix_.end( j ) )
4051 return Iterator( matrix_, index, j, pos );
4074 template<
typename MT
4077 Rows<MT,false,false,false,CRAs...>::find(
size_t i,
size_t j )
const 4079 const size_t index( idx(i) );
4080 const ConstIterator_<MT> pos( matrix_.find( index, j ) );
4082 if( pos != matrix_.end( j ) )
4105 template<
typename MT
4107 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 4108 Rows<MT,false,false,false,CRAs...>::lowerBound(
size_t i,
size_t j )
4110 const size_t index( idx(i) );
4114 const Iterator_<MT> pos( matrix_.find( index, j ) );
4116 if( pos != matrix_.end( j ) )
4117 return Iterator( matrix_, index, j, pos );
4140 template<
typename MT
4143 Rows<MT,false,false,false,CRAs...>::lowerBound(
size_t i,
size_t j )
const 4145 const size_t index( idx(i) );
4149 const ConstIterator_<MT> pos( matrix_.find( index, j ) );
4151 if( pos != matrix_.end( j ) )
4175 template<
typename MT
4177 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 4178 Rows<MT,false,false,false,CRAs...>::upperBound(
size_t i,
size_t j )
4180 return lowerBound( i, j+1UL );
4200 template<
typename MT
4203 Rows<MT,false,false,false,CRAs...>::upperBound(
size_t i,
size_t j )
const 4205 return lowerBound( i, j+1UL );
4232 template<
typename MT
4234 inline Rows<MT,
false,
false,
false,CRAs...>&
4246 if( IsRestricted<MT>::value ) {
4247 for(
size_t i=0UL; i<
rows(); ++i ) {
4248 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
4254 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
4278 template<
typename MT
4280 inline Rows<MT,
false,
false,
false,CRAs...>&
4292 if( IsRestricted<MT>::value ) {
4293 for(
size_t i=0UL; i<
rows(); ++i ) {
4294 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
4300 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
4324 template<
typename MT
4326 template<
typename Other >
4327 inline Rows<MT,
false,
false,
false,CRAs...>&
4328 Rows<MT,false,false,false,CRAs...>::scale(
const Other& scalar )
4334 for(
size_t j=0UL; j<
columns(); ++j ) {
4335 const auto end( matrix_.end( j ) );
4336 for(
size_t i=0UL; i<
rows(); ++i ) {
4337 auto pos = matrix_.find( idx(i), j );
4339 pos->value() *= scalar;
4369 template<
typename MT
4371 template<
typename Other >
4372 inline bool Rows<MT,false,false,false,CRAs...>::canAlias(
const Other* alias )
const noexcept
4374 return matrix_.isAliased( alias );
4391 template<
typename MT
4393 template<
typename Other >
4394 inline bool Rows<MT,false,false,false,CRAs...>::isAliased(
const Other* alias )
const noexcept
4396 return matrix_.isAliased( alias );
4413 template<
typename MT
4415 inline bool Rows<MT,false,false,false,CRAs...>::canSMPAssign() const noexcept
4435 template<
typename MT
4437 template<
typename MT2
4439 inline void Rows<MT,false,false,false,CRAs...>::assign(
const DenseMatrix<MT2,SO>& rhs )
4444 using RT = If_< IsComputation<MT2>, ElementType_<MT>,
const ElementType_<MT2>& >;
4449 for(
size_t j=0UL; j<
columns(); ++j ) {
4450 for(
size_t i=0UL; i<
rows(); ++i ) {
4451 RT value( (~rhs)(i,j) );
4452 if( !isDefault<strict>( value ) )
4453 matrix_.set( idx(i), j, std::move( value ) );
4454 else matrix_.erase( idx(i), j );
4474 template<
typename MT
4476 template<
typename MT2 >
4477 inline void Rows<MT,false,false,false,CRAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
4482 using RT = If_< IsComputation<MT2>, ElementType_<MT>,
const ElementType_<MT2>& >;
4488 for(
size_t i=0UL; i<
rows(); ++i ) {
4489 const size_t index( idx(i) );
4490 for( ConstIterator_<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
4491 RT value( element->value() );
4492 if( !isDefault<strict>( value ) )
4493 matrix_.set( index, element->index(), std::move( value ) );
4494 else matrix_.erase( index, element->index() );
4514 template<
typename MT
4516 template<
typename MT2 >
4517 inline void Rows<MT,false,false,false,CRAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
4524 using RT = If_< IsComputation<MT2>, ElementType_<MT>,
const ElementType_<MT2>& >;
4530 for(
size_t j=0UL; j<
columns(); ++j ) {
4531 for( ConstIterator_<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element ) {
4532 RT value( element->value() );
4533 if( !isDefault<strict>( value ) )
4534 matrix_.set( idx( element->index() ), j, std::move( value ) );
4535 else matrix_.erase( idx( element->index() ), j );
4555 template<
typename MT
4557 template<
typename MT2
4559 inline void Rows<MT,false,false,false,CRAs...>::addAssign(
const Matrix<MT2,SO>& rhs )
4564 using AddType = AddTrait_< ResultType, ResultType_<MT2> >;
4571 const AddType tmp(
serial( *
this + (~rhs) ) );
4591 template<
typename MT
4593 template<
typename MT2
4595 inline void Rows<MT,false,false,false,CRAs...>::subAssign(
const Matrix<MT2,SO>& rhs )
4600 using SubType = SubTrait_< ResultType, ResultType_<MT2> >;
4607 const SubType tmp(
serial( *
this - (~rhs) ) );
4627 template<
typename MT
4629 template<
typename MT2
4631 inline void Rows<MT,false,false,false,CRAs...>::schurAssign(
const Matrix<MT2,SO>& rhs )
4636 using SchurType = SchurTrait_< ResultType, ResultType_<MT2> >;
4644 const SchurType tmp(
serial( *
this % (~rhs) ) );
4672 template<
typename MT
4674 class Rows<MT,false,false,true,CRAs...>
4675 :
public View< SparseMatrix< Rows<MT,false,false,true,CRAs...>, false > >
4676 ,
private RowsData<CRAs...>
4680 using DataType = RowsData<CRAs...>;
4681 using Operand = If_< IsExpression<MT>, MT, MT& >;
4687 using This = Rows<MT,
false,
false,
true,CRAs...>;
4689 using BaseType = SparseMatrix<This,false>;
4690 using ViewedType = MT;
4699 using ConstReference = ConstReference_<MT>;
4705 using ConstIterator = ConstIterator_<MT>;
4713 enum :
bool { smpAssignable = MT::smpAssignable };
4719 template<
typename... RRAs >
4720 explicit inline Rows( MT& matrix, RRAs... args );
4722 inline Rows(
const Rows& ) =
default;
4723 inline Rows( Rows&& ) =
default;
4734 inline Reference operator()(
size_t i,
size_t j );
4735 inline ConstReference operator()(
size_t i,
size_t j )
const;
4736 inline Reference at(
size_t i,
size_t j );
4737 inline ConstReference at(
size_t i,
size_t j )
const;
4739 inline ConstIterator
begin (
size_t i )
const;
4740 inline ConstIterator
cbegin(
size_t i )
const;
4742 inline ConstIterator
end (
size_t i )
const;
4743 inline ConstIterator
cend (
size_t i )
const;
4750 Rows& operator=(
const Rows& ) =
delete;
4757 using DataType::idx;
4758 using DataType::idces;
4761 inline MT& operand() noexcept;
4762 inline const MT& operand() const noexcept;
4764 inline
size_t columns() const noexcept;
4765 inline
size_t capacity() const noexcept;
4766 inline
size_t capacity(
size_t i ) const noexcept;
4768 inline
size_t nonZeros(
size_t i ) const;
4769 inline
void reset();
4770 inline
void reset(
size_t i );
4771 inline
void reserve(
size_t nonzeros );
4772 void reserve(
size_t i,
size_t nonzeros );
4774 inline
void trim(
size_t i );
4783 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
4784 inline
void finalize(
size_t i );
4791 inline
void erase(
size_t i,
size_t j );
4795 template< typename Pred >
4796 inline
void erase( Pred predicate );
4798 template< typename Pred >
4799 inline
void erase(
size_t i,
Iterator first,
Iterator last, Pred predicate );
4806 inline
Iterator find (
size_t i,
size_t j );
4807 inline ConstIterator find (
size_t i,
size_t j ) const;
4808 inline
Iterator lowerBound(
size_t i,
size_t j );
4809 inline ConstIterator lowerBound(
size_t i,
size_t j ) const;
4810 inline
Iterator upperBound(
size_t i,
size_t j );
4811 inline ConstIterator upperBound(
size_t i,
size_t j ) const;
4818 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
4819 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
4821 inline
bool canSMPAssign() const noexcept;
4870 template< typename MT
4872 template< typename... RRAs >
4873 inline Rows<MT,false,false,true,CRAs...>::Rows( MT& matrix, RRAs... args )
4874 : DataType( args... )
4875 , matrix_ ( matrix )
4877 if( !Contains< TypeList<RRAs...>,
Unchecked >::value ) {
4878 for(
size_t i=0UL; i<
rows(); ++i ) {
4879 if( matrix_.rows() <= idx(i) ) {
4908 template<
typename MT
4910 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Reference 4911 Rows<MT,false,false,true,CRAs...>::operator()(
size_t i,
size_t j )
4916 return matrix_(j,idx(i));
4933 template<
typename MT
4936 Rows<MT,false,false,true,CRAs...>::operator()(
size_t i,
size_t j )
const 4941 return const_cast<const MT&
>( matrix_ )(j,idx(i));
4959 template<
typename MT
4961 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Reference 4962 Rows<MT,false,false,true,CRAs...>::at(
size_t i,
size_t j )
4970 return (*
this)(i,j);
4988 template<
typename MT
4991 Rows<MT,false,false,true,CRAs...>::at(
size_t i,
size_t j )
const 4999 return (*
this)(i,j);
5014 template<
typename MT
5016 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5021 return matrix_.begin( idx(i) );
5036 template<
typename MT
5043 return matrix_.cbegin( idx(i) );
5058 template<
typename MT
5065 return matrix_.cbegin( idx(i) );
5080 template<
typename MT
5082 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5087 return matrix_.end( idx(i) );
5102 template<
typename MT
5109 return matrix_.cend( idx(i) );
5124 template<
typename MT
5131 return matrix_.cend( idx(i) );
5151 template<
typename MT
5153 inline MT& Rows<MT,false,false,true,CRAs...>::operand() noexcept
5167 template<
typename MT
5169 inline const MT& Rows<MT,false,false,true,CRAs...>::operand() const noexcept
5183 template<
typename MT
5187 return matrix_.columns();
5199 template<
typename MT
5203 return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
5218 template<
typename MT
5224 return matrix_.capacity( idx(i) );
5236 template<
typename MT
5240 size_t nonzeros( 0UL );
5242 for(
size_t i=0UL; i<
rows(); ++i )
5260 template<
typename MT
5266 return matrix_.nonZeros( idx(i) );
5278 template<
typename MT
5282 for(
size_t i=0UL; i<
rows(); ++i ) {
5283 matrix_.reset( idx(i) );
5300 template<
typename MT
5304 matrix_.reset( idx(i) );
5321 template<
typename MT
5323 inline void Rows<MT,false,false,true,CRAs...>::reserve(
size_t nonzeros )
5325 const size_t current(
capacity() );
5327 if( nonzeros > current ) {
5328 matrix_.reserve( matrix_.capacity() + nonzeros - current );
5348 template<
typename MT
5350 void Rows<MT,false,false,true,CRAs...>::reserve(
size_t i,
size_t nonzeros )
5352 matrix_.reserve( idx(i), nonzeros );
5368 template<
typename MT
5370 void Rows<MT,false,false,true,CRAs...>::trim()
5372 for(
size_t i=0UL; i<
rows(); ++i ) {
5391 template<
typename MT
5393 void Rows<MT,false,false,true,CRAs...>::trim(
size_t i )
5397 matrix_.trim( idx(i) );
5424 template<
typename MT
5426 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5429 return matrix_.set( j, idx(i), value );
5449 template<
typename MT
5451 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5452 Rows<MT,false,false,true,CRAs...>::insert(
size_t i,
size_t j,
const ElementType& value )
5454 return matrix_.insert( j, idx(i), value );
5504 template<
typename MT
5506 inline void Rows<MT,false,false,true,CRAs...>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
5508 if( !check || !isDefault<strict>( value ) )
5509 matrix_.insert( j, idx(i), value );
5529 template<
typename MT
5531 inline void Rows<MT,false,false,true,CRAs...>::finalize(
size_t i )
5559 template<
typename MT
5561 inline void Rows<MT,false,false,true,CRAs...>::erase(
size_t i,
size_t j )
5566 matrix_.erase( j, idx(i) );
5582 template<
typename MT
5584 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5585 Rows<MT,false,false,true,CRAs...>::erase(
size_t i,
Iterator pos )
5589 return matrix_.erase( idx(i), pos );
5606 template<
typename MT
5608 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5609 Rows<MT,false,false,true,CRAs...>::erase(
size_t i,
Iterator first,
Iterator last )
5613 return matrix_.erase( idx(i), first, last );
5642 template<
typename MT
5644 template<
typename Pred >
5645 inline void Rows<MT,false,false,true,CRAs...>::erase( Pred predicate )
5647 for(
size_t i=0UL; i<
rows(); ++i ) {
5648 matrix_.erase( idx(i),
begin(i),
end(i), predicate );
5682 template<
typename MT
5684 template<
typename Pred >
5685 inline void Rows<MT,false,false,true,CRAs...>::erase(
size_t i,
Iterator first,
Iterator last, Pred predicate )
5689 matrix_.erase( idx(i), first, last, predicate );
5718 template<
typename MT
5720 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5721 Rows<MT,false,false,true,CRAs...>::find(
size_t i,
size_t j )
5723 return matrix_.find( j, idx(i) );
5744 template<
typename MT
5747 Rows<MT,false,false,true,CRAs...>::find(
size_t i,
size_t j )
const 5749 return matrix_.find( j, idx(i) );
5769 template<
typename MT
5771 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5772 Rows<MT,false,false,true,CRAs...>::lowerBound(
size_t i,
size_t j )
5774 return matrix_.lowerBound( j, idx(i) );
5794 template<
typename MT
5797 Rows<MT,false,false,true,CRAs...>::lowerBound(
size_t i,
size_t j )
const 5799 return matrix_.lowerBound( j, idx(i) );
5819 template<
typename MT
5821 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5822 Rows<MT,false,false,true,CRAs...>::upperBound(
size_t i,
size_t j )
5824 return matrix_.upperBound( j, idx(i) );
5844 template<
typename MT
5847 Rows<MT,false,false,true,CRAs...>::upperBound(
size_t i,
size_t j )
const 5849 return matrix_.upperBound( j, idx(i) );
5874 template<
typename MT
5876 template<
typename Other >
5877 inline bool Rows<MT,false,false,true,CRAs...>::canAlias(
const Other* alias )
const noexcept
5879 return matrix_.isAliased( alias );
5896 template<
typename MT
5898 template<
typename Other >
5899 inline bool Rows<MT,false,false,true,CRAs...>::isAliased(
const Other* alias )
const noexcept
5901 return matrix_.isAliased( alias );
5918 template<
typename MT
5920 inline bool Rows<MT,false,false,true,CRAs...>::canSMPAssign() const noexcept
#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.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:131
Headerfile for the generic min algorithm.
Header file for the blaze::checked and blaze::unchecked instances.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3077
Header file for the Schur product trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ROWS_TYPE(T)
Constraint on the data type.In case the given data type T is a row selection type (i...
Definition: Rows.h:81
#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:522
Header file for basic type definitions.
Header file for the View base class.
#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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3076
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:364
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3074
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3078
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1903
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SUBMATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a submatrix type (i.e. a dense or sparse submatrix), a compilation error is created.
Definition: Submatrix.h:81
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:827
#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 Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3083
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:560
#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
Header file for the decltype(auto) workaround.
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:733
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3084
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
Header file for the extended initializer_list functionality.
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:1950
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:474
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:408
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Constraint on the data type.
Header file for the implementation of a matrix representation of an initializer list.
Headerfile for the generic max algorithm.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3082
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
decltype(auto) ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatMapExpr.h:1359
Header file for the If class template.
#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
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
#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
EnableIf_< IsDenseMatrix< MT1 > > smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:102
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3079
#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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
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.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:506
Header file for the SparseElement base class.
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:430
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8893
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.
Header file for the IsStrictlyLower type trait.
typename RowsTrait< MT, CRAs... >::Type RowsTrait_
Auxiliary alias declaration for the RowsTrait type trait.The RowsTrait_ alias declaration provides a ...
Definition: RowsTrait.h:145
Constraint on the data type.
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
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:1357
Header file for run time assertion macros.
Header file for the relaxation flag types.
Header file for the addition trait.
Header file for the Unique class template.
Check< false > Unchecked
Type of the blaze::unchecked instance.blaze::Unchecked is the type of the blaze::unchecked instance...
Definition: Check.h:96
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:131
#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
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
Constraints on the storage order of matrix types.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:816
#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 rows trait.
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:789
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
Constraint on the data type.
Header file for the implementation of the RowsData class template.
Header file for the IsComputation type trait class.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3081
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:254
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
#define BLAZE_THROW_LOGIC_ERROR(MESSAGE)
Macro for the emission of a std::logic_error exception.This macro encapsulates the default way of Bla...
Definition: Exception.h:187
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:1375
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 implementation of the Rows base template.
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
Header file for the IsHermitian type trait.
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:61
Header file for the IsExpression type trait class.
Constraint on the data type.
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:801