35 #ifndef _BLAZE_MATH_VIEWS_ROW_SPARSE_H_ 36 #define _BLAZE_MATH_VIEWS_ROW_SPARSE_H_ 112 template<
typename MT
114 class Row<MT,true,false,SF>
115 :
public View< SparseVector< Row<MT,true,false,SF>, true > >
120 using Operand = If_< IsExpression<MT>, MT, MT& >;
125 using This = Row<MT,true,false,SF>;
126 using BaseType = SparseVector<This,true>;
148 enum :
bool { smpAssignable =
false };
154 explicit inline Row( Operand matrix,
size_t index );
166 inline Reference operator[](
size_t index );
167 inline ConstReference operator[](
size_t index )
const;
169 inline ConstReference at(
size_t index )
const;
171 inline ConstIterator
begin ()
const;
172 inline ConstIterator
cbegin()
const;
174 inline ConstIterator
end ()
const;
175 inline ConstIterator
cend ()
const;
182 inline Row& operator=(
const Row& rhs );
184 template<
typename VT >
inline Row& operator= (
const DenseVector<VT,true>& rhs );
185 template<
typename VT >
inline Row& operator= (
const SparseVector<VT,true>& rhs );
186 template<
typename VT >
inline Row&
operator+=(
const DenseVector<VT,true>& rhs );
187 template<
typename VT >
inline Row&
operator+=(
const SparseVector<VT,true>& rhs );
188 template<
typename VT >
inline Row&
operator-=(
const DenseVector<VT,true>& rhs );
189 template<
typename VT >
inline Row&
operator-=(
const SparseVector<VT,true>& rhs );
190 template<
typename VT >
inline Row&
operator*=(
const Vector<VT,true>& rhs );
191 template<
typename VT >
inline Row&
operator/=(
const DenseVector<VT,true>& rhs );
192 template<
typename VT >
inline Row& operator%=(
const Vector<VT,true>& rhs );
194 template<
typename Other >
195 inline EnableIf_<IsNumeric<Other>, Row >&
operator*=( Other rhs );
197 template<
typename Other >
198 inline EnableIf_<IsNumeric<Other>, Row >&
operator/=( Other rhs );
205 inline Operand operand() const noexcept;
206 inline
size_t row() const noexcept;
207 inline
size_t size() const noexcept;
208 inline
size_t capacity() const noexcept;
211 inline
void reserve(
size_t n );
220 inline
void append(
size_t index, const
ElementType& value,
bool check=false );
227 inline
void erase(
size_t index );
231 template< typename Pred, typename =
DisableIf_< IsIntegral<Pred> > >
232 inline
void erase( Pred predicate );
234 template< typename Pred >
242 inline
Iterator find (
size_t index );
243 inline ConstIterator find (
size_t index ) const;
244 inline
Iterator lowerBound(
size_t index );
245 inline ConstIterator lowerBound(
size_t index ) const;
246 inline
Iterator upperBound(
size_t index );
247 inline ConstIterator upperBound(
size_t index ) const;
254 template< typename Other > inline Row& scale( const Other& scalar );
261 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
262 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
264 template< typename VT > inline
void assign ( const DenseVector <VT,true>& rhs );
265 template< typename VT > inline
void assign ( const SparseVector<VT,true>& rhs );
266 template< typename VT > inline
void addAssign( const DenseVector <VT,true>& rhs );
267 template< typename VT > inline
void addAssign( const SparseVector<VT,true>& rhs );
268 template< typename VT > inline
void subAssign( const DenseVector <VT,true>& rhs );
269 template< typename VT > inline
void subAssign( const SparseVector<VT,true>& rhs );
277 inline
size_t extendCapacity() const noexcept;
318 template< typename MT
320 inline Row<MT,true,false,SF>::Row( Operand matrix,
size_t index )
324 if( matrix_.rows() <= index ) {
350 template<
typename MT
355 return matrix_(row_,index);
371 template<
typename MT
374 Row<MT,true,false,SF>::operator[](
size_t index )
const 377 return const_cast<const MT&
>( matrix_ )(row_,index);
394 template<
typename MT
398 if( index >=
size() ) {
401 return (*
this)[index];
418 template<
typename MT
422 if( index >=
size() ) {
425 return (*
this)[index];
439 template<
typename MT
443 return matrix_.begin( row_ );
457 template<
typename MT
461 return matrix_.cbegin( row_ );
475 template<
typename MT
479 return matrix_.cbegin( row_ );
493 template<
typename MT
497 return matrix_.end( row_ );
511 template<
typename MT
515 return matrix_.cend( row_ );
529 template<
typename MT
533 return matrix_.cend( row_ );
561 template<
typename MT
563 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator=(
const Row& rhs )
571 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
574 if(
size() != rhs.size() ) {
578 if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
582 decltype(
auto) left( derestrict( *this ) );
584 if( rhs.canAlias( &matrix_ ) ) {
587 left.reserve( tmp.nonZeros() );
592 left.reserve( rhs.nonZeros() );
618 template<
typename MT
620 template<
typename VT >
621 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator=(
const DenseVector<VT,true>& rhs )
633 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
636 if( !tryAssign( matrix_, right, row_, 0UL ) ) {
640 decltype(
auto) left( derestrict( *this ) );
642 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
643 const ResultType_<VT> tmp( right );
649 assign( left, right );
674 template<
typename MT
676 template<
typename VT >
677 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator=(
const SparseVector<VT,true>& rhs )
689 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
692 if( !tryAssign( matrix_, right, row_, 0UL ) ) {
696 decltype(
auto) left( derestrict( *this ) );
698 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
699 const ResultType_<VT> tmp( right );
701 left.reserve( tmp.nonZeros() );
706 left.reserve( right.nonZeros() );
707 assign( left, right );
732 template<
typename MT
734 template<
typename VT >
746 using AddType = AddTrait_< ResultType, ResultType_<VT> >;
756 const AddType tmp( *
this + (~rhs) );
758 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
762 decltype(
auto) left( derestrict( *this ) );
789 template< typename MT
791 template< typename VT >
792 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator+=( const SparseVector<VT,true>& rhs )
803 using AddType = AddTrait_< ResultType, ResultType_<VT> >;
813 const AddType tmp( *
this + (~rhs) );
815 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
819 decltype(
auto) left( derestrict( *this ) );
848 template< typename MT
850 template< typename VT >
851 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator-=( const DenseVector<VT,true>& rhs )
862 using SubType = SubTrait_< ResultType, ResultType_<VT> >;
872 const SubType tmp( *
this - (~rhs) );
874 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
878 decltype(
auto) left( derestrict( *this ) );
906 template< typename MT
908 template< typename VT >
909 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator-=( const SparseVector<VT,true>& rhs )
920 using SubType = SubTrait_< ResultType, ResultType_<VT> >;
930 const SubType tmp( *
this - (~rhs) );
932 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
936 decltype(
auto) left( derestrict( *this ) );
939 left.reserve( tmp.nonZeros() );
963 template< typename MT
965 template< typename VT >
966 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator*=( const Vector<VT,true>& rhs )
976 using MultType = MultTrait_< ResultType, ResultType_<VT> >;
985 const MultType tmp( *
this * (~rhs) );
987 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
991 decltype(
auto) left( derestrict( *this ) );
1016 template< typename MT
1018 template< typename VT >
1019 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator/=( const DenseVector<VT,true>& rhs )
1021 using blaze::assign;
1030 using DivType = DivTrait_< ResultType, ResultType_<VT> >;
1040 const DivType tmp( *
this / (~rhs) );
1042 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
1046 decltype(
auto) left( derestrict( *this ) );
1049 assign( left, tmp );
1072 template< typename MT
1074 template< typename VT >
1075 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator%=( const Vector<VT,true>& rhs )
1077 using blaze::assign;
1082 using CrossType = CrossTrait_< ResultType, ResultType_<VT> >;
1088 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
1092 const CrossType tmp( *
this % (~rhs) );
1094 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
1098 decltype(
auto) left( derestrict( *this ) );
1101 assign( left, tmp );
1126 template< typename MT
1128 template< typename Other >
1129 inline
EnableIf_<IsNumeric<Other>, Row<MT,true,false,SF> >&
1130 Row<MT,true,false,SF>::operator*=( Other rhs )
1135 element->value() *= rhs;
1160 template<
typename MT
1162 template<
typename Other >
1163 inline EnableIf_<IsNumeric<Other>, Row<MT,true,false,SF> >&
1170 using DT = DivTrait_<ElementType,Other>;
1171 using Tmp = If_< IsNumeric<DT>, DT, Other >;
1175 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
1176 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1178 element->value() *= tmp;
1182 element->value() /= rhs;
1205 template<
typename MT
1207 inline typename Row<MT,true,false,SF>::Operand Row<MT,true,false,SF>::operand() const noexcept
1221 template<
typename MT
1237 template<
typename MT
1241 return matrix_.columns();
1253 template<
typename MT
1257 return matrix_.capacity( row_ );
1272 template<
typename MT
1276 return matrix_.nonZeros( row_ );
1288 template<
typename MT
1292 matrix_.reset( row_ );
1308 template<
typename MT
1310 void Row<MT,true,false,SF>::reserve(
size_t n )
1312 matrix_.reserve( row_, n );
1327 template<
typename MT
1329 inline size_t Row<MT,true,false,SF>::extendCapacity() const noexcept
1334 size_t nonzeros( 2UL*
capacity()+1UL );
1335 nonzeros =
max( nonzeros, 7UL );
1336 nonzeros =
min( nonzeros,
size() );
1366 template<
typename MT
1371 return matrix_.set( row_, index, value );
1390 template<
typename MT
1393 Row<MT,true,false,SF>::insert(
size_t index,
const ElementType& value )
1395 return matrix_.insert( row_, index, value );
1426 template<
typename MT
1428 inline void Row<MT,true,false,SF>::append(
size_t index,
const ElementType& value,
bool check )
1430 matrix_.append( row_, index, value, check );
1453 template<
typename MT
1455 inline void Row<MT,true,false,SF>::erase(
size_t index )
1457 matrix_.erase( row_, index );
1472 template<
typename MT
1476 return matrix_.erase( row_, pos );
1492 template<
typename MT
1497 return matrix_.erase( row_, first, last );
1526 template<
typename MT
1528 template<
typename Pred
1530 inline void Row<MT,true,false,SF>::erase( Pred predicate )
1532 matrix_.erase( row_,
begin(),
end(), predicate );
1563 template<
typename MT
1565 template<
typename Pred >
1566 inline void Row<MT,true,false,SF>::erase(
Iterator first,
Iterator last, Pred predicate )
1568 matrix_.erase( row_, first, last, predicate );
1596 template<
typename MT
1600 return matrix_.find( row_, index );
1620 template<
typename MT
1624 return matrix_.find( row_, index );
1643 template<
typename MT
1647 return matrix_.lowerBound( row_, index );
1666 template<
typename MT
1670 return matrix_.lowerBound( row_, index );
1689 template<
typename MT
1693 return matrix_.upperBound( row_, index );
1712 template<
typename MT
1716 return matrix_.upperBound( row_, index );
1743 template<
typename MT
1745 template<
typename Other >
1746 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::scale(
const Other& scalar )
1751 element->value() *= scalar;
1777 template<
typename MT
1779 template<
typename Other >
1780 inline bool Row<MT,true,false,SF>::canAlias(
const Other* alias )
const noexcept
1782 return matrix_.isAliased( alias );
1799 template<
typename MT
1801 template<
typename Other >
1802 inline bool Row<MT,true,false,SF>::isAliased(
const Other* alias )
const noexcept
1804 return matrix_.isAliased( alias );
1822 template<
typename MT
1824 template<
typename VT >
1825 inline void Row<MT,true,false,SF>::assign(
const DenseVector<VT,true>& rhs )
1830 for(
size_t j=0UL; j<
size(); ++j )
1832 if( matrix_.nonZeros( row_ ) == matrix_.capacity( row_ ) )
1833 matrix_.reserve( row_, extendCapacity() );
1835 matrix_.append( row_, j, (~rhs)[j],
true );
1854 template<
typename MT
1856 template<
typename VT >
1857 inline void Row<MT,true,false,SF>::assign(
const SparseVector<VT,true>& rhs )
1862 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1863 matrix_.append( row_, element->index(), element->value(), true );
1882 template<
typename MT
1884 template<
typename VT >
1885 inline void Row<MT,true,false,SF>::addAssign(
const DenseVector<VT,true>& rhs )
1887 using AddType = AddTrait_< ResultType, ResultType_<VT> >;
1895 const AddType tmp(
serial( *
this + (~rhs) ) );
1896 matrix_.reset( row_ );
1915 template<
typename MT
1917 template<
typename VT >
1918 inline void Row<MT,true,false,SF>::addAssign(
const SparseVector<VT,true>& rhs )
1920 using AddType = AddTrait_< ResultType, ResultType_<VT> >;
1928 const AddType tmp(
serial( *
this + (~rhs) ) );
1929 matrix_.reset( row_ );
1930 matrix_.reserve( row_, tmp.nonZeros() );
1949 template<
typename MT
1951 template<
typename VT >
1952 inline void Row<MT,true,false,SF>::subAssign(
const DenseVector<VT,true>& rhs )
1954 using SubType = SubTrait_< ResultType, ResultType_<VT> >;
1962 const SubType tmp(
serial( *
this - (~rhs) ) );
1963 matrix_.reset( row_ );
1982 template<
typename MT
1984 template<
typename VT >
1985 inline void Row<MT,true,false,SF>::subAssign(
const SparseVector<VT,true>& rhs )
1987 using SubType = SubTrait_< ResultType, ResultType_<VT> >;
1995 const SubType tmp(
serial( *
this - (~rhs) ) );
1996 matrix_.reset( row_ );
1997 matrix_.reserve( row_, tmp.nonZeros() );
2024 template<
typename MT >
2025 class Row<MT,false,false,false>
2026 :
public View< SparseVector< Row<MT,false,false,false>, true > >
2031 using Operand = If_< IsExpression<MT>, MT, MT& >;
2036 using This = Row<MT,false,false,false>;
2037 using BaseType = SparseVector<This,true>;
2045 using ConstReference = ConstReference_<MT>;
2054 template<
typename MatrixType
2055 ,
typename IteratorType >
2057 :
private SparseElement
2066 inline RowElement( IteratorType pos,
size_t column )
2078 template<
typename T >
inline RowElement& operator=(
const T& v ) {
2090 template<
typename T >
inline RowElement&
operator+=(
const T& v ) {
2102 template<
typename T >
inline RowElement&
operator-=(
const T& v ) {
2114 template<
typename T >
inline RowElement&
operator*=(
const T& v ) {
2126 template<
typename T >
inline RowElement&
operator/=(
const T& v ) {
2137 inline const RowElement* operator->()
const {
2147 inline decltype(
auto) value()
const {
2148 return pos_->value();
2157 inline size_t index()
const {
2173 template<
typename MatrixType
2174 ,
typename IteratorType >
2179 using IteratorCategory = std::forward_iterator_tag;
2180 using ValueType = RowElement<MatrixType,IteratorType>;
2181 using PointerType = ValueType;
2182 using ReferenceType = ValueType;
2183 using DifferenceType = ptrdiff_t;
2186 using iterator_category = IteratorCategory;
2187 using value_type = ValueType;
2188 using pointer = PointerType;
2189 using reference = ReferenceType;
2190 using difference_type = DifferenceType;
2196 inline RowIterator()
2197 : matrix_( nullptr )
2211 inline RowIterator( MatrixType& matrix,
size_t row,
size_t column )
2212 : matrix_( &matrix )
2217 for( ; column_<matrix_->columns(); ++column_ ) {
2218 pos_ = matrix_->find( row_, column_ );
2219 if( pos_ != matrix_->end( column_ ) )
break;
2232 inline RowIterator( MatrixType& matrix,
size_t row,
size_t column, IteratorType pos )
2233 : matrix_( &matrix )
2247 template<
typename MatrixType2,
typename IteratorType2 >
2248 inline RowIterator(
const RowIterator<MatrixType2,IteratorType2>& it )
2249 : matrix_( it.matrix_ )
2251 , column_( it.column_ )
2261 inline RowIterator& operator++() {
2263 for( ; column_<matrix_->columns(); ++column_ ) {
2264 pos_ = matrix_->find( row_, column_ );
2265 if( pos_ != matrix_->end( column_ ) )
break;
2277 inline const RowIterator operator++(
int ) {
2278 const RowIterator tmp( *
this );
2289 inline ReferenceType
operator*()
const {
2290 return ReferenceType( pos_, column_ );
2299 inline PointerType operator->()
const {
2300 return PointerType( pos_, column_ );
2310 template<
typename MatrixType2,
typename IteratorType2 >
2311 inline bool operator==(
const RowIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2312 return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
2322 template<
typename MatrixType2,
typename IteratorType2 >
2323 inline bool operator!=(
const RowIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2324 return !( *
this == rhs );
2334 inline DifferenceType
operator-(
const RowIterator& rhs )
const {
2335 size_t counter( 0UL );
2336 for(
size_t j=rhs.column_; j<column_; ++j ) {
2337 if( matrix_->find( row_, j ) != matrix_->end( j ) )
2346 MatrixType* matrix_;
2353 template<
typename MatrixType2,
typename IteratorType2 >
friend class RowIterator;
2354 template<
typename MT2,
bool SO2,
bool DF2,
bool SF2 >
friend class Row;
2361 using ConstIterator = RowIterator< const MT, ConstIterator_<MT> >;
2369 enum :
bool { smpAssignable =
false };
2375 explicit inline Row( Operand matrix,
size_t index );
2387 inline Reference operator[](
size_t index );
2388 inline ConstReference operator[](
size_t index )
const;
2390 inline ConstReference at(
size_t index )
const;
2392 inline ConstIterator
begin ()
const;
2393 inline ConstIterator
cbegin()
const;
2395 inline ConstIterator
end ()
const;
2396 inline ConstIterator
cend ()
const;
2403 inline Row& operator= (
const Row& rhs );
2404 template<
typename VT >
inline Row& operator= (
const Vector<VT,true>& rhs );
2405 template<
typename VT >
inline Row&
operator+=(
const Vector<VT,true>& rhs );
2406 template<
typename VT >
inline Row&
operator-=(
const Vector<VT,true>& rhs );
2407 template<
typename VT >
inline Row&
operator*=(
const Vector<VT,true>& rhs );
2408 template<
typename VT >
inline Row&
operator/=(
const DenseVector<VT,true>& rhs );
2409 template<
typename VT >
inline Row& operator%=(
const Vector<VT,true>& rhs );
2411 template<
typename Other >
2412 inline EnableIf_<IsNumeric<Other>, Row >&
operator*=( Other rhs );
2414 template<
typename Other >
2415 inline EnableIf_<IsNumeric<Other>, Row >&
operator/=( Other rhs );
2422 inline Operand operand() const noexcept;
2423 inline
size_t row() const noexcept;
2424 inline
size_t size() const noexcept;
2425 inline
size_t capacity() const noexcept;
2426 inline
size_t nonZeros() const;
2427 inline
void reset();
2428 inline
void reserve(
size_t n );
2437 inline
void append(
size_t index, const
ElementType& value,
bool check=false );
2444 inline
void erase(
size_t index );
2448 template< typename Pred, typename =
DisableIf_< IsIntegral<Pred> > >
2449 inline
void erase( Pred predicate );
2451 template< typename Pred >
2459 inline
Iterator find (
size_t index );
2460 inline ConstIterator find (
size_t index ) const;
2461 inline
Iterator lowerBound(
size_t index );
2462 inline ConstIterator lowerBound(
size_t index ) const;
2463 inline
Iterator upperBound(
size_t index );
2464 inline ConstIterator upperBound(
size_t index ) const;
2471 template< typename Other > inline Row& scale( const Other& scalar );
2478 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
2479 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
2481 template< typename VT > inline
void assign ( const DenseVector <VT,true>& rhs );
2482 template< typename VT > inline
void assign ( const SparseVector<VT,true>& rhs );
2483 template< typename VT > inline
void addAssign( const Vector<VT,true>& rhs );
2484 template< typename VT > inline
void subAssign( const Vector<VT,true>& rhs );
2527 template< typename MT >
2528 inline Row<MT,false,false,false>::Row( Operand matrix,
size_t index )
2532 if( matrix_.rows() <= index ) {
2558 template<
typename MT >
2560 Row<MT,false,false,false>::operator[](
size_t index )
2563 return matrix_(row_,index);
2579 template<
typename MT >
2581 Row<MT,false,false,false>::operator[](
size_t index )
const 2584 return const_cast<const MT&
>( matrix_ )(row_,index);
2601 template<
typename MT >
2603 Row<MT,false,false,false>::at(
size_t index )
2605 if( index >=
size() ) {
2608 return (*
this)[index];
2625 template<
typename MT >
2627 Row<MT,false,false,false>::at(
size_t index )
const 2629 if( index >=
size() ) {
2632 return (*
this)[index];
2646 template<
typename MT >
2649 return Iterator( matrix_, row_, 0UL );
2663 template<
typename MT >
2680 template<
typename MT >
2697 template<
typename MT >
2714 template<
typename MT >
2731 template<
typename MT >
2762 template<
typename MT >
2763 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator=(
const Row& rhs )
2765 using blaze::assign;
2771 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
2774 if(
size() != rhs.size() ) {
2778 if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
2782 decltype(
auto) left( derestrict( *this ) );
2784 if( rhs.canAlias( &matrix_ ) ) {
2786 assign( left, tmp );
2789 assign( left, rhs );
2814 template<
typename MT >
2815 template<
typename VT >
2816 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator=(
const Vector<VT,true>& rhs )
2818 using blaze::assign;
2824 const CompositeType_<VT> tmp( ~rhs );
2826 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2830 decltype(
auto) left( derestrict( *this ) );
2832 assign( left, tmp );
2856 template< typename MT >
2857 template< typename VT >
2858 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator+=( const Vector<VT,true>& rhs )
2860 using blaze::assign;
2868 using AddType = AddTrait_< ResultType, ResultType_<VT> >;
2877 const AddType tmp( *
this + (~rhs) );
2879 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2883 decltype(
auto) left( derestrict( *this ) );
2885 assign( left, tmp );
2909 template< typename MT >
2910 template< typename VT >
2911 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator-=( const Vector<VT,true>& rhs )
2913 using blaze::assign;
2921 using SubType = SubTrait_< ResultType, ResultType_<VT> >;
2930 const SubType tmp( *
this - (~rhs) );
2932 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2936 decltype(
auto) left( derestrict( *this ) );
2938 assign( left, tmp );
2961 template< typename MT >
2962 template< typename VT >
2963 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator*=( const Vector<VT,true>& rhs )
2965 using blaze::assign;
2973 using MultType = MultTrait_< ResultType, ResultType_<VT> >;
2982 const MultType tmp( *
this * (~rhs) );
2984 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2988 decltype(
auto) left( derestrict( *this ) );
2990 assign( left, tmp );
3012 template< typename MT >
3013 template< typename VT >
3014 inline Row<MT,false,false,false>&
3015 Row<MT,false,false,false>::operator/=( const DenseVector<VT,true>& rhs )
3017 using blaze::assign;
3026 using DivType = DivTrait_< ResultType, ResultType_<VT> >;
3036 const DivType tmp( *
this / (~rhs) );
3038 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
3042 decltype(
auto) left( derestrict( *this ) );
3044 assign( left, tmp );
3067 template< typename MT >
3068 template< typename VT >
3069 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator%=( const Vector<VT,true>& rhs )
3071 using blaze::assign;
3076 using CrossType = CrossTrait_< ResultType, ResultType_<VT> >;
3082 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
3086 const CrossType tmp( *
this % (~rhs) );
3088 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
3092 decltype(
auto) left( derestrict( *this ) );
3094 assign( left, tmp );
3119 template< typename MT >
3120 template< typename Other >
3121 inline
EnableIf_<IsNumeric<Other>, Row<MT,false,false,false> >&
3122 Row<MT,false,false,false>::operator*=( Other rhs )
3127 element->value() *= rhs;
3152 template<
typename MT >
3153 template<
typename Other >
3154 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,false> >&
3161 using DT = DivTrait_<ElementType,Other>;
3162 using Tmp = If_< IsNumeric<DT>, DT, Other >;
3166 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
3167 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
3169 element->value() *= tmp;
3173 element->value() /= rhs;
3196 template<
typename MT >
3197 inline typename Row<MT,false,false,false>::Operand Row<MT,false,false,false>::operand() const noexcept
3211 template<
typename MT >
3226 template<
typename MT >
3229 return matrix_.columns();
3241 template<
typename MT >
3244 return matrix_.columns();
3259 template<
typename MT >
3262 size_t counter( 0UL );
3263 for( ConstIterator element=
begin(); element!=
end(); ++element ) {
3278 template<
typename MT >
3281 const size_t jbegin( ( IsUpper<MT>::value )
3282 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3286 const size_t jend ( ( IsLower<MT>::value )
3287 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3292 for(
size_t j=jbegin; j<jend; ++j ) {
3293 matrix_.erase( row_, j );
3310 template<
typename MT >
3311 void Row<MT,false,false,false>::reserve(
size_t n )
3341 template<
typename MT >
3345 return Iterator( matrix_, row_, index, matrix_.set( row_, index, value ) );
3364 template<
typename MT >
3366 Row<MT,false,false,false>::insert(
size_t index,
const ElementType& value )
3368 return Iterator( matrix_, row_, index, matrix_.insert( row_, index, value ) );
3399 template<
typename MT >
3400 inline void Row<MT,false,false,false>::append(
size_t index,
const ElementType& value,
bool check )
3403 matrix_.insert( row_, index, value );
3426 template<
typename MT >
3427 inline void Row<MT,false,false,false>::erase(
size_t index )
3429 matrix_.erase( row_, index );
3444 template<
typename MT >
3447 const size_t column( pos.column_ );
3449 if( column ==
size() )
3452 matrix_.erase( column, pos.pos_ );
3453 return Iterator( matrix_, row_, column+1UL );
3469 template<
typename MT >
3473 for( ; first!=last; ++first ) {
3474 matrix_.erase( first.column_, first.pos_ );
3505 template<
typename MT >
3506 template<
typename Pred
3508 inline void Row<MT,false,false,false>::erase( Pred predicate )
3511 if( predicate( element->value() ) )
3512 matrix_.erase( element.column_, element.pos_ );
3544 template<
typename MT >
3545 template<
typename Pred >
3546 inline void Row<MT,false,false,false>::erase(
Iterator first,
Iterator last, Pred predicate )
3548 for( ; first!=last; ++first ) {
3549 if( predicate( first->value() ) )
3550 matrix_.erase( first.column_, first.pos_ );
3579 template<
typename MT >
3582 const Iterator_<MT> pos( matrix_.find( row_, index ) );
3584 if( pos != matrix_.end( index ) )
3585 return Iterator( matrix_, row_, index, pos );
3607 template<
typename MT >
3609 Row<MT,false,false,false>::find(
size_t index )
const 3611 const ConstIterator_<MT> pos( matrix_.find( row_, index ) );
3613 if( pos != matrix_.end( index ) )
3635 template<
typename MT >
3637 Row<MT,false,false,false>::lowerBound(
size_t index )
3639 for(
size_t i=index; i<
size(); ++i )
3641 const Iterator_<MT> pos( matrix_.find( row_, i ) );
3643 if( pos != matrix_.end( i ) )
3644 return Iterator( matrix_, row_, i, pos );
3666 template<
typename MT >
3668 Row<MT,false,false,false>::lowerBound(
size_t index )
const 3670 for(
size_t i=index; i<
size(); ++i )
3672 const ConstIterator_<MT> pos( matrix_.find( row_, i ) );
3674 if( pos != matrix_.end( i ) )
3697 template<
typename MT >
3699 Row<MT,false,false,false>::upperBound(
size_t index )
3701 for(
size_t i=index+1UL; i<
size(); ++i )
3703 const Iterator_<MT> pos( matrix_.find( row_, i ) );
3705 if( pos != matrix_.end( i ) )
3706 return Iterator( matrix_, row_, i, pos );
3728 template<
typename MT >
3730 Row<MT,false,false,false>::upperBound(
size_t index )
const 3732 for(
size_t i=index+1UL; i<
size(); ++i )
3734 const ConstIterator_<MT> pos( matrix_.find( row_, i ) );
3736 if( pos != matrix_.end( i ) )
3767 template<
typename MT >
3768 template<
typename Other >
3769 inline Row<MT,false,false,false>& Row<MT,false,false,false>::scale(
const Other& scalar )
3774 element->value() *= scalar;
3800 template<
typename MT >
3801 template<
typename Other >
3802 inline bool Row<MT,false,false,false>::canAlias(
const Other* alias )
const noexcept
3804 return matrix_.isAliased( alias );
3817 template<
typename MT >
3818 template<
typename Other >
3819 inline bool Row<MT,false,false,false>::isAliased(
const Other* alias )
const noexcept
3821 return matrix_.isAliased( alias );
3839 template<
typename MT >
3840 template<
typename VT >
3841 inline void Row<MT,false,false,false>::assign(
const DenseVector<VT,true>& rhs )
3845 for(
size_t j=0UL; j<(~rhs).
size(); ++j ) {
3846 matrix_(row_,j) = (~rhs)[j];
3865 template<
typename MT >
3866 template<
typename VT >
3867 inline void Row<MT,false,false,false>::assign(
const SparseVector<VT,true>& rhs )
3873 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
3874 for( ; j<element->index(); ++j )
3875 matrix_.erase( row_, j );
3876 matrix_(row_,j++) = element->value();
3878 for( ; j<
size(); ++j ) {
3879 matrix_.erase( row_, j );
3898 template<
typename MT >
3899 template<
typename VT >
3900 inline void Row<MT,false,false,false>::addAssign(
const Vector<VT,true>& rhs )
3902 using AddType = AddTrait_< ResultType, ResultType_<VT> >;
3909 const AddType tmp(
serial( *
this + (~rhs) ) );
3928 template<
typename MT >
3929 template<
typename VT >
3930 inline void Row<MT,false,false,false>::subAssign(
const Vector<VT,true>& rhs )
3932 using SubType = SubTrait_< ResultType, ResultType_<VT> >;
3939 const SubType tmp(
serial( *
this - (~rhs) ) );
3966 template<
typename MT >
3967 class Row<MT,false,false,true>
3968 :
public View< SparseVector< Row<MT,false,false,true>, true > >
3973 using Operand = If_< IsExpression<MT>, MT, MT& >;
3978 using This = Row<MT,false,false,true>;
3979 using BaseType = SparseVector<This,true>;
3987 using ConstReference = ConstReference_<MT>;
3993 using ConstIterator = ConstIterator_<MT>;
4001 enum :
bool { smpAssignable =
false };
4007 explicit inline Row( Operand matrix,
size_t index );
4019 inline Reference operator[](
size_t index );
4020 inline ConstReference operator[](
size_t index )
const;
4022 inline ConstReference at(
size_t index )
const;
4024 inline ConstIterator
begin ()
const;
4025 inline ConstIterator
cbegin()
const;
4027 inline ConstIterator
end ()
const;
4028 inline ConstIterator
cend ()
const;
4035 inline Row& operator=(
const Row& rhs );
4037 template<
typename VT >
inline Row& operator= (
const DenseVector<VT,true>& rhs );
4038 template<
typename VT >
inline Row& operator= (
const SparseVector<VT,true>& rhs );
4039 template<
typename VT >
inline Row&
operator+=(
const DenseVector<VT,true>& rhs );
4040 template<
typename VT >
inline Row&
operator+=(
const SparseVector<VT,true>& rhs );
4041 template<
typename VT >
inline Row&
operator-=(
const DenseVector<VT,true>& rhs );
4042 template<
typename VT >
inline Row&
operator-=(
const SparseVector<VT,true>& rhs );
4043 template<
typename VT >
inline Row&
operator*=(
const Vector<VT,true>& rhs );
4044 template<
typename VT >
inline Row&
operator/=(
const DenseVector<VT,true>& rhs );
4045 template<
typename VT >
inline Row& operator%=(
const Vector<VT,true>& rhs );
4047 template<
typename Other >
4048 inline EnableIf_<IsNumeric<Other>, Row >&
operator*=( Other rhs );
4050 template<
typename Other >
4051 inline EnableIf_<IsNumeric<Other>, Row >&
operator/=( Other rhs );
4058 inline Operand operand() const noexcept;
4059 inline
size_t row() const noexcept;
4060 inline
size_t size() const noexcept;
4061 inline
size_t capacity() const noexcept;
4062 inline
size_t nonZeros() const;
4063 inline
void reset();
4064 inline
void reserve(
size_t n );
4073 inline
void append(
size_t index, const
ElementType& value,
bool check=false );
4080 inline
void erase(
size_t index );
4084 template< typename Pred, typename =
DisableIf_< IsIntegral<Pred> > >
4085 inline
void erase( Pred predicate );
4087 template< typename Pred >
4095 inline
Iterator find (
size_t index );
4096 inline ConstIterator find (
size_t index ) const;
4097 inline
Iterator lowerBound(
size_t index );
4098 inline ConstIterator lowerBound(
size_t index ) const;
4099 inline
Iterator upperBound(
size_t index );
4100 inline ConstIterator upperBound(
size_t index ) const;
4107 template< typename Other > inline Row& scale( const Other& scalar );
4114 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
4115 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
4117 template< typename VT > inline
void assign ( const DenseVector <VT,true>& rhs );
4118 template< typename VT > inline
void assign ( const SparseVector<VT,true>& rhs );
4119 template< typename VT > inline
void addAssign( const DenseVector <VT,true>& rhs );
4120 template< typename VT > inline
void addAssign( const SparseVector<VT,true>& rhs );
4121 template< typename VT > inline
void subAssign( const DenseVector <VT,true>& rhs );
4122 template< typename VT > inline
void subAssign( const SparseVector<VT,true>& rhs );
4130 inline
size_t extendCapacity() const;
4172 template< typename MT >
4173 inline Row<MT,false,false,true>::Row( Operand matrix,
size_t index )
4177 if( matrix_.rows() <= index ) {
4203 template<
typename MT >
4205 Row<MT,false,false,true>::operator[](
size_t index )
4208 return matrix_(index,row_);
4224 template<
typename MT >
4226 Row<MT,false,false,true>::operator[](
size_t index )
const 4229 return const_cast<const MT&
>( matrix_ )(index,row_);
4246 template<
typename MT >
4248 Row<MT,false,false,true>::at(
size_t index )
4250 if( index >=
size() ) {
4253 return (*
this)[index];
4270 template<
typename MT >
4272 Row<MT,false,false,true>::at(
size_t index )
const 4274 if( index >=
size() ) {
4277 return (*
this)[index];
4291 template<
typename MT >
4294 return matrix_.begin( row_ );
4308 template<
typename MT >
4311 return matrix_.cbegin( row_ );
4325 template<
typename MT >
4328 return matrix_.cbegin( row_ );
4342 template<
typename MT >
4345 return matrix_.end( row_ );
4359 template<
typename MT >
4362 return matrix_.cend( row_ );
4376 template<
typename MT >
4379 return matrix_.cend( row_ );
4407 template<
typename MT >
4408 inline Row<MT,false,false,true>& Row<MT,false,false,true>::operator=(
const Row& rhs )
4410 using blaze::assign;
4416 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
4419 if(
size() != rhs.size() ) {
4423 if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
4427 decltype(
auto) left( derestrict( *this ) );
4429 if( rhs.canAlias( &matrix_ ) ) {
4432 left.reserve( tmp.nonZeros() );
4433 assign( left, tmp );
4437 left.reserve( rhs.nonZeros() );
4438 assign( left, rhs );
4463 template<
typename MT >
4464 template<
typename VT >
4465 inline Row<MT,false,false,true>&
4466 Row<MT,false,false,true>::operator=(
const DenseVector<VT,true>& rhs )
4468 using blaze::assign;
4478 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
4479 Right right( ~rhs );
4481 if( !tryAssign( matrix_, right, row_, 0UL ) ) {
4485 decltype(
auto) left( derestrict( *this ) );
4487 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4488 const ResultType_<VT> tmp( right );
4490 assign( left, tmp );
4494 assign( left, right );
4519 template<
typename MT >
4520 template<
typename VT >
4521 inline Row<MT,false,false,true>&
4522 Row<MT,false,false,true>::operator=(
const SparseVector<VT,true>& rhs )
4524 using blaze::assign;
4534 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
4535 Right right( ~rhs );
4537 if( !tryAssign( matrix_, right, row_, 0UL ) ) {
4541 decltype(
auto) left( derestrict( *this ) );
4543 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4544 const ResultType_<VT> tmp( right );
4546 left.reserve( tmp.nonZeros() );
4547 assign( left, tmp );
4551 left.reserve( right.nonZeros() );
4552 assign( left, right );
4577 template<
typename MT >
4578 template<
typename VT >
4579 inline Row<MT,false,false,true>&
4582 using blaze::assign;
4591 using AddType = AddTrait_< ResultType, ResultType_<VT> >;
4601 const AddType tmp( *
this + (~rhs) );
4603 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4607 decltype(
auto) left( derestrict( *this ) );
4610 assign( left, tmp );
4634 template< typename MT >
4635 template< typename VT >
4636 inline Row<MT,false,false,true>&
4637 Row<MT,false,false,true>::operator+=( const SparseVector<VT,true>& rhs )
4639 using blaze::assign;
4648 using AddType = AddTrait_< ResultType, ResultType_<VT> >;
4658 const AddType tmp( *
this + (~rhs) );
4660 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4664 decltype(
auto) left( derestrict( *this ) );
4667 left.reserve( tmp.nonZeros() );
4668 assign( left, tmp );
4693 template< typename MT >
4694 template< typename VT >
4695 inline Row<MT,false,false,true>&
4696 Row<MT,false,false,true>::operator-=( const DenseVector<VT,true>& rhs )
4698 using blaze::assign;
4707 using SubType = SubTrait_< ResultType, ResultType_<VT> >;
4717 const SubType tmp( *
this - (~rhs) );
4719 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4723 decltype(
auto) left( derestrict( *this ) );
4726 assign( left, tmp );
4751 template< typename MT >
4752 template< typename VT >
4753 inline Row<MT,false,false,true>&
4754 Row<MT,false,false,true>::operator-=( const SparseVector<VT,true>& rhs )
4756 using blaze::assign;
4765 using SubType = SubTrait_< ResultType, ResultType_<VT> >;
4775 const SubType tmp( *
this - (~rhs) );
4777 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4781 decltype(
auto) left( derestrict( *this ) );
4784 left.reserve( tmp.nonZeros() );
4785 assign( left, tmp );
4808 template< typename MT >
4809 template< typename VT >
4810 inline Row<MT,false,false,true>&
4811 Row<MT,false,false,true>::operator*=( const Vector<VT,true>& rhs )
4813 using blaze::assign;
4821 using MultType = MultTrait_< ResultType, ResultType_<VT> >;
4830 const MultType tmp( *
this * (~rhs) );
4832 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4836 decltype(
auto) left( derestrict( *this ) );
4839 assign( left, tmp );
4861 template< typename MT >
4862 template< typename VT >
4863 inline Row<MT,false,false,true>&
4864 Row<MT,false,false,true>::operator/=( const DenseVector<VT,true>& rhs )
4866 using blaze::assign;
4875 using DivType = DivTrait_< ResultType, ResultType_<VT> >;
4885 const DivType tmp( *
this / (~rhs) );
4887 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4891 decltype(
auto) left( derestrict( *this ) );
4894 assign( left, tmp );
4917 template< typename MT >
4918 template< typename VT >
4919 inline Row<MT,false,false,true>&
4920 Row<MT,false,false,true>::operator%=( const Vector<VT,true>& rhs )
4922 using blaze::assign;
4927 using CrossType = CrossTrait_< ResultType, ResultType_<VT> >;
4933 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
4937 const CrossType tmp( *
this % (~rhs) );
4939 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4943 decltype(
auto) left( derestrict( *this ) );
4946 assign( left, tmp );
4971 template< typename MT >
4972 template< typename Other >
4973 inline
EnableIf_<IsNumeric<Other>, Row<MT,false,false,true> >&
4974 Row<MT,false,false,true>::operator*=( Other rhs )
4979 element->value() *= rhs;
5004 template<
typename MT >
5005 template<
typename Other >
5006 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,true> >&
5013 using DT = DivTrait_<ElementType,Other>;
5014 using Tmp = If_< IsNumeric<DT>, DT, Other >;
5018 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
5019 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
5021 element->value() *= tmp;
5025 element->value() /= rhs;
5048 template<
typename MT >
5049 inline typename Row<MT,false,false,true>::Operand Row<MT,false,false,true>::operand() const noexcept
5063 template<
typename MT >
5078 template<
typename MT >
5081 return matrix_.columns();
5093 template<
typename MT >
5096 return matrix_.capacity( row_ );
5111 template<
typename MT >
5114 return matrix_.nonZeros( row_ );
5126 template<
typename MT >
5129 matrix_.reset( row_ );
5145 template<
typename MT >
5146 void Row<MT,false,false,true>::reserve(
size_t n )
5148 matrix_.reserve( row_, n );
5163 template<
typename MT >
5164 inline size_t Row<MT,false,false,true>::extendCapacity()
const 5169 size_t nonzeros( 2UL*
capacity()+1UL );
5170 nonzeros =
max( nonzeros, 7UL );
5171 nonzeros =
min( nonzeros,
size() );
5201 template<
typename MT >
5205 return matrix_.set( index, row_, value );
5224 template<
typename MT >
5226 Row<MT,false,false,true>::insert(
size_t index,
const ElementType& value )
5228 return matrix_.insert( index, row_, value );
5259 template<
typename MT >
5260 inline void Row<MT,false,false,true>::append(
size_t index,
const ElementType& value,
bool check )
5262 matrix_.append( index, row_, value, check );
5285 template<
typename MT >
5286 inline void Row<MT,false,false,true>::erase(
size_t index )
5288 matrix_.erase( index, row_ );
5303 template<
typename MT >
5305 Row<MT,false,false,true>::erase(
Iterator pos )
5307 return matrix_.erase( row_, pos );
5323 template<
typename MT >
5327 return matrix_.erase( row_, first, last );
5356 template<
typename MT >
5357 template<
typename Pred
5359 inline void Row<MT,false,false,true>::erase( Pred predicate )
5361 matrix_.erase( row_,
begin(),
end(), predicate );
5392 template<
typename MT >
5393 template<
typename Pred >
5394 inline void Row<MT,false,false,true>::erase(
Iterator first,
Iterator last, Pred predicate )
5396 matrix_.erase( row_, first, last, predicate );
5424 template<
typename MT >
5426 Row<MT,false,false,true>::find(
size_t index )
5428 return matrix_.find( index, row_ );
5448 template<
typename MT >
5450 Row<MT,false,false,true>::find(
size_t index )
const 5452 return matrix_.find( index, row_ );
5471 template<
typename MT >
5473 Row<MT,false,false,true>::lowerBound(
size_t index )
5475 return matrix_.lowerBound( index, row_ );
5494 template<
typename MT >
5496 Row<MT,false,false,true>::lowerBound(
size_t index )
const 5498 return matrix_.lowerBound( index, row_ );
5517 template<
typename MT >
5519 Row<MT,false,false,true>::upperBound(
size_t index )
5521 return matrix_.upperBound( index, row_ );
5540 template<
typename MT >
5542 Row<MT,false,false,true>::upperBound(
size_t index )
const 5544 return matrix_.upperBound( index, row_ );
5571 template<
typename MT >
5572 template<
typename Other >
5573 inline Row<MT,false,false,true>& Row<MT,false,false,true>::scale(
const Other& scalar )
5578 element->value() *= scalar;
5604 template<
typename MT >
5605 template<
typename Other >
5606 inline bool Row<MT,false,false,true>::canAlias(
const Other* alias )
const noexcept
5608 return matrix_.isAliased( alias );
5625 template<
typename MT >
5626 template<
typename Other >
5627 inline bool Row<MT,false,false,true>::isAliased(
const Other* alias )
const noexcept
5629 return matrix_.isAliased( alias );
5647 template<
typename MT >
5648 template<
typename VT >
5649 inline void Row<MT,false,false,true>::assign(
const DenseVector<VT,true>& rhs )
5654 for(
size_t i=0UL; i<
size(); ++i )
5656 if( matrix_.nonZeros( row_ ) == matrix_.capacity( row_ ) )
5657 matrix_.reserve( row_, extendCapacity() );
5659 matrix_.append( i, row_, (~rhs)[i],
true );
5678 template<
typename MT >
5679 template<
typename VT >
5680 inline void Row<MT,false,false,true>::assign(
const SparseVector<VT,true>& rhs )
5685 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
5686 matrix_.append( element->index(), row_, element->value(), true );
5705 template<
typename MT >
5706 template<
typename VT >
5707 inline void Row<MT,false,false,true>::addAssign(
const DenseVector<VT,true>& rhs )
5709 using AddType = AddTrait_< ResultType, ResultType_<VT> >;
5717 const AddType tmp(
serial( *
this + (~rhs) ) );
5718 matrix_.reset( row_ );
5737 template<
typename MT >
5738 template<
typename VT >
5739 inline void Row<MT,false,false,true>::addAssign(
const SparseVector<VT,true>& rhs )
5741 using AddType = AddTrait_< ResultType, ResultType_<VT> >;
5749 const AddType tmp(
serial( *
this + (~rhs) ) );
5750 matrix_.reset( row_ );
5751 matrix_.reserve( row_, tmp.nonZeros() );
5770 template<
typename MT >
5771 template<
typename VT >
5772 inline void Row<MT,false,false,true>::subAssign(
const DenseVector<VT,true>& rhs )
5774 using SubType = SubTrait_< ResultType, ResultType_<VT> >;
5782 const SubType tmp(
serial( *
this - (~rhs) ) );
5783 matrix_.reset( row_ );
5802 template<
typename MT >
5803 template<
typename VT >
5804 inline void Row<MT,false,false,true>::subAssign(
const SparseVector<VT,true>& rhs )
5806 using SubType = SubTrait_< ResultType, ResultType_<VT> >;
5814 const SubType tmp(
serial( *
this - (~rhs) ) );
5815 matrix_.reset( row_ );
5816 matrix_.reserve( row_, tmp.nonZeros() );
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
Headerfile for the generic min algorithm.
#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:356
Header file for basic type definitions.
Header file for the SparseVector base class.
Header file for the View base class.
Header file for the row trait.
Header file for the serial shim.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:265
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1411
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3078
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:198
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
Header file for the IsIntegral type trait.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3080
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1762
#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:3085
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:394
Column< MT > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:124
#define BLAZE_CONSTRAINT_MUST_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a symmetric matrix type...
Definition: Symmetric.h:60
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3086
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1393
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:1809
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:308
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:242
Constraint on the data type.
Row< MT > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:124
Constraint on the data type.
Headerfile for the generic max algorithm.
Header file for the DisableIf class template.
Header file for the implementation of the Row base template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3084
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3077
#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:3081
#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:3087
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Header file for the IsLower type trait.
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:61
Header file for the SparseElement base class.
Constraint on the data type.
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:264
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.
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Constraint on the data type.
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
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 addition trait.
Header file for the cross product trait.
Header file for the division trait.
Header file for the reset shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
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:819
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the IsReference type trait.
Header file for the RemoveReference type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3083
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:252
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: RowVector.h:61
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
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 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
Constraint on the transpose flag of vector types.
Header file for the IsExpression type trait class.