35 #ifndef _BLAZE_MATH_VIEWS_ROWS_SPARSE_H_ 36 #define _BLAZE_MATH_VIEWS_ROWS_SPARSE_H_ 111 template<
typename MT
114 class Rows<MT,true,false,SF,CRAs...>
115 :
public View< SparseMatrix< Rows<MT,true,false,SF,CRAs...>, false > >
116 ,
private RowsData<CRAs...>
120 using DataType = RowsData<CRAs...>;
121 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
131 using This = Rows<MT,
true,
false,SF,CRAs...>;
133 using BaseType = SparseMatrix<This,false>;
134 using ViewedType = MT;
163 template<
typename... RRAs >
164 explicit inline Rows( MT& matrix, RRAs... args );
166 Rows(
const Rows& ) =
default;
167 Rows( Rows&& ) =
default;
181 inline Reference operator()(
size_t i,
size_t j );
183 inline Reference at(
size_t i,
size_t j );
197 inline Rows& operator=( initializer_list< initializer_list<ElementType> > list );
198 inline Rows& operator=(
const Rows& rhs );
200 template<
typename MT2,
bool SO >
inline Rows& operator= (
const Matrix<MT2,SO>& rhs );
201 template<
typename MT2,
bool SO >
inline Rows&
operator+=(
const Matrix<MT2,SO>& rhs );
202 template<
typename MT2,
bool SO >
inline Rows&
operator-=(
const Matrix<MT2,SO>& rhs );
203 template<
typename MT2,
bool SO >
inline Rows& operator%=(
const Matrix<MT2,SO>& rhs );
211 using DataType::idces;
214 inline MT& operand() noexcept;
215 inline const MT& operand() const noexcept;
217 inline
size_t columns() const noexcept;
218 inline
size_t capacity() const noexcept;
219 inline
size_t capacity(
size_t i ) const noexcept;
221 inline
size_t nonZeros(
size_t i ) const;
223 inline
void reset(
size_t i );
224 inline
void reserve(
size_t nonzeros );
225 void reserve(
size_t i,
size_t nonzeros );
227 inline
void trim(
size_t i );
236 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
237 inline
void finalize(
size_t i );
244 inline
void erase(
size_t i,
size_t j );
248 template< typename Pred >
249 inline
void erase( Pred predicate );
251 template< typename Pred >
252 inline
void erase(
size_t i,
Iterator first,
Iterator last, Pred predicate );
259 inline
Iterator find (
size_t i,
size_t j );
261 inline
Iterator lowerBound(
size_t i,
size_t j );
263 inline
Iterator upperBound(
size_t i,
size_t j );
274 template< typename Other > inline Rows& scale( const Other& scalar );
281 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
282 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
284 inline
bool canSMPAssign() const noexcept;
286 template< typename MT2,
bool SO > inline
void assign ( const DenseMatrix<MT2,SO>& rhs );
287 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,false>& rhs );
288 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,true>& rhs );
289 template< typename MT2,
bool SO > inline
void addAssign ( const Matrix<MT2,SO>& rhs );
290 template< typename MT2,
bool SO > inline
void subAssign ( const Matrix<MT2,SO>& rhs );
291 template< typename MT2,
bool SO > inline
void schurAssign( const Matrix<MT2,SO>& rhs );
299 inline
size_t extendCapacity(
size_t i ) const noexcept;
346 template< typename MT
349 template< typename... RRAs >
350 inline Rows<MT,true,false,SF,CRAs...>::Rows( MT& matrix, RRAs... args )
351 : DataType( args... )
355 for(
size_t i=0UL; i<
rows(); ++i ) {
356 if( matrix_.rows() <= idx(i) ) {
385 template<
typename MT
388 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Reference 389 Rows<MT,true,false,SF,CRAs...>::operator()(
size_t i,
size_t j )
394 return matrix_(idx(i),j);
411 template<
typename MT
415 Rows<MT,true,false,SF,CRAs...>::operator()(
size_t i,
size_t j )
const 420 return const_cast<const MT&
>( matrix_ )(idx(i),j);
438 template<
typename MT
441 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Reference 442 Rows<MT,true,false,SF,CRAs...>::at(
size_t i,
size_t j )
468 template<
typename MT
472 Rows<MT,true,false,SF,CRAs...>::at(
size_t i,
size_t j )
const 495 template<
typename MT
498 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 503 return matrix_.begin( idx(i) );
518 template<
typename MT
526 return matrix_.cbegin( idx(i) );
541 template<
typename MT
549 return matrix_.cbegin( idx(i) );
564 template<
typename MT
567 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 572 return matrix_.end( idx(i) );
587 template<
typename MT
595 return matrix_.cend( idx(i) );
610 template<
typename MT
618 return matrix_.cend( idx(i) );
648 template<
typename MT
651 inline Rows<MT,
true,
false,SF,CRAs...>&
652 Rows<MT,true,false,SF,CRAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
657 if( list.size() !=
rows() ) {
661 const InitializerMatrix<ElementType> tmp( list,
columns() );
663 if( IsRestricted_v<MT> ) {
664 for(
size_t i=0UL; i<
rows(); ++i ) {
665 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), i, 0UL ) ) {
671 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
697 template<
typename MT
700 inline Rows<MT,
true,
false,SF,CRAs...>&
701 Rows<MT,true,false,SF,CRAs...>::operator=(
const Rows& rhs )
709 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && compareIndices( *
this, rhs ) ) )
712 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
716 if( IsRestricted_v<MT> ) {
717 for(
size_t i=0UL; i<
rows(); ++i ) {
718 if( !tryAssign( matrix_,
row( rhs, i,
unchecked ), idx(i), 0UL ) ) {
724 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
726 if( rhs.canAlias( &matrix_ ) ) {
759 template<
typename MT
762 template<
typename MT2
764 inline Rows<MT,
true,
false,SF,CRAs...>&
765 Rows<MT,true,false,SF,CRAs...>::operator=(
const Matrix<MT2,SO>& rhs )
776 using Right = CompositeType_t<MT2>;
779 if( IsRestricted_v<MT> ) {
780 for(
size_t i=0UL; i<
rows(); ++i ) {
781 if( !tryAssign( matrix_,
row( right, i,
unchecked ), idx(i), 0UL ) ) {
787 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
789 if( IsReference_v<Right> && right.canAlias( &matrix_ ) ) {
790 const ResultType_t<MT2> tmp( right );
821 template<
typename MT
824 template<
typename MT2
826 inline Rows<MT,
true,
false,SF,CRAs...>&
836 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
844 const AddType tmp( *
this + (~rhs) );
846 if( IsRestricted_v<MT> ) {
847 for(
size_t i=0UL; i<
rows(); ++i ) {
848 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
854 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
881 template<
typename MT
884 template<
typename MT2
886 inline Rows<MT,
true,
false,SF,CRAs...>&
896 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
904 const SubType tmp( *
this - (~rhs) );
906 if( IsRestricted_v<MT> ) {
907 for(
size_t i=0UL; i<
rows(); ++i ) {
908 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
914 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
941 template<
typename MT
944 template<
typename MT2
946 inline Rows<MT,
true,
false,SF,CRAs...>&
947 Rows<MT,true,false,SF,CRAs...>::operator%=(
const Matrix<MT2,SO>& rhs )
956 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
964 const SchurType tmp( *
this % (~rhs) );
966 if( IsRestricted_v<MT> ) {
967 for(
size_t i=0UL; i<
rows(); ++i ) {
968 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
974 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1001 template<
typename MT
1003 ,
typename... CRAs >
1004 inline MT& Rows<MT,true,false,SF,CRAs...>::operand() noexcept
1018 template<
typename MT
1020 ,
typename... CRAs >
1021 inline const MT& Rows<MT,true,false,SF,CRAs...>::operand() const noexcept
1035 template<
typename MT
1037 ,
typename... CRAs >
1040 return matrix_.columns();
1052 template<
typename MT
1054 ,
typename... CRAs >
1057 return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
1072 template<
typename MT
1074 ,
typename... CRAs >
1079 return matrix_.capacity( idx(i) );
1091 template<
typename MT
1093 ,
typename... CRAs >
1096 size_t nonzeros( 0UL );
1098 for(
size_t i=0UL; i<
rows(); ++i )
1116 template<
typename MT
1118 ,
typename... CRAs >
1123 return matrix_.nonZeros( idx(i) );
1135 template<
typename MT
1137 ,
typename... CRAs >
1140 for(
size_t i=0UL; i<
rows(); ++i ) {
1141 matrix_.reset( idx(i) );
1158 template<
typename MT
1160 ,
typename... CRAs >
1163 matrix_.reset( idx(i) );
1180 template<
typename MT
1182 ,
typename... CRAs >
1183 inline void Rows<MT,true,false,SF,CRAs...>::reserve(
size_t nonzeros )
1185 const size_t current(
capacity() );
1187 if( nonzeros > current ) {
1188 matrix_.reserve( matrix_.capacity() + nonzeros - current );
1208 template<
typename MT
1210 ,
typename... CRAs >
1211 void Rows<MT,true,false,SF,CRAs...>::reserve(
size_t i,
size_t nonzeros )
1213 matrix_.reserve( idx(i), nonzeros );
1229 template<
typename MT
1231 ,
typename... CRAs >
1232 void Rows<MT,true,false,SF,CRAs...>::trim()
1234 for(
size_t i=0UL; i<
rows(); ++i ) {
1253 template<
typename MT
1255 ,
typename... CRAs >
1256 void Rows<MT,true,false,SF,CRAs...>::trim(
size_t i )
1260 matrix_.trim( idx(i) );
1276 template<
typename MT
1278 ,
typename... CRAs >
1279 inline size_t Rows<MT,true,false,SF,CRAs...>::extendCapacity(
size_t i )
const noexcept
1284 size_t nonzeros( 2UL*
capacity( i )+1UL );
1285 nonzeros =
max( nonzeros, 7UL );
1317 template<
typename MT
1319 ,
typename... CRAs >
1320 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1323 return matrix_.set( idx(i), j, value );
1343 template<
typename MT
1345 ,
typename... CRAs >
1346 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1347 Rows<MT,true,false,SF,CRAs...>::insert(
size_t i,
size_t j,
const ElementType& value )
1349 return matrix_.insert( idx(i), j, value );
1399 template<
typename MT
1401 ,
typename... CRAs >
1402 inline void Rows<MT,true,false,SF,CRAs...>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
1404 if( !check || !isDefault<strict>( value ) )
1405 matrix_.insert( idx(i), j, value );
1425 template<
typename MT
1427 ,
typename... CRAs >
1428 inline void Rows<MT,true,false,SF,CRAs...>::finalize(
size_t i )
1456 template<
typename MT
1458 ,
typename... CRAs >
1459 inline void Rows<MT,true,false,SF,CRAs...>::erase(
size_t i,
size_t j )
1464 matrix_.erase( idx(i), j );
1480 template<
typename MT
1482 ,
typename... CRAs >
1483 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1484 Rows<MT,true,false,SF,CRAs...>::erase(
size_t i,
Iterator pos )
1488 return matrix_.erase( idx(i), pos );
1505 template<
typename MT
1507 ,
typename... CRAs >
1508 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1509 Rows<MT,true,false,SF,CRAs...>::erase(
size_t i,
Iterator first,
Iterator last )
1513 return matrix_.erase( idx(i), first, last );
1542 template<
typename MT
1544 ,
typename... CRAs >
1545 template<
typename Pred >
1546 inline void Rows<MT,true,false,SF,CRAs...>::erase( Pred predicate )
1548 for(
size_t i=0UL; i<
rows(); ++i ) {
1549 matrix_.erase( idx(i),
begin(i),
end(i), predicate );
1583 template<
typename MT
1585 ,
typename... CRAs >
1586 template<
typename Pred >
1587 inline void Rows<MT,true,false,SF,CRAs...>::erase(
size_t i,
Iterator first,
Iterator last, Pred predicate )
1591 matrix_.erase( idx(i), first, last, predicate );
1620 template<
typename MT
1622 ,
typename... CRAs >
1623 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1624 Rows<MT,true,false,SF,CRAs...>::find(
size_t i,
size_t j )
1626 return matrix_.find( idx(i), j );
1647 template<
typename MT
1649 ,
typename... CRAs >
1651 Rows<MT,true,false,SF,CRAs...>::find(
size_t i,
size_t j )
const 1653 return matrix_.find( idx(i), j );
1673 template<
typename MT
1675 ,
typename... CRAs >
1676 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1677 Rows<MT,true,false,SF,CRAs...>::lowerBound(
size_t i,
size_t j )
1679 return matrix_.lowerBound( idx(i), j );
1699 template<
typename MT
1701 ,
typename... CRAs >
1703 Rows<MT,true,false,SF,CRAs...>::lowerBound(
size_t i,
size_t j )
const 1705 return matrix_.lowerBound( idx(i), j );
1725 template<
typename MT
1727 ,
typename... CRAs >
1728 inline typename Rows<MT,
true,
false,SF,CRAs...>
::Iterator 1729 Rows<MT,true,false,SF,CRAs...>::upperBound(
size_t i,
size_t j )
1731 return matrix_.upperBound( idx(i), j );
1751 template<
typename MT
1753 ,
typename... CRAs >
1755 Rows<MT,true,false,SF,CRAs...>::upperBound(
size_t i,
size_t j )
const 1757 return matrix_.upperBound( idx(i), j );
1784 template<
typename MT
1786 ,
typename... CRAs >
1787 inline Rows<MT,
true,
false,SF,CRAs...>&
1799 if( IsRestricted_v<MT> ) {
1800 for(
size_t i=0UL; i<
rows(); ++i ) {
1801 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
1807 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1831 template<
typename MT
1833 ,
typename... CRAs >
1834 inline Rows<MT,
true,
false,SF,CRAs...>&
1846 if( IsRestricted_v<MT> ) {
1847 for(
size_t i=0UL; i<
rows(); ++i ) {
1848 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
1854 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1878 template<
typename MT
1880 ,
typename... CRAs >
1881 template<
typename Other >
1882 inline Rows<MT,
true,
false,SF,CRAs...>&
1883 Rows<MT,true,false,SF,CRAs...>::scale(
const Other& scalar )
1889 for(
size_t i=0UL; i<
rows(); ++i ) {
1892 element->value() *= scalar;
1920 template<
typename MT
1922 ,
typename... CRAs >
1923 template<
typename Other >
1924 inline bool Rows<MT,true,false,SF,CRAs...>::canAlias(
const Other* alias )
const noexcept
1926 return matrix_.isAliased( alias );
1943 template<
typename MT
1945 ,
typename... CRAs >
1946 template<
typename Other >
1947 inline bool Rows<MT,true,false,SF,CRAs...>::isAliased(
const Other* alias )
const noexcept
1949 return matrix_.isAliased( alias );
1966 template<
typename MT
1968 ,
typename... CRAs >
1969 inline bool Rows<MT,true,false,SF,CRAs...>::canSMPAssign() const noexcept
1989 template<
typename MT
1991 ,
typename... CRAs >
1992 template<
typename MT2
1994 inline void Rows<MT,true,false,SF,CRAs...>::assign(
const DenseMatrix<MT2,SO>& rhs )
2003 for(
size_t i=0UL; i<
rows(); ++i )
2005 const size_t index( idx(i) );
2006 size_t remaining( matrix_.capacity( index ) );
2008 for(
size_t j=0UL; j<
columns(); ++j )
2010 if( remaining == 0UL ) {
2011 matrix_.reserve( index, extendCapacity( i ) );
2012 remaining = matrix_.capacity( index ) - matrix_.nonZeros( index );
2015 matrix_.append( index, j, (~rhs)(i,j),
true );
2036 template<
typename MT
2038 ,
typename... CRAs >
2039 template<
typename MT2 >
2040 inline void Rows<MT,true,false,SF,CRAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
2049 for(
size_t i=0UL; i<
rows(); ++i )
2051 const size_t index( idx(i) );
2052 size_t remaining( matrix_.capacity( index ) );
2054 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
2056 if( remaining == 0UL ) {
2057 matrix_.reserve( index, extendCapacity( i ) );
2058 remaining = matrix_.capacity( index ) - matrix_.nonZeros( index );
2061 matrix_.append( index, element->index(), element->value(), true );
2082 template<
typename MT
2084 ,
typename... CRAs >
2085 template<
typename MT2 >
2086 inline void Rows<MT,true,false,SF,CRAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
2098 std::vector<size_t> rowLengths(
rows(), 0UL );
2099 for(
size_t j=0UL; j<
columns(); ++j ) {
2100 for(
auto element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
2101 ++rowLengths[element->index()];
2105 for(
size_t i=0UL; i<
rows(); ++i ) {
2106 reserve( i, rowLengths[i] );
2110 for(
size_t j=0UL; j<
columns(); ++j ) {
2111 for(
auto element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
2112 append( element->index(), j, element->value(), true );
2131 template<
typename MT
2133 ,
typename... CRAs >
2134 template<
typename MT2
2136 inline void Rows<MT,true,false,SF,CRAs...>::addAssign(
const Matrix<MT2,SO>& rhs )
2141 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
2148 const AddType tmp(
serial( *
this + (~rhs) ) );
2168 template<
typename MT
2170 ,
typename... CRAs >
2171 template<
typename MT2
2173 inline void Rows<MT,true,false,SF,CRAs...>::subAssign(
const Matrix<MT2,SO>& rhs )
2178 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
2185 const SubType tmp(
serial( *
this - (~rhs) ) );
2205 template<
typename MT
2207 ,
typename... CRAs >
2208 template<
typename MT2
2210 inline void Rows<MT,true,false,SF,CRAs...>::schurAssign(
const Matrix<MT2,SO>& rhs )
2215 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
2223 const SchurType tmp(
serial( *
this % (~rhs) ) );
2251 template<
typename MT
2252 ,
typename... CRAs >
2253 class Rows<MT,false,false,false,CRAs...>
2254 :
public View< SparseMatrix< Rows<MT,false,false,false,CRAs...>, false > >
2255 ,
private RowsData<CRAs...>
2259 using DataType = RowsData<CRAs...>;
2260 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
2270 using This = Rows<MT,
false,
false,
false,CRAs...>;
2272 using BaseType = SparseMatrix<This,false>;
2273 using ViewedType = MT;
2291 template<
typename MatrixType
2292 ,
typename IteratorType >
2294 :
private SparseElement
2303 inline RowsElement( IteratorType pos,
size_t column )
2315 template<
typename T >
inline RowsElement& operator=(
const T& v ) {
2327 template<
typename T >
inline RowsElement&
operator+=(
const T& v ) {
2339 template<
typename T >
inline RowsElement&
operator-=(
const T& v ) {
2351 template<
typename T >
inline RowsElement&
operator*=(
const T& v ) {
2363 template<
typename T >
inline RowsElement&
operator/=(
const T& v ) {
2374 inline const RowsElement* operator->()
const {
2384 inline decltype(
auto) value()
const {
2385 return pos_->value();
2394 inline size_t index()
const {
2410 template<
typename MatrixType
2411 ,
typename IteratorType >
2416 using IteratorCategory = std::forward_iterator_tag;
2417 using ValueType = RowsElement<MatrixType,IteratorType>;
2418 using PointerType = ValueType;
2419 using ReferenceType = ValueType;
2420 using DifferenceType = ptrdiff_t;
2423 using iterator_category = IteratorCategory;
2424 using value_type = ValueType;
2425 using pointer = PointerType;
2426 using reference = ReferenceType;
2427 using difference_type = DifferenceType;
2433 inline RowsIterator()
2434 : matrix_( nullptr )
2448 inline RowsIterator( MatrixType& matrix,
size_t row,
size_t column )
2449 : matrix_( &matrix )
2454 for( ; column_<matrix_->columns(); ++column_ ) {
2455 pos_ = matrix_->find( row_, column_ );
2456 if( pos_ != matrix_->end( column_ ) )
break;
2469 inline RowsIterator( MatrixType& matrix,
size_t row,
size_t column, IteratorType pos )
2470 : matrix_( &matrix )
2484 template<
typename MatrixType2,
typename IteratorType2 >
2485 inline RowsIterator(
const RowsIterator<MatrixType2,IteratorType2>& it )
2486 : matrix_( it.matrix_ )
2488 , column_( it.column_ )
2498 inline RowsIterator& operator++() {
2500 for( ; column_<matrix_->columns(); ++column_ ) {
2501 pos_ = matrix_->find( row_, column_ );
2502 if( pos_ != matrix_->end( column_ ) )
break;
2514 inline const RowsIterator operator++(
int ) {
2515 const RowsIterator tmp( *
this );
2526 inline ReferenceType
operator*()
const {
2527 return ReferenceType( pos_, column_ );
2536 inline PointerType operator->()
const {
2537 return PointerType( pos_, column_ );
2547 template<
typename MatrixType2,
typename IteratorType2 >
2548 inline bool operator==(
const RowsIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2549 return column_ == rhs.column_;
2559 template<
typename MatrixType2,
typename IteratorType2 >
2560 inline bool operator!=(
const RowsIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2561 return !( *
this == rhs );
2571 inline DifferenceType
operator-(
const RowsIterator& rhs )
const {
2572 size_t counter( 0UL );
2573 for(
size_t j=rhs.column_; j<column_; ++j ) {
2574 if( matrix_->find( row_, j ) != matrix_->end( j ) )
2583 MatrixType* matrix_;
2590 template<
typename MatrixType2,
typename IteratorType2 >
friend class RowsIterator;
2591 template<
typename MT2,
bool SO2,
bool DF2,
bool SF2,
typename... CRAs2 >
friend class Rows;
2598 using ConstIterator = RowsIterator< const MT, ConstIterator_t<MT> >;
2612 template<
typename... RRAs >
2613 explicit inline Rows( MT& matrix, RRAs... args );
2615 Rows(
const Rows& ) =
default;
2616 Rows( Rows&& ) =
default;
2630 inline Reference operator()(
size_t i,
size_t j );
2632 inline Reference at(
size_t i,
size_t j );
2646 inline Rows& operator=( initializer_list< initializer_list<ElementType> > list );
2647 inline Rows& operator=(
const Rows& rhs );
2649 template<
typename MT2,
bool SO >
inline Rows& operator= (
const Matrix<MT2,SO>& rhs );
2650 template<
typename MT2,
bool SO >
inline Rows&
operator+=(
const Matrix<MT2,SO>& rhs );
2651 template<
typename MT2,
bool SO >
inline Rows&
operator-=(
const Matrix<MT2,SO>& rhs );
2652 template<
typename MT2,
bool SO >
inline Rows& operator%=(
const Matrix<MT2,SO>& rhs );
2659 using DataType::idx;
2660 using DataType::idces;
2663 inline MT& operand() noexcept;
2664 inline const MT& operand() const noexcept;
2666 inline
size_t columns() const noexcept;
2667 inline
size_t capacity() const noexcept;
2668 inline
size_t capacity(
size_t i ) const noexcept;
2670 inline
size_t nonZeros(
size_t i ) const;
2671 inline
void reset();
2672 inline
void reset(
size_t i );
2673 inline
void reserve(
size_t nonzeros );
2674 void reserve(
size_t i,
size_t nonzeros );
2676 inline
void trim(
size_t j );
2685 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
2686 inline
void finalize(
size_t i );
2693 inline
void erase(
size_t i,
size_t j );
2697 template< typename Pred >
2698 inline
void erase( Pred predicate );
2700 template< typename Pred >
2701 inline
void erase(
size_t i,
Iterator first,
Iterator last, Pred predicate );
2708 inline
Iterator find (
size_t i,
size_t j );
2710 inline
Iterator lowerBound(
size_t i,
size_t j );
2711 inline
ConstIterator lowerBound(
size_t i,
size_t j ) const;
2712 inline
Iterator upperBound(
size_t i,
size_t j );
2713 inline
ConstIterator upperBound(
size_t i,
size_t j ) const;
2723 template< typename Other > inline Rows& scale( const Other& scalar );
2730 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
2731 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
2733 inline
bool canSMPAssign() const noexcept;
2735 template< typename MT2,
bool SO > inline
void assign ( const DenseMatrix<MT2,SO>& rhs );
2736 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,true>& rhs );
2737 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,false>& rhs );
2738 template< typename MT2,
bool SO > inline
void addAssign ( const Matrix<MT2,SO>& rhs );
2739 template< typename MT2,
bool SO > inline
void subAssign ( const Matrix<MT2,SO>& rhs );
2740 template< typename MT2,
bool SO > inline
void schurAssign( const Matrix<MT2,SO>& rhs );
2789 template< typename MT
2790 , typename... CRAs >
2791 template< typename... RRAs >
2792 inline Rows<MT,false,false,false,CRAs...>::Rows( MT& matrix, RRAs... args )
2793 : DataType( args... )
2794 , matrix_ ( matrix )
2797 for(
size_t i=0UL; i<
rows(); ++i ) {
2798 if( matrix_.rows() <= idx(i) ) {
2827 template<
typename MT
2828 ,
typename... CRAs >
2829 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Reference 2830 Rows<MT,false,false,false,CRAs...>::operator()(
size_t i,
size_t j )
2835 return matrix_(idx(i),j);
2852 template<
typename MT
2853 ,
typename... CRAs >
2855 Rows<MT,false,false,false,CRAs...>::operator()(
size_t i,
size_t j )
const 2860 return const_cast<const MT&
>( matrix_ )(idx(i),j);
2878 template<
typename MT
2879 ,
typename... CRAs >
2880 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Reference 2881 Rows<MT,false,false,false,CRAs...>::at(
size_t i,
size_t j )
2889 return (*
this)(i,j);
2907 template<
typename MT
2908 ,
typename... CRAs >
2910 Rows<MT,false,false,false,CRAs...>::at(
size_t i,
size_t j )
const 2918 return (*
this)(i,j);
2933 template<
typename MT
2934 ,
typename... CRAs >
2935 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 2940 return Iterator( matrix_, idx(i), 0UL );
2955 template<
typename MT
2956 ,
typename... CRAs >
2977 template<
typename MT
2978 ,
typename... CRAs >
2999 template<
typename MT
3000 ,
typename... CRAs >
3001 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 3021 template<
typename MT
3022 ,
typename... CRAs >
3043 template<
typename MT
3044 ,
typename... CRAs >
3080 template<
typename MT
3081 ,
typename... CRAs >
3082 inline Rows<MT,
false,
false,
false,CRAs...>&
3083 Rows<MT,false,false,false,CRAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
3088 if( list.size() !=
rows() ) {
3092 const InitializerMatrix<ElementType> tmp( list,
columns() );
3094 if( IsRestricted_v<MT> ) {
3095 for(
size_t i=0UL; i<
rows(); ++i ) {
3096 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), i, 0UL ) ) {
3102 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3127 template<
typename MT
3128 ,
typename... CRAs >
3129 inline Rows<MT,
false,
false,
false,CRAs...>&
3130 Rows<MT,false,false,false,CRAs...>::operator=(
const Rows& rhs )
3138 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && compareIndices( *
this, rhs ) ) )
3141 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
3145 if( IsRestricted_v<MT> ) {
3146 for(
size_t i=0UL; i<
rows(); ++i ) {
3147 if( !tryAssign( matrix_,
row( rhs, i,
unchecked ), idx(i), 0UL ) ) {
3153 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3155 if( rhs.canAlias( &matrix_ ) ) {
3188 template<
typename MT
3189 ,
typename... CRAs >
3190 template<
typename MT2
3192 inline Rows<MT,
false,
false,
false,CRAs...>&
3193 Rows<MT,false,false,false,CRAs...>::operator=(
const Matrix<MT2,SO>& rhs )
3204 using Right = CompositeType_t<MT2>;
3205 Right right( ~rhs );
3207 if( IsRestricted_v<MT> ) {
3208 for(
size_t i=0UL; i<
rows(); ++i ) {
3209 if( !tryAssign( matrix_,
row( right, i,
unchecked ), idx(i), 0UL ) ) {
3215 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3217 if( IsReference_v<Right> && right.canAlias( &matrix_ ) ) {
3218 const ResultType_t<MT2> tmp( right );
3224 if( IsSparseMatrix_v<MT2> )
3251 template<
typename MT
3252 ,
typename... CRAs >
3253 template<
typename MT2
3255 inline Rows<MT,
false,
false,
false,CRAs...>&
3265 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
3273 const AddType tmp( *
this + (~rhs) );
3275 if( IsRestricted_v<MT> ) {
3276 for(
size_t i=0UL; i<
rows(); ++i ) {
3277 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
3283 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3285 if( IsSparseMatrix_v<AddType> ) {
3313 template<
typename MT
3314 ,
typename... CRAs >
3315 template<
typename MT2
3317 inline Rows<MT,
false,
false,
false,CRAs...>&
3327 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
3335 const SubType tmp( *
this - (~rhs) );
3337 if( IsRestricted_v<MT> ) {
3338 for(
size_t i=0UL; i<
rows(); ++i ) {
3339 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
3345 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3347 if( IsSparseMatrix_v<SubType> ) {
3375 template<
typename MT
3376 ,
typename... CRAs >
3377 template<
typename MT2
3379 inline Rows<MT,
false,
false,
false,CRAs...>&
3380 Rows<MT,false,false,false,CRAs...>::operator%=(
const Matrix<MT2,SO>& rhs )
3389 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
3397 const SchurType tmp( *
this % (~rhs) );
3399 if( IsRestricted_v<MT> ) {
3400 for(
size_t i=0UL; i<
rows(); ++i ) {
3401 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
3407 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3409 if( IsSparseMatrix_v<SchurType> ) {
3437 template<
typename MT
3438 ,
typename... CRAs >
3439 inline MT& Rows<MT,false,false,false,CRAs...>::operand() noexcept
3453 template<
typename MT
3454 ,
typename... CRAs >
3455 inline const MT& Rows<MT,false,false,false,CRAs...>::operand() const noexcept
3469 template<
typename MT
3470 ,
typename... CRAs >
3473 return matrix_.columns();
3485 template<
typename MT
3486 ,
typename... CRAs >
3504 template<
typename MT
3505 ,
typename... CRAs >
3524 template<
typename MT
3525 ,
typename... CRAs >
3528 size_t nonzeros( 0UL );
3530 for(
size_t j=0UL; j<
columns(); ++j ) {
3531 const auto end( matrix_.end( j ) );
3532 for(
size_t i=0UL; i<
rows(); ++i ) {
3533 auto pos = matrix_.find( idx(i), j );
3555 template<
typename MT
3556 ,
typename... CRAs >
3561 size_t counter( 0UL );
3580 template<
typename MT
3581 ,
typename... CRAs >
3584 for(
size_t i=0UL; i<
rows(); ++i ) {
3602 template<
typename MT
3603 ,
typename... CRAs >
3606 const size_t index( idx(i) );
3608 const size_t jbegin( ( IsUpper_v<MT> )
3609 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
3613 const size_t jend ( ( IsLower_v<MT> )
3614 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
3619 for(
size_t j=jbegin; j<jend; ++j ) {
3620 matrix_.erase( index, j );
3638 template<
typename MT
3639 ,
typename... CRAs >
3640 inline void Rows<MT,false,false,false,CRAs...>::reserve(
size_t nonzeros )
3663 template<
typename MT
3664 ,
typename... CRAs >
3665 void Rows<MT,false,false,false,CRAs...>::reserve(
size_t i,
size_t nonzeros )
3685 template<
typename MT
3686 ,
typename... CRAs >
3687 void Rows<MT,false,false,false,CRAs...>::trim()
3706 template<
typename MT
3707 ,
typename... CRAs >
3708 void Rows<MT,false,false,false,CRAs...>::trim(
size_t i )
3741 template<
typename MT
3742 ,
typename... CRAs >
3743 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 3746 return Iterator( matrix_, idx(i), j, matrix_.set( idx(i), j, value ) );
3766 template<
typename MT
3767 ,
typename... CRAs >
3768 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 3769 Rows<MT,false,false,false,CRAs...>::insert(
size_t i,
size_t j,
const ElementType& value )
3771 return Iterator( matrix_, idx(i), j, matrix_.insert( idx(i), j, value ) );
3821 template<
typename MT
3822 ,
typename... CRAs >
3823 inline void Rows<MT,false,false,false,CRAs...>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
3825 if( !check || !isDefault<strict>( value ) )
3826 matrix_.insert( idx(i), j, value );
3846 template<
typename MT
3847 ,
typename... CRAs >
3848 inline void Rows<MT,false,false,false,CRAs...>::finalize(
size_t i )
3876 template<
typename MT
3877 ,
typename... CRAs >
3878 inline void Rows<MT,false,false,false,CRAs...>::erase(
size_t i,
size_t j )
3883 matrix_.erase( idx(i), j );
3899 template<
typename MT
3900 ,
typename... CRAs >
3901 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 3902 Rows<MT,false,false,false,CRAs...>::erase(
size_t i,
Iterator pos )
3904 const size_t column( pos.column_ );
3909 matrix_.erase(
column, pos.pos_ );
3927 template<
typename MT
3928 ,
typename... CRAs >
3929 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 3930 Rows<MT,false,false,false,CRAs...>::erase(
size_t i,
Iterator first,
Iterator last )
3936 for( ; first!=last; ++first ) {
3937 matrix_.erase( first.column_, first.pos_ );
3969 template<
typename MT
3970 ,
typename... CRAs >
3971 template<
typename Pred >
3972 inline void Rows<MT,false,false,false,CRAs...>::erase( Pred predicate )
3974 for(
size_t i=0UL; i<
rows(); ++i ) {
3976 if( predicate( element->value() ) )
3977 matrix_.erase( element.column_, element.pos_ );
4012 template<
typename MT
4013 ,
typename... CRAs >
4014 template<
typename Pred >
4015 inline void Rows<MT,false,false,false,CRAs...>::erase(
size_t i,
Iterator first,
Iterator last, Pred predicate )
4021 for( ; first!=last; ++first ) {
4022 if( predicate( first->value() ) )
4023 matrix_.erase( first.column_, first.pos_ );
4053 template<
typename MT
4054 ,
typename... CRAs >
4055 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 4056 Rows<MT,false,false,false,CRAs...>::find(
size_t i,
size_t j )
4058 const size_t index( idx(i) );
4059 const Iterator_t<MT> pos( matrix_.find( index, j ) );
4061 if( pos != matrix_.end( j ) )
4062 return Iterator( matrix_, index, j, pos );
4085 template<
typename MT
4086 ,
typename... CRAs >
4088 Rows<MT,false,false,false,CRAs...>::find(
size_t i,
size_t j )
const 4090 const size_t index( idx(i) );
4091 const ConstIterator_t<MT> pos( matrix_.find( index, j ) );
4093 if( pos != matrix_.end( j ) )
4116 template<
typename MT
4117 ,
typename... CRAs >
4118 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 4119 Rows<MT,false,false,false,CRAs...>::lowerBound(
size_t i,
size_t j )
4121 const size_t index( idx(i) );
4125 const Iterator_t<MT> pos( matrix_.find( index, j ) );
4127 if( pos != matrix_.end( j ) )
4128 return Iterator( matrix_, index, j, pos );
4151 template<
typename MT
4152 ,
typename... CRAs >
4154 Rows<MT,false,false,false,CRAs...>::lowerBound(
size_t i,
size_t j )
const 4156 const size_t index( idx(i) );
4160 const ConstIterator_t<MT> pos( matrix_.find( index, j ) );
4162 if( pos != matrix_.end( j ) )
4186 template<
typename MT
4187 ,
typename... CRAs >
4188 inline typename Rows<MT,
false,
false,
false,CRAs...>
::Iterator 4189 Rows<MT,false,false,false,CRAs...>::upperBound(
size_t i,
size_t j )
4191 return lowerBound( i, j+1UL );
4211 template<
typename MT
4212 ,
typename... CRAs >
4214 Rows<MT,false,false,false,CRAs...>::upperBound(
size_t i,
size_t j )
const 4216 return lowerBound( i, j+1UL );
4243 template<
typename MT
4244 ,
typename... CRAs >
4245 inline Rows<MT,
false,
false,
false,CRAs...>&
4257 if( IsRestricted_v<MT> ) {
4258 for(
size_t i=0UL; i<
rows(); ++i ) {
4259 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
4265 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
4289 template<
typename MT
4290 ,
typename... CRAs >
4291 inline Rows<MT,
false,
false,
false,CRAs...>&
4303 if( IsRestricted_v<MT> ) {
4304 for(
size_t i=0UL; i<
rows(); ++i ) {
4305 if( !tryAssign( matrix_,
row( tmp, i,
unchecked ), idx(i), 0UL ) ) {
4311 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
4335 template<
typename MT
4336 ,
typename... CRAs >
4337 template<
typename Other >
4338 inline Rows<MT,
false,
false,
false,CRAs...>&
4339 Rows<MT,false,false,false,CRAs...>::scale(
const Other& scalar )
4345 for(
size_t j=0UL; j<
columns(); ++j ) {
4346 const auto end( matrix_.end( j ) );
4347 for(
size_t i=0UL; i<
rows(); ++i ) {
4348 auto pos = matrix_.find( idx(i), j );
4350 pos->value() *= scalar;
4380 template<
typename MT
4381 ,
typename... CRAs >
4382 template<
typename Other >
4383 inline bool Rows<MT,false,false,false,CRAs...>::canAlias(
const Other* alias )
const noexcept
4385 return matrix_.isAliased( alias );
4402 template<
typename MT
4403 ,
typename... CRAs >
4404 template<
typename Other >
4405 inline bool Rows<MT,false,false,false,CRAs...>::isAliased(
const Other* alias )
const noexcept
4407 return matrix_.isAliased( alias );
4424 template<
typename MT
4425 ,
typename... CRAs >
4426 inline bool Rows<MT,false,false,false,CRAs...>::canSMPAssign() const noexcept
4446 template<
typename MT
4447 ,
typename... CRAs >
4448 template<
typename MT2
4450 inline void Rows<MT,false,false,false,CRAs...>::assign(
const DenseMatrix<MT2,SO>& rhs )
4455 using RT = If_t< IsComputation_v<MT2>, ElementType_t<MT>,
const ElementType_t<MT2>& >;
4460 for(
size_t j=0UL; j<
columns(); ++j ) {
4461 for(
size_t i=0UL; i<
rows(); ++i ) {
4462 RT value( (~rhs)(i,j) );
4463 if( !isDefault<strict>( value ) )
4464 matrix_.set( idx(i), j, std::move( value ) );
4465 else matrix_.erase( idx(i), j );
4485 template<
typename MT
4486 ,
typename... CRAs >
4487 template<
typename MT2 >
4488 inline void Rows<MT,false,false,false,CRAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
4493 using RT = If_t< IsComputation_v<MT2>, ElementType_t<MT>,
const ElementType_t<MT2>& >;
4499 for(
size_t i=0UL; i<
rows(); ++i ) {
4500 const size_t index( idx(i) );
4501 for( ConstIterator_t<MT2> element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
4502 RT value( element->value() );
4503 if( !isDefault<strict>( value ) )
4504 matrix_.set( index, element->index(), std::move( value ) );
4505 else matrix_.erase( index, element->index() );
4525 template<
typename MT
4526 ,
typename... CRAs >
4527 template<
typename MT2 >
4528 inline void Rows<MT,false,false,false,CRAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
4535 using RT = If_t< IsComputation_v<MT2>, ElementType_t<MT>,
const ElementType_t<MT2>& >;
4541 for(
size_t j=0UL; j<
columns(); ++j ) {
4542 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element ) {
4543 RT value( element->value() );
4544 if( !isDefault<strict>( value ) )
4545 matrix_.set( idx( element->index() ), j, std::move( value ) );
4546 else matrix_.erase( idx( element->index() ), j );
4566 template<
typename MT
4567 ,
typename... CRAs >
4568 template<
typename MT2
4570 inline void Rows<MT,false,false,false,CRAs...>::addAssign(
const Matrix<MT2,SO>& rhs )
4575 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
4582 const AddType tmp(
serial( *
this + (~rhs) ) );
4602 template<
typename MT
4603 ,
typename... CRAs >
4604 template<
typename MT2
4606 inline void Rows<MT,false,false,false,CRAs...>::subAssign(
const Matrix<MT2,SO>& rhs )
4611 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
4618 const SubType tmp(
serial( *
this - (~rhs) ) );
4638 template<
typename MT
4639 ,
typename... CRAs >
4640 template<
typename MT2
4642 inline void Rows<MT,false,false,false,CRAs...>::schurAssign(
const Matrix<MT2,SO>& rhs )
4647 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
4655 const SchurType tmp(
serial( *
this % (~rhs) ) );
4683 template<
typename MT
4684 ,
typename... CRAs >
4685 class Rows<MT,false,false,true,CRAs...>
4686 :
public View< SparseMatrix< Rows<MT,false,false,true,CRAs...>, false > >
4687 ,
private RowsData<CRAs...>
4691 using DataType = RowsData<CRAs...>;
4692 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
4702 using This = Rows<MT,
false,
false,
true,CRAs...>;
4704 using BaseType = SparseMatrix<This,false>;
4705 using ViewedType = MT;
4734 template<
typename... RRAs >
4735 explicit inline Rows( MT& matrix, RRAs... args );
4737 Rows(
const Rows& ) =
default;
4738 Rows( Rows&& ) =
default;
4752 inline Reference operator()(
size_t i,
size_t j );
4754 inline Reference at(
size_t i,
size_t j );
4768 Rows& operator=(
const Rows& ) =
delete;
4775 using DataType::idx;
4776 using DataType::idces;
4779 inline MT& operand() noexcept;
4780 inline const MT& operand() const noexcept;
4782 inline
size_t columns() const noexcept;
4783 inline
size_t capacity() const noexcept;
4784 inline
size_t capacity(
size_t i ) const noexcept;
4786 inline
size_t nonZeros(
size_t i ) const;
4787 inline
void reset();
4788 inline
void reset(
size_t i );
4789 inline
void reserve(
size_t nonzeros );
4790 void reserve(
size_t i,
size_t nonzeros );
4792 inline
void trim(
size_t i );
4801 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
4802 inline
void finalize(
size_t i );
4809 inline
void erase(
size_t i,
size_t j );
4813 template< typename Pred >
4814 inline
void erase( Pred predicate );
4816 template< typename Pred >
4817 inline
void erase(
size_t i,
Iterator first,
Iterator last, Pred predicate );
4824 inline
Iterator find (
size_t i,
size_t j );
4826 inline
Iterator lowerBound(
size_t i,
size_t j );
4827 inline
ConstIterator lowerBound(
size_t i,
size_t j ) const;
4828 inline
Iterator upperBound(
size_t i,
size_t j );
4829 inline
ConstIterator upperBound(
size_t i,
size_t j ) const;
4836 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
4837 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
4839 inline
bool canSMPAssign() const noexcept;
4888 template< typename MT
4889 , typename... CRAs >
4890 template< typename... RRAs >
4891 inline Rows<MT,false,false,true,CRAs...>::Rows( MT& matrix, RRAs... args )
4892 : DataType( args... )
4893 , matrix_ ( matrix )
4896 for(
size_t i=0UL; i<
rows(); ++i ) {
4897 if( matrix_.rows() <= idx(i) ) {
4926 template<
typename MT
4927 ,
typename... CRAs >
4928 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Reference 4929 Rows<MT,false,false,true,CRAs...>::operator()(
size_t i,
size_t j )
4934 return matrix_(j,idx(i));
4951 template<
typename MT
4952 ,
typename... CRAs >
4954 Rows<MT,false,false,true,CRAs...>::operator()(
size_t i,
size_t j )
const 4959 return const_cast<const MT&
>( matrix_ )(j,idx(i));
4977 template<
typename MT
4978 ,
typename... CRAs >
4979 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Reference 4980 Rows<MT,false,false,true,CRAs...>::at(
size_t i,
size_t j )
4988 return (*
this)(i,j);
5006 template<
typename MT
5007 ,
typename... CRAs >
5009 Rows<MT,false,false,true,CRAs...>::at(
size_t i,
size_t j )
const 5017 return (*
this)(i,j);
5032 template<
typename MT
5033 ,
typename... CRAs >
5034 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5039 return matrix_.begin( idx(i) );
5054 template<
typename MT
5055 ,
typename... CRAs >
5061 return matrix_.cbegin( idx(i) );
5076 template<
typename MT
5077 ,
typename... CRAs >
5083 return matrix_.cbegin( idx(i) );
5098 template<
typename MT
5099 ,
typename... CRAs >
5100 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5105 return matrix_.end( idx(i) );
5120 template<
typename MT
5121 ,
typename... CRAs >
5127 return matrix_.cend( idx(i) );
5142 template<
typename MT
5143 ,
typename... CRAs >
5149 return matrix_.cend( idx(i) );
5169 template<
typename MT
5170 ,
typename... CRAs >
5171 inline MT& Rows<MT,false,false,true,CRAs...>::operand() noexcept
5185 template<
typename MT
5186 ,
typename... CRAs >
5187 inline const MT& Rows<MT,false,false,true,CRAs...>::operand() const noexcept
5201 template<
typename MT
5202 ,
typename... CRAs >
5205 return matrix_.columns();
5217 template<
typename MT
5218 ,
typename... CRAs >
5221 return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
5236 template<
typename MT
5237 ,
typename... CRAs >
5242 return matrix_.capacity( idx(i) );
5254 template<
typename MT
5255 ,
typename... CRAs >
5258 size_t nonzeros( 0UL );
5260 for(
size_t i=0UL; i<
rows(); ++i )
5278 template<
typename MT
5279 ,
typename... CRAs >
5284 return matrix_.nonZeros( idx(i) );
5296 template<
typename MT
5297 ,
typename... CRAs >
5300 for(
size_t i=0UL; i<
rows(); ++i ) {
5301 matrix_.reset( idx(i) );
5318 template<
typename MT
5319 ,
typename... CRAs >
5322 matrix_.reset( idx(i) );
5339 template<
typename MT
5340 ,
typename... CRAs >
5341 inline void Rows<MT,false,false,true,CRAs...>::reserve(
size_t nonzeros )
5343 const size_t current(
capacity() );
5345 if( nonzeros > current ) {
5346 matrix_.reserve( matrix_.capacity() + nonzeros - current );
5366 template<
typename MT
5367 ,
typename... CRAs >
5368 void Rows<MT,false,false,true,CRAs...>::reserve(
size_t i,
size_t nonzeros )
5370 matrix_.reserve( idx(i), nonzeros );
5386 template<
typename MT
5387 ,
typename... CRAs >
5388 void Rows<MT,false,false,true,CRAs...>::trim()
5390 for(
size_t i=0UL; i<
rows(); ++i ) {
5409 template<
typename MT
5410 ,
typename... CRAs >
5411 void Rows<MT,false,false,true,CRAs...>::trim(
size_t i )
5415 matrix_.trim( idx(i) );
5442 template<
typename MT
5443 ,
typename... CRAs >
5444 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5447 return matrix_.set( j, idx(i), value );
5467 template<
typename MT
5468 ,
typename... CRAs >
5469 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5470 Rows<MT,false,false,true,CRAs...>::insert(
size_t i,
size_t j,
const ElementType& value )
5472 return matrix_.insert( j, idx(i), value );
5522 template<
typename MT
5523 ,
typename... CRAs >
5524 inline void Rows<MT,false,false,true,CRAs...>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
5526 if( !check || !isDefault<strict>( value ) )
5527 matrix_.insert( j, idx(i), value );
5547 template<
typename MT
5548 ,
typename... CRAs >
5549 inline void Rows<MT,false,false,true,CRAs...>::finalize(
size_t i )
5577 template<
typename MT
5578 ,
typename... CRAs >
5579 inline void Rows<MT,false,false,true,CRAs...>::erase(
size_t i,
size_t j )
5584 matrix_.erase( j, idx(i) );
5600 template<
typename MT
5601 ,
typename... CRAs >
5602 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5603 Rows<MT,false,false,true,CRAs...>::erase(
size_t i,
Iterator pos )
5607 return matrix_.erase( idx(i), pos );
5624 template<
typename MT
5625 ,
typename... CRAs >
5626 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5627 Rows<MT,false,false,true,CRAs...>::erase(
size_t i,
Iterator first,
Iterator last )
5631 return matrix_.erase( idx(i), first, last );
5660 template<
typename MT
5661 ,
typename... CRAs >
5662 template<
typename Pred >
5663 inline void Rows<MT,false,false,true,CRAs...>::erase( Pred predicate )
5665 for(
size_t i=0UL; i<
rows(); ++i ) {
5666 matrix_.erase( idx(i),
begin(i),
end(i), predicate );
5700 template<
typename MT
5701 ,
typename... CRAs >
5702 template<
typename Pred >
5703 inline void Rows<MT,false,false,true,CRAs...>::erase(
size_t i,
Iterator first,
Iterator last, Pred predicate )
5707 matrix_.erase( idx(i), first, last, predicate );
5736 template<
typename MT
5737 ,
typename... CRAs >
5738 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5739 Rows<MT,false,false,true,CRAs...>::find(
size_t i,
size_t j )
5741 return matrix_.find( j, idx(i) );
5762 template<
typename MT
5763 ,
typename... CRAs >
5765 Rows<MT,false,false,true,CRAs...>::find(
size_t i,
size_t j )
const 5767 return matrix_.find( j, idx(i) );
5787 template<
typename MT
5788 ,
typename... CRAs >
5789 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5790 Rows<MT,false,false,true,CRAs...>::lowerBound(
size_t i,
size_t j )
5792 return matrix_.lowerBound( j, idx(i) );
5812 template<
typename MT
5813 ,
typename... CRAs >
5815 Rows<MT,false,false,true,CRAs...>::lowerBound(
size_t i,
size_t j )
const 5817 return matrix_.lowerBound( j, idx(i) );
5837 template<
typename MT
5838 ,
typename... CRAs >
5839 inline typename Rows<MT,
false,
false,
true,CRAs...>
::Iterator 5840 Rows<MT,false,false,true,CRAs...>::upperBound(
size_t i,
size_t j )
5842 return matrix_.upperBound( j, idx(i) );
5862 template<
typename MT
5863 ,
typename... CRAs >
5865 Rows<MT,false,false,true,CRAs...>::upperBound(
size_t i,
size_t j )
const 5867 return matrix_.upperBound( j, idx(i) );
5892 template<
typename MT
5893 ,
typename... CRAs >
5894 template<
typename Other >
5895 inline bool Rows<MT,false,false,true,CRAs...>::canAlias(
const Other* alias )
const noexcept
5897 return matrix_.isAliased( alias );
5914 template<
typename MT
5915 ,
typename... CRAs >
5916 template<
typename Other >
5917 inline bool Rows<MT,false,false,true,CRAs...>::isAliased(
const Other* alias )
const noexcept
5919 return matrix_.isAliased( alias );
5936 template<
typename MT
5937 ,
typename... CRAs >
5938 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:133
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:3078
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
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:354
constexpr bool IsSparseMatrix_v
Auxiliary variable template for the IsSparseMatrix type trait.The IsSparseMatrix_v variable template ...
Definition: IsSparseMatrix.h:139
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
Header file for the subtraction trait.
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
constexpr 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:750
Header file for the View base class.
Header file for the IsSparseMatrix type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
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:3079
#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
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
#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:3084
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
#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.
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
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.
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the IsUniLower type trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
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:482
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:416
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.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
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:1364
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:3076
#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
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3080
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
#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:3086
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:253
constexpr bool Contains_v
Auxiliary variable template for the Contains type trait.The Contains_v variable template provides a c...
Definition: Contains.h:139
Header file for the IsLower type trait.
Header file for the SparseElement base class.
Constraint on the data type.
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1179
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:438
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:8908
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
Constraint on the data type.
Header file for the IsStrictlyLower type trait.
Constraint on the data type.
#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:133
#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.
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
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:808
#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.
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the rows trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
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:3082
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:290
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
#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.
Header file for the implementation of the Rows base template.
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.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825