Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_ROW_SPARSE_H_
36 #define _BLAZE_MATH_VIEWS_ROW_SPARSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <blaze/math/Aliases.h>
56 #include <blaze/math/Exception.h>
59 #include <blaze/math/Functions.h>
61 #include <blaze/math/shims/Reset.h>
79 #include <blaze/util/Assert.h>
82 #include <blaze/util/DisableIf.h>
83 #include <blaze/util/EnableIf.h>
84 #include <blaze/util/mpl/If.h>
85 #include <blaze/util/Types.h>
92 #include <blaze/util/Unused.h>
93 
94 
95 namespace blaze {
96 
97 //=================================================================================================
98 //
99 // CLASS TEMPLATE SPECIALIZATION FOR ROW-MAJOR SPARSE MATRICES
100 //
101 //=================================================================================================
102 
103 //*************************************************************************************************
111 template< typename MT // Type of the sparse matrix
112  , bool SF > // Symmetry flag
113 class Row<MT,true,false,SF>
114  : public SparseVector< Row<MT,true,false,SF>, true >
115  , private View
116 {
117  private:
118  //**Type definitions****************************************************************************
120  typedef If_< IsExpression<MT>, MT, MT& > Operand;
121  //**********************************************************************************************
122 
123  public:
124  //**Type definitions****************************************************************************
125  typedef Row<MT,true,false,SF> This;
126  typedef SparseVector<This,true> BaseType;
127  typedef RowTrait_<MT> ResultType;
128  typedef TransposeType_<ResultType> TransposeType;
129  typedef ElementType_<MT> ElementType;
130  typedef ReturnType_<MT> ReturnType;
131  typedef const Row& CompositeType;
132 
134  typedef ConstReference_<MT> ConstReference;
135 
137  typedef If_< IsConst<MT>, ConstReference, Reference_<MT> > Reference;
138 
140  typedef ConstIterator_<MT> ConstIterator;
141 
143  typedef If_< IsConst<MT>, ConstIterator, Iterator_<MT> > Iterator;
144  //**********************************************************************************************
145 
146  //**Compilation flags***************************************************************************
148  enum : bool { smpAssignable = false };
149  //**********************************************************************************************
150 
151  //**Constructors********************************************************************************
154  explicit inline Row( Operand matrix, size_t index );
155  // No explicitly declared copy constructor.
157  //**********************************************************************************************
158 
159  //**Destructor**********************************************************************************
160  // No explicitly declared destructor.
161  //**********************************************************************************************
162 
163  //**Data access functions***********************************************************************
166  inline Reference operator[]( size_t index );
167  inline ConstReference operator[]( size_t index ) const;
168  inline Reference at( size_t index );
169  inline ConstReference at( size_t index ) const;
170  inline Iterator begin ();
171  inline ConstIterator begin () const;
172  inline ConstIterator cbegin() const;
173  inline Iterator end ();
174  inline ConstIterator end () const;
175  inline ConstIterator cend () const;
177  //**********************************************************************************************
178 
179  //**Assignment operators************************************************************************
182  inline Row& operator=( const Row& rhs );
183 
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 
193  template< typename Other >
194  inline EnableIf_<IsNumeric<Other>, Row >& operator*=( Other rhs );
195 
196  template< typename Other >
197  inline EnableIf_<IsNumeric<Other>, Row >& operator/=( Other rhs );
199  //**********************************************************************************************
200 
201  //**Utility functions***************************************************************************
204  inline size_t size() const noexcept;
205  inline size_t capacity() const noexcept;
206  inline size_t nonZeros() const;
207  inline void reset();
208  inline void reserve( size_t n );
210  //**********************************************************************************************
211 
212  //**Insertion functions*************************************************************************
215  inline Iterator set ( size_t index, const ElementType& value );
216  inline Iterator insert( size_t index, const ElementType& value );
217  inline void append( size_t index, const ElementType& value, bool check=false );
219  //**********************************************************************************************
220 
221  //**Erase functions*****************************************************************************
224  inline void erase( size_t index );
225  inline Iterator erase( Iterator pos );
226  inline Iterator erase( Iterator first, Iterator last );
227 
228  template< typename Pred, typename = DisableIf_< IsIntegral<Pred> > >
229  inline void erase( Pred predicate );
230 
231  template< typename Pred >
232  inline void erase( Iterator first, Iterator last, Pred predicate );
234  //**********************************************************************************************
235 
236  //**Lookup functions****************************************************************************
239  inline Iterator find ( size_t index );
240  inline ConstIterator find ( size_t index ) const;
241  inline Iterator lowerBound( size_t index );
242  inline ConstIterator lowerBound( size_t index ) const;
243  inline Iterator upperBound( size_t index );
244  inline ConstIterator upperBound( size_t index ) const;
246  //**********************************************************************************************
247 
248  //**Numeric functions***************************************************************************
251  template< typename Other > inline Row& scale( const Other& scalar );
253  //**********************************************************************************************
254 
255  //**Expression template evaluation functions****************************************************
258  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
259  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
260 
261  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
262  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
263  template< typename VT > inline void addAssign( const DenseVector <VT,true>& rhs );
264  template< typename VT > inline void addAssign( const SparseVector<VT,true>& rhs );
265  template< typename VT > inline void subAssign( const DenseVector <VT,true>& rhs );
266  template< typename VT > inline void subAssign( const SparseVector<VT,true>& rhs );
268  //**********************************************************************************************
269 
270  private:
271  //**Utility functions***************************************************************************
274  inline size_t extendCapacity() const noexcept;
276  //**********************************************************************************************
277 
278  //**Member variables****************************************************************************
281  Operand matrix_;
282  const size_t row_;
283 
284  //**********************************************************************************************
285 
286  //**Friend declarations*************************************************************************
287  template< typename MT2, bool SO2, bool DF2, bool SF2 >
288  friend bool isIntact( const Row<MT2,SO2,DF2,SF2>& row ) noexcept;
289 
290  template< typename MT2, bool SO2, bool DF2, bool SF2 >
291  friend bool isSame( const Row<MT2,SO2,DF2,SF2>& a, const Row<MT2,SO2,DF2,SF2>& b ) noexcept;
292 
293  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
294  friend bool tryAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
295 
296  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
297  friend bool tryAddAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
298 
299  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
300  friend bool trySubAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
301 
302  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
303  friend bool tryMultAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
304 
305  template< typename MT2, bool SO2, bool DF2, bool SF2 >
306  friend DerestrictTrait_< Row<MT2,SO2,DF2,SF2> > derestrict( Row<MT2,SO2,DF2,SF2>& row );
307  //**********************************************************************************************
308 
309  //**Compile time checks*************************************************************************
316  //**********************************************************************************************
317 };
319 //*************************************************************************************************
320 
321 
322 
323 
324 //=================================================================================================
325 //
326 // CONSTRUCTOR
327 //
328 //=================================================================================================
329 
330 //*************************************************************************************************
338 template< typename MT // Type of the sparse matrix
339  , bool SF > // Symmetry flag
340 inline Row<MT,true,false,SF>::Row( Operand matrix, size_t index )
341  : matrix_( matrix ) // The sparse matrix containing the row
342  , row_ ( index ) // The index of the row in the matrix
343 {
344  if( matrix_.rows() <= index ) {
345  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
346  }
347 }
349 //*************************************************************************************************
350 
351 
352 
353 
354 //=================================================================================================
355 //
356 // DATA ACCESS FUNCTIONS
357 //
358 //=================================================================================================
359 
360 //*************************************************************************************************
370 template< typename MT // Type of the sparse matrix
371  , bool SF > // Symmetry flag
372 inline typename Row<MT,true,false,SF>::Reference Row<MT,true,false,SF>::operator[]( size_t index )
373 {
374  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
375  return matrix_(row_,index);
376 }
378 //*************************************************************************************************
379 
380 
381 //*************************************************************************************************
391 template< typename MT // Type of the sparse matrix
392  , bool SF > // Symmetry flag
394  Row<MT,true,false,SF>::operator[]( size_t index ) const
395 {
396  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
397  return const_cast<const MT&>( matrix_ )(row_,index);
398 }
400 //*************************************************************************************************
401 
402 
403 //*************************************************************************************************
414 template< typename MT // Type of the sparse matrix
415  , bool SF > // Symmetry flag
416 inline typename Row<MT,true,false,SF>::Reference Row<MT,true,false,SF>::at( size_t index )
417 {
418  if( index >= size() ) {
419  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
420  }
421  return (*this)[index];
422 }
424 //*************************************************************************************************
425 
426 
427 //*************************************************************************************************
438 template< typename MT // Type of the sparse matrix
439  , bool SF > // Symmetry flag
440 inline typename Row<MT,true,false,SF>::ConstReference Row<MT,true,false,SF>::at( size_t index ) const
441 {
442  if( index >= size() ) {
443  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
444  }
445  return (*this)[index];
446 }
448 //*************************************************************************************************
449 
450 
451 //*************************************************************************************************
459 template< typename MT // Type of the sparse matrix
460  , bool SF > // Symmetry flag
462 {
463  return matrix_.begin( row_ );
464 }
466 //*************************************************************************************************
467 
468 
469 //*************************************************************************************************
477 template< typename MT // Type of the sparse matrix
478  , bool SF > // Symmetry flag
480 {
481  return matrix_.cbegin( row_ );
482 }
484 //*************************************************************************************************
485 
486 
487 //*************************************************************************************************
495 template< typename MT // Type of the sparse matrix
496  , bool SF > // Symmetry flag
498 {
499  return matrix_.cbegin( row_ );
500 }
502 //*************************************************************************************************
503 
504 
505 //*************************************************************************************************
513 template< typename MT // Type of the sparse matrix
514  , bool SF > // Symmetry flag
516 {
517  return matrix_.end( row_ );
518 }
520 //*************************************************************************************************
521 
522 
523 //*************************************************************************************************
531 template< typename MT // Type of the sparse matrix
532  , bool SF > // Symmetry flag
534 {
535  return matrix_.cend( row_ );
536 }
538 //*************************************************************************************************
539 
540 
541 //*************************************************************************************************
549 template< typename MT // Type of the sparse matrix
550  , bool SF > // Symmetry flag
552 {
553  return matrix_.cend( row_ );
554 }
556 //*************************************************************************************************
557 
558 
559 
560 
561 //=================================================================================================
562 //
563 // ASSIGNMENT OPERATORS
564 //
565 //=================================================================================================
566 
567 //*************************************************************************************************
581 template< typename MT // Type of the sparse matrix
582  , bool SF > // Symmetry flag
583 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator=( const Row& rhs )
584 {
585  using blaze::assign;
586 
590 
591  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
592  return *this;
593 
594  if( size() != rhs.size() ) {
595  BLAZE_THROW_INVALID_ARGUMENT( "Row sizes do not match" );
596  }
597 
598  if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
599  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
600  }
601 
602  DerestrictTrait_<This> left( derestrict( *this ) );
603 
604  if( rhs.canAlias( &matrix_ ) ) {
605  const ResultType tmp( rhs );
606  left.reset();
607  left.reserve( tmp.nonZeros() );
608  assign( left, tmp );
609  }
610  else {
611  left.reset();
612  left.reserve( rhs.nonZeros() );
613  assign( left, rhs );
614  }
615 
616  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
617 
618  return *this;
619 }
621 //*************************************************************************************************
622 
623 
624 //*************************************************************************************************
638 template< typename MT // Type of the sparse matrix
639  , bool SF > // Symmetry flag
640 template< typename VT > // Type of the right-hand side dense vector
641 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator=( const DenseVector<VT,true>& rhs )
642 {
643  using blaze::assign;
644 
645  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
646  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
648 
649  if( size() != (~rhs).size() ) {
650  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
651  }
652 
653  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
654  Right right( ~rhs );
655 
656  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
657  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
658  }
659 
660  DerestrictTrait_<This> left( derestrict( *this ) );
661 
662  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
663  const ResultType_<VT> tmp( right );
664  left.reset();
665  assign( left, tmp );
666  }
667  else {
668  left.reset();
669  assign( left, right );
670  }
671 
672  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
673 
674  return *this;
675 }
677 //*************************************************************************************************
678 
679 
680 //*************************************************************************************************
694 template< typename MT // Type of the sparse matrix
695  , bool SF > // Symmetry flag
696 template< typename VT > // Type of the right-hand side sparse vector
697 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator=( const SparseVector<VT,true>& rhs )
698 {
699  using blaze::assign;
700 
702  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
704 
705  if( size() != (~rhs).size() ) {
706  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
707  }
708 
709  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
710  Right right( ~rhs );
711 
712  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
713  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
714  }
715 
716  DerestrictTrait_<This> left( derestrict( *this ) );
717 
718  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
719  const ResultType_<VT> tmp( right );
720  left.reset();
721  left.reserve( tmp.nonZeros() );
722  assign( left, tmp );
723  }
724  else {
725  left.reset();
726  left.reserve( right.nonZeros() );
727  assign( left, right );
728  }
729 
730  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
731 
732  return *this;
733 }
735 //*************************************************************************************************
736 
737 
738 //*************************************************************************************************
752 template< typename MT // Type of the sparse matrix
753  , bool SF > // Symmetry flag
754 template< typename VT > // Type of the right-hand side dense vector
755 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator+=( const DenseVector<VT,true>& rhs )
756 {
757  using blaze::assign;
758 
762  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
763  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
765 
766  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
767 
771 
772  if( size() != (~rhs).size() ) {
773  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
774  }
775 
776  const AddType tmp( *this + (~rhs) );
777 
778  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
779  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
780  }
781 
782  DerestrictTrait_<This> left( derestrict( *this ) );
783 
784  left.reset();
785  assign( left, tmp );
786 
787  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
788 
789  return *this;
790 }
792 //*************************************************************************************************
793 
794 
795 //*************************************************************************************************
809 template< typename MT // Type of the sparse matrix
810  , bool SF > // Symmetry flag
811 template< typename VT > // Type of the right-hand side sparse vector
812 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator+=( const SparseVector<VT,true>& rhs )
813 {
814  using blaze::assign;
815 
820  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
822 
823  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
824 
828 
829  if( size() != (~rhs).size() ) {
830  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
831  }
832 
833  const AddType tmp( *this + (~rhs) );
834 
835  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
836  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
837  }
838 
839  DerestrictTrait_<This> left( derestrict( *this ) );
840 
841  left.reset();
842  left.reserve( tmp.nonZeros() );
843  assign( left, tmp );
844 
845  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
846 
847  return *this;
848 }
850 //*************************************************************************************************
851 
852 
853 //*************************************************************************************************
868 template< typename MT // Type of the sparse matrix
869  , bool SF > // Symmetry flag
870 template< typename VT > // Type of the right-hand side dense vector
871 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator-=( const DenseVector<VT,true>& rhs )
872 {
873  using blaze::assign;
874 
878  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
879  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
881 
882  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
883 
887 
888  if( size() != (~rhs).size() ) {
889  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
890  }
891 
892  const SubType tmp( *this - (~rhs) );
893 
894  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
895  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
896  }
897 
898  DerestrictTrait_<This> left( derestrict( *this ) );
899 
900  left.reset();
901  assign( left, tmp );
902 
903  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
904 
905  return *this;
906 }
908 //*************************************************************************************************
909 
910 
911 //*************************************************************************************************
926 template< typename MT // Type of the sparse matrix
927  , bool SF > // Symmetry flag
928 template< typename VT > // Type of the right-hand side sparse vector
929 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator-=( const SparseVector<VT,true>& rhs )
930 {
931  using blaze::assign;
932 
937  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
939 
940  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
941 
945 
946  if( size() != (~rhs).size() ) {
947  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
948  }
949 
950  const SubType tmp( *this - (~rhs) );
951 
952  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
953  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
954  }
955 
956  DerestrictTrait_<This> left( derestrict( *this ) );
957 
958  left.reset();
959  left.reserve( tmp.nonZeros() );
960  assign( left, tmp );
961 
962  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
963 
964  return *this;
965 }
967 //*************************************************************************************************
968 
969 
970 //*************************************************************************************************
983 template< typename MT // Type of the sparse matrix
984  , bool SF > // Symmetry flag
985 template< typename VT > // Type of the right-hand side vector
986 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator*=( const Vector<VT,true>& rhs )
987 {
988  using blaze::assign;
989 
993  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
995 
996  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
997 
1000 
1001  if( size() != (~rhs).size() ) {
1002  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1003  }
1004 
1005  const MultType tmp( *this * (~rhs) );
1006 
1007  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
1008  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1009  }
1010 
1011  DerestrictTrait_<This> left( derestrict( *this ) );
1012 
1013  left.reset();
1014  assign( left, tmp );
1015 
1016  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1017 
1018  return *this;
1019 }
1021 //*************************************************************************************************
1022 
1023 
1024 //*************************************************************************************************
1036 template< typename MT // Type of the sparse matrix
1037  , bool SF > // Symmetry flag
1038 template< typename VT > // Type of the right-hand side vector
1039 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator/=( const DenseVector<VT,true>& rhs )
1040 {
1041  using blaze::assign;
1042 
1046  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
1047  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
1049 
1050  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
1051 
1055 
1056  if( size() != (~rhs).size() ) {
1057  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1058  }
1059 
1060  const DivType tmp( *this / (~rhs) );
1061 
1062  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
1063  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1064  }
1065 
1066  DerestrictTrait_<This> left( derestrict( *this ) );
1067 
1068  left.reset();
1069  assign( left, tmp );
1070 
1071  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1072 
1073  return *this;
1074 }
1076 //*************************************************************************************************
1077 
1078 
1079 //*************************************************************************************************
1094 template< typename MT // Type of the sparse matrix
1095  , bool SF > // Symmetry flag
1096 template< typename Other > // Data type of the right-hand side scalar
1097 inline EnableIf_<IsNumeric<Other>, Row<MT,true,false,SF> >&
1099 {
1101 
1102  for( Iterator element=begin(); element!=end(); ++element )
1103  element->value() *= rhs;
1104  return *this;
1105 }
1107 //*************************************************************************************************
1108 
1109 
1110 //*************************************************************************************************
1128 template< typename MT // Type of the sparse matrix
1129  , bool SF > // Symmetry flag
1130 template< typename Other > // Data type of the right-hand side scalar
1131 inline EnableIf_<IsNumeric<Other>, Row<MT,true,false,SF> >&
1133 {
1135 
1136  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1137 
1138  typedef DivTrait_<ElementType,Other> DT;
1139  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
1140 
1141  // Depending on the two involved data types, an integer division is applied or a
1142  // floating point division is selected.
1143  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
1144  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1145  for( Iterator element=begin(); element!=end(); ++element )
1146  element->value() *= tmp;
1147  }
1148  else {
1149  for( Iterator element=begin(); element!=end(); ++element )
1150  element->value() /= rhs;
1151  }
1152 
1153  return *this;
1154 }
1156 //*************************************************************************************************
1157 
1158 
1159 
1160 
1161 //=================================================================================================
1162 //
1163 // UTILITY FUNCTIONS
1164 //
1165 //=================================================================================================
1166 
1167 //*************************************************************************************************
1173 template< typename MT // Type of the sparse matrix
1174  , bool SF > // Symmetry flag
1175 inline size_t Row<MT,true,false,SF>::size() const noexcept
1176 {
1177  return matrix_.columns();
1178 }
1180 //*************************************************************************************************
1181 
1182 
1183 //*************************************************************************************************
1189 template< typename MT // Type of the sparse matrix
1190  , bool SF > // Symmetry flag
1191 inline size_t Row<MT,true,false,SF>::capacity() const noexcept
1192 {
1193  return matrix_.capacity( row_ );
1194 }
1196 //*************************************************************************************************
1197 
1198 
1199 //*************************************************************************************************
1208 template< typename MT // Type of the sparse matrix
1209  , bool SF > // Symmetry flag
1210 inline size_t Row<MT,true,false,SF>::nonZeros() const
1211 {
1212  return matrix_.nonZeros( row_ );
1213 }
1215 //*************************************************************************************************
1216 
1217 
1218 //*************************************************************************************************
1224 template< typename MT // Type of the sparse matrix
1225  , bool SF > // Symmetry flag
1226 inline void Row<MT,true,false,SF>::reset()
1227 {
1228  matrix_.reset( row_ );
1229 }
1231 //*************************************************************************************************
1232 
1233 
1234 //*************************************************************************************************
1244 template< typename MT // Type of the sparse matrix
1245  , bool SF > // Symmetry flag
1246 void Row<MT,true,false,SF>::reserve( size_t n )
1247 {
1248  matrix_.reserve( row_, n );
1249 }
1251 //*************************************************************************************************
1252 
1253 
1254 //*************************************************************************************************
1263 template< typename MT // Type of the sparse matrix
1264  , bool SF > // Symmetry flag
1265 inline size_t Row<MT,true,false,SF>::extendCapacity() const noexcept
1266 {
1267  using blaze::max;
1268  using blaze::min;
1269 
1270  size_t nonzeros( 2UL*capacity()+1UL );
1271  nonzeros = max( nonzeros, 7UL );
1272  nonzeros = min( nonzeros, size() );
1273 
1274  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
1275 
1276  return nonzeros;
1277 }
1279 //*************************************************************************************************
1280 
1281 
1282 
1283 
1284 //=================================================================================================
1285 //
1286 // INSERTION FUNCTIONS
1287 //
1288 //=================================================================================================
1289 
1290 //*************************************************************************************************
1302 template< typename MT // Type of the sparse matrix
1303  , bool SF > // Symmetry flag
1304 inline typename Row<MT,true,false,SF>::Iterator
1305  Row<MT,true,false,SF>::set( size_t index, const ElementType& value )
1306 {
1307  return matrix_.set( row_, index, value );
1308 }
1310 //*************************************************************************************************
1311 
1312 
1313 //*************************************************************************************************
1326 template< typename MT // Type of the sparse matrix
1327  , bool SF > // Symmetry flag
1328 inline typename Row<MT,true,false,SF>::Iterator
1329  Row<MT,true,false,SF>::insert( size_t index, const ElementType& value )
1330 {
1331  return matrix_.insert( row_, index, value );
1332 }
1334 //*************************************************************************************************
1335 
1336 
1337 //*************************************************************************************************
1362 template< typename MT // Type of the sparse matrix
1363  , bool SF > // Symmetry flag
1364 inline void Row<MT,true,false,SF>::append( size_t index, const ElementType& value, bool check )
1365 {
1366  matrix_.append( row_, index, value, check );
1367 }
1369 //*************************************************************************************************
1370 
1371 
1372 
1373 
1374 //=================================================================================================
1375 //
1376 // ERASE FUNCTIONS
1377 //
1378 //=================================================================================================
1379 
1380 //*************************************************************************************************
1389 template< typename MT // Type of the sparse matrix
1390  , bool SF > // Symmetry flag
1391 inline void Row<MT,true,false,SF>::erase( size_t index )
1392 {
1393  matrix_.erase( row_, index );
1394 }
1396 //*************************************************************************************************
1397 
1398 
1399 //*************************************************************************************************
1408 template< typename MT // Type of the sparse matrix
1409  , bool SF > // Symmetry flag
1410 inline typename Row<MT,true,false,SF>::Iterator Row<MT,true,false,SF>::erase( Iterator pos )
1411 {
1412  return matrix_.erase( row_, pos );
1413 }
1415 //*************************************************************************************************
1416 
1417 
1418 //*************************************************************************************************
1428 template< typename MT // Type of the sparse matrix
1429  , bool SF > // Symmetry flag
1430 inline typename Row<MT,true,false,SF>::Iterator
1431  Row<MT,true,false,SF>::erase( Iterator first, Iterator last )
1432 {
1433  return matrix_.erase( row_, first, last );
1434 }
1436 //*************************************************************************************************
1437 
1438 
1439 //*************************************************************************************************
1462 template< typename MT // Type of the sparse matrix
1463  , bool SF > // Symmetry flag
1464 template< typename Pred // Type of the unary predicate
1465  , typename > // Type restriction on the unary predicate
1466 inline void Row<MT,true,false,SF>::erase( Pred predicate )
1467 {
1468  matrix_.erase( row_, begin(), end(), predicate );
1469 }
1471 //*************************************************************************************************
1472 
1473 
1474 //*************************************************************************************************
1499 template< typename MT // Type of the sparse matrix
1500  , bool SF > // Symmetry flag
1501 template< typename Pred > // Type of the unary predicate
1502 inline void Row<MT,true,false,SF>::erase( Iterator first, Iterator last, Pred predicate )
1503 {
1504  matrix_.erase( row_, first, last, predicate );
1505 }
1507 //*************************************************************************************************
1508 
1509 
1510 
1511 
1512 //=================================================================================================
1513 //
1514 // LOOKUP FUNCTIONS
1515 //
1516 //=================================================================================================
1517 
1518 //*************************************************************************************************
1532 template< typename MT // Type of the sparse matrix
1533  , bool SF > // Symmetry flag
1534 inline typename Row<MT,true,false,SF>::Iterator Row<MT,true,false,SF>::find( size_t index )
1535 {
1536  return matrix_.find( row_, index );
1537 }
1539 //*************************************************************************************************
1540 
1541 
1542 //*************************************************************************************************
1556 template< typename MT // Type of the sparse matrix
1557  , bool SF > // Symmetry flag
1558 inline typename Row<MT,true,false,SF>::ConstIterator Row<MT,true,false,SF>::find( size_t index ) const
1559 {
1560  return matrix_.find( row_, index );
1561 }
1563 //*************************************************************************************************
1564 
1565 
1566 //*************************************************************************************************
1579 template< typename MT // Type of the sparse matrix
1580  , bool SF > // Symmetry flag
1581 inline typename Row<MT,true,false,SF>::Iterator Row<MT,true,false,SF>::lowerBound( size_t index )
1582 {
1583  return matrix_.lowerBound( row_, index );
1584 }
1586 //*************************************************************************************************
1587 
1588 
1589 //*************************************************************************************************
1602 template< typename MT // Type of the sparse matrix
1603  , bool SF > // Symmetry flag
1604 inline typename Row<MT,true,false,SF>::ConstIterator Row<MT,true,false,SF>::lowerBound( size_t index ) const
1605 {
1606  return matrix_.lowerBound( row_, index );
1607 }
1609 //*************************************************************************************************
1610 
1611 
1612 //*************************************************************************************************
1625 template< typename MT // Type of the sparse matrix
1626  , bool SF > // Symmetry flag
1627 inline typename Row<MT,true,false,SF>::Iterator Row<MT,true,false,SF>::upperBound( size_t index )
1628 {
1629  return matrix_.upperBound( row_, index );
1630 }
1632 //*************************************************************************************************
1633 
1634 
1635 //*************************************************************************************************
1648 template< typename MT // Type of the sparse matrix
1649  , bool SF > // Symmetry flag
1650 inline typename Row<MT,true,false,SF>::ConstIterator Row<MT,true,false,SF>::upperBound( size_t index ) const
1651 {
1652  return matrix_.upperBound( row_, index );
1653 }
1655 //*************************************************************************************************
1656 
1657 
1658 
1659 
1660 //=================================================================================================
1661 //
1662 // NUMERIC FUNCTIONS
1663 //
1664 //=================================================================================================
1665 
1666 //*************************************************************************************************
1677 template< typename MT // Type of the sparse matrix
1678  , bool SF > // Symmetry flag
1679 template< typename Other > // Data type of the scalar value
1680 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::scale( const Other& scalar )
1681 {
1683 
1684  for( Iterator element=begin(); element!=end(); ++element )
1685  element->value() *= scalar;
1686  return *this;
1687 }
1689 //*************************************************************************************************
1690 
1691 
1692 
1693 
1694 //=================================================================================================
1695 //
1696 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1697 //
1698 //=================================================================================================
1699 
1700 //*************************************************************************************************
1711 template< typename MT // Type of the sparse matrix
1712  , bool SF > // Symmetry flag
1713 template< typename Other > // Data type of the foreign expression
1714 inline bool Row<MT,true,false,SF>::canAlias( const Other* alias ) const noexcept
1715 {
1716  return matrix_.isAliased( alias );
1717 }
1719 //*************************************************************************************************
1720 
1721 
1722 //*************************************************************************************************
1733 template< typename MT // Type of the sparse matrix
1734  , bool SF > // Symmetry flag
1735 template< typename Other > // Data type of the foreign expression
1736 inline bool Row<MT,true,false,SF>::isAliased( const Other* alias ) const noexcept
1737 {
1738  return matrix_.isAliased( alias );
1739 }
1741 //*************************************************************************************************
1742 
1743 
1744 //*************************************************************************************************
1756 template< typename MT // Type of the sparse matrix
1757  , bool SF > // Symmetry flag
1758 template< typename VT > // Type of the right-hand side dense vector
1759 inline void Row<MT,true,false,SF>::assign( const DenseVector<VT,true>& rhs )
1760 {
1761  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1762  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1763 
1764  for( size_t j=0UL; j<size(); ++j )
1765  {
1766  if( matrix_.nonZeros( row_ ) == matrix_.capacity( row_ ) )
1767  matrix_.reserve( row_, extendCapacity() );
1768 
1769  matrix_.append( row_, j, (~rhs)[j], true );
1770  }
1771 }
1773 //*************************************************************************************************
1774 
1775 
1776 //*************************************************************************************************
1788 template< typename MT // Type of the sparse matrix
1789  , bool SF > // Symmetry flag
1790 template< typename VT > // Type of the right-hand side sparse vector
1791 inline void Row<MT,true,false,SF>::assign( const SparseVector<VT,true>& rhs )
1792 {
1793  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1794  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1795 
1796  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
1797  matrix_.append( row_, element->index(), element->value(), true );
1798  }
1799 }
1801 //*************************************************************************************************
1802 
1803 
1804 //*************************************************************************************************
1816 template< typename MT // Type of the sparse matrix
1817  , bool SF > // Symmetry flag
1818 template< typename VT > // Type of the right-hand side dense vector
1819 inline void Row<MT,true,false,SF>::addAssign( const DenseVector<VT,true>& rhs )
1820 {
1821  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
1822 
1826 
1827  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1828 
1829  const AddType tmp( serial( *this + (~rhs) ) );
1830  matrix_.reset( row_ );
1831  assign( tmp );
1832 }
1834 //*************************************************************************************************
1835 
1836 
1837 //*************************************************************************************************
1849 template< typename MT // Type of the sparse matrix
1850  , bool SF > // Symmetry flag
1851 template< typename VT > // Type of the right-hand side sparse vector
1852 inline void Row<MT,true,false,SF>::addAssign( const SparseVector<VT,true>& rhs )
1853 {
1854  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
1855 
1859 
1860  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1861 
1862  const AddType tmp( serial( *this + (~rhs) ) );
1863  matrix_.reset( row_ );
1864  matrix_.reserve( row_, tmp.nonZeros() );
1865  assign( tmp );
1866 }
1868 //*************************************************************************************************
1869 
1870 
1871 //*************************************************************************************************
1883 template< typename MT // Type of the sparse matrix
1884  , bool SF > // Symmetry flag
1885 template< typename VT > // Type of the right-hand side dense vector
1886 inline void Row<MT,true,false,SF>::subAssign( const DenseVector<VT,true>& rhs )
1887 {
1888  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
1889 
1893 
1894  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1895 
1896  const SubType tmp( serial( *this - (~rhs) ) );
1897  matrix_.reset( row_ );
1898  assign( tmp );
1899 }
1901 //*************************************************************************************************
1902 
1903 
1904 //*************************************************************************************************
1916 template< typename MT // Type of the sparse matrix
1917  , bool SF > // Symmetry flag
1918 template< typename VT > // Type of the right-hand side sparse vector
1919 inline void Row<MT,true,false,SF>::subAssign( const SparseVector<VT,true>& rhs )
1920 {
1921  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
1922 
1926 
1927  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1928 
1929  const SubType tmp( serial( *this - (~rhs) ) );
1930  matrix_.reset( row_ );
1931  matrix_.reserve( row_, tmp.nonZeros() );
1932  assign( tmp );
1933 }
1935 //*************************************************************************************************
1936 
1937 
1938 
1939 
1940 
1941 
1942 
1943 
1944 //=================================================================================================
1945 //
1946 // CLASS TEMPLATE SPECIALIZATION FOR GENERAL COLUMN-MAJOR SPARSE MATRICES
1947 //
1948 //=================================================================================================
1949 
1950 //*************************************************************************************************
1958 template< typename MT > // Type of the sparse matrix
1959 class Row<MT,false,false,false>
1960  : public SparseVector< Row<MT,false,false,false>, true >
1961  , private View
1962 {
1963  private:
1964  //**Type definitions****************************************************************************
1966  typedef If_< IsExpression<MT>, MT, MT& > Operand;
1967  //**********************************************************************************************
1968 
1969  public:
1970  //**Type definitions****************************************************************************
1971  typedef Row<MT,false,false,false> This;
1972  typedef SparseVector<This,true> BaseType;
1973  typedef RowTrait_<MT> ResultType;
1974  typedef TransposeType_<ResultType> TransposeType;
1975  typedef ElementType_<MT> ElementType;
1976  typedef ReturnType_<MT> ReturnType;
1977  typedef const Row& CompositeType;
1978 
1980  typedef ConstReference_<MT> ConstReference;
1981 
1983  typedef If_< IsConst<MT>, ConstReference, Reference_<MT> > Reference;
1984  //**********************************************************************************************
1985 
1986  //**RowElement class definition*****************************************************************
1989  template< typename MatrixType // Type of the sparse matrix
1990  , typename IteratorType > // Type of the sparse matrix iterator
1991  class RowElement : private SparseElement
1992  {
1993  private:
1994  //*******************************************************************************************
1996 
2001  enum : bool { returnConst = IsConst<MatrixType>::value };
2002  //*******************************************************************************************
2003 
2004  //**Type definitions*************************************************************************
2006  typedef typename std::iterator_traits<IteratorType>::value_type SET;
2007 
2008  typedef Reference_<SET> RT;
2009  typedef ConstReference_<SET> CRT;
2010  //*******************************************************************************************
2011 
2012  public:
2013  //**Type definitions*************************************************************************
2014  typedef ValueType_<SET> ValueType;
2015  typedef size_t IndexType;
2016  typedef IfTrue_<returnConst,CRT,RT> Reference;
2017  typedef CRT ConstReference;
2018  //*******************************************************************************************
2019 
2020  //**Constructor******************************************************************************
2026  inline RowElement( IteratorType pos, size_t column )
2027  : pos_ ( pos ) // Iterator to the current position within the sparse row
2028  , column_( column ) // Index of the according column
2029  {}
2030  //*******************************************************************************************
2031 
2032  //**Assignment operator**********************************************************************
2038  template< typename T > inline RowElement& operator=( const T& v ) {
2039  *pos_ = v;
2040  return *this;
2041  }
2042  //*******************************************************************************************
2043 
2044  //**Addition assignment operator*************************************************************
2050  template< typename T > inline RowElement& operator+=( const T& v ) {
2051  *pos_ += v;
2052  return *this;
2053  }
2054  //*******************************************************************************************
2055 
2056  //**Subtraction assignment operator**********************************************************
2062  template< typename T > inline RowElement& operator-=( const T& v ) {
2063  *pos_ -= v;
2064  return *this;
2065  }
2066  //*******************************************************************************************
2067 
2068  //**Multiplication assignment operator*******************************************************
2074  template< typename T > inline RowElement& operator*=( const T& v ) {
2075  *pos_ *= v;
2076  return *this;
2077  }
2078  //*******************************************************************************************
2079 
2080  //**Division assignment operator*************************************************************
2086  template< typename T > inline RowElement& operator/=( const T& v ) {
2087  *pos_ /= v;
2088  return *this;
2089  }
2090  //*******************************************************************************************
2091 
2092  //**Element access operator******************************************************************
2097  inline const RowElement* operator->() const {
2098  return this;
2099  }
2100  //*******************************************************************************************
2101 
2102  //**Value function***************************************************************************
2107  inline Reference value() const {
2108  return pos_->value();
2109  }
2110  //*******************************************************************************************
2111 
2112  //**Index function***************************************************************************
2117  inline IndexType index() const {
2118  return column_;
2119  }
2120  //*******************************************************************************************
2121 
2122  private:
2123  //**Member variables*************************************************************************
2124  IteratorType pos_;
2125  size_t column_;
2126  //*******************************************************************************************
2127  };
2128  //**********************************************************************************************
2129 
2130  //**RowIterator class definition****************************************************************
2133  template< typename MatrixType // Type of the sparse matrix
2134  , typename IteratorType > // Type of the sparse matrix iterator
2135  class RowIterator
2136  {
2137  public:
2138  //**Type definitions*************************************************************************
2139  typedef std::forward_iterator_tag IteratorCategory;
2140  typedef RowElement<MatrixType,IteratorType> ValueType;
2141  typedef ValueType PointerType;
2142  typedef ValueType ReferenceType;
2143  typedef ptrdiff_t DifferenceType;
2144 
2145  // STL iterator requirements
2146  typedef IteratorCategory iterator_category;
2147  typedef ValueType value_type;
2148  typedef PointerType pointer;
2149  typedef ReferenceType reference;
2150  typedef DifferenceType difference_type;
2151  //*******************************************************************************************
2152 
2153  //**Constructor******************************************************************************
2156  inline RowIterator()
2157  : matrix_( nullptr ) // The sparse matrix containing the row.
2158  , row_ ( 0UL ) // The current row index.
2159  , column_( 0UL ) // The current column index.
2160  , pos_ () // Iterator to the current sparse element.
2161  {}
2162  //*******************************************************************************************
2163 
2164  //**Constructor******************************************************************************
2171  inline RowIterator( MatrixType& matrix, size_t row, size_t column )
2172  : matrix_( &matrix ) // The sparse matrix containing the row.
2173  , row_ ( row ) // The current row index.
2174  , column_( column ) // The current column index.
2175  , pos_ () // Iterator to the current sparse element.
2176  {
2177  for( ; column_<matrix_->columns(); ++column_ ) {
2178  pos_ = matrix_->find( row_, column_ );
2179  if( pos_ != matrix_->end( column_ ) ) break;
2180  }
2181  }
2182  //*******************************************************************************************
2183 
2184  //**Constructor******************************************************************************
2192  inline RowIterator( MatrixType& matrix, size_t row, size_t column, IteratorType pos )
2193  : matrix_( &matrix ) // The sparse matrix containing the row.
2194  , row_ ( row ) // The current row index.
2195  , column_( column ) // The current column index.
2196  , pos_ ( pos ) // Iterator to the current sparse element.
2197  {
2198  BLAZE_INTERNAL_ASSERT( matrix.find( row, column ) == pos, "Invalid initial iterator position" );
2199  }
2200  //*******************************************************************************************
2201 
2202  //**Constructor******************************************************************************
2207  template< typename MatrixType2, typename IteratorType2 >
2208  inline RowIterator( const RowIterator<MatrixType2,IteratorType2>& it )
2209  : matrix_( it.matrix_ ) // The sparse matrix containing the row.
2210  , row_ ( it.row_ ) // The current row index.
2211  , column_( it.column_ ) // The current column index.
2212  , pos_ ( it.pos_ ) // Iterator to the current sparse element.
2213  {}
2214  //*******************************************************************************************
2215 
2216  //**Prefix increment operator****************************************************************
2221  inline RowIterator& operator++() {
2222  ++column_;
2223  for( ; column_<matrix_->columns(); ++column_ ) {
2224  pos_ = matrix_->find( row_, column_ );
2225  if( pos_ != matrix_->end( column_ ) ) break;
2226  }
2227 
2228  return *this;
2229  }
2230  //*******************************************************************************************
2231 
2232  //**Postfix increment operator***************************************************************
2237  inline const RowIterator operator++( int ) {
2238  const RowIterator tmp( *this );
2239  ++(*this);
2240  return tmp;
2241  }
2242  //*******************************************************************************************
2243 
2244  //**Element access operator******************************************************************
2249  inline ReferenceType operator*() const {
2250  return ReferenceType( pos_, column_ );
2251  }
2252  //*******************************************************************************************
2253 
2254  //**Element access operator******************************************************************
2259  inline PointerType operator->() const {
2260  return PointerType( pos_, column_ );
2261  }
2262  //*******************************************************************************************
2263 
2264  //**Equality operator************************************************************************
2270  template< typename MatrixType2, typename IteratorType2 >
2271  inline bool operator==( const RowIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
2272  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
2273  }
2274  //*******************************************************************************************
2275 
2276  //**Inequality operator**********************************************************************
2282  template< typename MatrixType2, typename IteratorType2 >
2283  inline bool operator!=( const RowIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
2284  return !( *this == rhs );
2285  }
2286  //*******************************************************************************************
2287 
2288  //**Subtraction operator*********************************************************************
2294  inline DifferenceType operator-( const RowIterator& rhs ) const {
2295  size_t counter( 0UL );
2296  for( size_t j=rhs.column_; j<column_; ++j ) {
2297  if( matrix_->find( row_, j ) != matrix_->end( j ) )
2298  ++counter;
2299  }
2300  return counter;
2301  }
2302  //*******************************************************************************************
2303 
2304  private:
2305  //**Member variables*************************************************************************
2306  MatrixType* matrix_;
2307  size_t row_;
2308  size_t column_;
2309  IteratorType pos_;
2310  //*******************************************************************************************
2311 
2312  //**Friend declarations**********************************************************************
2313  template< typename MatrixType2, typename IteratorType2 > friend class RowIterator;
2314  template< typename MT2, bool SO2, bool DF2, bool SF2 > friend class Row;
2315  //*******************************************************************************************
2316  };
2317  //**********************************************************************************************
2318 
2319  //**Type definitions****************************************************************************
2321  typedef RowIterator< const MT, ConstIterator_<MT> > ConstIterator;
2322 
2324  typedef If_< IsConst<MT>, ConstIterator, RowIterator< MT, Iterator_<MT> > > Iterator;
2325  //**********************************************************************************************
2326 
2327  //**Compilation flags***************************************************************************
2329  enum : bool { smpAssignable = false };
2330  //**********************************************************************************************
2331 
2332  //**Constructors********************************************************************************
2335  explicit inline Row( Operand matrix, size_t index );
2336  // No explicitly declared copy constructor.
2338  //**********************************************************************************************
2339 
2340  //**Destructor**********************************************************************************
2341  // No explicitly declared destructor.
2342  //**********************************************************************************************
2343 
2344  //**Data access functions***********************************************************************
2347  inline Reference operator[]( size_t index );
2348  inline ConstReference operator[]( size_t index ) const;
2349  inline Reference at( size_t index );
2350  inline ConstReference at( size_t index ) const;
2351  inline Iterator begin ();
2352  inline ConstIterator begin () const;
2353  inline ConstIterator cbegin() const;
2354  inline Iterator end ();
2355  inline ConstIterator end () const;
2356  inline ConstIterator cend () const;
2358  //**********************************************************************************************
2359 
2360  //**Assignment operators************************************************************************
2363  inline Row& operator= ( const Row& rhs );
2364  template< typename VT > inline Row& operator= ( const Vector<VT,true>& rhs );
2365  template< typename VT > inline Row& operator+=( const Vector<VT,true>& rhs );
2366  template< typename VT > inline Row& operator-=( const Vector<VT,true>& rhs );
2367  template< typename VT > inline Row& operator*=( const Vector<VT,true>& rhs );
2368  template< typename VT > inline Row& operator/=( const DenseVector<VT,true>& rhs );
2369 
2370  template< typename Other >
2371  inline EnableIf_<IsNumeric<Other>, Row >& operator*=( Other rhs );
2372 
2373  template< typename Other >
2374  inline EnableIf_<IsNumeric<Other>, Row >& operator/=( Other rhs );
2376  //**********************************************************************************************
2377 
2378  //**Utility functions***************************************************************************
2381  inline size_t size() const noexcept;
2382  inline size_t capacity() const noexcept;
2383  inline size_t nonZeros() const;
2384  inline void reset();
2385  inline void reserve( size_t n );
2387  //**********************************************************************************************
2388 
2389  //**Insertion functions*************************************************************************
2392  inline Iterator set ( size_t index, const ElementType& value );
2393  inline Iterator insert( size_t index, const ElementType& value );
2394  inline void append( size_t index, const ElementType& value, bool check=false );
2396  //**********************************************************************************************
2397 
2398  //**Erase functions*****************************************************************************
2401  inline void erase( size_t index );
2402  inline Iterator erase( Iterator pos );
2403  inline Iterator erase( Iterator first, Iterator last );
2404 
2405  template< typename Pred, typename = DisableIf_< IsIntegral<Pred> > >
2406  inline void erase( Pred predicate );
2407 
2408  template< typename Pred >
2409  inline void erase( Iterator first, Iterator last, Pred predicate );
2411  //**********************************************************************************************
2412 
2413  //**Lookup functions****************************************************************************
2416  inline Iterator find ( size_t index );
2417  inline ConstIterator find ( size_t index ) const;
2418  inline Iterator lowerBound( size_t index );
2419  inline ConstIterator lowerBound( size_t index ) const;
2420  inline Iterator upperBound( size_t index );
2421  inline ConstIterator upperBound( size_t index ) const;
2423  //**********************************************************************************************
2424 
2425  //**Numeric functions***************************************************************************
2428  template< typename Other > inline Row& scale( const Other& scalar );
2430  //**********************************************************************************************
2431 
2432  //**Expression template evaluation functions****************************************************
2435  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
2436  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
2437 
2438  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
2439  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
2440  template< typename VT > inline void addAssign( const Vector<VT,true>& rhs );
2441  template< typename VT > inline void subAssign( const Vector<VT,true>& rhs );
2443  //**********************************************************************************************
2444 
2445  private:
2446  //**Member variables****************************************************************************
2449  Operand matrix_;
2450  const size_t row_;
2451 
2452  //**********************************************************************************************
2453 
2454  //**Friend declarations*************************************************************************
2455  template< typename MT2, bool SO2, bool DF2, bool SF2 >
2456  friend bool isIntact( const Row<MT2,SO2,DF2,SF2>& row ) noexcept;
2457 
2458  template< typename MT2, bool SO2, bool DF2, bool SF2 >
2459  friend bool isSame( const Row<MT2,SO2,DF2,SF2>& a, const Row<MT2,SO2,DF2,SF2>& b ) noexcept;
2460 
2461  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2462  friend bool tryAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
2463 
2464  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2465  friend bool tryAddAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
2466 
2467  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2468  friend bool trySubAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
2469 
2470  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2471  friend bool tryMultAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
2472 
2473  template< typename MT2, bool SO2, bool DF2, bool SF2 >
2474  friend DerestrictTrait_< Row<MT2,SO2,DF2,SF2> > derestrict( Row<MT2,SO2,DF2,SF2>& row );
2475  //**********************************************************************************************
2476 
2477  //**Compile time checks*************************************************************************
2485  //**********************************************************************************************
2486 };
2488 //*************************************************************************************************
2489 
2490 
2491 
2492 
2493 //=================================================================================================
2494 //
2495 // CONSTRUCTOR
2496 //
2497 //=================================================================================================
2498 
2499 //*************************************************************************************************
2507 template< typename MT > // Type of the sparse matrix
2508 inline Row<MT,false,false,false>::Row( Operand matrix, size_t index )
2509  : matrix_( matrix ) // The sparse matrix containing the row
2510  , row_ ( index ) // The index of the row in the matrix
2511 {
2512  if( matrix_.rows() <= index ) {
2513  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
2514  }
2515 }
2517 //*************************************************************************************************
2518 
2519 
2520 
2521 
2522 //=================================================================================================
2523 //
2524 // DATA ACCESS FUNCTIONS
2525 //
2526 //=================================================================================================
2527 
2528 //*************************************************************************************************
2538 template< typename MT > // Type of the sparse matrix
2540  Row<MT,false,false,false>::operator[]( size_t index )
2541 {
2542  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2543  return matrix_(row_,index);
2544 }
2546 //*************************************************************************************************
2547 
2548 
2549 //*************************************************************************************************
2559 template< typename MT > // Type of the sparse matrix
2561  Row<MT,false,false,false>::operator[]( size_t index ) const
2562 {
2563  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2564  return const_cast<const MT&>( matrix_ )(row_,index);
2565 }
2567 //*************************************************************************************************
2568 
2569 
2570 //*************************************************************************************************
2581 template< typename MT > // Type of the sparse matrix
2583  Row<MT,false,false,false>::at( size_t index )
2584 {
2585  if( index >= size() ) {
2586  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
2587  }
2588  return (*this)[index];
2589 }
2591 //*************************************************************************************************
2592 
2593 
2594 //*************************************************************************************************
2605 template< typename MT > // Type of the sparse matrix
2607  Row<MT,false,false,false>::at( size_t index ) const
2608 {
2609  if( index >= size() ) {
2610  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
2611  }
2612  return (*this)[index];
2613 }
2615 //*************************************************************************************************
2616 
2617 
2618 //*************************************************************************************************
2626 template< typename MT > // Type of the sparse matrix
2628 {
2629  return Iterator( matrix_, row_, 0UL );
2630 }
2632 //*************************************************************************************************
2633 
2634 
2635 //*************************************************************************************************
2643 template< typename MT > // Type of the sparse matrix
2645 {
2646  return ConstIterator( matrix_, row_, 0UL );
2647 }
2649 //*************************************************************************************************
2650 
2651 
2652 //*************************************************************************************************
2660 template< typename MT > // Type of the sparse matrix
2662 {
2663  return ConstIterator( matrix_, row_, 0UL );
2664 }
2666 //*************************************************************************************************
2667 
2668 
2669 //*************************************************************************************************
2677 template< typename MT > // Type of the sparse matrix
2679 {
2680  return Iterator( matrix_, row_, size() );
2681 }
2683 //*************************************************************************************************
2684 
2685 
2686 //*************************************************************************************************
2694 template< typename MT > // Type of the sparse matrix
2696 {
2697  return ConstIterator( matrix_, row_, size() );
2698 }
2700 //*************************************************************************************************
2701 
2702 
2703 //*************************************************************************************************
2711 template< typename MT > // Type of the sparse matrix
2713 {
2714  return ConstIterator( matrix_, row_, size() );
2715 }
2717 //*************************************************************************************************
2718 
2719 
2720 
2721 
2722 //=================================================================================================
2723 //
2724 // ASSIGNMENT OPERATORS
2725 //
2726 //=================================================================================================
2727 
2728 //*************************************************************************************************
2742 template< typename MT > // Type of the sparse matrix
2743 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator=( const Row& rhs )
2744 {
2745  using blaze::assign;
2746 
2750 
2751  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
2752  return *this;
2753 
2754  if( size() != rhs.size() ) {
2755  BLAZE_THROW_INVALID_ARGUMENT( "Row sizes do not match" );
2756  }
2757 
2758  if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
2759  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2760  }
2761 
2762  DerestrictTrait_<This> left( derestrict( *this ) );
2763 
2764  if( rhs.canAlias( &matrix_ ) ) {
2765  const ResultType tmp( rhs );
2766  assign( left, tmp );
2767  }
2768  else {
2769  assign( left, rhs );
2770  }
2771 
2772  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2773 
2774  return *this;
2775 }
2777 //*************************************************************************************************
2778 
2779 
2780 //*************************************************************************************************
2794 template< typename MT > // Type of the sparse matrix
2795 template< typename VT > // Type of the right-hand side vector
2796 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator=( const Vector<VT,true>& rhs )
2797 {
2798  using blaze::assign;
2799 
2800  if( size() != (~rhs).size() ) {
2801  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2802  }
2803 
2804  const CompositeType_<VT> tmp( ~rhs );
2805 
2806  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2807  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2808  }
2809 
2810  DerestrictTrait_<This> left( derestrict( *this ) );
2811 
2812  assign( left, tmp );
2813 
2814  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2815 
2816  return *this;
2817 }
2819 //*************************************************************************************************
2820 
2821 
2822 //*************************************************************************************************
2836 template< typename MT > // Type of the sparse matrix
2837 template< typename VT > // Type of the right-hand side vector
2838 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator+=( const Vector<VT,true>& rhs )
2839 {
2840  using blaze::assign;
2841 
2845  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
2847 
2848  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
2849 
2852 
2853  if( size() != (~rhs).size() ) {
2854  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2855  }
2856 
2857  const AddType tmp( *this + (~rhs) );
2858 
2859  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2860  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2861  }
2862 
2863  DerestrictTrait_<This> left( derestrict( *this ) );
2864 
2865  assign( left, tmp );
2866 
2867  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2868 
2869  return *this;
2870 }
2872 //*************************************************************************************************
2873 
2874 
2875 //*************************************************************************************************
2889 template< typename MT > // Type of the sparse matrix
2890 template< typename VT > // Type of the right-hand side vector
2891 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator-=( const Vector<VT,true>& rhs )
2892 {
2893  using blaze::assign;
2894 
2898  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
2900 
2901  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
2902 
2905 
2906  if( size() != (~rhs).size() ) {
2907  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2908  }
2909 
2910  const SubType tmp( *this - (~rhs) );
2911 
2912  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2913  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2914  }
2915 
2916  DerestrictTrait_<This> left( derestrict( *this ) );
2917 
2918  assign( left, tmp );
2919 
2920  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2921 
2922  return *this;
2923 }
2925 //*************************************************************************************************
2926 
2927 
2928 //*************************************************************************************************
2941 template< typename MT > // Type of the sparse matrix
2942 template< typename VT > // Type of the right-hand side vector
2943 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator*=( const Vector<VT,true>& rhs )
2944 {
2945  using blaze::assign;
2946 
2950  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
2952 
2953  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
2954 
2957 
2958  if( size() != (~rhs).size() ) {
2959  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2960  }
2961 
2962  const MultType tmp( *this * (~rhs) );
2963 
2964  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2965  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2966  }
2967 
2968  DerestrictTrait_<This> left( derestrict( *this ) );
2969 
2970  assign( left, tmp );
2971 
2972  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2973 
2974  return *this;
2975 }
2977 //*************************************************************************************************
2978 
2979 
2980 //*************************************************************************************************
2992 template< typename MT > // Type of the sparse matrix
2993 template< typename VT > // Type of the right-hand side vector
2994 inline Row<MT,false,false,false>&
2995  Row<MT,false,false,false>::operator/=( const DenseVector<VT,true>& rhs )
2996 {
2997  using blaze::assign;
2998 
3002  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
3003  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
3005 
3006  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
3007 
3011 
3012  if( size() != (~rhs).size() ) {
3013  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3014  }
3015 
3016  const DivType tmp( *this / (~rhs) );
3017 
3018  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
3019  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3020  }
3021 
3022  DerestrictTrait_<This> left( derestrict( *this ) );
3023 
3024  assign( left, tmp );
3025 
3026  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3027 
3028  return *this;
3029 }
3031 //*************************************************************************************************
3032 
3033 
3034 //*************************************************************************************************
3049 template< typename MT > // Type of the sparse matrix
3050 template< typename Other > // Data type of the right-hand side scalar
3051 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,false> >&
3053 {
3055 
3056  for( Iterator element=begin(); element!=end(); ++element )
3057  element->value() *= rhs;
3058  return *this;
3059 }
3061 //*************************************************************************************************
3062 
3063 
3064 //*************************************************************************************************
3082 template< typename MT > // Type of the sparse matrix
3083 template< typename Other > // Data type of the right-hand side scalar
3084 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,false> >&
3086 {
3088 
3089  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3090 
3091  typedef DivTrait_<ElementType,Other> DT;
3092  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
3093 
3094  // Depending on the two involved data types, an integer division is applied or a
3095  // floating point division is selected.
3096  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
3097  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
3098  for( Iterator element=begin(); element!=end(); ++element )
3099  element->value() *= tmp;
3100  }
3101  else {
3102  for( Iterator element=begin(); element!=end(); ++element )
3103  element->value() /= rhs;
3104  }
3105 
3106  return *this;
3107 }
3109 //*************************************************************************************************
3110 
3111 
3112 
3113 
3114 //=================================================================================================
3115 //
3116 // UTILITY FUNCTIONS
3117 //
3118 //=================================================================================================
3119 
3120 //*************************************************************************************************
3126 template< typename MT > // Type of the sparse matrix
3127 inline size_t Row<MT,false,false,false>::size() const noexcept
3128 {
3129  return matrix_.columns();
3130 }
3132 //*************************************************************************************************
3133 
3134 
3135 //*************************************************************************************************
3141 template< typename MT > // Type of the sparse matrix
3142 inline size_t Row<MT,false,false,false>::capacity() const noexcept
3143 {
3144  return matrix_.columns();
3145 }
3147 //*************************************************************************************************
3148 
3149 
3150 //*************************************************************************************************
3159 template< typename MT > // Type of the sparse matrix
3160 inline size_t Row<MT,false,false,false>::nonZeros() const
3161 {
3162  size_t counter( 0UL );
3163  for( ConstIterator element=begin(); element!=end(); ++element ) {
3164  ++counter;
3165  }
3166  return counter;
3167 }
3169 //*************************************************************************************************
3170 
3171 
3172 //*************************************************************************************************
3178 template< typename MT > // Type of the sparse matrix
3180 {
3181  const size_t jbegin( ( IsUpper<MT>::value )
3182  ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3183  ?( row_+1UL )
3184  :( row_ ) )
3185  :( 0UL ) );
3186  const size_t jend ( ( IsLower<MT>::value )
3187  ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3188  ?( row_ )
3189  :( row_+1UL ) )
3190  :( size() ) );
3191 
3192  for( size_t j=jbegin; j<jend; ++j ) {
3193  matrix_.erase( row_, j );
3194  }
3195 }
3197 //*************************************************************************************************
3198 
3199 
3200 //*************************************************************************************************
3210 template< typename MT > // Type of the sparse matrix
3211 void Row<MT,false,false,false>::reserve( size_t n )
3212 {
3213  UNUSED_PARAMETER( n );
3214 
3215  return;
3216 }
3218 //*************************************************************************************************
3219 
3220 
3221 
3222 
3223 //=================================================================================================
3224 //
3225 // INSERTION FUNCTIONS
3226 //
3227 //=================================================================================================
3228 
3229 //*************************************************************************************************
3241 template< typename MT > // Type of the sparse matrix
3243  Row<MT,false,false,false>::set( size_t index, const ElementType& value )
3244 {
3245  return Iterator( matrix_, row_, index, matrix_.set( row_, index, value ) );
3246 }
3248 //*************************************************************************************************
3249 
3250 
3251 //*************************************************************************************************
3264 template< typename MT > // Type of the sparse matrix
3266  Row<MT,false,false,false>::insert( size_t index, const ElementType& value )
3267 {
3268  return Iterator( matrix_, row_, index, matrix_.insert( row_, index, value ) );
3269 }
3271 //*************************************************************************************************
3272 
3273 
3274 //*************************************************************************************************
3299 template< typename MT > // Type of the sparse matrix
3300 inline void Row<MT,false,false,false>::append( size_t index, const ElementType& value, bool check )
3301 {
3302  if( !check || !isDefault( value ) )
3303  matrix_.insert( row_, index, value );
3304 }
3306 //*************************************************************************************************
3307 
3308 
3309 
3310 
3311 //=================================================================================================
3312 //
3313 // ERASE FUNCTIONS
3314 //
3315 //=================================================================================================
3316 
3317 //*************************************************************************************************
3326 template< typename MT > // Type of the sparse matrix
3327 inline void Row<MT,false,false,false>::erase( size_t index )
3328 {
3329  matrix_.erase( row_, index );
3330 }
3332 //*************************************************************************************************
3333 
3334 
3335 //*************************************************************************************************
3344 template< typename MT > // Type of the sparse matrix
3345 inline typename Row<MT,false,false,false>::Iterator Row<MT,false,false,false>::erase( Iterator pos )
3346 {
3347  const size_t column( pos.column_ );
3348 
3349  if( column == size() )
3350  return pos;
3351 
3352  matrix_.erase( column, pos.pos_ );
3353  return Iterator( matrix_, row_, column+1UL );
3354 }
3356 //*************************************************************************************************
3357 
3358 
3359 //*************************************************************************************************
3369 template< typename MT > // Type of the sparse matrix
3371  Row<MT,false,false,false>::erase( Iterator first, Iterator last )
3372 {
3373  for( ; first!=last; ++first ) {
3374  matrix_.erase( first.column_, first.pos_ );
3375  }
3376  return last;
3377 }
3379 //*************************************************************************************************
3380 
3381 
3382 //*************************************************************************************************
3405 template< typename MT > // Type of the sparse matrix
3406 template< typename Pred // Type of the unary predicate
3407  , typename > // Type restriction on the unary predicate
3408 inline void Row<MT,false,false,false>::erase( Pred predicate )
3409 {
3410  for( Iterator element=begin(); element!=end(); ++element ) {
3411  if( predicate( element->value() ) )
3412  matrix_.erase( element.column_, element.pos_ );
3413  }
3414 }
3416 //*************************************************************************************************
3417 
3418 
3419 //*************************************************************************************************
3444 template< typename MT > // Type of the sparse matrix
3445 template< typename Pred > // Type of the unary predicate
3446 inline void Row<MT,false,false,false>::erase( Iterator first, Iterator last, Pred predicate )
3447 {
3448  for( ; first!=last; ++first ) {
3449  if( predicate( first->value() ) )
3450  matrix_.erase( first.column_, first.pos_ );
3451  }
3452 }
3454 //*************************************************************************************************
3455 
3456 
3457 
3458 
3459 //=================================================================================================
3460 //
3461 // LOOKUP FUNCTIONS
3462 //
3463 //=================================================================================================
3464 
3465 //*************************************************************************************************
3479 template< typename MT > // Type of the sparse matrix
3480 inline typename Row<MT,false,false,false>::Iterator Row<MT,false,false,false>::find( size_t index )
3481 {
3482  const Iterator_<MT> pos( matrix_.find( row_, index ) );
3483 
3484  if( pos != matrix_.end( index ) )
3485  return Iterator( matrix_, row_, index, pos );
3486  else
3487  return end();
3488 }
3490 //*************************************************************************************************
3491 
3492 
3493 //*************************************************************************************************
3507 template< typename MT > // Type of the sparse matrix
3509  Row<MT,false,false,false>::find( size_t index ) const
3510 {
3511  const ConstIterator_<MT> pos( matrix_.find( row_, index ) );
3512 
3513  if( pos != matrix_.end( index ) )
3514  return ConstIterator( matrix_, row_, index, pos );
3515  else
3516  return end();
3517 }
3519 //*************************************************************************************************
3520 
3521 
3522 //*************************************************************************************************
3535 template< typename MT > // Type of the sparse matrix
3537  Row<MT,false,false,false>::lowerBound( size_t index )
3538 {
3539  for( size_t i=index; i<size(); ++i )
3540  {
3541  const Iterator_<MT> pos( matrix_.find( row_, i ) );
3542 
3543  if( pos != matrix_.end( i ) )
3544  return Iterator( matrix_, row_, i, pos );
3545  }
3546 
3547  return end();
3548 }
3550 //*************************************************************************************************
3551 
3552 
3553 //*************************************************************************************************
3566 template< typename MT > // Type of the sparse matrix
3568  Row<MT,false,false,false>::lowerBound( size_t index ) const
3569 {
3570  for( size_t i=index; i<size(); ++i )
3571  {
3572  const ConstIterator_<MT> pos( matrix_.find( row_, i ) );
3573 
3574  if( pos != matrix_.end( i ) )
3575  return ConstIterator( matrix_, row_, i, pos );
3576  }
3577 
3578  return end();
3579 }
3581 //*************************************************************************************************
3582 
3583 
3584 //*************************************************************************************************
3597 template< typename MT > // Type of the sparse matrix
3599  Row<MT,false,false,false>::upperBound( size_t index )
3600 {
3601  for( size_t i=index+1UL; i<size(); ++i )
3602  {
3603  const Iterator_<MT> pos( matrix_.find( row_, i ) );
3604 
3605  if( pos != matrix_.end( i ) )
3606  return Iterator( matrix_, row_, i, pos );
3607  }
3608 
3609  return end();
3610 }
3612 //*************************************************************************************************
3613 
3614 
3615 //*************************************************************************************************
3628 template< typename MT > // Type of the sparse matrix
3630  Row<MT,false,false,false>::upperBound( size_t index ) const
3631 {
3632  for( size_t i=index+1UL; i<size(); ++i )
3633  {
3634  const ConstIterator_<MT> pos( matrix_.find( row_, i ) );
3635 
3636  if( pos != matrix_.end( i ) )
3637  return ConstIterator( matrix_, row_, i, pos );
3638  }
3639 
3640  return end();
3641 }
3643 //*************************************************************************************************
3644 
3645 
3646 
3647 
3648 //=================================================================================================
3649 //
3650 // NUMERIC FUNCTIONS
3651 //
3652 //=================================================================================================
3653 
3654 //*************************************************************************************************
3665 template< typename MT > // Type of the sparse matrix
3666 template< typename Other > // Data type of the scalar value
3667 inline Row<MT,false,false,false>& Row<MT,false,false,false>::scale( const Other& scalar )
3668 {
3670 
3671  for( Iterator element=begin(); element!=end(); ++element )
3672  element->value() *= scalar;
3673  return *this;
3674 }
3676 //*************************************************************************************************
3677 
3678 
3679 
3680 
3681 //=================================================================================================
3682 //
3683 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
3684 //
3685 //=================================================================================================
3686 
3687 //*************************************************************************************************
3698 template< typename MT > // Type of the sparse matrix
3699 template< typename Other > // Data type of the foreign expression
3700 inline bool Row<MT,false,false,false>::canAlias( const Other* alias ) const noexcept
3701 {
3702  return matrix_.isAliased( alias );
3703 }
3705 //*************************************************************************************************
3706 
3707 
3708 //*************************************************************************************************
3715 template< typename MT > // Type of the sparse matrix
3716 template< typename Other > // Data type of the foreign expression
3717 inline bool Row<MT,false,false,false>::isAliased( const Other* alias ) const noexcept
3718 {
3719  return matrix_.isAliased( alias );
3720 }
3722 //*************************************************************************************************
3723 
3724 
3725 //*************************************************************************************************
3737 template< typename MT > // Type of the sparse matrix
3738 template< typename VT > // Type of the right-hand side dense vector
3739 inline void Row<MT,false,false,false>::assign( const DenseVector<VT,true>& rhs )
3740 {
3741  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3742 
3743  for( size_t j=0UL; j<(~rhs).size(); ++j ) {
3744  matrix_(row_,j) = (~rhs)[j];
3745  }
3746 }
3748 //*************************************************************************************************
3749 
3750 
3751 //*************************************************************************************************
3763 template< typename MT > // Type of the sparse matrix
3764 template< typename VT > // Type of the right-hand side sparse vector
3765 inline void Row<MT,false,false,false>::assign( const SparseVector<VT,true>& rhs )
3766 {
3767  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3768 
3769  size_t j( 0UL );
3770 
3771  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
3772  for( ; j<element->index(); ++j )
3773  matrix_.erase( row_, j );
3774  matrix_(row_,j++) = element->value();
3775  }
3776  for( ; j<size(); ++j ) {
3777  matrix_.erase( row_, j );
3778  }
3779 }
3781 //*************************************************************************************************
3782 
3783 
3784 //*************************************************************************************************
3796 template< typename MT > // Type of the sparse matrix
3797 template< typename VT > // Type of the right-hand side vector
3798 inline void Row<MT,false,false,false>::addAssign( const Vector<VT,true>& rhs )
3799 {
3800  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
3801 
3804 
3805  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3806 
3807  const AddType tmp( serial( *this + (~rhs) ) );
3808  assign( tmp );
3809 }
3811 //*************************************************************************************************
3812 
3813 
3814 //*************************************************************************************************
3826 template< typename MT > // Type of the sparse matrix
3827 template< typename VT > // Type of the right-hand side vector
3828 inline void Row<MT,false,false,false>::subAssign( const Vector<VT,true>& rhs )
3829 {
3830  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
3831 
3834 
3835  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3836 
3837  const SubType tmp( serial( *this - (~rhs) ) );
3838  assign( tmp );
3839 }
3841 //*************************************************************************************************
3842 
3843 
3844 
3845 
3846 
3847 
3848 
3849 
3850 //=================================================================================================
3851 //
3852 // CLASS TEMPLATE SPECIALIZATION FOR SYMMETRIC COLUMN-MAJOR SPARSE MATRICES
3853 //
3854 //=================================================================================================
3855 
3856 //*************************************************************************************************
3864 template< typename MT > // Type of the sparse matrix
3865 class Row<MT,false,false,true>
3866  : public SparseVector< Row<MT,false,false,true>, true >
3867  , private View
3868 {
3869  private:
3870  //**Type definitions****************************************************************************
3872  typedef If_< IsExpression<MT>, MT, MT& > Operand;
3873  //**********************************************************************************************
3874 
3875  public:
3876  //**Type definitions****************************************************************************
3877  typedef Row<MT,false,false,true> This;
3878  typedef SparseVector<This,true> BaseType;
3879  typedef RowTrait_<MT> ResultType;
3880  typedef TransposeType_<ResultType> TransposeType;
3881  typedef ElementType_<MT> ElementType;
3882  typedef ReturnType_<MT> ReturnType;
3883  typedef const Row& CompositeType;
3884 
3886  typedef ConstReference_<MT> ConstReference;
3887 
3889  typedef If_< IsConst<MT>, ConstReference, Reference_<MT> > Reference;
3890 
3892  typedef ConstIterator_<MT> ConstIterator;
3893 
3895  typedef If_< IsConst<MT>, ConstIterator, Iterator_<MT> > Iterator;
3896  //**********************************************************************************************
3897 
3898  //**Compilation flags***************************************************************************
3900  enum : bool { smpAssignable = false };
3901  //**********************************************************************************************
3902 
3903  //**Constructors********************************************************************************
3906  explicit inline Row( Operand matrix, size_t index );
3907  // No explicitly declared copy constructor.
3909  //**********************************************************************************************
3910 
3911  //**Destructor**********************************************************************************
3912  // No explicitly declared destructor.
3913  //**********************************************************************************************
3914 
3915  //**Data access functions***********************************************************************
3918  inline Reference operator[]( size_t index );
3919  inline ConstReference operator[]( size_t index ) const;
3920  inline Reference at( size_t index );
3921  inline ConstReference at( size_t index ) const;
3922  inline Iterator begin ();
3923  inline ConstIterator begin () const;
3924  inline ConstIterator cbegin() const;
3925  inline Iterator end ();
3926  inline ConstIterator end () const;
3927  inline ConstIterator cend () const;
3929  //**********************************************************************************************
3930 
3931  //**Assignment operators************************************************************************
3934  inline Row& operator=( const Row& rhs );
3935 
3936  template< typename VT > inline Row& operator= ( const DenseVector<VT,true>& rhs );
3937  template< typename VT > inline Row& operator= ( const SparseVector<VT,true>& rhs );
3938  template< typename VT > inline Row& operator+=( const DenseVector<VT,true>& rhs );
3939  template< typename VT > inline Row& operator+=( const SparseVector<VT,true>& rhs );
3940  template< typename VT > inline Row& operator-=( const DenseVector<VT,true>& rhs );
3941  template< typename VT > inline Row& operator-=( const SparseVector<VT,true>& rhs );
3942  template< typename VT > inline Row& operator*=( const Vector<VT,true>& rhs );
3943  template< typename VT > inline Row& operator/=( const DenseVector<VT,true>& rhs );
3944 
3945  template< typename Other >
3946  inline EnableIf_<IsNumeric<Other>, Row >& operator*=( Other rhs );
3947 
3948  template< typename Other >
3949  inline EnableIf_<IsNumeric<Other>, Row >& operator/=( Other rhs );
3951  //**********************************************************************************************
3952 
3953  //**Utility functions***************************************************************************
3956  inline size_t size() const noexcept;
3957  inline size_t capacity() const noexcept;
3958  inline size_t nonZeros() const;
3959  inline void reset();
3960  inline void reserve( size_t n );
3962  //**********************************************************************************************
3963 
3964  //**Insertion functions*************************************************************************
3967  inline Iterator set ( size_t index, const ElementType& value );
3968  inline Iterator insert( size_t index, const ElementType& value );
3969  inline void append( size_t index, const ElementType& value, bool check=false );
3971  //**********************************************************************************************
3972 
3973  //**Erase functions*****************************************************************************
3976  inline void erase( size_t index );
3977  inline Iterator erase( Iterator pos );
3978  inline Iterator erase( Iterator first, Iterator last );
3979 
3980  template< typename Pred, typename = DisableIf_< IsIntegral<Pred> > >
3981  inline void erase( Pred predicate );
3982 
3983  template< typename Pred >
3984  inline void erase( Iterator first, Iterator last, Pred predicate );
3986  //**********************************************************************************************
3987 
3988  //**Lookup functions****************************************************************************
3991  inline Iterator find ( size_t index );
3992  inline ConstIterator find ( size_t index ) const;
3993  inline Iterator lowerBound( size_t index );
3994  inline ConstIterator lowerBound( size_t index ) const;
3995  inline Iterator upperBound( size_t index );
3996  inline ConstIterator upperBound( size_t index ) const;
3998  //**********************************************************************************************
3999 
4000  //**Numeric functions***************************************************************************
4003  template< typename Other > inline Row& scale( const Other& scalar );
4005  //**********************************************************************************************
4006 
4007  //**Expression template evaluation functions****************************************************
4010  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
4011  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
4012 
4013  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
4014  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
4015  template< typename VT > inline void addAssign( const DenseVector <VT,true>& rhs );
4016  template< typename VT > inline void addAssign( const SparseVector<VT,true>& rhs );
4017  template< typename VT > inline void subAssign( const DenseVector <VT,true>& rhs );
4018  template< typename VT > inline void subAssign( const SparseVector<VT,true>& rhs );
4020  //**********************************************************************************************
4021 
4022  private:
4023  //**Utility functions***************************************************************************
4026  inline size_t extendCapacity() const;
4028  //**********************************************************************************************
4029 
4030  //**Member variables****************************************************************************
4033  Operand matrix_;
4034  const size_t row_;
4035 
4036  //**********************************************************************************************
4037 
4038  //**Friend declarations*************************************************************************
4039  template< typename MT2, bool SO2, bool DF2, bool SF2 >
4040  friend bool isIntact( const Row<MT2,SO2,DF2,SF2>& row ) noexcept;
4041 
4042  template< typename MT2, bool SO2, bool DF2, bool SF2 >
4043  friend bool isSame( const Row<MT2,SO2,DF2,SF2>& a, const Row<MT2,SO2,DF2,SF2>& b ) noexcept;
4044 
4045  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
4046  friend bool tryAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
4047 
4048  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
4049  friend bool tryAddAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
4050 
4051  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
4052  friend bool trySubAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
4053 
4054  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
4055  friend bool tryMultAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
4056 
4057  template< typename MT2, bool SO2, bool DF2, bool SF2 >
4058  friend DerestrictTrait_< Row<MT2,SO2,DF2,SF2> > derestrict( Row<MT2,SO2,DF2,SF2>& row );
4059  //**********************************************************************************************
4060 
4061  //**Compile time checks*************************************************************************
4069  //**********************************************************************************************
4070 };
4072 //*************************************************************************************************
4073 
4074 
4075 
4076 
4077 //=================================================================================================
4078 //
4079 // CONSTRUCTOR
4080 //
4081 //=================================================================================================
4082 
4083 //*************************************************************************************************
4091 template< typename MT > // Type of the sparse matrix
4092 inline Row<MT,false,false,true>::Row( Operand matrix, size_t index )
4093  : matrix_( matrix ) // The sparse matrix containing the row
4094  , row_ ( index ) // The index of the row in the matrix
4095 {
4096  if( matrix_.rows() <= index ) {
4097  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
4098  }
4099 }
4101 //*************************************************************************************************
4102 
4103 
4104 
4105 
4106 //=================================================================================================
4107 //
4108 // DATA ACCESS FUNCTIONS
4109 //
4110 //=================================================================================================
4111 
4112 //*************************************************************************************************
4122 template< typename MT > // Type of the sparse matrix
4124  Row<MT,false,false,true>::operator[]( size_t index )
4125 {
4126  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
4127  return matrix_(index,row_);
4128 }
4130 //*************************************************************************************************
4131 
4132 
4133 //*************************************************************************************************
4143 template< typename MT > // Type of the sparse matrix
4145  Row<MT,false,false,true>::operator[]( size_t index ) const
4146 {
4147  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
4148  return const_cast<const MT&>( matrix_ )(index,row_);
4149 }
4151 //*************************************************************************************************
4152 
4153 
4154 //*************************************************************************************************
4165 template< typename MT > // Type of the sparse matrix
4167  Row<MT,false,false,true>::at( size_t index )
4168 {
4169  if( index >= size() ) {
4170  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
4171  }
4172  return (*this)[index];
4173 }
4175 //*************************************************************************************************
4176 
4177 
4178 //*************************************************************************************************
4189 template< typename MT > // Type of the sparse matrix
4191  Row<MT,false,false,true>::at( size_t index ) const
4192 {
4193  if( index >= size() ) {
4194  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
4195  }
4196  return (*this)[index];
4197 }
4199 //*************************************************************************************************
4200 
4201 
4202 //*************************************************************************************************
4210 template< typename MT > // Type of the sparse matrix
4212 {
4213  return matrix_.begin( row_ );
4214 }
4216 //*************************************************************************************************
4217 
4218 
4219 //*************************************************************************************************
4227 template< typename MT > // Type of the sparse matrix
4229 {
4230  return matrix_.cbegin( row_ );
4231 }
4233 //*************************************************************************************************
4234 
4235 
4236 //*************************************************************************************************
4244 template< typename MT > // Type of the sparse matrix
4246 {
4247  return matrix_.cbegin( row_ );
4248 }
4250 //*************************************************************************************************
4251 
4252 
4253 //*************************************************************************************************
4261 template< typename MT > // Type of the sparse matrix
4263 {
4264  return matrix_.end( row_ );
4265 }
4267 //*************************************************************************************************
4268 
4269 
4270 //*************************************************************************************************
4278 template< typename MT > // Type of the sparse matrix
4280 {
4281  return matrix_.cend( row_ );
4282 }
4284 //*************************************************************************************************
4285 
4286 
4287 //*************************************************************************************************
4295 template< typename MT > // Type of the sparse matrix
4297 {
4298  return matrix_.cend( row_ );
4299 }
4301 //*************************************************************************************************
4302 
4303 
4304 
4305 
4306 //=================================================================================================
4307 //
4308 // ASSIGNMENT OPERATORS
4309 //
4310 //=================================================================================================
4311 
4312 //*************************************************************************************************
4326 template< typename MT > // Type of the sparse matrix
4327 inline Row<MT,false,false,true>& Row<MT,false,false,true>::operator=( const Row& rhs )
4328 {
4329  using blaze::assign;
4330 
4334 
4335  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
4336  return *this;
4337 
4338  if( size() != rhs.size() ) {
4339  BLAZE_THROW_INVALID_ARGUMENT( "Row sizes do not match" );
4340  }
4341 
4342  if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
4343  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4344  }
4345 
4346  DerestrictTrait_<This> left( derestrict( *this ) );
4347 
4348  if( rhs.canAlias( &matrix_ ) ) {
4349  const ResultType tmp( rhs );
4350  left.reset();
4351  left.reserve( tmp.nonZeros() );
4352  assign( left, tmp );
4353  }
4354  else {
4355  left.reset();
4356  left.reserve( rhs.nonZeros() );
4357  assign( left, rhs );
4358  }
4359 
4360  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4361 
4362  return *this;
4363 }
4365 //*************************************************************************************************
4366 
4367 
4368 //*************************************************************************************************
4382 template< typename MT > // Type of the sparse matrix
4383 template< typename VT > // Type of the right-hand side dense vector
4384 inline Row<MT,false,false,true>&
4385  Row<MT,false,false,true>::operator=( const DenseVector<VT,true>& rhs )
4386 {
4387  using blaze::assign;
4388 
4389  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4390  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4392 
4393  if( size() != (~rhs).size() ) {
4394  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4395  }
4396 
4397  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
4398  Right right( ~rhs );
4399 
4400  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
4401  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4402  }
4403 
4404  DerestrictTrait_<This> left( derestrict( *this ) );
4405 
4406  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4407  const ResultType_<VT> tmp( right );
4408  left.reset();
4409  assign( left, tmp );
4410  }
4411  else {
4412  left.reset();
4413  assign( left, right );
4414  }
4415 
4416  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4417 
4418  return *this;
4419 }
4421 //*************************************************************************************************
4422 
4423 
4424 //*************************************************************************************************
4438 template< typename MT > // Type of the sparse matrix
4439 template< typename VT > // Type of the right-hand side sparse vector
4440 inline Row<MT,false,false,true>&
4441  Row<MT,false,false,true>::operator=( const SparseVector<VT,true>& rhs )
4442 {
4443  using blaze::assign;
4444 
4445  BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE ( ResultType_<VT> );
4446  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4448 
4449  if( size() != (~rhs).size() ) {
4450  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4451  }
4452 
4453  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
4454  Right right( ~rhs );
4455 
4456  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
4457  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4458  }
4459 
4460  DerestrictTrait_<This> left( derestrict( *this ) );
4461 
4462  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4463  const ResultType_<VT> tmp( right );
4464  left.reset();
4465  left.reserve( tmp.nonZeros() );
4466  assign( left, tmp );
4467  }
4468  else {
4469  left.reset();
4470  left.reserve( right.nonZeros() );
4471  assign( left, right );
4472  }
4473 
4474  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4475 
4476  return *this;
4477 }
4479 //*************************************************************************************************
4480 
4481 
4482 //*************************************************************************************************
4496 template< typename MT > // Type of the sparse matrix
4497 template< typename VT > // Type of the right-hand side dense vector
4498 inline Row<MT,false,false,true>&
4499  Row<MT,false,false,true>::operator+=( const DenseVector<VT,true>& rhs )
4500 {
4501  using blaze::assign;
4502 
4506  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4507  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4509 
4510  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
4511 
4515 
4516  if( size() != (~rhs).size() ) {
4517  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4518  }
4519 
4520  const AddType tmp( *this + (~rhs) );
4521 
4522  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4523  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4524  }
4525 
4526  DerestrictTrait_<This> left( derestrict( *this ) );
4527 
4528  left.reset();
4529  assign( left, tmp );
4530 
4531  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4532 
4533  return *this;
4534 }
4536 //*************************************************************************************************
4537 
4538 
4539 //*************************************************************************************************
4553 template< typename MT > // Type of the sparse matrix
4554 template< typename VT > // Type of the right-hand side sparse vector
4555 inline Row<MT,false,false,true>&
4556  Row<MT,false,false,true>::operator+=( const SparseVector<VT,true>& rhs )
4557 {
4558  using blaze::assign;
4559 
4563  BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE ( ResultType_<VT> );
4564  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4566 
4567  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
4568 
4572 
4573  if( size() != (~rhs).size() ) {
4574  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4575  }
4576 
4577  const AddType tmp( *this + (~rhs) );
4578 
4579  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4580  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4581  }
4582 
4583  DerestrictTrait_<This> left( derestrict( *this ) );
4584 
4585  left.reset();
4586  left.reserve( tmp.nonZeros() );
4587  assign( left, tmp );
4588 
4589  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4590 
4591  return *this;
4592 }
4594 //*************************************************************************************************
4595 
4596 
4597 //*************************************************************************************************
4612 template< typename MT > // Type of the sparse matrix
4613 template< typename VT > // Type of the right-hand side dense vector
4614 inline Row<MT,false,false,true>&
4615  Row<MT,false,false,true>::operator-=( const DenseVector<VT,true>& rhs )
4616 {
4617  using blaze::assign;
4618 
4622  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4623  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4625 
4626  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
4627 
4631 
4632  if( size() != (~rhs).size() ) {
4633  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4634  }
4635 
4636  const SubType tmp( *this - (~rhs) );
4637 
4638  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4639  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4640  }
4641 
4642  DerestrictTrait_<This> left( derestrict( *this ) );
4643 
4644  left.reset();
4645  assign( left, tmp );
4646 
4647  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4648 
4649  return *this;
4650 }
4652 //*************************************************************************************************
4653 
4654 
4655 //*************************************************************************************************
4670 template< typename MT > // Type of the sparse matrix
4671 template< typename VT > // Type of the right-hand side sparse vector
4672 inline Row<MT,false,false,true>&
4673  Row<MT,false,false,true>::operator-=( const SparseVector<VT,true>& rhs )
4674 {
4675  using blaze::assign;
4676 
4680  BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE ( ResultType_<VT> );
4681  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4683 
4684  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
4685 
4689 
4690  if( size() != (~rhs).size() ) {
4691  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4692  }
4693 
4694  const SubType tmp( *this - (~rhs) );
4695 
4696  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4697  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4698  }
4699 
4700  DerestrictTrait_<This> left( derestrict( *this ) );
4701 
4702  left.reset();
4703  left.reserve( tmp.nonZeros() );
4704  assign( left, tmp );
4705 
4706  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4707 
4708  return *this;
4709 }
4711 //*************************************************************************************************
4712 
4713 
4714 //*************************************************************************************************
4727 template< typename MT > // Type of the sparse matrix
4728 template< typename VT > // Type of the right-hand side vector
4729 inline Row<MT,false,false,true>&
4730  Row<MT,false,false,true>::operator*=( const Vector<VT,true>& rhs )
4731 {
4732  using blaze::assign;
4733 
4737  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4739 
4740  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
4741 
4744 
4745  if( size() != (~rhs).size() ) {
4746  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4747  }
4748 
4749  const MultType tmp( *this * (~rhs) );
4750 
4751  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4752  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4753  }
4754 
4755  DerestrictTrait_<This> left( derestrict( *this ) );
4756 
4757  left.reset();
4758  assign( left, tmp );
4759 
4760  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4761 
4762  return *this;
4763 }
4765 //*************************************************************************************************
4766 
4767 
4768 //*************************************************************************************************
4780 template< typename MT > // Type of the sparse matrix
4781 template< typename VT > // Type of the right-hand side vector
4782 inline Row<MT,false,false,true>&
4783  Row<MT,false,false,true>::operator/=( const DenseVector<VT,true>& rhs )
4784 {
4785  using blaze::assign;
4786 
4790  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4791  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4793 
4794  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
4795 
4799 
4800  if( size() != (~rhs).size() ) {
4801  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4802  }
4803 
4804  const DivType tmp( *this / (~rhs) );
4805 
4806  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4807  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4808  }
4809 
4810  DerestrictTrait_<This> left( derestrict( *this ) );
4811 
4812  left.reset();
4813  assign( left, tmp );
4814 
4815  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4816 
4817  return *this;
4818 }
4820 //*************************************************************************************************
4821 
4822 
4823 //*************************************************************************************************
4838 template< typename MT > // Type of the sparse matrix
4839 template< typename Other > // Data type of the right-hand side scalar
4840 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,true> >&
4842 {
4844 
4845  for( Iterator element=begin(); element!=end(); ++element )
4846  element->value() *= rhs;
4847  return *this;
4848 }
4850 //*************************************************************************************************
4851 
4852 
4853 //*************************************************************************************************
4871 template< typename MT > // Type of the sparse matrix
4872 template< typename Other > // Data type of the right-hand side scalar
4873 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,true> >&
4875 {
4877 
4878  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
4879 
4880  typedef DivTrait_<ElementType,Other> DT;
4881  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
4882 
4883  // Depending on the two involved data types, an integer division is applied or a
4884  // floating point division is selected.
4885  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
4886  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
4887  for( Iterator element=begin(); element!=end(); ++element )
4888  element->value() *= tmp;
4889  }
4890  else {
4891  for( Iterator element=begin(); element!=end(); ++element )
4892  element->value() /= rhs;
4893  }
4894 
4895  return *this;
4896 }
4898 //*************************************************************************************************
4899 
4900 
4901 
4902 
4903 //=================================================================================================
4904 //
4905 // UTILITY FUNCTIONS
4906 //
4907 //=================================================================================================
4908 
4909 //*************************************************************************************************
4915 template< typename MT > // Type of the sparse matrix
4916 inline size_t Row<MT,false,false,true>::size() const noexcept
4917 {
4918  return matrix_.columns();
4919 }
4921 //*************************************************************************************************
4922 
4923 
4924 //*************************************************************************************************
4930 template< typename MT > // Type of the sparse matrix
4931 inline size_t Row<MT,false,false,true>::capacity() const noexcept
4932 {
4933  return matrix_.capacity( row_ );
4934 }
4936 //*************************************************************************************************
4937 
4938 
4939 //*************************************************************************************************
4948 template< typename MT > // Type of the sparse matrix
4949 inline size_t Row<MT,false,false,true>::nonZeros() const
4950 {
4951  return matrix_.nonZeros( row_ );
4952 }
4954 //*************************************************************************************************
4955 
4956 
4957 //*************************************************************************************************
4963 template< typename MT > // Type of the sparse matrix
4964 inline void Row<MT,false,false,true>::reset()
4965 {
4966  matrix_.reset( row_ );
4967 }
4969 //*************************************************************************************************
4970 
4971 
4972 //*************************************************************************************************
4982 template< typename MT > // Type of the sparse matrix
4983 void Row<MT,false,false,true>::reserve( size_t n )
4984 {
4985  matrix_.reserve( row_, n );
4986 }
4988 //*************************************************************************************************
4989 
4990 
4991 //*************************************************************************************************
5000 template< typename MT > // Type of the sparse matrix
5001 inline size_t Row<MT,false,false,true>::extendCapacity() const
5002 {
5003  using blaze::max;
5004  using blaze::min;
5005 
5006  size_t nonzeros( 2UL*capacity()+1UL );
5007  nonzeros = max( nonzeros, 7UL );
5008  nonzeros = min( nonzeros, size() );
5009 
5010  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
5011 
5012  return nonzeros;
5013 }
5015 //*************************************************************************************************
5016 
5017 
5018 
5019 
5020 //=================================================================================================
5021 //
5022 // INSERTION FUNCTIONS
5023 //
5024 //=================================================================================================
5025 
5026 //*************************************************************************************************
5038 template< typename MT > // Type of the sparse matrix
5039 inline typename Row<MT,false,false,true>::Iterator
5040  Row<MT,false,false,true>::set( size_t index, const ElementType& value )
5041 {
5042  return matrix_.set( index, row_, value );
5043 }
5045 //*************************************************************************************************
5046 
5047 
5048 //*************************************************************************************************
5061 template< typename MT > // Type of the sparse matrix
5062 inline typename Row<MT,false,false,true>::Iterator
5063  Row<MT,false,false,true>::insert( size_t index, const ElementType& value )
5064 {
5065  return matrix_.insert( index, row_, value );
5066 }
5068 //*************************************************************************************************
5069 
5070 
5071 //*************************************************************************************************
5096 template< typename MT > // Type of the sparse matrix
5097 inline void Row<MT,false,false,true>::append( size_t index, const ElementType& value, bool check )
5098 {
5099  matrix_.append( index, row_, value, check );
5100 }
5102 //*************************************************************************************************
5103 
5104 
5105 
5106 
5107 //=================================================================================================
5108 //
5109 // ERASE FUNCTIONS
5110 //
5111 //=================================================================================================
5112 
5113 //*************************************************************************************************
5122 template< typename MT > // Type of the sparse matrix
5123 inline void Row<MT,false,false,true>::erase( size_t index )
5124 {
5125  matrix_.erase( index, row_ );
5126 }
5128 //*************************************************************************************************
5129 
5130 
5131 //*************************************************************************************************
5140 template< typename MT > // Type of the sparse matrix
5141 inline typename Row<MT,false,false,true>::Iterator
5142  Row<MT,false,false,true>::erase( Iterator pos )
5143 {
5144  return matrix_.erase( row_, pos );
5145 }
5147 //*************************************************************************************************
5148 
5149 
5150 //*************************************************************************************************
5160 template< typename MT > // Type of the sparse matrix
5161 inline typename Row<MT,false,false,true>::Iterator
5162  Row<MT,false,false,true>::erase( Iterator first, Iterator last )
5163 {
5164  return matrix_.erase( row_, first, last );
5165 }
5167 //*************************************************************************************************
5168 
5169 
5170 //*************************************************************************************************
5193 template< typename MT > // Type of the sparse matrix
5194 template< typename Pred // Type of the unary predicate
5195  , typename > // Type restriction on the unary predicate
5196 inline void Row<MT,false,false,true>::erase( Pred predicate )
5197 {
5198  matrix_.erase( row_, begin(), end(), predicate );
5199 }
5201 //*************************************************************************************************
5202 
5203 
5204 //*************************************************************************************************
5229 template< typename MT > // Type of the sparse matrix
5230 template< typename Pred > // Type of the unary predicate
5231 inline void Row<MT,false,false,true>::erase( Iterator first, Iterator last, Pred predicate )
5232 {
5233  matrix_.erase( row_, first, last, predicate );
5234 }
5236 //*************************************************************************************************
5237 
5238 
5239 
5240 
5241 //=================================================================================================
5242 //
5243 // LOOKUP FUNCTIONS
5244 //
5245 //=================================================================================================
5246 
5247 //*************************************************************************************************
5261 template< typename MT > // Type of the sparse matrix
5262 inline typename Row<MT,false,false,true>::Iterator
5263  Row<MT,false,false,true>::find( size_t index )
5264 {
5265  return matrix_.find( index, row_ );
5266 }
5268 //*************************************************************************************************
5269 
5270 
5271 //*************************************************************************************************
5285 template< typename MT > // Type of the sparse matrix
5287  Row<MT,false,false,true>::find( size_t index ) const
5288 {
5289  return matrix_.find( index, row_ );
5290 }
5292 //*************************************************************************************************
5293 
5294 
5295 //*************************************************************************************************
5308 template< typename MT > // Type of the sparse matrix
5309 inline typename Row<MT,false,false,true>::Iterator
5310  Row<MT,false,false,true>::lowerBound( size_t index )
5311 {
5312  return matrix_.lowerBound( index, row_ );
5313 }
5315 //*************************************************************************************************
5316 
5317 
5318 //*************************************************************************************************
5331 template< typename MT > // Type of the sparse matrix
5333  Row<MT,false,false,true>::lowerBound( size_t index ) const
5334 {
5335  return matrix_.lowerBound( index, row_ );
5336 }
5338 //*************************************************************************************************
5339 
5340 
5341 //*************************************************************************************************
5354 template< typename MT > // Type of the sparse matrix
5355 inline typename Row<MT,false,false,true>::Iterator
5356  Row<MT,false,false,true>::upperBound( size_t index )
5357 {
5358  return matrix_.upperBound( index, row_ );
5359 }
5361 //*************************************************************************************************
5362 
5363 
5364 //*************************************************************************************************
5377 template< typename MT > // Type of the sparse matrix
5379  Row<MT,false,false,true>::upperBound( size_t index ) const
5380 {
5381  return matrix_.upperBound( index, row_ );
5382 }
5384 //*************************************************************************************************
5385 
5386 
5387 
5388 
5389 //=================================================================================================
5390 //
5391 // NUMERIC FUNCTIONS
5392 //
5393 //=================================================================================================
5394 
5395 //*************************************************************************************************
5406 template< typename MT > // Type of the sparse matrix
5407 template< typename Other > // Data type of the scalar value
5408 inline Row<MT,false,false,true>& Row<MT,false,false,true>::scale( const Other& scalar )
5409 {
5411 
5412  for( Iterator element=begin(); element!=end(); ++element )
5413  element->value() *= scalar;
5414  return *this;
5415 }
5417 //*************************************************************************************************
5418 
5419 
5420 
5421 
5422 //=================================================================================================
5423 //
5424 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
5425 //
5426 //=================================================================================================
5427 
5428 //*************************************************************************************************
5439 template< typename MT > // Type of the sparse matrix
5440 template< typename Other > // Data type of the foreign expression
5441 inline bool Row<MT,false,false,true>::canAlias( const Other* alias ) const noexcept
5442 {
5443  return matrix_.isAliased( alias );
5444 }
5446 //*************************************************************************************************
5447 
5448 
5449 //*************************************************************************************************
5460 template< typename MT > // Type of the sparse matrix
5461 template< typename Other > // Data type of the foreign expression
5462 inline bool Row<MT,false,false,true>::isAliased( const Other* alias ) const noexcept
5463 {
5464  return matrix_.isAliased( alias );
5465 }
5467 //*************************************************************************************************
5468 
5469 
5470 //*************************************************************************************************
5482 template< typename MT > // Type of the sparse matrix
5483 template< typename VT > // Type of the right-hand side dense vector
5484 inline void Row<MT,false,false,true>::assign( const DenseVector<VT,true>& rhs )
5485 {
5486  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5487  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
5488 
5489  for( size_t i=0UL; i<size(); ++i )
5490  {
5491  if( matrix_.nonZeros( row_ ) == matrix_.capacity( row_ ) )
5492  matrix_.reserve( row_, extendCapacity() );
5493 
5494  matrix_.append( i, row_, (~rhs)[i], true );
5495  }
5496 }
5498 //*************************************************************************************************
5499 
5500 
5501 //*************************************************************************************************
5513 template< typename MT > // Type of the sparse matrix
5514 template< typename VT > // Type of the right-hand side sparse vector
5515 inline void Row<MT,false,false,true>::assign( const SparseVector<VT,true>& rhs )
5516 {
5517  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5518  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
5519 
5520  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
5521  matrix_.append( element->index(), row_, element->value(), true );
5522  }
5523 }
5525 //*************************************************************************************************
5526 
5527 
5528 //*************************************************************************************************
5540 template< typename MT > // Type of the sparse matrix
5541 template< typename VT > // Type of the right-hand side dense vector
5542 inline void Row<MT,false,false,true>::addAssign( const DenseVector<VT,true>& rhs )
5543 {
5544  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
5545 
5549 
5550  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5551 
5552  const AddType tmp( serial( *this + (~rhs) ) );
5553  matrix_.reset( row_ );
5554  assign( tmp );
5555 }
5557 //*************************************************************************************************
5558 
5559 
5560 //*************************************************************************************************
5572 template< typename MT > // Type of the sparse matrix
5573 template< typename VT > // Type of the right-hand side sparse vector
5574 inline void Row<MT,false,false,true>::addAssign( const SparseVector<VT,true>& rhs )
5575 {
5576  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
5577 
5581 
5582  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5583 
5584  const AddType tmp( serial( *this + (~rhs) ) );
5585  matrix_.reset( row_ );
5586  matrix_.reserve( row_, tmp.nonZeros() );
5587  assign( tmp );
5588 }
5590 //*************************************************************************************************
5591 
5592 
5593 //*************************************************************************************************
5605 template< typename MT > // Type of the sparse matrix
5606 template< typename VT > // Type of the right-hand side dense vector
5607 inline void Row<MT,false,false,true>::subAssign( const DenseVector<VT,true>& rhs )
5608 {
5609  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
5610 
5614 
5615  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5616 
5617  const SubType tmp( serial( *this - (~rhs) ) );
5618  matrix_.reset( row_ );
5619  assign( tmp );
5620 }
5622 //*************************************************************************************************
5623 
5624 
5625 //*************************************************************************************************
5637 template< typename MT > // Type of the sparse matrix
5638 template< typename VT > // Type of the right-hand side sparse vector
5639 inline void Row<MT,false,false,true>::subAssign( const SparseVector<VT,true>& rhs )
5640 {
5641  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
5642 
5646 
5647  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5648 
5649  const SubType tmp( serial( *this - (~rhs) ) );
5650  matrix_.reset( row_ );
5651  matrix_.reserve( row_, tmp.nonZeros() );
5652  assign( tmp );
5653 }
5655 //*************************************************************************************************
5656 
5657 } // namespace blaze
5658 
5659 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
Header file for mathematical functions.
typename DerestrictTrait< T >::Type DerestrictTrait_
Auxiliary alias declaration for the DerestrictTrait type trait.The DerestrictTrait_ alias declaration...
Definition: DerestrictTrait.h:110
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:352
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:721
Header file for basic type definitions.
Header file for the SparseVector base class.
Header file for the View base class.
Header file for the row trait.
Header file for the serial shim.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:261
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:194
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2935
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
Header file for the IsIntegral type trait.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1755
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2928
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:390
#define BLAZE_CONSTRAINT_MUST_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a symmetric matrix type...
Definition: Symmetric.h:60
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Header file for the IsUniLower type trait.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1802
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:304
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:238
Constraint on the data type.
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the implementation of the Row base template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Header file for the IsLower type trait.
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:61
Header file for the SparseElement base class.
Constraint on the data type.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:128
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2932
Constraint on the data type.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:260
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:2933
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Constraint on the data type.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2937
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:128
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the DerestrictTrait class template.
Constraint on the data type.
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2934
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the division trait.
Header file for the reset shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2938
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the IsReference type trait.
Header file for the RemoveReference type trait.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2929
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2930
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:249
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: RowVector.h:61
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2936
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
Header file for the IsUpper type trait.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the IsRestricted type trait.
const DMatDMatMultExpr< T1, T2, false, false, false, false > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7505
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Constraint on the transpose flag of vector types.
Header file for the IsExpression type trait class.