35 #ifndef _BLAZE_MATH_VIEWS_ROW_SPARSE_H_
36 #define _BLAZE_MATH_VIEWS_ROW_SPARSE_H_
109 template<
typename MT
111 class Row<MT,true,false,SF>
112 :
public SparseVector< Row<MT,true,false,SF>, true >
118 typedef If_< IsExpression<MT>, MT, MT& > Operand;
123 typedef Row<MT,true,false,SF>
This;
124 typedef SparseVector<This,true>
BaseType;
146 enum :
bool { smpAssignable =
false };
152 explicit inline Row( Operand matrix,
size_t index );
164 inline Reference operator[](
size_t index );
165 inline ConstReference operator[](
size_t index )
const;
166 inline Reference at(
size_t index );
167 inline ConstReference at(
size_t index )
const;
168 inline Iterator
begin ();
169 inline ConstIterator
begin ()
const;
170 inline ConstIterator
cbegin()
const;
171 inline Iterator
end ();
172 inline ConstIterator
end ()
const;
173 inline ConstIterator
cend ()
const;
180 inline Row& operator=(
const Row& rhs );
182 template<
typename VT >
inline Row& operator= (
const DenseVector<VT,true>& rhs );
183 template<
typename VT >
inline Row& operator= (
const SparseVector<VT,true>& 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 Vector<VT,true>& rhs );
189 template<
typename VT >
inline Row&
operator/=(
const DenseVector<VT,true>& rhs );
191 template<
typename Other >
192 inline EnableIf_<IsNumeric<Other>, Row >&
operator*=( Other rhs );
194 template<
typename Other >
195 inline EnableIf_<IsNumeric<Other>, Row >&
operator/=( Other rhs );
202 inline size_t size() const noexcept;
203 inline
size_t capacity() const noexcept;
206 inline Iterator
set (
size_t index, const ElementType& value );
207 inline Iterator insert (
size_t index, const ElementType& value );
208 inline
void erase (
size_t index );
209 inline Iterator erase ( Iterator pos );
210 inline Iterator erase ( Iterator first, Iterator last );
211 inline
void reserve(
size_t n );
212 template< typename Other > inline Row& scale ( const Other& scalar );
219 inline Iterator find (
size_t index );
220 inline ConstIterator find (
size_t index ) const;
221 inline Iterator lowerBound(
size_t index );
222 inline ConstIterator lowerBound(
size_t index ) const;
223 inline Iterator upperBound(
size_t index );
224 inline ConstIterator upperBound(
size_t index ) const;
231 inline
void append(
size_t index, const ElementType& value,
bool check=false );
238 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
239 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
241 template< typename VT > inline
void assign ( const DenseVector <VT,true>& rhs );
242 template< typename VT > inline
void assign ( const SparseVector<VT,true>& rhs );
243 template< typename VT > inline
void addAssign( const DenseVector <VT,true>& rhs );
244 template< typename VT > inline
void addAssign( const SparseVector<VT,true>& rhs );
245 template< typename VT > inline
void subAssign( const DenseVector <VT,true>& rhs );
246 template< typename VT > inline
void subAssign( const SparseVector<VT,true>& rhs );
254 inline
size_t extendCapacity() const noexcept;
267 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
268 friend
bool isIntact( const Row<MT2,SO2,DF2,SF2>&
row ) noexcept;
270 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
271 friend
bool isSame( const Row<MT2,SO2,DF2,SF2>& a, const Row<MT2,SO2,DF2,SF2>& b ) noexcept;
273 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
274 friend
bool tryAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
276 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
277 friend
bool tryAddAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
279 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
280 friend
bool trySubAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
282 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
283 friend
bool tryMultAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
285 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
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 DerestrictTrait_<This> left( derestrict( *
this ) );
584 if( rhs.canAlias( &matrix_ ) ) {
585 const ResultType tmp( rhs );
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 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
636 if( !tryAssign( matrix_, right, row_, 0UL ) ) {
640 DerestrictTrait_<This> 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 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
692 if( !tryAssign( matrix_, right, row_, 0UL ) ) {
696 DerestrictTrait_<This> 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 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
756 const AddType tmp( *
this + (~rhs) );
758 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
762 DerestrictTrait_<This> left( derestrict( *
this ) );
789 template<
typename MT
791 template<
typename VT >
803 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
813 const AddType tmp( *
this + (~rhs) );
815 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
819 DerestrictTrait_<This> left( derestrict( *
this ) );
822 left.reserve( tmp.nonZeros() );
848 template<
typename MT
850 template<
typename VT >
862 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
872 const SubType tmp( *
this - (~rhs) );
874 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
878 DerestrictTrait_<This> left( derestrict( *
this ) );
906 template<
typename MT
908 template<
typename VT >
920 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
930 const SubType tmp( *
this - (~rhs) );
932 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
936 DerestrictTrait_<This> left( derestrict( *
this ) );
939 left.reserve( tmp.nonZeros() );
963 template<
typename MT
965 template<
typename VT >
976 typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
985 const MultType tmp( *
this * (~rhs) );
987 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
991 DerestrictTrait_<This> left( derestrict( *
this ) );
1016 template<
typename MT
1018 template<
typename VT >
1021 using blaze::assign;
1030 typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
1040 const DivType tmp( *
this / (~rhs) );
1042 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
1046 DerestrictTrait_<This> left( derestrict( *
this ) );
1049 assign( left, tmp );
1074 template<
typename MT
1076 template<
typename Other >
1077 inline EnableIf_<IsNumeric<Other>, Row<MT,true,false,SF> >&
1082 for( Iterator element=
begin(); element!=
end(); ++element )
1083 element->value() *= rhs;
1108 template<
typename MT
1110 template<
typename Other >
1111 inline EnableIf_<IsNumeric<Other>, Row<MT,true,false,SF> >&
1118 typedef DivTrait_<ElementType,Other> DT;
1119 typedef If_< IsNumeric<DT>, DT, Other > Tmp;
1123 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
1124 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1125 for( Iterator element=
begin(); element!=
end(); ++element )
1126 element->value() *= tmp;
1129 for( Iterator element=
begin(); element!=
end(); ++element )
1130 element->value() /= rhs;
1153 template<
typename MT
1157 return matrix_.columns();
1169 template<
typename MT
1173 return matrix_.capacity( row_ );
1188 template<
typename MT
1192 return matrix_.nonZeros( row_ );
1204 template<
typename MT
1208 matrix_.reset( row_ );
1226 template<
typename MT
1231 return matrix_.set( row_, index, value );
1250 template<
typename MT
1253 Row<MT,true,false,SF>::insert(
size_t index,
const ElementType& value )
1255 return matrix_.insert( row_, index, value );
1270 template<
typename MT
1272 inline void Row<MT,true,false,SF>::erase(
size_t index )
1274 matrix_.erase( row_, index );
1289 template<
typename MT
1293 return matrix_.erase( row_, pos );
1309 template<
typename MT
1312 Row<MT,true,false,SF>::erase( Iterator first, Iterator last )
1314 return matrix_.erase( row_, first, last );
1330 template<
typename MT
1332 void Row<MT,true,false,SF>::reserve(
size_t n )
1334 matrix_.reserve( row_, n );
1351 template<
typename MT
1353 template<
typename Other >
1354 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::scale(
const Other& scalar )
1358 for( Iterator element=
begin(); element!=
end(); ++element )
1359 element->value() *= scalar;
1375 template<
typename MT
1377 inline size_t Row<MT,true,false,SF>::extendCapacity() const noexcept
1382 size_t nonzeros( 2UL*
capacity()+1UL );
1383 nonzeros =
max( nonzeros, 7UL );
1384 nonzeros =
min( nonzeros,
size() );
1416 template<
typename MT
1420 return matrix_.find( row_, index );
1440 template<
typename MT
1444 return matrix_.find( row_, index );
1463 template<
typename MT
1467 return matrix_.lowerBound( row_, index );
1486 template<
typename MT
1490 return matrix_.lowerBound( row_, index );
1509 template<
typename MT
1513 return matrix_.upperBound( row_, index );
1532 template<
typename MT
1536 return matrix_.upperBound( row_, index );
1575 template<
typename MT
1577 inline void Row<MT,true,false,SF>::append(
size_t index,
const ElementType& value,
bool check )
1579 matrix_.append( row_, index, value, check );
1604 template<
typename MT
1606 template<
typename Other >
1607 inline bool Row<MT,true,false,SF>::canAlias(
const Other* alias )
const noexcept
1609 return matrix_.isAliased( alias );
1626 template<
typename MT
1628 template<
typename Other >
1629 inline bool Row<MT,true,false,SF>::isAliased(
const Other* alias )
const noexcept
1631 return matrix_.isAliased( alias );
1649 template<
typename MT
1651 template<
typename VT >
1652 inline void Row<MT,true,false,SF>::assign(
const DenseVector<VT,true>& rhs )
1657 for(
size_t j=0UL; j<
size(); ++j )
1659 if( matrix_.nonZeros( row_ ) == matrix_.capacity( row_ ) )
1660 matrix_.reserve( row_, extendCapacity() );
1662 matrix_.append( row_, j, (~rhs)[j],
true );
1681 template<
typename MT
1683 template<
typename VT >
1684 inline void Row<MT,true,false,SF>::assign(
const SparseVector<VT,true>& rhs )
1689 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
1690 matrix_.append( row_, element->index(), element->value(), true );
1709 template<
typename MT
1711 template<
typename VT >
1712 inline void Row<MT,true,false,SF>::addAssign(
const DenseVector<VT,true>& rhs )
1714 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
1722 const AddType tmp(
serial( *
this + (~rhs) ) );
1723 matrix_.reset( row_ );
1742 template<
typename MT
1744 template<
typename VT >
1745 inline void Row<MT,true,false,SF>::addAssign(
const SparseVector<VT,true>& rhs )
1747 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
1755 const AddType tmp(
serial( *
this + (~rhs) ) );
1756 matrix_.reset( row_ );
1757 matrix_.reserve( row_, tmp.nonZeros() );
1776 template<
typename MT
1778 template<
typename VT >
1779 inline void Row<MT,true,false,SF>::subAssign(
const DenseVector<VT,true>& rhs )
1781 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
1789 const SubType tmp(
serial( *
this - (~rhs) ) );
1790 matrix_.reset( row_ );
1809 template<
typename MT
1811 template<
typename VT >
1812 inline void Row<MT,true,false,SF>::subAssign(
const SparseVector<VT,true>& rhs )
1814 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
1822 const SubType tmp(
serial( *
this - (~rhs) ) );
1823 matrix_.reset( row_ );
1824 matrix_.reserve( row_, tmp.nonZeros() );
1851 template<
typename MT >
1852 class Row<MT,false,false,false>
1853 :
public SparseVector< Row<MT,false,false,false>, true >
1859 typedef If_< IsExpression<MT>, MT, MT& > Operand;
1864 typedef Row<MT,false,false,false>
This;
1865 typedef SparseVector<This,true>
BaseType;
1882 template<
typename MatrixType
1883 ,
typename IteratorType >
1884 class RowElement :
private SparseElement
1894 enum :
bool { returnConst = IsConst<MatrixType>::value };
1899 typedef typename std::iterator_traits<IteratorType>::value_type SET;
1901 typedef Reference_<SET> RT;
1902 typedef ConstReference_<SET> CRT;
1907 typedef ValueType_<SET> ValueType;
1908 typedef size_t IndexType;
1909 typedef IfTrue_<returnConst,CRT,RT>
Reference;
1919 inline RowElement( IteratorType pos,
size_t column )
1931 template<
typename T >
inline RowElement& operator=(
const T& v ) {
1943 template<
typename T >
inline RowElement&
operator+=(
const T& v ) {
1955 template<
typename T >
inline RowElement&
operator-=(
const T& v ) {
1967 template<
typename T >
inline RowElement&
operator*=(
const T& v ) {
1979 template<
typename T >
inline RowElement&
operator/=(
const T& v ) {
1990 inline const RowElement* operator->()
const {
2000 inline Reference value()
const {
2001 return pos_->value();
2010 inline IndexType index()
const {
2026 template<
typename MatrixType
2027 ,
typename IteratorType >
2032 typedef std::forward_iterator_tag IteratorCategory;
2033 typedef RowElement<MatrixType,IteratorType> ValueType;
2034 typedef ValueType PointerType;
2035 typedef ValueType ReferenceType;
2036 typedef ptrdiff_t DifferenceType;
2039 typedef IteratorCategory iterator_category;
2040 typedef ValueType value_type;
2041 typedef PointerType pointer;
2042 typedef ReferenceType reference;
2043 typedef DifferenceType difference_type;
2049 inline RowIterator()
2050 : matrix_( nullptr )
2064 inline RowIterator( MatrixType& matrix,
size_t row,
size_t column )
2065 : matrix_( &matrix )
2070 for( ; column_<matrix_->columns(); ++column_ ) {
2071 pos_ = matrix_->find( row_, column_ );
2072 if( pos_ != matrix_->end( column_ ) )
break;
2085 inline RowIterator( MatrixType& matrix,
size_t row,
size_t column, IteratorType pos )
2086 : matrix_( &matrix )
2100 template<
typename MatrixType2,
typename IteratorType2 >
2101 inline RowIterator(
const RowIterator<MatrixType2,IteratorType2>& it )
2102 : matrix_( it.matrix_ )
2104 , column_( it.column_ )
2114 inline RowIterator& operator++() {
2116 for( ; column_<matrix_->columns(); ++column_ ) {
2117 pos_ = matrix_->find( row_, column_ );
2118 if( pos_ != matrix_->end( column_ ) )
break;
2130 inline const RowIterator operator++(
int ) {
2131 const RowIterator tmp( *
this );
2142 inline ReferenceType
operator*()
const {
2143 return ReferenceType( pos_, column_ );
2152 inline PointerType operator->()
const {
2153 return PointerType( pos_, column_ );
2163 template<
typename MatrixType2,
typename IteratorType2 >
2164 inline bool operator==(
const RowIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2165 return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
2175 template<
typename MatrixType2,
typename IteratorType2 >
2176 inline bool operator!=(
const RowIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2177 return !( *
this == rhs );
2187 inline DifferenceType
operator-(
const RowIterator& rhs )
const {
2188 size_t counter( 0UL );
2189 for(
size_t j=rhs.column_; j<column_; ++j ) {
2190 if( matrix_->find( row_, j ) != matrix_->end( j ) )
2199 MatrixType* matrix_;
2206 template<
typename MatrixType2,
typename IteratorType2 >
friend class RowIterator;
2207 template<
typename MT2,
bool SO2,
bool DF2,
bool SF2 >
friend class Row;
2214 typedef RowIterator< const MT, ConstIterator_<MT> >
ConstIterator;
2222 enum :
bool { smpAssignable =
false };
2228 explicit inline Row( Operand matrix,
size_t index );
2240 inline Reference operator[](
size_t index );
2241 inline ConstReference operator[](
size_t index )
const;
2242 inline Reference at(
size_t index );
2243 inline ConstReference at(
size_t index )
const;
2244 inline Iterator
begin ();
2245 inline ConstIterator
begin ()
const;
2246 inline ConstIterator
cbegin()
const;
2247 inline Iterator
end ();
2248 inline ConstIterator
end ()
const;
2249 inline ConstIterator
cend ()
const;
2256 inline Row& operator= (
const Row& rhs );
2257 template<
typename VT >
inline Row& operator= (
const Vector<VT,true>& rhs );
2258 template<
typename VT >
inline Row&
operator+=(
const Vector<VT,true>& rhs );
2259 template<
typename VT >
inline Row&
operator-=(
const Vector<VT,true>& rhs );
2260 template<
typename VT >
inline Row&
operator*=(
const Vector<VT,true>& rhs );
2261 template<
typename VT >
inline Row&
operator/=(
const DenseVector<VT,true>& rhs );
2263 template<
typename Other >
2264 inline EnableIf_<IsNumeric<Other>, Row >&
operator*=( Other rhs );
2266 template<
typename Other >
2267 inline EnableIf_<IsNumeric<Other>, Row >&
operator/=( Other rhs );
2274 inline size_t size() const noexcept;
2275 inline
size_t capacity() const noexcept;
2277 inline
void reset();
2278 inline Iterator
set (
size_t index, const ElementType& value );
2279 inline Iterator insert (
size_t index, const ElementType& value );
2280 inline
void erase (
size_t index );
2281 inline Iterator erase ( Iterator pos );
2282 inline Iterator erase ( Iterator first, Iterator last );
2283 inline
void reserve(
size_t n );
2284 template< typename Other > inline Row& scale ( const Other& scalar );
2291 inline Iterator find (
size_t index );
2292 inline ConstIterator find (
size_t index ) const;
2293 inline Iterator lowerBound(
size_t index );
2294 inline ConstIterator lowerBound(
size_t index ) const;
2295 inline Iterator upperBound(
size_t index );
2296 inline ConstIterator upperBound(
size_t index ) const;
2303 inline
void append(
size_t index, const ElementType& value,
bool check=false );
2310 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
2311 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
2313 template< typename VT > inline
void assign ( const DenseVector <VT,true>& rhs );
2314 template< typename VT > inline
void assign ( const SparseVector<VT,true>& rhs );
2315 template< typename VT > inline
void addAssign( const Vector<VT,true>& rhs );
2316 template< typename VT > inline
void subAssign( const Vector<VT,true>& rhs );
2330 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
2331 friend
bool isIntact( const Row<MT2,SO2,DF2,SF2>& row ) noexcept;
2333 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
2334 friend
bool isSame( const Row<MT2,SO2,DF2,SF2>& a, const Row<MT2,SO2,DF2,SF2>& b ) noexcept;
2336 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2337 friend
bool tryAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
2339 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2340 friend
bool tryAddAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
2342 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2343 friend
bool trySubAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
2345 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2346 friend
bool tryMultAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
2348 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
2349 friend
DerestrictTrait_< Row<MT2,SO2,DF2,SF2> > derestrict( Row<MT2,SO2,DF2,SF2>& row );
2382 template< typename MT >
2383 inline Row<MT,false,false,false>::Row( Operand matrix,
size_t index )
2387 if( matrix_.rows() <= index ) {
2413 template<
typename MT >
2415 Row<MT,false,false,false>::operator[](
size_t index )
2418 return matrix_(row_,index);
2434 template<
typename MT >
2436 Row<MT,false,false,false>::operator[](
size_t index )
const
2439 return const_cast<const MT&
>( matrix_ )(row_,index);
2456 template<
typename MT >
2458 Row<MT,false,false,false>::at(
size_t index )
2460 if( index >=
size() ) {
2463 return (*
this)[index];
2480 template<
typename MT >
2482 Row<MT,false,false,false>::at(
size_t index )
const
2484 if( index >=
size() ) {
2487 return (*
this)[index];
2501 template<
typename MT >
2504 return Iterator( matrix_, row_, 0UL );
2518 template<
typename MT >
2535 template<
typename MT >
2552 template<
typename MT >
2569 template<
typename MT >
2586 template<
typename MT >
2617 template<
typename MT >
2618 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator=(
const Row& rhs )
2620 using blaze::assign;
2626 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
2629 if(
size() != rhs.size() ) {
2633 if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
2637 DerestrictTrait_<This> left( derestrict( *
this ) );
2639 if( rhs.canAlias( &matrix_ ) ) {
2640 const ResultType tmp( rhs );
2641 assign( left, tmp );
2644 assign( left, rhs );
2669 template<
typename MT >
2670 template<
typename VT >
2671 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator=(
const Vector<VT,true>& rhs )
2673 using blaze::assign;
2679 const CompositeType_<VT> tmp( ~rhs );
2681 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2685 DerestrictTrait_<This> left( derestrict( *
this ) );
2687 assign( left, tmp );
2711 template<
typename MT >
2712 template<
typename VT >
2715 using blaze::assign;
2723 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
2732 const AddType tmp( *
this + (~rhs) );
2734 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2738 DerestrictTrait_<This> left( derestrict( *
this ) );
2740 assign( left, tmp );
2764 template<
typename MT >
2765 template<
typename VT >
2768 using blaze::assign;
2776 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
2785 const SubType tmp( *
this - (~rhs) );
2787 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2791 DerestrictTrait_<This> left( derestrict( *
this ) );
2793 assign( left, tmp );
2816 template<
typename MT >
2817 template<
typename VT >
2820 using blaze::assign;
2828 typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
2837 const MultType tmp( *
this * (~rhs) );
2839 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2843 DerestrictTrait_<This> left( derestrict( *
this ) );
2845 assign( left, tmp );
2867 template<
typename MT >
2868 template<
typename VT >
2869 inline Row<MT,false,false,false>&
2872 using blaze::assign;
2881 typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
2891 const DivType tmp( *
this / (~rhs) );
2893 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2897 DerestrictTrait_<This> left( derestrict( *
this ) );
2899 assign( left, tmp );
2924 template<
typename MT >
2925 template<
typename Other >
2926 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,false> >&
2931 for( Iterator element=
begin(); element!=
end(); ++element )
2932 element->value() *= rhs;
2957 template<
typename MT >
2958 template<
typename Other >
2959 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,false> >&
2966 typedef DivTrait_<ElementType,Other> DT;
2967 typedef If_< IsNumeric<DT>, DT, Other > Tmp;
2971 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2972 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2973 for( Iterator element=
begin(); element!=
end(); ++element )
2974 element->value() *= tmp;
2977 for( Iterator element=
begin(); element!=
end(); ++element )
2978 element->value() /= rhs;
3001 template<
typename MT >
3004 return matrix_.columns();
3016 template<
typename MT >
3019 return matrix_.columns();
3034 template<
typename MT >
3037 size_t counter( 0UL );
3038 for( ConstIterator element=
begin(); element!=
end(); ++element ) {
3053 template<
typename MT >
3056 const size_t jbegin( ( IsUpper<MT>::value )
3057 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3061 const size_t jend ( ( IsLower<MT>::value )
3062 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3067 for(
size_t j=jbegin; j<jend; ++j ) {
3068 matrix_.erase( row_, j );
3088 template<
typename MT >
3090 Row<MT,false,false,false>::insert(
size_t index,
const ElementType& value )
3092 return Iterator( matrix_, row_, index, matrix_.insert( row_, index, value ) );
3110 template<
typename MT >
3114 return Iterator( matrix_, row_, index, matrix_.set( row_, index, value ) );
3129 template<
typename MT >
3130 inline void Row<MT,false,false,false>::erase(
size_t index )
3132 matrix_.erase( row_, index );
3147 template<
typename MT >
3150 const size_t column( pos.column_ );
3152 if( column ==
size() )
3155 matrix_.erase( column, pos.pos_ );
3156 return Iterator( matrix_, row_, column+1UL );
3172 template<
typename MT >
3174 Row<MT,false,false,false>::erase( Iterator first, Iterator last )
3176 for( ; first!=last; ++first ) {
3177 matrix_.erase( first.column_, first.pos_ );
3195 template<
typename MT >
3196 void Row<MT,false,false,false>::reserve(
size_t n )
3217 template<
typename MT >
3218 template<
typename Other >
3219 inline Row<MT,false,false,false>& Row<MT,false,false,false>::scale(
const Other& scalar )
3223 for( Iterator element=
begin(); element!=
end(); ++element )
3224 element->value() *= scalar;
3253 template<
typename MT >
3256 const Iterator_<MT> pos( matrix_.find( row_, index ) );
3258 if( pos != matrix_.end( index ) )
3259 return Iterator( matrix_, row_, index, pos );
3281 template<
typename MT >
3283 Row<MT,false,false,false>::find(
size_t index )
const
3285 const ConstIterator_<MT> pos( matrix_.find( row_, index ) );
3287 if( pos != matrix_.end( index ) )
3309 template<
typename MT >
3311 Row<MT,false,false,false>::lowerBound(
size_t index )
3313 for(
size_t i=index; i<
size(); ++i )
3315 const Iterator_<MT> pos( matrix_.find( row_, i ) );
3317 if( pos != matrix_.end( i ) )
3318 return Iterator( matrix_, row_, i, pos );
3340 template<
typename MT >
3342 Row<MT,false,false,false>::lowerBound(
size_t index )
const
3344 for(
size_t i=index; i<
size(); ++i )
3346 const ConstIterator_<MT> pos( matrix_.find( row_, i ) );
3348 if( pos != matrix_.end( i ) )
3371 template<
typename MT >
3373 Row<MT,false,false,false>::upperBound(
size_t index )
3375 for(
size_t i=index+1UL; i<
size(); ++i )
3377 const Iterator_<MT> pos( matrix_.find( row_, i ) );
3379 if( pos != matrix_.end( i ) )
3380 return Iterator( matrix_, row_, i, pos );
3402 template<
typename MT >
3404 Row<MT,false,false,false>::upperBound(
size_t index )
const
3406 for(
size_t i=index+1UL; i<
size(); ++i )
3408 const ConstIterator_<MT> pos( matrix_.find( row_, i ) );
3410 if( pos != matrix_.end( i ) )
3453 template<
typename MT >
3454 inline void Row<MT,false,false,false>::append(
size_t index,
const ElementType& value,
bool check )
3457 matrix_.insert( row_, index, value );
3482 template<
typename MT >
3483 template<
typename Other >
3484 inline bool Row<MT,false,false,false>::canAlias(
const Other* alias )
const noexcept
3486 return matrix_.isAliased( alias );
3499 template<
typename MT >
3500 template<
typename Other >
3501 inline bool Row<MT,false,false,false>::isAliased(
const Other* alias )
const noexcept
3503 return matrix_.isAliased( alias );
3521 template<
typename MT >
3522 template<
typename VT >
3523 inline void Row<MT,false,false,false>::assign(
const DenseVector<VT,true>& rhs )
3527 for(
size_t j=0UL; j<(~rhs).
size(); ++j ) {
3528 matrix_(row_,j) = (~rhs)[j];
3547 template<
typename MT >
3548 template<
typename VT >
3549 inline void Row<MT,false,false,false>::assign(
const SparseVector<VT,true>& rhs )
3555 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
3556 for( ; j<element->index(); ++j )
3557 matrix_.erase( row_, j );
3558 matrix_(row_,j++) = element->value();
3560 for( ; j<
size(); ++j ) {
3561 matrix_.erase( row_, j );
3580 template<
typename MT >
3581 template<
typename VT >
3582 inline void Row<MT,false,false,false>::addAssign(
const Vector<VT,true>& rhs )
3584 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
3591 const AddType tmp(
serial( *
this + (~rhs) ) );
3610 template<
typename MT >
3611 template<
typename VT >
3612 inline void Row<MT,false,false,false>::subAssign(
const Vector<VT,true>& rhs )
3614 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
3621 const SubType tmp(
serial( *
this - (~rhs) ) );
3648 template<
typename MT >
3649 class Row<MT,false,false,true>
3650 :
public SparseVector< Row<MT,false,false,true>, true >
3656 typedef If_< IsExpression<MT>, MT, MT& > Operand;
3661 typedef Row<MT,false,false,true>
This;
3662 typedef SparseVector<This,true>
BaseType;
3684 enum :
bool { smpAssignable =
false };
3690 explicit inline Row( Operand matrix,
size_t index );
3702 inline Reference operator[](
size_t index );
3703 inline ConstReference operator[](
size_t index )
const;
3704 inline Reference at(
size_t index );
3705 inline ConstReference at(
size_t index )
const;
3706 inline Iterator
begin ();
3707 inline ConstIterator
begin ()
const;
3708 inline ConstIterator
cbegin()
const;
3709 inline Iterator
end ();
3710 inline ConstIterator
end ()
const;
3711 inline ConstIterator
cend ()
const;
3718 inline Row& operator=(
const Row& rhs );
3720 template<
typename VT >
inline Row& operator= (
const DenseVector<VT,true>& rhs );
3721 template<
typename VT >
inline Row& operator= (
const SparseVector<VT,true>& rhs );
3722 template<
typename VT >
inline Row&
operator+=(
const DenseVector<VT,true>& rhs );
3723 template<
typename VT >
inline Row&
operator+=(
const SparseVector<VT,true>& rhs );
3724 template<
typename VT >
inline Row&
operator-=(
const DenseVector<VT,true>& rhs );
3725 template<
typename VT >
inline Row&
operator-=(
const SparseVector<VT,true>& rhs );
3726 template<
typename VT >
inline Row&
operator*=(
const Vector<VT,true>& rhs );
3727 template<
typename VT >
inline Row&
operator/=(
const DenseVector<VT,true>& rhs );
3729 template<
typename Other >
3730 inline EnableIf_<IsNumeric<Other>, Row >&
operator*=( Other rhs );
3732 template<
typename Other >
3733 inline EnableIf_<IsNumeric<Other>, Row >&
operator/=( Other rhs );
3740 inline size_t size() const noexcept;
3741 inline
size_t capacity() const noexcept;
3743 inline
void reset();
3744 inline Iterator
set (
size_t index, const ElementType& value );
3745 inline Iterator insert (
size_t index, const ElementType& value );
3746 inline
void erase (
size_t index );
3747 inline Iterator erase ( Iterator pos );
3748 inline Iterator erase ( Iterator first, Iterator last );
3749 inline
void reserve(
size_t n );
3750 template< typename Other > inline Row& scale ( const Other& scalar );
3757 inline Iterator find (
size_t index );
3758 inline ConstIterator find (
size_t index ) const;
3759 inline Iterator lowerBound(
size_t index );
3760 inline ConstIterator lowerBound(
size_t index ) const;
3761 inline Iterator upperBound(
size_t index );
3762 inline ConstIterator upperBound(
size_t index ) const;
3769 inline
void append(
size_t index, const ElementType& value,
bool check=false );
3776 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
3777 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
3779 template< typename VT > inline
void assign ( const DenseVector <VT,true>& rhs );
3780 template< typename VT > inline
void assign ( const SparseVector<VT,true>& rhs );
3781 template< typename VT > inline
void addAssign( const DenseVector <VT,true>& rhs );
3782 template< typename VT > inline
void addAssign( const SparseVector<VT,true>& rhs );
3783 template< typename VT > inline
void subAssign( const DenseVector <VT,true>& rhs );
3784 template< typename VT > inline
void subAssign( const SparseVector<VT,true>& rhs );
3792 inline
size_t extendCapacity() const;
3805 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
3806 friend
bool isIntact( const Row<MT2,SO2,DF2,SF2>& row ) noexcept;
3808 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
3809 friend
bool isSame( const Row<MT2,SO2,DF2,SF2>& a, const Row<MT2,SO2,DF2,SF2>& b ) noexcept;
3811 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
3812 friend
bool tryAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
3814 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
3815 friend
bool tryAddAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
3817 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
3818 friend
bool trySubAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
3820 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
3821 friend
bool tryMultAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs,
size_t index );
3823 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
3824 friend
DerestrictTrait_< Row<MT2,SO2,DF2,SF2> > derestrict( Row<MT2,SO2,DF2,SF2>& row );
3857 template< typename MT >
3858 inline Row<MT,false,false,true>::Row( Operand matrix,
size_t index )
3862 if( matrix_.rows() <= index ) {
3888 template<
typename MT >
3890 Row<MT,false,false,true>::operator[](
size_t index )
3893 return matrix_(index,row_);
3909 template<
typename MT >
3911 Row<MT,false,false,true>::operator[](
size_t index )
const
3914 return const_cast<const MT&
>( matrix_ )(index,row_);
3931 template<
typename MT >
3933 Row<MT,false,false,true>::at(
size_t index )
3935 if( index >=
size() ) {
3938 return (*
this)[index];
3955 template<
typename MT >
3957 Row<MT,false,false,true>::at(
size_t index )
const
3959 if( index >=
size() ) {
3962 return (*
this)[index];
3976 template<
typename MT >
3979 return matrix_.begin( row_ );
3993 template<
typename MT >
3996 return matrix_.cbegin( row_ );
4010 template<
typename MT >
4013 return matrix_.cbegin( row_ );
4027 template<
typename MT >
4030 return matrix_.end( row_ );
4044 template<
typename MT >
4047 return matrix_.cend( row_ );
4061 template<
typename MT >
4064 return matrix_.cend( row_ );
4092 template<
typename MT >
4093 inline Row<MT,false,false,true>& Row<MT,false,false,true>::operator=(
const Row& rhs )
4095 using blaze::assign;
4101 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
4104 if(
size() != rhs.size() ) {
4108 if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
4112 DerestrictTrait_<This> left( derestrict( *
this ) );
4114 if( rhs.canAlias( &matrix_ ) ) {
4115 const ResultType tmp( rhs );
4117 left.reserve( tmp.nonZeros() );
4118 assign( left, tmp );
4122 left.reserve( rhs.nonZeros() );
4123 assign( left, rhs );
4148 template<
typename MT >
4149 template<
typename VT >
4150 inline Row<MT,false,false,true>&
4151 Row<MT,false,false,true>::operator=(
const DenseVector<VT,true>& rhs )
4153 using blaze::assign;
4163 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
4164 Right right( ~rhs );
4166 if( !tryAssign( matrix_, right, row_, 0UL ) ) {
4170 DerestrictTrait_<This> left( derestrict( *
this ) );
4172 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4173 const ResultType_<VT> tmp( right );
4175 assign( left, tmp );
4179 assign( left, right );
4204 template<
typename MT >
4205 template<
typename VT >
4206 inline Row<MT,false,false,true>&
4207 Row<MT,false,false,true>::operator=(
const SparseVector<VT,true>& rhs )
4209 using blaze::assign;
4219 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
4220 Right right( ~rhs );
4222 if( !tryAssign( matrix_, right, row_, 0UL ) ) {
4226 DerestrictTrait_<This> left( derestrict( *
this ) );
4228 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4229 const ResultType_<VT> tmp( right );
4231 left.reserve( tmp.nonZeros() );
4232 assign( left, tmp );
4236 left.reserve( right.nonZeros() );
4237 assign( left, right );
4262 template<
typename MT >
4263 template<
typename VT >
4264 inline Row<MT,false,false,true>&
4267 using blaze::assign;
4276 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
4286 const AddType tmp( *
this + (~rhs) );
4288 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4292 DerestrictTrait_<This> left( derestrict( *
this ) );
4295 assign( left, tmp );
4319 template<
typename MT >
4320 template<
typename VT >
4321 inline Row<MT,false,false,true>&
4324 using blaze::assign;
4333 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
4343 const AddType tmp( *
this + (~rhs) );
4345 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4349 DerestrictTrait_<This> left( derestrict( *
this ) );
4352 left.reserve( tmp.nonZeros() );
4353 assign( left, tmp );
4378 template<
typename MT >
4379 template<
typename VT >
4380 inline Row<MT,false,false,true>&
4383 using blaze::assign;
4392 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
4402 const SubType tmp( *
this - (~rhs) );
4404 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4408 DerestrictTrait_<This> left( derestrict( *
this ) );
4411 assign( left, tmp );
4436 template<
typename MT >
4437 template<
typename VT >
4438 inline Row<MT,false,false,true>&
4441 using blaze::assign;
4450 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
4460 const SubType tmp( *
this - (~rhs) );
4462 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4466 DerestrictTrait_<This> left( derestrict( *
this ) );
4469 left.reserve( tmp.nonZeros() );
4470 assign( left, tmp );
4493 template<
typename MT >
4494 template<
typename VT >
4495 inline Row<MT,false,false,true>&
4498 using blaze::assign;
4506 typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
4515 const MultType tmp( *
this * (~rhs) );
4517 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4521 DerestrictTrait_<This> left( derestrict( *
this ) );
4524 assign( left, tmp );
4546 template<
typename MT >
4547 template<
typename VT >
4548 inline Row<MT,false,false,true>&
4551 using blaze::assign;
4560 typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
4570 const DivType tmp( *
this / (~rhs) );
4572 if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4576 DerestrictTrait_<This> left( derestrict( *
this ) );
4579 assign( left, tmp );
4604 template<
typename MT >
4605 template<
typename Other >
4606 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,true> >&
4611 for( Iterator element=
begin(); element!=
end(); ++element )
4612 element->value() *= rhs;
4637 template<
typename MT >
4638 template<
typename Other >
4639 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,true> >&
4646 typedef DivTrait_<ElementType,Other> DT;
4647 typedef If_< IsNumeric<DT>, DT, Other > Tmp;
4651 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
4652 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
4653 for( Iterator element=
begin(); element!=
end(); ++element )
4654 element->value() *= tmp;
4657 for( Iterator element=
begin(); element!=
end(); ++element )
4658 element->value() /= rhs;
4681 template<
typename MT >
4684 return matrix_.columns();
4696 template<
typename MT >
4699 return matrix_.capacity( row_ );
4714 template<
typename MT >
4717 return matrix_.nonZeros( row_ );
4729 template<
typename MT >
4732 matrix_.reset( row_ );
4750 template<
typename MT >
4754 return matrix_.set( index, row_, value );
4773 template<
typename MT >
4775 Row<MT,false,false,true>::insert(
size_t index,
const ElementType& value )
4777 return matrix_.insert( index, row_, value );
4792 template<
typename MT >
4793 inline void Row<MT,false,false,true>::erase(
size_t index )
4795 matrix_.erase( index, row_ );
4810 template<
typename MT >
4812 Row<MT,false,false,true>::erase( Iterator pos )
4814 return matrix_.erase( row_, pos );
4830 template<
typename MT >
4832 Row<MT,false,false,true>::erase( Iterator first, Iterator last )
4834 return matrix_.erase( row_, first, last );
4850 template<
typename MT >
4851 void Row<MT,false,false,true>::reserve(
size_t n )
4853 matrix_.reserve( row_, n );
4870 template<
typename MT >
4871 template<
typename Other >
4872 inline Row<MT,false,false,true>& Row<MT,false,false,true>::scale(
const Other& scalar )
4876 for( Iterator element=
begin(); element!=
end(); ++element )
4877 element->value() *= scalar;
4893 template<
typename MT >
4894 inline size_t Row<MT,false,false,true>::extendCapacity()
const
4899 size_t nonzeros( 2UL*
capacity()+1UL );
4900 nonzeros =
max( nonzeros, 7UL );
4901 nonzeros =
min( nonzeros,
size() );
4933 template<
typename MT >
4935 Row<MT,false,false,true>::find(
size_t index )
4937 return matrix_.find( index, row_ );
4957 template<
typename MT >
4959 Row<MT,false,false,true>::find(
size_t index )
const
4961 return matrix_.find( index, row_ );
4980 template<
typename MT >
4982 Row<MT,false,false,true>::lowerBound(
size_t index )
4984 return matrix_.lowerBound( index, row_ );
5003 template<
typename MT >
5005 Row<MT,false,false,true>::lowerBound(
size_t index )
const
5007 return matrix_.lowerBound( index, row_ );
5026 template<
typename MT >
5028 Row<MT,false,false,true>::upperBound(
size_t index )
5030 return matrix_.upperBound( index, row_ );
5049 template<
typename MT >
5051 Row<MT,false,false,true>::upperBound(
size_t index )
const
5053 return matrix_.upperBound( index, row_ );
5092 template<
typename MT >
5093 inline void Row<MT,false,false,true>::append(
size_t index,
const ElementType& value,
bool check )
5095 matrix_.append( index, row_, value, check );
5120 template<
typename MT >
5121 template<
typename Other >
5122 inline bool Row<MT,false,false,true>::canAlias(
const Other* alias )
const noexcept
5124 return matrix_.isAliased( alias );
5141 template<
typename MT >
5142 template<
typename Other >
5143 inline bool Row<MT,false,false,true>::isAliased(
const Other* alias )
const noexcept
5145 return matrix_.isAliased( alias );
5163 template<
typename MT >
5164 template<
typename VT >
5165 inline void Row<MT,false,false,true>::assign(
const DenseVector<VT,true>& rhs )
5170 for(
size_t i=0UL; i<
size(); ++i )
5172 if( matrix_.nonZeros( row_ ) == matrix_.capacity( row_ ) )
5173 matrix_.reserve( row_, extendCapacity() );
5175 matrix_.append( i, row_, (~rhs)[i],
true );
5194 template<
typename MT >
5195 template<
typename VT >
5196 inline void Row<MT,false,false,true>::assign(
const SparseVector<VT,true>& rhs )
5201 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
5202 matrix_.append( element->index(), row_, element->value(), true );
5221 template<
typename MT >
5222 template<
typename VT >
5223 inline void Row<MT,false,false,true>::addAssign(
const DenseVector<VT,true>& rhs )
5225 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
5233 const AddType tmp(
serial( *
this + (~rhs) ) );
5234 matrix_.reset( row_ );
5253 template<
typename MT >
5254 template<
typename VT >
5255 inline void Row<MT,false,false,true>::addAssign(
const SparseVector<VT,true>& rhs )
5257 typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
5265 const AddType tmp(
serial( *
this + (~rhs) ) );
5266 matrix_.reset( row_ );
5267 matrix_.reserve( row_, tmp.nonZeros() );
5286 template<
typename MT >
5287 template<
typename VT >
5288 inline void Row<MT,false,false,true>::subAssign(
const DenseVector<VT,true>& rhs )
5290 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
5298 const SubType tmp(
serial( *
this - (~rhs) ) );
5299 matrix_.reset( row_ );
5318 template<
typename MT >
5319 template<
typename VT >
5320 inline void Row<MT,false,false,true>::subAssign(
const SparseVector<VT,true>& rhs )
5322 typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
5330 const SubType tmp(
serial( *
this - (~rhs) ) );
5331 matrix_.reset( row_ );
5332 matrix_.reserve( row_, tmp.nonZeros() );
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
Header file for mathematical functions.
typename DerestrictTrait< T >::Type DerestrictTrait_
Auxiliary alias declaration for the DerestrictTrait type trait.The DerestrictTrait_ alias declaration...
Definition: DerestrictTrait.h:110
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7800
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:346
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:653
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:258
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2643
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2636
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
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:384
#define BLAZE_CONSTRAINT_MUST_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a symmetric matrix type...
Definition: Symmetric.h:60
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Header file for the IsUniLower type trait.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:126
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:298
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:232
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
Constraint on the data type.
Header file for the implementation of the Row base template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
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.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
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:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
Constraint on the data type.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the DerestrictTrait class template.
Constraint on the data type.
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:126
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2642
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the division trait.
Header file for the reset shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the IsReference type trait.
Header file for the RemoveReference type trait.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2637
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2638
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
#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
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
Header file for the IsUpper type trait.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the IsRestricted type trait.
#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.