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/EnableIf.h>
83 #include <blaze/util/mpl/If.h>
84 #include <blaze/util/Types.h>
90 #include <blaze/util/Unused.h>
91 
92 
93 namespace blaze {
94 
95 //=================================================================================================
96 //
97 // CLASS TEMPLATE SPECIALIZATION FOR ROW-MAJOR SPARSE MATRICES
98 //
99 //=================================================================================================
100 
101 //*************************************************************************************************
109 template< typename MT // Type of the sparse matrix
110  , bool SF > // Symmetry flag
111 class Row<MT,true,false,SF>
112  : public SparseVector< Row<MT,true,false,SF>, true >
113  , private View
114 {
115  private:
116  //**Type definitions****************************************************************************
118  typedef If_< IsExpression<MT>, MT, MT& > Operand;
119  //**********************************************************************************************
120 
121  public:
122  //**Type definitions****************************************************************************
123  typedef Row<MT,true,false,SF> This;
124  typedef SparseVector<This,true> BaseType;
125  typedef RowTrait_<MT> ResultType;
126  typedef TransposeType_<ResultType> TransposeType;
127  typedef ElementType_<MT> ElementType;
128  typedef ReturnType_<MT> ReturnType;
129  typedef const Row& CompositeType;
130 
132  typedef ConstReference_<MT> ConstReference;
133 
135  typedef If_< IsConst<MT>, ConstReference, Reference_<MT> > Reference;
136 
138  typedef ConstIterator_<MT> ConstIterator;
139 
141  typedef If_< IsConst<MT>, ConstIterator, Iterator_<MT> > Iterator;
142  //**********************************************************************************************
143 
144  //**Compilation flags***************************************************************************
146  enum : bool { smpAssignable = false };
147  //**********************************************************************************************
148 
149  //**Constructors********************************************************************************
152  explicit inline Row( Operand matrix, size_t index );
153  // No explicitly declared copy constructor.
155  //**********************************************************************************************
156 
157  //**Destructor**********************************************************************************
158  // No explicitly declared destructor.
159  //**********************************************************************************************
160 
161  //**Data access functions***********************************************************************
164  inline Reference operator[]( size_t index );
165  inline ConstReference operator[]( size_t index ) const;
166  inline Reference at( size_t index );
167  inline ConstReference at( size_t index ) const;
168  inline Iterator begin ();
169  inline ConstIterator begin () const;
170  inline ConstIterator cbegin() const;
171  inline Iterator end ();
172  inline ConstIterator end () const;
173  inline ConstIterator cend () const;
175  //**********************************************************************************************
176 
177  //**Assignment operators************************************************************************
180  inline Row& operator=( const Row& rhs );
181 
182  template< typename VT > inline Row& operator= ( const DenseVector<VT,true>& rhs );
183  template< typename VT > inline Row& operator= ( const SparseVector<VT,true>& rhs );
184  template< typename VT > inline Row& operator+=( const DenseVector<VT,true>& rhs );
185  template< typename VT > inline Row& operator+=( const SparseVector<VT,true>& rhs );
186  template< typename VT > inline Row& operator-=( const DenseVector<VT,true>& rhs );
187  template< typename VT > inline Row& operator-=( const SparseVector<VT,true>& rhs );
188  template< typename VT > inline Row& operator*=( const Vector<VT,true>& rhs );
189  template< typename VT > inline Row& operator/=( const DenseVector<VT,true>& rhs );
190 
191  template< typename Other >
192  inline EnableIf_<IsNumeric<Other>, Row >& operator*=( Other rhs );
193 
194  template< typename Other >
195  inline EnableIf_<IsNumeric<Other>, Row >& operator/=( Other rhs );
197  //**********************************************************************************************
198 
199  //**Utility functions***************************************************************************
202  inline size_t size() const noexcept;
203  inline size_t capacity() const noexcept;
204  inline size_t nonZeros() const;
205  inline void reset();
206  inline Iterator set ( size_t index, const ElementType& value );
207  inline Iterator insert ( size_t index, const ElementType& value );
208  inline void erase ( size_t index );
209  inline Iterator erase ( Iterator pos );
210  inline Iterator erase ( Iterator first, Iterator last );
211  inline void reserve( size_t n );
212  template< typename Other > inline Row& scale ( const Other& scalar );
214  //**********************************************************************************************
215 
216  //**Lookup functions****************************************************************************
219  inline Iterator find ( size_t index );
220  inline ConstIterator find ( size_t index ) const;
221  inline Iterator lowerBound( size_t index );
222  inline ConstIterator lowerBound( size_t index ) const;
223  inline Iterator upperBound( size_t index );
224  inline ConstIterator upperBound( size_t index ) const;
226  //**********************************************************************************************
227 
228  //**Low-level utility functions*****************************************************************
231  inline void append( size_t index, const ElementType& value, bool check=false );
233  //**********************************************************************************************
234 
235  //**Expression template evaluation functions****************************************************
238  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
239  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
240 
241  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
242  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
243  template< typename VT > inline void addAssign( const DenseVector <VT,true>& rhs );
244  template< typename VT > inline void addAssign( const SparseVector<VT,true>& rhs );
245  template< typename VT > inline void subAssign( const DenseVector <VT,true>& rhs );
246  template< typename VT > inline void subAssign( const SparseVector<VT,true>& rhs );
248  //**********************************************************************************************
249 
250  private:
251  //**Utility functions***************************************************************************
254  inline size_t extendCapacity() const noexcept;
256  //**********************************************************************************************
257 
258  //**Member variables****************************************************************************
261  Operand matrix_;
262  const size_t row_;
263 
264  //**********************************************************************************************
265 
266  //**Friend declarations*************************************************************************
267  template< typename MT2, bool SO2, bool DF2, bool SF2 >
268  friend bool isIntact( const Row<MT2,SO2,DF2,SF2>& row ) noexcept;
269 
270  template< typename MT2, bool SO2, bool DF2, bool SF2 >
271  friend bool isSame( const Row<MT2,SO2,DF2,SF2>& a, const Row<MT2,SO2,DF2,SF2>& b ) noexcept;
272 
273  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
274  friend bool tryAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
275 
276  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
277  friend bool tryAddAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
278 
279  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
280  friend bool trySubAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
281 
282  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
283  friend bool tryMultAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
284 
285  template< typename MT2, bool SO2, bool DF2, bool SF2 >
286  friend DerestrictTrait_< Row<MT2,SO2,DF2,SF2> > derestrict( Row<MT2,SO2,DF2,SF2>& row );
287  //**********************************************************************************************
288 
289  //**Compile time checks*************************************************************************
296  //**********************************************************************************************
297 };
299 //*************************************************************************************************
300 
301 
302 
303 
304 //=================================================================================================
305 //
306 // CONSTRUCTOR
307 //
308 //=================================================================================================
309 
310 //*************************************************************************************************
318 template< typename MT // Type of the sparse matrix
319  , bool SF > // Symmetry flag
320 inline Row<MT,true,false,SF>::Row( Operand matrix, size_t index )
321  : matrix_( matrix ) // The sparse matrix containing the row
322  , row_ ( index ) // The index of the row in the matrix
323 {
324  if( matrix_.rows() <= index ) {
325  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
326  }
327 }
329 //*************************************************************************************************
330 
331 
332 
333 
334 //=================================================================================================
335 //
336 // DATA ACCESS FUNCTIONS
337 //
338 //=================================================================================================
339 
340 //*************************************************************************************************
350 template< typename MT // Type of the sparse matrix
351  , bool SF > // Symmetry flag
352 inline typename Row<MT,true,false,SF>::Reference Row<MT,true,false,SF>::operator[]( size_t index )
353 {
354  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
355  return matrix_(row_,index);
356 }
358 //*************************************************************************************************
359 
360 
361 //*************************************************************************************************
371 template< typename MT // Type of the sparse matrix
372  , bool SF > // Symmetry flag
374  Row<MT,true,false,SF>::operator[]( size_t index ) const
375 {
376  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
377  return const_cast<const MT&>( matrix_ )(row_,index);
378 }
380 //*************************************************************************************************
381 
382 
383 //*************************************************************************************************
394 template< typename MT // Type of the sparse matrix
395  , bool SF > // Symmetry flag
396 inline typename Row<MT,true,false,SF>::Reference Row<MT,true,false,SF>::at( size_t index )
397 {
398  if( index >= size() ) {
399  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
400  }
401  return (*this)[index];
402 }
404 //*************************************************************************************************
405 
406 
407 //*************************************************************************************************
418 template< typename MT // Type of the sparse matrix
419  , bool SF > // Symmetry flag
420 inline typename Row<MT,true,false,SF>::ConstReference Row<MT,true,false,SF>::at( size_t index ) const
421 {
422  if( index >= size() ) {
423  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
424  }
425  return (*this)[index];
426 }
428 //*************************************************************************************************
429 
430 
431 //*************************************************************************************************
439 template< typename MT // Type of the sparse matrix
440  , bool SF > // Symmetry flag
442 {
443  return matrix_.begin( row_ );
444 }
446 //*************************************************************************************************
447 
448 
449 //*************************************************************************************************
457 template< typename MT // Type of the sparse matrix
458  , bool SF > // Symmetry flag
460 {
461  return matrix_.cbegin( row_ );
462 }
464 //*************************************************************************************************
465 
466 
467 //*************************************************************************************************
475 template< typename MT // Type of the sparse matrix
476  , bool SF > // Symmetry flag
478 {
479  return matrix_.cbegin( row_ );
480 }
482 //*************************************************************************************************
483 
484 
485 //*************************************************************************************************
493 template< typename MT // Type of the sparse matrix
494  , bool SF > // Symmetry flag
496 {
497  return matrix_.end( row_ );
498 }
500 //*************************************************************************************************
501 
502 
503 //*************************************************************************************************
511 template< typename MT // Type of the sparse matrix
512  , bool SF > // Symmetry flag
514 {
515  return matrix_.cend( row_ );
516 }
518 //*************************************************************************************************
519 
520 
521 //*************************************************************************************************
529 template< typename MT // Type of the sparse matrix
530  , bool SF > // Symmetry flag
532 {
533  return matrix_.cend( row_ );
534 }
536 //*************************************************************************************************
537 
538 
539 
540 
541 //=================================================================================================
542 //
543 // ASSIGNMENT OPERATORS
544 //
545 //=================================================================================================
546 
547 //*************************************************************************************************
561 template< typename MT // Type of the sparse matrix
562  , bool SF > // Symmetry flag
563 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator=( const Row& rhs )
564 {
565  using blaze::assign;
566 
570 
571  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
572  return *this;
573 
574  if( size() != rhs.size() ) {
575  BLAZE_THROW_INVALID_ARGUMENT( "Row sizes do not match" );
576  }
577 
578  if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
579  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
580  }
581 
582  DerestrictTrait_<This> left( derestrict( *this ) );
583 
584  if( rhs.canAlias( &matrix_ ) ) {
585  const ResultType tmp( rhs );
586  left.reset();
587  left.reserve( tmp.nonZeros() );
588  assign( left, tmp );
589  }
590  else {
591  left.reset();
592  left.reserve( rhs.nonZeros() );
593  assign( left, rhs );
594  }
595 
596  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
597 
598  return *this;
599 }
601 //*************************************************************************************************
602 
603 
604 //*************************************************************************************************
618 template< typename MT // Type of the sparse matrix
619  , bool SF > // Symmetry flag
620 template< typename VT > // Type of the right-hand side dense vector
621 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator=( const DenseVector<VT,true>& rhs )
622 {
623  using blaze::assign;
624 
625  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
626  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
628 
629  if( size() != (~rhs).size() ) {
630  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
631  }
632 
633  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
634  Right right( ~rhs );
635 
636  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
637  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
638  }
639 
640  DerestrictTrait_<This> left( derestrict( *this ) );
641 
642  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
643  const ResultType_<VT> tmp( right );
644  left.reset();
645  assign( left, tmp );
646  }
647  else {
648  left.reset();
649  assign( left, right );
650  }
651 
652  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
653 
654  return *this;
655 }
657 //*************************************************************************************************
658 
659 
660 //*************************************************************************************************
674 template< typename MT // Type of the sparse matrix
675  , bool SF > // Symmetry flag
676 template< typename VT > // Type of the right-hand side sparse vector
677 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator=( const SparseVector<VT,true>& rhs )
678 {
679  using blaze::assign;
680 
682  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
684 
685  if( size() != (~rhs).size() ) {
686  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
687  }
688 
689  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
690  Right right( ~rhs );
691 
692  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
693  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
694  }
695 
696  DerestrictTrait_<This> left( derestrict( *this ) );
697 
698  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
699  const ResultType_<VT> tmp( right );
700  left.reset();
701  left.reserve( tmp.nonZeros() );
702  assign( left, tmp );
703  }
704  else {
705  left.reset();
706  left.reserve( right.nonZeros() );
707  assign( left, right );
708  }
709 
710  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
711 
712  return *this;
713 }
715 //*************************************************************************************************
716 
717 
718 //*************************************************************************************************
732 template< typename MT // Type of the sparse matrix
733  , bool SF > // Symmetry flag
734 template< typename VT > // Type of the right-hand side dense vector
735 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator+=( const DenseVector<VT,true>& rhs )
736 {
737  using blaze::assign;
738 
742  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
743  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
745 
746  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
747 
751 
752  if( size() != (~rhs).size() ) {
753  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
754  }
755 
756  const AddType tmp( *this + (~rhs) );
757 
758  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
759  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
760  }
761 
762  DerestrictTrait_<This> left( derestrict( *this ) );
763 
764  left.reset();
765  assign( left, tmp );
766 
767  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
768 
769  return *this;
770 }
772 //*************************************************************************************************
773 
774 
775 //*************************************************************************************************
789 template< typename MT // Type of the sparse matrix
790  , bool SF > // Symmetry flag
791 template< typename VT > // Type of the right-hand side sparse vector
792 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator+=( const SparseVector<VT,true>& rhs )
793 {
794  using blaze::assign;
795 
800  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
802 
803  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
804 
808 
809  if( size() != (~rhs).size() ) {
810  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
811  }
812 
813  const AddType tmp( *this + (~rhs) );
814 
815  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
816  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
817  }
818 
819  DerestrictTrait_<This> left( derestrict( *this ) );
820 
821  left.reset();
822  left.reserve( tmp.nonZeros() );
823  assign( left, tmp );
824 
825  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
826 
827  return *this;
828 }
830 //*************************************************************************************************
831 
832 
833 //*************************************************************************************************
848 template< typename MT // Type of the sparse matrix
849  , bool SF > // Symmetry flag
850 template< typename VT > // Type of the right-hand side dense vector
851 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator-=( const DenseVector<VT,true>& rhs )
852 {
853  using blaze::assign;
854 
858  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
859  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
861 
862  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
863 
867 
868  if( size() != (~rhs).size() ) {
869  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
870  }
871 
872  const SubType tmp( *this - (~rhs) );
873 
874  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
875  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
876  }
877 
878  DerestrictTrait_<This> left( derestrict( *this ) );
879 
880  left.reset();
881  assign( left, tmp );
882 
883  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
884 
885  return *this;
886 }
888 //*************************************************************************************************
889 
890 
891 //*************************************************************************************************
906 template< typename MT // Type of the sparse matrix
907  , bool SF > // Symmetry flag
908 template< typename VT > // Type of the right-hand side sparse vector
909 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator-=( const SparseVector<VT,true>& rhs )
910 {
911  using blaze::assign;
912 
917  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
919 
920  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
921 
925 
926  if( size() != (~rhs).size() ) {
927  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
928  }
929 
930  const SubType tmp( *this - (~rhs) );
931 
932  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
933  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
934  }
935 
936  DerestrictTrait_<This> left( derestrict( *this ) );
937 
938  left.reset();
939  left.reserve( tmp.nonZeros() );
940  assign( left, tmp );
941 
942  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
943 
944  return *this;
945 }
947 //*************************************************************************************************
948 
949 
950 //*************************************************************************************************
963 template< typename MT // Type of the sparse matrix
964  , bool SF > // Symmetry flag
965 template< typename VT > // Type of the right-hand side vector
966 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator*=( const Vector<VT,true>& rhs )
967 {
968  using blaze::assign;
969 
973  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
975 
976  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
977 
980 
981  if( size() != (~rhs).size() ) {
982  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
983  }
984 
985  const MultType tmp( *this * (~rhs) );
986 
987  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
988  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
989  }
990 
991  DerestrictTrait_<This> left( derestrict( *this ) );
992 
993  left.reset();
994  assign( left, tmp );
995 
996  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
997 
998  return *this;
999 }
1001 //*************************************************************************************************
1002 
1003 
1004 //*************************************************************************************************
1016 template< typename MT // Type of the sparse matrix
1017  , bool SF > // Symmetry flag
1018 template< typename VT > // Type of the right-hand side vector
1019 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::operator/=( const DenseVector<VT,true>& rhs )
1020 {
1021  using blaze::assign;
1022 
1026  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
1027  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
1029 
1030  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
1031 
1035 
1036  if( size() != (~rhs).size() ) {
1037  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1038  }
1039 
1040  const DivType tmp( *this / (~rhs) );
1041 
1042  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
1043  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1044  }
1045 
1046  DerestrictTrait_<This> left( derestrict( *this ) );
1047 
1048  left.reset();
1049  assign( left, tmp );
1050 
1051  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1052 
1053  return *this;
1054 }
1056 //*************************************************************************************************
1057 
1058 
1059 //*************************************************************************************************
1074 template< typename MT // Type of the sparse matrix
1075  , bool SF > // Symmetry flag
1076 template< typename Other > // Data type of the right-hand side scalar
1077 inline EnableIf_<IsNumeric<Other>, Row<MT,true,false,SF> >&
1079 {
1081 
1082  for( Iterator element=begin(); element!=end(); ++element )
1083  element->value() *= rhs;
1084  return *this;
1085 }
1087 //*************************************************************************************************
1088 
1089 
1090 //*************************************************************************************************
1108 template< typename MT // Type of the sparse matrix
1109  , bool SF > // Symmetry flag
1110 template< typename Other > // Data type of the right-hand side scalar
1111 inline EnableIf_<IsNumeric<Other>, Row<MT,true,false,SF> >&
1113 {
1115 
1116  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1117 
1118  typedef DivTrait_<ElementType,Other> DT;
1119  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
1120 
1121  // Depending on the two involved data types, an integer division is applied or a
1122  // floating point division is selected.
1123  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
1124  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1125  for( Iterator element=begin(); element!=end(); ++element )
1126  element->value() *= tmp;
1127  }
1128  else {
1129  for( Iterator element=begin(); element!=end(); ++element )
1130  element->value() /= rhs;
1131  }
1132 
1133  return *this;
1134 }
1136 //*************************************************************************************************
1137 
1138 
1139 
1140 
1141 //=================================================================================================
1142 //
1143 // UTILITY FUNCTIONS
1144 //
1145 //=================================================================================================
1146 
1147 //*************************************************************************************************
1153 template< typename MT // Type of the sparse matrix
1154  , bool SF > // Symmetry flag
1155 inline size_t Row<MT,true,false,SF>::size() const noexcept
1156 {
1157  return matrix_.columns();
1158 }
1160 //*************************************************************************************************
1161 
1162 
1163 //*************************************************************************************************
1169 template< typename MT // Type of the sparse matrix
1170  , bool SF > // Symmetry flag
1171 inline size_t Row<MT,true,false,SF>::capacity() const noexcept
1172 {
1173  return matrix_.capacity( row_ );
1174 }
1176 //*************************************************************************************************
1177 
1178 
1179 //*************************************************************************************************
1188 template< typename MT // Type of the sparse matrix
1189  , bool SF > // Symmetry flag
1190 inline size_t Row<MT,true,false,SF>::nonZeros() const
1191 {
1192  return matrix_.nonZeros( row_ );
1193 }
1195 //*************************************************************************************************
1196 
1197 
1198 //*************************************************************************************************
1204 template< typename MT // Type of the sparse matrix
1205  , bool SF > // Symmetry flag
1206 inline void Row<MT,true,false,SF>::reset()
1207 {
1208  matrix_.reset( row_ );
1209 }
1211 //*************************************************************************************************
1212 
1213 
1214 //*************************************************************************************************
1226 template< typename MT // Type of the sparse matrix
1227  , bool SF > // Symmetry flag
1228 inline typename Row<MT,true,false,SF>::Iterator
1229  Row<MT,true,false,SF>::set( size_t index, const ElementType& value )
1230 {
1231  return matrix_.set( row_, index, value );
1232 }
1234 //*************************************************************************************************
1235 
1236 
1237 //*************************************************************************************************
1250 template< typename MT // Type of the sparse matrix
1251  , bool SF > // Symmetry flag
1252 inline typename Row<MT,true,false,SF>::Iterator
1253  Row<MT,true,false,SF>::insert( size_t index, const ElementType& value )
1254 {
1255  return matrix_.insert( row_, index, value );
1256 }
1258 //*************************************************************************************************
1259 
1260 
1261 //*************************************************************************************************
1270 template< typename MT // Type of the sparse matrix
1271  , bool SF > // Symmetry flag
1272 inline void Row<MT,true,false,SF>::erase( size_t index )
1273 {
1274  matrix_.erase( row_, index );
1275 }
1277 //*************************************************************************************************
1278 
1279 
1280 //*************************************************************************************************
1289 template< typename MT // Type of the sparse matrix
1290  , bool SF > // Symmetry flag
1291 inline typename Row<MT,true,false,SF>::Iterator Row<MT,true,false,SF>::erase( Iterator pos )
1292 {
1293  return matrix_.erase( row_, pos );
1294 }
1296 //*************************************************************************************************
1297 
1298 
1299 //*************************************************************************************************
1309 template< typename MT // Type of the sparse matrix
1310  , bool SF > // Symmetry flag
1311 inline typename Row<MT,true,false,SF>::Iterator
1312  Row<MT,true,false,SF>::erase( Iterator first, Iterator last )
1313 {
1314  return matrix_.erase( row_, first, last );
1315 }
1317 //*************************************************************************************************
1318 
1319 
1320 //*************************************************************************************************
1330 template< typename MT // Type of the sparse matrix
1331  , bool SF > // Symmetry flag
1332 void Row<MT,true,false,SF>::reserve( size_t n )
1333 {
1334  matrix_.reserve( row_, n );
1335 }
1337 //*************************************************************************************************
1338 
1339 
1340 //*************************************************************************************************
1351 template< typename MT // Type of the sparse matrix
1352  , bool SF > // Symmetry flag
1353 template< typename Other > // Data type of the scalar value
1354 inline Row<MT,true,false,SF>& Row<MT,true,false,SF>::scale( const Other& scalar )
1355 {
1357 
1358  for( Iterator element=begin(); element!=end(); ++element )
1359  element->value() *= scalar;
1360  return *this;
1361 }
1363 //*************************************************************************************************
1364 
1365 
1366 //*************************************************************************************************
1375 template< typename MT // Type of the sparse matrix
1376  , bool SF > // Symmetry flag
1377 inline size_t Row<MT,true,false,SF>::extendCapacity() const noexcept
1378 {
1379  using blaze::max;
1380  using blaze::min;
1381 
1382  size_t nonzeros( 2UL*capacity()+1UL );
1383  nonzeros = max( nonzeros, 7UL );
1384  nonzeros = min( nonzeros, size() );
1385 
1386  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
1387 
1388  return nonzeros;
1389 }
1391 //*************************************************************************************************
1392 
1393 
1394 
1395 
1396 //=================================================================================================
1397 //
1398 // LOOKUP FUNCTIONS
1399 //
1400 //=================================================================================================
1401 
1402 //*************************************************************************************************
1416 template< typename MT // Type of the sparse matrix
1417  , bool SF > // Symmetry flag
1418 inline typename Row<MT,true,false,SF>::Iterator Row<MT,true,false,SF>::find( size_t index )
1419 {
1420  return matrix_.find( row_, index );
1421 }
1423 //*************************************************************************************************
1424 
1425 
1426 //*************************************************************************************************
1440 template< typename MT // Type of the sparse matrix
1441  , bool SF > // Symmetry flag
1442 inline typename Row<MT,true,false,SF>::ConstIterator Row<MT,true,false,SF>::find( size_t index ) const
1443 {
1444  return matrix_.find( row_, index );
1445 }
1447 //*************************************************************************************************
1448 
1449 
1450 //*************************************************************************************************
1463 template< typename MT // Type of the sparse matrix
1464  , bool SF > // Symmetry flag
1465 inline typename Row<MT,true,false,SF>::Iterator Row<MT,true,false,SF>::lowerBound( size_t index )
1466 {
1467  return matrix_.lowerBound( row_, index );
1468 }
1470 //*************************************************************************************************
1471 
1472 
1473 //*************************************************************************************************
1486 template< typename MT // Type of the sparse matrix
1487  , bool SF > // Symmetry flag
1488 inline typename Row<MT,true,false,SF>::ConstIterator Row<MT,true,false,SF>::lowerBound( size_t index ) const
1489 {
1490  return matrix_.lowerBound( row_, index );
1491 }
1493 //*************************************************************************************************
1494 
1495 
1496 //*************************************************************************************************
1509 template< typename MT // Type of the sparse matrix
1510  , bool SF > // Symmetry flag
1511 inline typename Row<MT,true,false,SF>::Iterator Row<MT,true,false,SF>::upperBound( size_t index )
1512 {
1513  return matrix_.upperBound( row_, index );
1514 }
1516 //*************************************************************************************************
1517 
1518 
1519 //*************************************************************************************************
1532 template< typename MT // Type of the sparse matrix
1533  , bool SF > // Symmetry flag
1534 inline typename Row<MT,true,false,SF>::ConstIterator Row<MT,true,false,SF>::upperBound( size_t index ) const
1535 {
1536  return matrix_.upperBound( row_, index );
1537 }
1539 //*************************************************************************************************
1540 
1541 
1542 
1543 
1544 //=================================================================================================
1545 //
1546 // LOW-LEVEL UTILITY FUNCTIONS
1547 //
1548 //=================================================================================================
1549 
1550 //*************************************************************************************************
1575 template< typename MT // Type of the sparse matrix
1576  , bool SF > // Symmetry flag
1577 inline void Row<MT,true,false,SF>::append( size_t index, const ElementType& value, bool check )
1578 {
1579  matrix_.append( row_, index, value, check );
1580 }
1582 //*************************************************************************************************
1583 
1584 
1585 
1586 
1587 //=================================================================================================
1588 //
1589 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1590 //
1591 //=================================================================================================
1592 
1593 //*************************************************************************************************
1604 template< typename MT // Type of the sparse matrix
1605  , bool SF > // Symmetry flag
1606 template< typename Other > // Data type of the foreign expression
1607 inline bool Row<MT,true,false,SF>::canAlias( const Other* alias ) const noexcept
1608 {
1609  return matrix_.isAliased( alias );
1610 }
1612 //*************************************************************************************************
1613 
1614 
1615 //*************************************************************************************************
1626 template< typename MT // Type of the sparse matrix
1627  , bool SF > // Symmetry flag
1628 template< typename Other > // Data type of the foreign expression
1629 inline bool Row<MT,true,false,SF>::isAliased( const Other* alias ) const noexcept
1630 {
1631  return matrix_.isAliased( alias );
1632 }
1634 //*************************************************************************************************
1635 
1636 
1637 //*************************************************************************************************
1649 template< typename MT // Type of the sparse matrix
1650  , bool SF > // Symmetry flag
1651 template< typename VT > // Type of the right-hand side dense vector
1652 inline void Row<MT,true,false,SF>::assign( const DenseVector<VT,true>& rhs )
1653 {
1654  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1655  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1656 
1657  for( size_t j=0UL; j<size(); ++j )
1658  {
1659  if( matrix_.nonZeros( row_ ) == matrix_.capacity( row_ ) )
1660  matrix_.reserve( row_, extendCapacity() );
1661 
1662  matrix_.append( row_, j, (~rhs)[j], true );
1663  }
1664 }
1666 //*************************************************************************************************
1667 
1668 
1669 //*************************************************************************************************
1681 template< typename MT // Type of the sparse matrix
1682  , bool SF > // Symmetry flag
1683 template< typename VT > // Type of the right-hand side sparse vector
1684 inline void Row<MT,true,false,SF>::assign( const SparseVector<VT,true>& rhs )
1685 {
1686  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1687  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1688 
1689  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
1690  matrix_.append( row_, element->index(), element->value(), true );
1691  }
1692 }
1694 //*************************************************************************************************
1695 
1696 
1697 //*************************************************************************************************
1709 template< typename MT // Type of the sparse matrix
1710  , bool SF > // Symmetry flag
1711 template< typename VT > // Type of the right-hand side dense vector
1712 inline void Row<MT,true,false,SF>::addAssign( const DenseVector<VT,true>& rhs )
1713 {
1714  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
1715 
1719 
1720  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1721 
1722  const AddType tmp( serial( *this + (~rhs) ) );
1723  matrix_.reset( row_ );
1724  assign( tmp );
1725 }
1727 //*************************************************************************************************
1728 
1729 
1730 //*************************************************************************************************
1742 template< typename MT // Type of the sparse matrix
1743  , bool SF > // Symmetry flag
1744 template< typename VT > // Type of the right-hand side sparse vector
1745 inline void Row<MT,true,false,SF>::addAssign( const SparseVector<VT,true>& rhs )
1746 {
1747  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
1748 
1752 
1753  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1754 
1755  const AddType tmp( serial( *this + (~rhs) ) );
1756  matrix_.reset( row_ );
1757  matrix_.reserve( row_, tmp.nonZeros() );
1758  assign( tmp );
1759 }
1761 //*************************************************************************************************
1762 
1763 
1764 //*************************************************************************************************
1776 template< typename MT // Type of the sparse matrix
1777  , bool SF > // Symmetry flag
1778 template< typename VT > // Type of the right-hand side dense vector
1779 inline void Row<MT,true,false,SF>::subAssign( const DenseVector<VT,true>& rhs )
1780 {
1781  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
1782 
1786 
1787  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1788 
1789  const SubType tmp( serial( *this - (~rhs) ) );
1790  matrix_.reset( row_ );
1791  assign( tmp );
1792 }
1794 //*************************************************************************************************
1795 
1796 
1797 //*************************************************************************************************
1809 template< typename MT // Type of the sparse matrix
1810  , bool SF > // Symmetry flag
1811 template< typename VT > // Type of the right-hand side sparse vector
1812 inline void Row<MT,true,false,SF>::subAssign( const SparseVector<VT,true>& rhs )
1813 {
1814  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
1815 
1819 
1820  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1821 
1822  const SubType tmp( serial( *this - (~rhs) ) );
1823  matrix_.reset( row_ );
1824  matrix_.reserve( row_, tmp.nonZeros() );
1825  assign( tmp );
1826 }
1828 //*************************************************************************************************
1829 
1830 
1831 
1832 
1833 
1834 
1835 
1836 
1837 //=================================================================================================
1838 //
1839 // CLASS TEMPLATE SPECIALIZATION FOR GENERAL COLUMN-MAJOR SPARSE MATRICES
1840 //
1841 //=================================================================================================
1842 
1843 //*************************************************************************************************
1851 template< typename MT > // Type of the sparse matrix
1852 class Row<MT,false,false,false>
1853  : public SparseVector< Row<MT,false,false,false>, true >
1854  , private View
1855 {
1856  private:
1857  //**Type definitions****************************************************************************
1859  typedef If_< IsExpression<MT>, MT, MT& > Operand;
1860  //**********************************************************************************************
1861 
1862  public:
1863  //**Type definitions****************************************************************************
1864  typedef Row<MT,false,false,false> This;
1865  typedef SparseVector<This,true> BaseType;
1866  typedef RowTrait_<MT> ResultType;
1867  typedef TransposeType_<ResultType> TransposeType;
1868  typedef ElementType_<MT> ElementType;
1869  typedef ReturnType_<MT> ReturnType;
1870  typedef const Row& CompositeType;
1871 
1873  typedef ConstReference_<MT> ConstReference;
1874 
1876  typedef If_< IsConst<MT>, ConstReference, Reference_<MT> > Reference;
1877  //**********************************************************************************************
1878 
1879  //**RowElement class definition*****************************************************************
1882  template< typename MatrixType // Type of the sparse matrix
1883  , typename IteratorType > // Type of the sparse matrix iterator
1884  class RowElement : private SparseElement
1885  {
1886  private:
1887  //*******************************************************************************************
1889 
1894  enum : bool { returnConst = IsConst<MatrixType>::value };
1895  //*******************************************************************************************
1896 
1897  //**Type definitions*************************************************************************
1899  typedef typename std::iterator_traits<IteratorType>::value_type SET;
1900 
1901  typedef Reference_<SET> RT;
1902  typedef ConstReference_<SET> CRT;
1903  //*******************************************************************************************
1904 
1905  public:
1906  //**Type definitions*************************************************************************
1907  typedef ValueType_<SET> ValueType;
1908  typedef size_t IndexType;
1909  typedef IfTrue_<returnConst,CRT,RT> Reference;
1910  typedef CRT ConstReference;
1911  //*******************************************************************************************
1912 
1913  //**Constructor******************************************************************************
1919  inline RowElement( IteratorType pos, size_t column )
1920  : pos_ ( pos ) // Iterator to the current position within the sparse row
1921  , column_( column ) // Index of the according column
1922  {}
1923  //*******************************************************************************************
1924 
1925  //**Assignment operator**********************************************************************
1931  template< typename T > inline RowElement& operator=( const T& v ) {
1932  *pos_ = v;
1933  return *this;
1934  }
1935  //*******************************************************************************************
1936 
1937  //**Addition assignment operator*************************************************************
1943  template< typename T > inline RowElement& operator+=( const T& v ) {
1944  *pos_ += v;
1945  return *this;
1946  }
1947  //*******************************************************************************************
1948 
1949  //**Subtraction assignment operator**********************************************************
1955  template< typename T > inline RowElement& operator-=( const T& v ) {
1956  *pos_ -= v;
1957  return *this;
1958  }
1959  //*******************************************************************************************
1960 
1961  //**Multiplication assignment operator*******************************************************
1967  template< typename T > inline RowElement& operator*=( const T& v ) {
1968  *pos_ *= v;
1969  return *this;
1970  }
1971  //*******************************************************************************************
1972 
1973  //**Division assignment operator*************************************************************
1979  template< typename T > inline RowElement& operator/=( const T& v ) {
1980  *pos_ /= v;
1981  return *this;
1982  }
1983  //*******************************************************************************************
1984 
1985  //**Element access operator******************************************************************
1990  inline const RowElement* operator->() const {
1991  return this;
1992  }
1993  //*******************************************************************************************
1994 
1995  //**Value function***************************************************************************
2000  inline Reference value() const {
2001  return pos_->value();
2002  }
2003  //*******************************************************************************************
2004 
2005  //**Index function***************************************************************************
2010  inline IndexType index() const {
2011  return column_;
2012  }
2013  //*******************************************************************************************
2014 
2015  private:
2016  //**Member variables*************************************************************************
2017  IteratorType pos_;
2018  size_t column_;
2019  //*******************************************************************************************
2020  };
2021  //**********************************************************************************************
2022 
2023  //**RowIterator class definition****************************************************************
2026  template< typename MatrixType // Type of the sparse matrix
2027  , typename IteratorType > // Type of the sparse matrix iterator
2028  class RowIterator
2029  {
2030  public:
2031  //**Type definitions*************************************************************************
2032  typedef std::forward_iterator_tag IteratorCategory;
2033  typedef RowElement<MatrixType,IteratorType> ValueType;
2034  typedef ValueType PointerType;
2035  typedef ValueType ReferenceType;
2036  typedef ptrdiff_t DifferenceType;
2037 
2038  // STL iterator requirements
2039  typedef IteratorCategory iterator_category;
2040  typedef ValueType value_type;
2041  typedef PointerType pointer;
2042  typedef ReferenceType reference;
2043  typedef DifferenceType difference_type;
2044  //*******************************************************************************************
2045 
2046  //**Constructor******************************************************************************
2049  inline RowIterator()
2050  : matrix_( nullptr ) // The sparse matrix containing the row.
2051  , row_ ( 0UL ) // The current row index.
2052  , column_( 0UL ) // The current column index.
2053  , pos_ () // Iterator to the current sparse element.
2054  {}
2055  //*******************************************************************************************
2056 
2057  //**Constructor******************************************************************************
2064  inline RowIterator( MatrixType& matrix, size_t row, size_t column )
2065  : matrix_( &matrix ) // The sparse matrix containing the row.
2066  , row_ ( row ) // The current row index.
2067  , column_( column ) // The current column index.
2068  , pos_ () // Iterator to the current sparse element.
2069  {
2070  for( ; column_<matrix_->columns(); ++column_ ) {
2071  pos_ = matrix_->find( row_, column_ );
2072  if( pos_ != matrix_->end( column_ ) ) break;
2073  }
2074  }
2075  //*******************************************************************************************
2076 
2077  //**Constructor******************************************************************************
2085  inline RowIterator( MatrixType& matrix, size_t row, size_t column, IteratorType pos )
2086  : matrix_( &matrix ) // The sparse matrix containing the row.
2087  , row_ ( row ) // The current row index.
2088  , column_( column ) // The current column index.
2089  , pos_ ( pos ) // Iterator to the current sparse element.
2090  {
2091  BLAZE_INTERNAL_ASSERT( matrix.find( row, column ) == pos, "Invalid initial iterator position" );
2092  }
2093  //*******************************************************************************************
2094 
2095  //**Constructor******************************************************************************
2100  template< typename MatrixType2, typename IteratorType2 >
2101  inline RowIterator( const RowIterator<MatrixType2,IteratorType2>& it )
2102  : matrix_( it.matrix_ ) // The sparse matrix containing the row.
2103  , row_ ( it.row_ ) // The current row index.
2104  , column_( it.column_ ) // The current column index.
2105  , pos_ ( it.pos_ ) // Iterator to the current sparse element.
2106  {}
2107  //*******************************************************************************************
2108 
2109  //**Prefix increment operator****************************************************************
2114  inline RowIterator& operator++() {
2115  ++column_;
2116  for( ; column_<matrix_->columns(); ++column_ ) {
2117  pos_ = matrix_->find( row_, column_ );
2118  if( pos_ != matrix_->end( column_ ) ) break;
2119  }
2120 
2121  return *this;
2122  }
2123  //*******************************************************************************************
2124 
2125  //**Postfix increment operator***************************************************************
2130  inline const RowIterator operator++( int ) {
2131  const RowIterator tmp( *this );
2132  ++(*this);
2133  return tmp;
2134  }
2135  //*******************************************************************************************
2136 
2137  //**Element access operator******************************************************************
2142  inline ReferenceType operator*() const {
2143  return ReferenceType( pos_, column_ );
2144  }
2145  //*******************************************************************************************
2146 
2147  //**Element access operator******************************************************************
2152  inline PointerType operator->() const {
2153  return PointerType( pos_, column_ );
2154  }
2155  //*******************************************************************************************
2156 
2157  //**Equality operator************************************************************************
2163  template< typename MatrixType2, typename IteratorType2 >
2164  inline bool operator==( const RowIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
2165  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
2166  }
2167  //*******************************************************************************************
2168 
2169  //**Inequality operator**********************************************************************
2175  template< typename MatrixType2, typename IteratorType2 >
2176  inline bool operator!=( const RowIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
2177  return !( *this == rhs );
2178  }
2179  //*******************************************************************************************
2180 
2181  //**Subtraction operator*********************************************************************
2187  inline DifferenceType operator-( const RowIterator& rhs ) const {
2188  size_t counter( 0UL );
2189  for( size_t j=rhs.column_; j<column_; ++j ) {
2190  if( matrix_->find( row_, j ) != matrix_->end( j ) )
2191  ++counter;
2192  }
2193  return counter;
2194  }
2195  //*******************************************************************************************
2196 
2197  private:
2198  //**Member variables*************************************************************************
2199  MatrixType* matrix_;
2200  size_t row_;
2201  size_t column_;
2202  IteratorType pos_;
2203  //*******************************************************************************************
2204 
2205  //**Friend declarations**********************************************************************
2206  template< typename MatrixType2, typename IteratorType2 > friend class RowIterator;
2207  template< typename MT2, bool SO2, bool DF2, bool SF2 > friend class Row;
2208  //*******************************************************************************************
2209  };
2210  //**********************************************************************************************
2211 
2212  //**Type definitions****************************************************************************
2214  typedef RowIterator< const MT, ConstIterator_<MT> > ConstIterator;
2215 
2217  typedef If_< IsConst<MT>, ConstIterator, RowIterator< MT, Iterator_<MT> > > Iterator;
2218  //**********************************************************************************************
2219 
2220  //**Compilation flags***************************************************************************
2222  enum : bool { smpAssignable = false };
2223  //**********************************************************************************************
2224 
2225  //**Constructors********************************************************************************
2228  explicit inline Row( Operand matrix, size_t index );
2229  // No explicitly declared copy constructor.
2231  //**********************************************************************************************
2232 
2233  //**Destructor**********************************************************************************
2234  // No explicitly declared destructor.
2235  //**********************************************************************************************
2236 
2237  //**Data access functions***********************************************************************
2240  inline Reference operator[]( size_t index );
2241  inline ConstReference operator[]( size_t index ) const;
2242  inline Reference at( size_t index );
2243  inline ConstReference at( size_t index ) const;
2244  inline Iterator begin ();
2245  inline ConstIterator begin () const;
2246  inline ConstIterator cbegin() const;
2247  inline Iterator end ();
2248  inline ConstIterator end () const;
2249  inline ConstIterator cend () const;
2251  //**********************************************************************************************
2252 
2253  //**Assignment operators************************************************************************
2256  inline Row& operator= ( const Row& rhs );
2257  template< typename VT > inline Row& operator= ( const Vector<VT,true>& rhs );
2258  template< typename VT > inline Row& operator+=( const Vector<VT,true>& rhs );
2259  template< typename VT > inline Row& operator-=( const Vector<VT,true>& rhs );
2260  template< typename VT > inline Row& operator*=( const Vector<VT,true>& rhs );
2261  template< typename VT > inline Row& operator/=( const DenseVector<VT,true>& rhs );
2262 
2263  template< typename Other >
2264  inline EnableIf_<IsNumeric<Other>, Row >& operator*=( Other rhs );
2265 
2266  template< typename Other >
2267  inline EnableIf_<IsNumeric<Other>, Row >& operator/=( Other rhs );
2269  //**********************************************************************************************
2270 
2271  //**Utility functions***************************************************************************
2274  inline size_t size() const noexcept;
2275  inline size_t capacity() const noexcept;
2276  inline size_t nonZeros() const;
2277  inline void reset();
2278  inline Iterator set ( size_t index, const ElementType& value );
2279  inline Iterator insert ( size_t index, const ElementType& value );
2280  inline void erase ( size_t index );
2281  inline Iterator erase ( Iterator pos );
2282  inline Iterator erase ( Iterator first, Iterator last );
2283  inline void reserve( size_t n );
2284  template< typename Other > inline Row& scale ( const Other& scalar );
2286  //**********************************************************************************************
2287 
2288  //**Lookup functions****************************************************************************
2291  inline Iterator find ( size_t index );
2292  inline ConstIterator find ( size_t index ) const;
2293  inline Iterator lowerBound( size_t index );
2294  inline ConstIterator lowerBound( size_t index ) const;
2295  inline Iterator upperBound( size_t index );
2296  inline ConstIterator upperBound( size_t index ) const;
2298  //**********************************************************************************************
2299 
2300  //**Low-level utility functions*****************************************************************
2303  inline void append( size_t index, const ElementType& value, bool check=false );
2305  //**********************************************************************************************
2306 
2307  //**Expression template evaluation functions****************************************************
2310  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
2311  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
2312 
2313  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
2314  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
2315  template< typename VT > inline void addAssign( const Vector<VT,true>& rhs );
2316  template< typename VT > inline void subAssign( const Vector<VT,true>& rhs );
2318  //**********************************************************************************************
2319 
2320  private:
2321  //**Member variables****************************************************************************
2324  Operand matrix_;
2325  const size_t row_;
2326 
2327  //**********************************************************************************************
2328 
2329  //**Friend declarations*************************************************************************
2330  template< typename MT2, bool SO2, bool DF2, bool SF2 >
2331  friend bool isIntact( const Row<MT2,SO2,DF2,SF2>& row ) noexcept;
2332 
2333  template< typename MT2, bool SO2, bool DF2, bool SF2 >
2334  friend bool isSame( const Row<MT2,SO2,DF2,SF2>& a, const Row<MT2,SO2,DF2,SF2>& b ) noexcept;
2335 
2336  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2337  friend bool tryAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
2338 
2339  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2340  friend bool tryAddAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
2341 
2342  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2343  friend bool trySubAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
2344 
2345  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2346  friend bool tryMultAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
2347 
2348  template< typename MT2, bool SO2, bool DF2, bool SF2 >
2349  friend DerestrictTrait_< Row<MT2,SO2,DF2,SF2> > derestrict( Row<MT2,SO2,DF2,SF2>& row );
2350  //**********************************************************************************************
2351 
2352  //**Compile time checks*************************************************************************
2360  //**********************************************************************************************
2361 };
2363 //*************************************************************************************************
2364 
2365 
2366 
2367 
2368 //=================================================================================================
2369 //
2370 // CONSTRUCTOR
2371 //
2372 //=================================================================================================
2373 
2374 //*************************************************************************************************
2382 template< typename MT > // Type of the sparse matrix
2383 inline Row<MT,false,false,false>::Row( Operand matrix, size_t index )
2384  : matrix_( matrix ) // The sparse matrix containing the row
2385  , row_ ( index ) // The index of the row in the matrix
2386 {
2387  if( matrix_.rows() <= index ) {
2388  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
2389  }
2390 }
2392 //*************************************************************************************************
2393 
2394 
2395 
2396 
2397 //=================================================================================================
2398 //
2399 // DATA ACCESS FUNCTIONS
2400 //
2401 //=================================================================================================
2402 
2403 //*************************************************************************************************
2413 template< typename MT > // Type of the sparse matrix
2415  Row<MT,false,false,false>::operator[]( size_t index )
2416 {
2417  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2418  return matrix_(row_,index);
2419 }
2421 //*************************************************************************************************
2422 
2423 
2424 //*************************************************************************************************
2434 template< typename MT > // Type of the sparse matrix
2436  Row<MT,false,false,false>::operator[]( size_t index ) const
2437 {
2438  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2439  return const_cast<const MT&>( matrix_ )(row_,index);
2440 }
2442 //*************************************************************************************************
2443 
2444 
2445 //*************************************************************************************************
2456 template< typename MT > // Type of the sparse matrix
2458  Row<MT,false,false,false>::at( size_t index )
2459 {
2460  if( index >= size() ) {
2461  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
2462  }
2463  return (*this)[index];
2464 }
2466 //*************************************************************************************************
2467 
2468 
2469 //*************************************************************************************************
2480 template< typename MT > // Type of the sparse matrix
2482  Row<MT,false,false,false>::at( size_t index ) const
2483 {
2484  if( index >= size() ) {
2485  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
2486  }
2487  return (*this)[index];
2488 }
2490 //*************************************************************************************************
2491 
2492 
2493 //*************************************************************************************************
2501 template< typename MT > // Type of the sparse matrix
2503 {
2504  return Iterator( matrix_, row_, 0UL );
2505 }
2507 //*************************************************************************************************
2508 
2509 
2510 //*************************************************************************************************
2518 template< typename MT > // Type of the sparse matrix
2520 {
2521  return ConstIterator( matrix_, row_, 0UL );
2522 }
2524 //*************************************************************************************************
2525 
2526 
2527 //*************************************************************************************************
2535 template< typename MT > // Type of the sparse matrix
2537 {
2538  return ConstIterator( matrix_, row_, 0UL );
2539 }
2541 //*************************************************************************************************
2542 
2543 
2544 //*************************************************************************************************
2552 template< typename MT > // Type of the sparse matrix
2554 {
2555  return Iterator( matrix_, row_, size() );
2556 }
2558 //*************************************************************************************************
2559 
2560 
2561 //*************************************************************************************************
2569 template< typename MT > // Type of the sparse matrix
2571 {
2572  return ConstIterator( matrix_, row_, size() );
2573 }
2575 //*************************************************************************************************
2576 
2577 
2578 //*************************************************************************************************
2586 template< typename MT > // Type of the sparse matrix
2588 {
2589  return ConstIterator( matrix_, row_, size() );
2590 }
2592 //*************************************************************************************************
2593 
2594 
2595 
2596 
2597 //=================================================================================================
2598 //
2599 // ASSIGNMENT OPERATORS
2600 //
2601 //=================================================================================================
2602 
2603 //*************************************************************************************************
2617 template< typename MT > // Type of the sparse matrix
2618 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator=( const Row& rhs )
2619 {
2620  using blaze::assign;
2621 
2625 
2626  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
2627  return *this;
2628 
2629  if( size() != rhs.size() ) {
2630  BLAZE_THROW_INVALID_ARGUMENT( "Row sizes do not match" );
2631  }
2632 
2633  if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
2634  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2635  }
2636 
2637  DerestrictTrait_<This> left( derestrict( *this ) );
2638 
2639  if( rhs.canAlias( &matrix_ ) ) {
2640  const ResultType tmp( rhs );
2641  assign( left, tmp );
2642  }
2643  else {
2644  assign( left, rhs );
2645  }
2646 
2647  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2648 
2649  return *this;
2650 }
2652 //*************************************************************************************************
2653 
2654 
2655 //*************************************************************************************************
2669 template< typename MT > // Type of the sparse matrix
2670 template< typename VT > // Type of the right-hand side vector
2671 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator=( const Vector<VT,true>& rhs )
2672 {
2673  using blaze::assign;
2674 
2675  if( size() != (~rhs).size() ) {
2676  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2677  }
2678 
2679  const CompositeType_<VT> tmp( ~rhs );
2680 
2681  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2682  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2683  }
2684 
2685  DerestrictTrait_<This> left( derestrict( *this ) );
2686 
2687  assign( left, tmp );
2688 
2689  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2690 
2691  return *this;
2692 }
2694 //*************************************************************************************************
2695 
2696 
2697 //*************************************************************************************************
2711 template< typename MT > // Type of the sparse matrix
2712 template< typename VT > // Type of the right-hand side vector
2713 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator+=( const Vector<VT,true>& rhs )
2714 {
2715  using blaze::assign;
2716 
2720  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
2722 
2723  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
2724 
2727 
2728  if( size() != (~rhs).size() ) {
2729  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2730  }
2731 
2732  const AddType tmp( *this + (~rhs) );
2733 
2734  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2735  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2736  }
2737 
2738  DerestrictTrait_<This> left( derestrict( *this ) );
2739 
2740  assign( left, tmp );
2741 
2742  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2743 
2744  return *this;
2745 }
2747 //*************************************************************************************************
2748 
2749 
2750 //*************************************************************************************************
2764 template< typename MT > // Type of the sparse matrix
2765 template< typename VT > // Type of the right-hand side vector
2766 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator-=( const Vector<VT,true>& rhs )
2767 {
2768  using blaze::assign;
2769 
2773  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
2775 
2776  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
2777 
2780 
2781  if( size() != (~rhs).size() ) {
2782  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2783  }
2784 
2785  const SubType tmp( *this - (~rhs) );
2786 
2787  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2788  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2789  }
2790 
2791  DerestrictTrait_<This> left( derestrict( *this ) );
2792 
2793  assign( left, tmp );
2794 
2795  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2796 
2797  return *this;
2798 }
2800 //*************************************************************************************************
2801 
2802 
2803 //*************************************************************************************************
2816 template< typename MT > // Type of the sparse matrix
2817 template< typename VT > // Type of the right-hand side vector
2818 inline Row<MT,false,false,false>& Row<MT,false,false,false>::operator*=( const Vector<VT,true>& rhs )
2819 {
2820  using blaze::assign;
2821 
2825  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
2827 
2828  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
2829 
2832 
2833  if( size() != (~rhs).size() ) {
2834  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2835  }
2836 
2837  const MultType tmp( *this * (~rhs) );
2838 
2839  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2840  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2841  }
2842 
2843  DerestrictTrait_<This> left( derestrict( *this ) );
2844 
2845  assign( left, tmp );
2846 
2847  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2848 
2849  return *this;
2850 }
2852 //*************************************************************************************************
2853 
2854 
2855 //*************************************************************************************************
2867 template< typename MT > // Type of the sparse matrix
2868 template< typename VT > // Type of the right-hand side vector
2869 inline Row<MT,false,false,false>&
2870  Row<MT,false,false,false>::operator/=( const DenseVector<VT,true>& rhs )
2871 {
2872  using blaze::assign;
2873 
2877  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
2878  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
2880 
2881  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
2882 
2886 
2887  if( size() != (~rhs).size() ) {
2888  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2889  }
2890 
2891  const DivType tmp( *this / (~rhs) );
2892 
2893  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
2894  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2895  }
2896 
2897  DerestrictTrait_<This> left( derestrict( *this ) );
2898 
2899  assign( left, tmp );
2900 
2901  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2902 
2903  return *this;
2904 }
2906 //*************************************************************************************************
2907 
2908 
2909 //*************************************************************************************************
2924 template< typename MT > // Type of the sparse matrix
2925 template< typename Other > // Data type of the right-hand side scalar
2926 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,false> >&
2928 {
2930 
2931  for( Iterator element=begin(); element!=end(); ++element )
2932  element->value() *= rhs;
2933  return *this;
2934 }
2936 //*************************************************************************************************
2937 
2938 
2939 //*************************************************************************************************
2957 template< typename MT > // Type of the sparse matrix
2958 template< typename Other > // Data type of the right-hand side scalar
2959 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,false> >&
2961 {
2963 
2964  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
2965 
2966  typedef DivTrait_<ElementType,Other> DT;
2967  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
2968 
2969  // Depending on the two involved data types, an integer division is applied or a
2970  // floating point division is selected.
2971  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2972  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2973  for( Iterator element=begin(); element!=end(); ++element )
2974  element->value() *= tmp;
2975  }
2976  else {
2977  for( Iterator element=begin(); element!=end(); ++element )
2978  element->value() /= rhs;
2979  }
2980 
2981  return *this;
2982 }
2984 //*************************************************************************************************
2985 
2986 
2987 
2988 
2989 //=================================================================================================
2990 //
2991 // UTILITY FUNCTIONS
2992 //
2993 //=================================================================================================
2994 
2995 //*************************************************************************************************
3001 template< typename MT > // Type of the sparse matrix
3002 inline size_t Row<MT,false,false,false>::size() const noexcept
3003 {
3004  return matrix_.columns();
3005 }
3007 //*************************************************************************************************
3008 
3009 
3010 //*************************************************************************************************
3016 template< typename MT > // Type of the sparse matrix
3017 inline size_t Row<MT,false,false,false>::capacity() const noexcept
3018 {
3019  return matrix_.columns();
3020 }
3022 //*************************************************************************************************
3023 
3024 
3025 //*************************************************************************************************
3034 template< typename MT > // Type of the sparse matrix
3035 inline size_t Row<MT,false,false,false>::nonZeros() const
3036 {
3037  size_t counter( 0UL );
3038  for( ConstIterator element=begin(); element!=end(); ++element ) {
3039  ++counter;
3040  }
3041  return counter;
3042 }
3044 //*************************************************************************************************
3045 
3046 
3047 //*************************************************************************************************
3053 template< typename MT > // Type of the sparse matrix
3055 {
3056  const size_t jbegin( ( IsUpper<MT>::value )
3057  ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3058  ?( row_+1UL )
3059  :( row_ ) )
3060  :( 0UL ) );
3061  const size_t jend ( ( IsLower<MT>::value )
3062  ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3063  ?( row_ )
3064  :( row_+1UL ) )
3065  :( size() ) );
3066 
3067  for( size_t j=jbegin; j<jend; ++j ) {
3068  matrix_.erase( row_, j );
3069  }
3070 }
3072 //*************************************************************************************************
3073 
3074 
3075 //*************************************************************************************************
3088 template< typename MT > // Type of the sparse matrix
3090  Row<MT,false,false,false>::insert( size_t index, const ElementType& value )
3091 {
3092  return Iterator( matrix_, row_, index, matrix_.insert( row_, index, value ) );
3093 }
3095 //*************************************************************************************************
3096 
3097 
3098 //*************************************************************************************************
3110 template< typename MT > // Type of the sparse matrix
3112  Row<MT,false,false,false>::set( size_t index, const ElementType& value )
3113 {
3114  return Iterator( matrix_, row_, index, matrix_.set( row_, index, value ) );
3115 }
3117 //*************************************************************************************************
3118 
3119 
3120 //*************************************************************************************************
3129 template< typename MT > // Type of the sparse matrix
3130 inline void Row<MT,false,false,false>::erase( size_t index )
3131 {
3132  matrix_.erase( row_, index );
3133 }
3135 //*************************************************************************************************
3136 
3137 
3138 //*************************************************************************************************
3147 template< typename MT > // Type of the sparse matrix
3148 inline typename Row<MT,false,false,false>::Iterator Row<MT,false,false,false>::erase( Iterator pos )
3149 {
3150  const size_t column( pos.column_ );
3151 
3152  if( column == size() )
3153  return pos;
3154 
3155  matrix_.erase( column, pos.pos_ );
3156  return Iterator( matrix_, row_, column+1UL );
3157 }
3159 //*************************************************************************************************
3160 
3161 
3162 //*************************************************************************************************
3172 template< typename MT > // Type of the sparse matrix
3174  Row<MT,false,false,false>::erase( Iterator first, Iterator last )
3175 {
3176  for( ; first!=last; ++first ) {
3177  matrix_.erase( first.column_, first.pos_ );
3178  }
3179  return last;
3180 }
3182 //*************************************************************************************************
3183 
3184 
3185 //*************************************************************************************************
3195 template< typename MT > // Type of the sparse matrix
3196 void Row<MT,false,false,false>::reserve( size_t n )
3197 {
3198  UNUSED_PARAMETER( n );
3199 
3200  return;
3201 }
3203 //*************************************************************************************************
3204 
3205 
3206 //*************************************************************************************************
3217 template< typename MT > // Type of the sparse matrix
3218 template< typename Other > // Data type of the scalar value
3219 inline Row<MT,false,false,false>& Row<MT,false,false,false>::scale( const Other& scalar )
3220 {
3222 
3223  for( Iterator element=begin(); element!=end(); ++element )
3224  element->value() *= scalar;
3225  return *this;
3226 }
3228 //*************************************************************************************************
3229 
3230 
3231 
3232 
3233 //=================================================================================================
3234 //
3235 // LOOKUP FUNCTIONS
3236 //
3237 //=================================================================================================
3238 
3239 //*************************************************************************************************
3253 template< typename MT > // Type of the sparse matrix
3254 inline typename Row<MT,false,false,false>::Iterator Row<MT,false,false,false>::find( size_t index )
3255 {
3256  const Iterator_<MT> pos( matrix_.find( row_, index ) );
3257 
3258  if( pos != matrix_.end( index ) )
3259  return Iterator( matrix_, row_, index, pos );
3260  else
3261  return end();
3262 }
3264 //*************************************************************************************************
3265 
3266 
3267 //*************************************************************************************************
3281 template< typename MT > // Type of the sparse matrix
3283  Row<MT,false,false,false>::find( size_t index ) const
3284 {
3285  const ConstIterator_<MT> pos( matrix_.find( row_, index ) );
3286 
3287  if( pos != matrix_.end( index ) )
3288  return ConstIterator( matrix_, row_, index, pos );
3289  else
3290  return end();
3291 }
3293 //*************************************************************************************************
3294 
3295 
3296 //*************************************************************************************************
3309 template< typename MT > // Type of the sparse matrix
3311  Row<MT,false,false,false>::lowerBound( size_t index )
3312 {
3313  for( size_t i=index; i<size(); ++i )
3314  {
3315  const Iterator_<MT> pos( matrix_.find( row_, i ) );
3316 
3317  if( pos != matrix_.end( i ) )
3318  return Iterator( matrix_, row_, i, pos );
3319  }
3320 
3321  return end();
3322 }
3324 //*************************************************************************************************
3325 
3326 
3327 //*************************************************************************************************
3340 template< typename MT > // Type of the sparse matrix
3342  Row<MT,false,false,false>::lowerBound( size_t index ) const
3343 {
3344  for( size_t i=index; i<size(); ++i )
3345  {
3346  const ConstIterator_<MT> pos( matrix_.find( row_, i ) );
3347 
3348  if( pos != matrix_.end( i ) )
3349  return ConstIterator( matrix_, row_, i, pos );
3350  }
3351 
3352  return end();
3353 }
3355 //*************************************************************************************************
3356 
3357 
3358 //*************************************************************************************************
3371 template< typename MT > // Type of the sparse matrix
3373  Row<MT,false,false,false>::upperBound( size_t index )
3374 {
3375  for( size_t i=index+1UL; i<size(); ++i )
3376  {
3377  const Iterator_<MT> pos( matrix_.find( row_, i ) );
3378 
3379  if( pos != matrix_.end( i ) )
3380  return Iterator( matrix_, row_, i, pos );
3381  }
3382 
3383  return end();
3384 }
3386 //*************************************************************************************************
3387 
3388 
3389 //*************************************************************************************************
3402 template< typename MT > // Type of the sparse matrix
3404  Row<MT,false,false,false>::upperBound( size_t index ) const
3405 {
3406  for( size_t i=index+1UL; i<size(); ++i )
3407  {
3408  const ConstIterator_<MT> pos( matrix_.find( row_, i ) );
3409 
3410  if( pos != matrix_.end( i ) )
3411  return ConstIterator( matrix_, row_, i, pos );
3412  }
3413 
3414  return end();
3415 }
3417 //*************************************************************************************************
3418 
3419 
3420 
3421 
3422 //=================================================================================================
3423 //
3424 // LOW-LEVEL UTILITY FUNCTIONS
3425 //
3426 //=================================================================================================
3427 
3428 //*************************************************************************************************
3453 template< typename MT > // Type of the sparse matrix
3454 inline void Row<MT,false,false,false>::append( size_t index, const ElementType& value, bool check )
3455 {
3456  if( !check || !isDefault( value ) )
3457  matrix_.insert( row_, index, value );
3458 }
3460 //*************************************************************************************************
3461 
3462 
3463 
3464 
3465 //=================================================================================================
3466 //
3467 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
3468 //
3469 //=================================================================================================
3470 
3471 //*************************************************************************************************
3482 template< typename MT > // Type of the sparse matrix
3483 template< typename Other > // Data type of the foreign expression
3484 inline bool Row<MT,false,false,false>::canAlias( const Other* alias ) const noexcept
3485 {
3486  return matrix_.isAliased( alias );
3487 }
3489 //*************************************************************************************************
3490 
3491 
3492 //*************************************************************************************************
3499 template< typename MT > // Type of the sparse matrix
3500 template< typename Other > // Data type of the foreign expression
3501 inline bool Row<MT,false,false,false>::isAliased( const Other* alias ) const noexcept
3502 {
3503  return matrix_.isAliased( alias );
3504 }
3506 //*************************************************************************************************
3507 
3508 
3509 //*************************************************************************************************
3521 template< typename MT > // Type of the sparse matrix
3522 template< typename VT > // Type of the right-hand side dense vector
3523 inline void Row<MT,false,false,false>::assign( const DenseVector<VT,true>& rhs )
3524 {
3525  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3526 
3527  for( size_t j=0UL; j<(~rhs).size(); ++j ) {
3528  matrix_(row_,j) = (~rhs)[j];
3529  }
3530 }
3532 //*************************************************************************************************
3533 
3534 
3535 //*************************************************************************************************
3547 template< typename MT > // Type of the sparse matrix
3548 template< typename VT > // Type of the right-hand side sparse vector
3549 inline void Row<MT,false,false,false>::assign( const SparseVector<VT,true>& rhs )
3550 {
3551  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3552 
3553  size_t j( 0UL );
3554 
3555  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
3556  for( ; j<element->index(); ++j )
3557  matrix_.erase( row_, j );
3558  matrix_(row_,j++) = element->value();
3559  }
3560  for( ; j<size(); ++j ) {
3561  matrix_.erase( row_, j );
3562  }
3563 }
3565 //*************************************************************************************************
3566 
3567 
3568 //*************************************************************************************************
3580 template< typename MT > // Type of the sparse matrix
3581 template< typename VT > // Type of the right-hand side vector
3582 inline void Row<MT,false,false,false>::addAssign( const Vector<VT,true>& rhs )
3583 {
3584  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
3585 
3588 
3589  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3590 
3591  const AddType tmp( serial( *this + (~rhs) ) );
3592  assign( tmp );
3593 }
3595 //*************************************************************************************************
3596 
3597 
3598 //*************************************************************************************************
3610 template< typename MT > // Type of the sparse matrix
3611 template< typename VT > // Type of the right-hand side vector
3612 inline void Row<MT,false,false,false>::subAssign( const Vector<VT,true>& rhs )
3613 {
3614  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
3615 
3618 
3619  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3620 
3621  const SubType tmp( serial( *this - (~rhs) ) );
3622  assign( tmp );
3623 }
3625 //*************************************************************************************************
3626 
3627 
3628 
3629 
3630 
3631 
3632 
3633 
3634 //=================================================================================================
3635 //
3636 // CLASS TEMPLATE SPECIALIZATION FOR SYMMETRIC COLUMN-MAJOR SPARSE MATRICES
3637 //
3638 //=================================================================================================
3639 
3640 //*************************************************************************************************
3648 template< typename MT > // Type of the sparse matrix
3649 class Row<MT,false,false,true>
3650  : public SparseVector< Row<MT,false,false,true>, true >
3651  , private View
3652 {
3653  private:
3654  //**Type definitions****************************************************************************
3656  typedef If_< IsExpression<MT>, MT, MT& > Operand;
3657  //**********************************************************************************************
3658 
3659  public:
3660  //**Type definitions****************************************************************************
3661  typedef Row<MT,false,false,true> This;
3662  typedef SparseVector<This,true> BaseType;
3663  typedef RowTrait_<MT> ResultType;
3664  typedef TransposeType_<ResultType> TransposeType;
3665  typedef ElementType_<MT> ElementType;
3666  typedef ReturnType_<MT> ReturnType;
3667  typedef const Row& CompositeType;
3668 
3670  typedef ConstReference_<MT> ConstReference;
3671 
3673  typedef If_< IsConst<MT>, ConstReference, Reference_<MT> > Reference;
3674 
3676  typedef ConstIterator_<MT> ConstIterator;
3677 
3679  typedef If_< IsConst<MT>, ConstIterator, Iterator_<MT> > Iterator;
3680  //**********************************************************************************************
3681 
3682  //**Compilation flags***************************************************************************
3684  enum : bool { smpAssignable = false };
3685  //**********************************************************************************************
3686 
3687  //**Constructors********************************************************************************
3690  explicit inline Row( Operand matrix, size_t index );
3691  // No explicitly declared copy constructor.
3693  //**********************************************************************************************
3694 
3695  //**Destructor**********************************************************************************
3696  // No explicitly declared destructor.
3697  //**********************************************************************************************
3698 
3699  //**Data access functions***********************************************************************
3702  inline Reference operator[]( size_t index );
3703  inline ConstReference operator[]( size_t index ) const;
3704  inline Reference at( size_t index );
3705  inline ConstReference at( size_t index ) const;
3706  inline Iterator begin ();
3707  inline ConstIterator begin () const;
3708  inline ConstIterator cbegin() const;
3709  inline Iterator end ();
3710  inline ConstIterator end () const;
3711  inline ConstIterator cend () const;
3713  //**********************************************************************************************
3714 
3715  //**Assignment operators************************************************************************
3718  inline Row& operator=( const Row& rhs );
3719 
3720  template< typename VT > inline Row& operator= ( const DenseVector<VT,true>& rhs );
3721  template< typename VT > inline Row& operator= ( const SparseVector<VT,true>& rhs );
3722  template< typename VT > inline Row& operator+=( const DenseVector<VT,true>& rhs );
3723  template< typename VT > inline Row& operator+=( const SparseVector<VT,true>& rhs );
3724  template< typename VT > inline Row& operator-=( const DenseVector<VT,true>& rhs );
3725  template< typename VT > inline Row& operator-=( const SparseVector<VT,true>& rhs );
3726  template< typename VT > inline Row& operator*=( const Vector<VT,true>& rhs );
3727  template< typename VT > inline Row& operator/=( const DenseVector<VT,true>& rhs );
3728 
3729  template< typename Other >
3730  inline EnableIf_<IsNumeric<Other>, Row >& operator*=( Other rhs );
3731 
3732  template< typename Other >
3733  inline EnableIf_<IsNumeric<Other>, Row >& operator/=( Other rhs );
3735  //**********************************************************************************************
3736 
3737  //**Utility functions***************************************************************************
3740  inline size_t size() const noexcept;
3741  inline size_t capacity() const noexcept;
3742  inline size_t nonZeros() const;
3743  inline void reset();
3744  inline Iterator set ( size_t index, const ElementType& value );
3745  inline Iterator insert ( size_t index, const ElementType& value );
3746  inline void erase ( size_t index );
3747  inline Iterator erase ( Iterator pos );
3748  inline Iterator erase ( Iterator first, Iterator last );
3749  inline void reserve( size_t n );
3750  template< typename Other > inline Row& scale ( const Other& scalar );
3752  //**********************************************************************************************
3753 
3754  //**Lookup functions****************************************************************************
3757  inline Iterator find ( size_t index );
3758  inline ConstIterator find ( size_t index ) const;
3759  inline Iterator lowerBound( size_t index );
3760  inline ConstIterator lowerBound( size_t index ) const;
3761  inline Iterator upperBound( size_t index );
3762  inline ConstIterator upperBound( size_t index ) const;
3764  //**********************************************************************************************
3765 
3766  //**Low-level utility functions*****************************************************************
3769  inline void append( size_t index, const ElementType& value, bool check=false );
3771  //**********************************************************************************************
3772 
3773  //**Expression template evaluation functions****************************************************
3776  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
3777  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
3778 
3779  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
3780  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
3781  template< typename VT > inline void addAssign( const DenseVector <VT,true>& rhs );
3782  template< typename VT > inline void addAssign( const SparseVector<VT,true>& rhs );
3783  template< typename VT > inline void subAssign( const DenseVector <VT,true>& rhs );
3784  template< typename VT > inline void subAssign( const SparseVector<VT,true>& rhs );
3786  //**********************************************************************************************
3787 
3788  private:
3789  //**Utility functions***************************************************************************
3792  inline size_t extendCapacity() const;
3794  //**********************************************************************************************
3795 
3796  //**Member variables****************************************************************************
3799  Operand matrix_;
3800  const size_t row_;
3801 
3802  //**********************************************************************************************
3803 
3804  //**Friend declarations*************************************************************************
3805  template< typename MT2, bool SO2, bool DF2, bool SF2 >
3806  friend bool isIntact( const Row<MT2,SO2,DF2,SF2>& row ) noexcept;
3807 
3808  template< typename MT2, bool SO2, bool DF2, bool SF2 >
3809  friend bool isSame( const Row<MT2,SO2,DF2,SF2>& a, const Row<MT2,SO2,DF2,SF2>& b ) noexcept;
3810 
3811  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
3812  friend bool tryAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
3813 
3814  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
3815  friend bool tryAddAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
3816 
3817  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
3818  friend bool trySubAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
3819 
3820  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
3821  friend bool tryMultAssign( const Row<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
3822 
3823  template< typename MT2, bool SO2, bool DF2, bool SF2 >
3824  friend DerestrictTrait_< Row<MT2,SO2,DF2,SF2> > derestrict( Row<MT2,SO2,DF2,SF2>& row );
3825  //**********************************************************************************************
3826 
3827  //**Compile time checks*************************************************************************
3835  //**********************************************************************************************
3836 };
3838 //*************************************************************************************************
3839 
3840 
3841 
3842 
3843 //=================================================================================================
3844 //
3845 // CONSTRUCTOR
3846 //
3847 //=================================================================================================
3848 
3849 //*************************************************************************************************
3857 template< typename MT > // Type of the sparse matrix
3858 inline Row<MT,false,false,true>::Row( Operand matrix, size_t index )
3859  : matrix_( matrix ) // The sparse matrix containing the row
3860  , row_ ( index ) // The index of the row in the matrix
3861 {
3862  if( matrix_.rows() <= index ) {
3863  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
3864  }
3865 }
3867 //*************************************************************************************************
3868 
3869 
3870 
3871 
3872 //=================================================================================================
3873 //
3874 // DATA ACCESS FUNCTIONS
3875 //
3876 //=================================================================================================
3877 
3878 //*************************************************************************************************
3888 template< typename MT > // Type of the sparse matrix
3890  Row<MT,false,false,true>::operator[]( size_t index )
3891 {
3892  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
3893  return matrix_(index,row_);
3894 }
3896 //*************************************************************************************************
3897 
3898 
3899 //*************************************************************************************************
3909 template< typename MT > // Type of the sparse matrix
3911  Row<MT,false,false,true>::operator[]( size_t index ) const
3912 {
3913  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
3914  return const_cast<const MT&>( matrix_ )(index,row_);
3915 }
3917 //*************************************************************************************************
3918 
3919 
3920 //*************************************************************************************************
3931 template< typename MT > // Type of the sparse matrix
3933  Row<MT,false,false,true>::at( size_t index )
3934 {
3935  if( index >= size() ) {
3936  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
3937  }
3938  return (*this)[index];
3939 }
3941 //*************************************************************************************************
3942 
3943 
3944 //*************************************************************************************************
3955 template< typename MT > // Type of the sparse matrix
3957  Row<MT,false,false,true>::at( size_t index ) const
3958 {
3959  if( index >= size() ) {
3960  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
3961  }
3962  return (*this)[index];
3963 }
3965 //*************************************************************************************************
3966 
3967 
3968 //*************************************************************************************************
3976 template< typename MT > // Type of the sparse matrix
3978 {
3979  return matrix_.begin( row_ );
3980 }
3982 //*************************************************************************************************
3983 
3984 
3985 //*************************************************************************************************
3993 template< typename MT > // Type of the sparse matrix
3995 {
3996  return matrix_.cbegin( row_ );
3997 }
3999 //*************************************************************************************************
4000 
4001 
4002 //*************************************************************************************************
4010 template< typename MT > // Type of the sparse matrix
4012 {
4013  return matrix_.cbegin( row_ );
4014 }
4016 //*************************************************************************************************
4017 
4018 
4019 //*************************************************************************************************
4027 template< typename MT > // Type of the sparse matrix
4029 {
4030  return matrix_.end( row_ );
4031 }
4033 //*************************************************************************************************
4034 
4035 
4036 //*************************************************************************************************
4044 template< typename MT > // Type of the sparse matrix
4046 {
4047  return matrix_.cend( row_ );
4048 }
4050 //*************************************************************************************************
4051 
4052 
4053 //*************************************************************************************************
4061 template< typename MT > // Type of the sparse matrix
4063 {
4064  return matrix_.cend( row_ );
4065 }
4067 //*************************************************************************************************
4068 
4069 
4070 
4071 
4072 //=================================================================================================
4073 //
4074 // ASSIGNMENT OPERATORS
4075 //
4076 //=================================================================================================
4077 
4078 //*************************************************************************************************
4092 template< typename MT > // Type of the sparse matrix
4093 inline Row<MT,false,false,true>& Row<MT,false,false,true>::operator=( const Row& rhs )
4094 {
4095  using blaze::assign;
4096 
4100 
4101  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
4102  return *this;
4103 
4104  if( size() != rhs.size() ) {
4105  BLAZE_THROW_INVALID_ARGUMENT( "Row sizes do not match" );
4106  }
4107 
4108  if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
4109  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4110  }
4111 
4112  DerestrictTrait_<This> left( derestrict( *this ) );
4113 
4114  if( rhs.canAlias( &matrix_ ) ) {
4115  const ResultType tmp( rhs );
4116  left.reset();
4117  left.reserve( tmp.nonZeros() );
4118  assign( left, tmp );
4119  }
4120  else {
4121  left.reset();
4122  left.reserve( rhs.nonZeros() );
4123  assign( left, rhs );
4124  }
4125 
4126  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4127 
4128  return *this;
4129 }
4131 //*************************************************************************************************
4132 
4133 
4134 //*************************************************************************************************
4148 template< typename MT > // Type of the sparse matrix
4149 template< typename VT > // Type of the right-hand side dense vector
4150 inline Row<MT,false,false,true>&
4151  Row<MT,false,false,true>::operator=( const DenseVector<VT,true>& rhs )
4152 {
4153  using blaze::assign;
4154 
4155  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4156  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4158 
4159  if( size() != (~rhs).size() ) {
4160  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4161  }
4162 
4163  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
4164  Right right( ~rhs );
4165 
4166  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
4167  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4168  }
4169 
4170  DerestrictTrait_<This> left( derestrict( *this ) );
4171 
4172  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4173  const ResultType_<VT> tmp( right );
4174  left.reset();
4175  assign( left, tmp );
4176  }
4177  else {
4178  left.reset();
4179  assign( left, right );
4180  }
4181 
4182  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4183 
4184  return *this;
4185 }
4187 //*************************************************************************************************
4188 
4189 
4190 //*************************************************************************************************
4204 template< typename MT > // Type of the sparse matrix
4205 template< typename VT > // Type of the right-hand side sparse vector
4206 inline Row<MT,false,false,true>&
4207  Row<MT,false,false,true>::operator=( const SparseVector<VT,true>& rhs )
4208 {
4209  using blaze::assign;
4210 
4211  BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE ( ResultType_<VT> );
4212  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4214 
4215  if( size() != (~rhs).size() ) {
4216  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4217  }
4218 
4219  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
4220  Right right( ~rhs );
4221 
4222  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
4223  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4224  }
4225 
4226  DerestrictTrait_<This> left( derestrict( *this ) );
4227 
4228  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4229  const ResultType_<VT> tmp( right );
4230  left.reset();
4231  left.reserve( tmp.nonZeros() );
4232  assign( left, tmp );
4233  }
4234  else {
4235  left.reset();
4236  left.reserve( right.nonZeros() );
4237  assign( left, right );
4238  }
4239 
4240  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4241 
4242  return *this;
4243 }
4245 //*************************************************************************************************
4246 
4247 
4248 //*************************************************************************************************
4262 template< typename MT > // Type of the sparse matrix
4263 template< typename VT > // Type of the right-hand side dense vector
4264 inline Row<MT,false,false,true>&
4265  Row<MT,false,false,true>::operator+=( const DenseVector<VT,true>& rhs )
4266 {
4267  using blaze::assign;
4268 
4272  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4273  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4275 
4276  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
4277 
4281 
4282  if( size() != (~rhs).size() ) {
4283  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4284  }
4285 
4286  const AddType tmp( *this + (~rhs) );
4287 
4288  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4289  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4290  }
4291 
4292  DerestrictTrait_<This> left( derestrict( *this ) );
4293 
4294  left.reset();
4295  assign( left, tmp );
4296 
4297  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4298 
4299  return *this;
4300 }
4302 //*************************************************************************************************
4303 
4304 
4305 //*************************************************************************************************
4319 template< typename MT > // Type of the sparse matrix
4320 template< typename VT > // Type of the right-hand side sparse vector
4321 inline Row<MT,false,false,true>&
4322  Row<MT,false,false,true>::operator+=( const SparseVector<VT,true>& rhs )
4323 {
4324  using blaze::assign;
4325 
4329  BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE ( ResultType_<VT> );
4330  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4332 
4333  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
4334 
4338 
4339  if( size() != (~rhs).size() ) {
4340  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4341  }
4342 
4343  const AddType tmp( *this + (~rhs) );
4344 
4345  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4346  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4347  }
4348 
4349  DerestrictTrait_<This> left( derestrict( *this ) );
4350 
4351  left.reset();
4352  left.reserve( tmp.nonZeros() );
4353  assign( left, tmp );
4354 
4355  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4356 
4357  return *this;
4358 }
4360 //*************************************************************************************************
4361 
4362 
4363 //*************************************************************************************************
4378 template< typename MT > // Type of the sparse matrix
4379 template< typename VT > // Type of the right-hand side dense vector
4380 inline Row<MT,false,false,true>&
4381  Row<MT,false,false,true>::operator-=( const DenseVector<VT,true>& rhs )
4382 {
4383  using blaze::assign;
4384 
4388  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4389  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4391 
4392  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
4393 
4397 
4398  if( size() != (~rhs).size() ) {
4399  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4400  }
4401 
4402  const SubType tmp( *this - (~rhs) );
4403 
4404  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4405  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4406  }
4407 
4408  DerestrictTrait_<This> left( derestrict( *this ) );
4409 
4410  left.reset();
4411  assign( left, tmp );
4412 
4413  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4414 
4415  return *this;
4416 }
4418 //*************************************************************************************************
4419 
4420 
4421 //*************************************************************************************************
4436 template< typename MT > // Type of the sparse matrix
4437 template< typename VT > // Type of the right-hand side sparse vector
4438 inline Row<MT,false,false,true>&
4439  Row<MT,false,false,true>::operator-=( const SparseVector<VT,true>& rhs )
4440 {
4441  using blaze::assign;
4442 
4446  BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE ( ResultType_<VT> );
4447  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4449 
4450  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
4451 
4455 
4456  if( size() != (~rhs).size() ) {
4457  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4458  }
4459 
4460  const SubType tmp( *this - (~rhs) );
4461 
4462  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4463  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4464  }
4465 
4466  DerestrictTrait_<This> left( derestrict( *this ) );
4467 
4468  left.reset();
4469  left.reserve( tmp.nonZeros() );
4470  assign( left, tmp );
4471 
4472  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4473 
4474  return *this;
4475 }
4477 //*************************************************************************************************
4478 
4479 
4480 //*************************************************************************************************
4493 template< typename MT > // Type of the sparse matrix
4494 template< typename VT > // Type of the right-hand side vector
4495 inline Row<MT,false,false,true>&
4496  Row<MT,false,false,true>::operator*=( const Vector<VT,true>& rhs )
4497 {
4498  using blaze::assign;
4499 
4503  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4505 
4506  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
4507 
4510 
4511  if( size() != (~rhs).size() ) {
4512  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4513  }
4514 
4515  const MultType tmp( *this * (~rhs) );
4516 
4517  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4518  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4519  }
4520 
4521  DerestrictTrait_<This> left( derestrict( *this ) );
4522 
4523  left.reset();
4524  assign( left, tmp );
4525 
4526  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4527 
4528  return *this;
4529 }
4531 //*************************************************************************************************
4532 
4533 
4534 //*************************************************************************************************
4546 template< typename MT > // Type of the sparse matrix
4547 template< typename VT > // Type of the right-hand side vector
4548 inline Row<MT,false,false,true>&
4549  Row<MT,false,false,true>::operator/=( const DenseVector<VT,true>& rhs )
4550 {
4551  using blaze::assign;
4552 
4556  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4557  BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE ( ResultType_<VT> );
4559 
4560  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
4561 
4565 
4566  if( size() != (~rhs).size() ) {
4567  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4568  }
4569 
4570  const DivType tmp( *this / (~rhs) );
4571 
4572  if( !tryAssign( matrix_, tmp, row_, 0UL ) ) {
4573  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4574  }
4575 
4576  DerestrictTrait_<This> left( derestrict( *this ) );
4577 
4578  left.reset();
4579  assign( left, tmp );
4580 
4581  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4582 
4583  return *this;
4584 }
4586 //*************************************************************************************************
4587 
4588 
4589 //*************************************************************************************************
4604 template< typename MT > // Type of the sparse matrix
4605 template< typename Other > // Data type of the right-hand side scalar
4606 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,true> >&
4608 {
4610 
4611  for( Iterator element=begin(); element!=end(); ++element )
4612  element->value() *= rhs;
4613  return *this;
4614 }
4616 //*************************************************************************************************
4617 
4618 
4619 //*************************************************************************************************
4637 template< typename MT > // Type of the sparse matrix
4638 template< typename Other > // Data type of the right-hand side scalar
4639 inline EnableIf_<IsNumeric<Other>, Row<MT,false,false,true> >&
4641 {
4643 
4644  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
4645 
4646  typedef DivTrait_<ElementType,Other> DT;
4647  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
4648 
4649  // Depending on the two involved data types, an integer division is applied or a
4650  // floating point division is selected.
4651  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
4652  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
4653  for( Iterator element=begin(); element!=end(); ++element )
4654  element->value() *= tmp;
4655  }
4656  else {
4657  for( Iterator element=begin(); element!=end(); ++element )
4658  element->value() /= rhs;
4659  }
4660 
4661  return *this;
4662 }
4664 //*************************************************************************************************
4665 
4666 
4667 
4668 
4669 //=================================================================================================
4670 //
4671 // UTILITY FUNCTIONS
4672 //
4673 //=================================================================================================
4674 
4675 //*************************************************************************************************
4681 template< typename MT > // Type of the sparse matrix
4682 inline size_t Row<MT,false,false,true>::size() const noexcept
4683 {
4684  return matrix_.columns();
4685 }
4687 //*************************************************************************************************
4688 
4689 
4690 //*************************************************************************************************
4696 template< typename MT > // Type of the sparse matrix
4697 inline size_t Row<MT,false,false,true>::capacity() const noexcept
4698 {
4699  return matrix_.capacity( row_ );
4700 }
4702 //*************************************************************************************************
4703 
4704 
4705 //*************************************************************************************************
4714 template< typename MT > // Type of the sparse matrix
4715 inline size_t Row<MT,false,false,true>::nonZeros() const
4716 {
4717  return matrix_.nonZeros( row_ );
4718 }
4720 //*************************************************************************************************
4721 
4722 
4723 //*************************************************************************************************
4729 template< typename MT > // Type of the sparse matrix
4730 inline void Row<MT,false,false,true>::reset()
4731 {
4732  matrix_.reset( row_ );
4733 }
4735 //*************************************************************************************************
4736 
4737 
4738 //*************************************************************************************************
4750 template< typename MT > // Type of the sparse matrix
4751 inline typename Row<MT,false,false,true>::Iterator
4752  Row<MT,false,false,true>::set( size_t index, const ElementType& value )
4753 {
4754  return matrix_.set( index, row_, value );
4755 }
4757 //*************************************************************************************************
4758 
4759 
4760 //*************************************************************************************************
4773 template< typename MT > // Type of the sparse matrix
4774 inline typename Row<MT,false,false,true>::Iterator
4775  Row<MT,false,false,true>::insert( size_t index, const ElementType& value )
4776 {
4777  return matrix_.insert( index, row_, value );
4778 }
4780 //*************************************************************************************************
4781 
4782 
4783 //*************************************************************************************************
4792 template< typename MT > // Type of the sparse matrix
4793 inline void Row<MT,false,false,true>::erase( size_t index )
4794 {
4795  matrix_.erase( index, row_ );
4796 }
4798 //*************************************************************************************************
4799 
4800 
4801 //*************************************************************************************************
4810 template< typename MT > // Type of the sparse matrix
4811 inline typename Row<MT,false,false,true>::Iterator
4812  Row<MT,false,false,true>::erase( Iterator pos )
4813 {
4814  return matrix_.erase( row_, pos );
4815 }
4817 //*************************************************************************************************
4818 
4819 
4820 //*************************************************************************************************
4830 template< typename MT > // Type of the sparse matrix
4831 inline typename Row<MT,false,false,true>::Iterator
4832  Row<MT,false,false,true>::erase( Iterator first, Iterator last )
4833 {
4834  return matrix_.erase( row_, first, last );
4835 }
4837 //*************************************************************************************************
4838 
4839 
4840 //*************************************************************************************************
4850 template< typename MT > // Type of the sparse matrix
4851 void Row<MT,false,false,true>::reserve( size_t n )
4852 {
4853  matrix_.reserve( row_, n );
4854 }
4856 //*************************************************************************************************
4857 
4858 
4859 //*************************************************************************************************
4870 template< typename MT > // Type of the sparse matrix
4871 template< typename Other > // Data type of the scalar value
4872 inline Row<MT,false,false,true>& Row<MT,false,false,true>::scale( const Other& scalar )
4873 {
4875 
4876  for( Iterator element=begin(); element!=end(); ++element )
4877  element->value() *= scalar;
4878  return *this;
4879 }
4881 //*************************************************************************************************
4882 
4883 
4884 //*************************************************************************************************
4893 template< typename MT > // Type of the sparse matrix
4894 inline size_t Row<MT,false,false,true>::extendCapacity() const
4895 {
4896  using blaze::max;
4897  using blaze::min;
4898 
4899  size_t nonzeros( 2UL*capacity()+1UL );
4900  nonzeros = max( nonzeros, 7UL );
4901  nonzeros = min( nonzeros, size() );
4902 
4903  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
4904 
4905  return nonzeros;
4906 }
4908 //*************************************************************************************************
4909 
4910 
4911 
4912 
4913 //=================================================================================================
4914 //
4915 // LOOKUP FUNCTIONS
4916 //
4917 //=================================================================================================
4918 
4919 //*************************************************************************************************
4933 template< typename MT > // Type of the sparse matrix
4934 inline typename Row<MT,false,false,true>::Iterator
4935  Row<MT,false,false,true>::find( size_t index )
4936 {
4937  return matrix_.find( index, row_ );
4938 }
4940 //*************************************************************************************************
4941 
4942 
4943 //*************************************************************************************************
4957 template< typename MT > // Type of the sparse matrix
4959  Row<MT,false,false,true>::find( size_t index ) const
4960 {
4961  return matrix_.find( index, row_ );
4962 }
4964 //*************************************************************************************************
4965 
4966 
4967 //*************************************************************************************************
4980 template< typename MT > // Type of the sparse matrix
4981 inline typename Row<MT,false,false,true>::Iterator
4982  Row<MT,false,false,true>::lowerBound( size_t index )
4983 {
4984  return matrix_.lowerBound( index, row_ );
4985 }
4987 //*************************************************************************************************
4988 
4989 
4990 //*************************************************************************************************
5003 template< typename MT > // Type of the sparse matrix
5005  Row<MT,false,false,true>::lowerBound( size_t index ) const
5006 {
5007  return matrix_.lowerBound( index, row_ );
5008 }
5010 //*************************************************************************************************
5011 
5012 
5013 //*************************************************************************************************
5026 template< typename MT > // Type of the sparse matrix
5027 inline typename Row<MT,false,false,true>::Iterator
5028  Row<MT,false,false,true>::upperBound( size_t index )
5029 {
5030  return matrix_.upperBound( index, row_ );
5031 }
5033 //*************************************************************************************************
5034 
5035 
5036 //*************************************************************************************************
5049 template< typename MT > // Type of the sparse matrix
5051  Row<MT,false,false,true>::upperBound( size_t index ) const
5052 {
5053  return matrix_.upperBound( index, row_ );
5054 }
5056 //*************************************************************************************************
5057 
5058 
5059 
5060 
5061 //=================================================================================================
5062 //
5063 // LOW-LEVEL UTILITY FUNCTIONS
5064 //
5065 //=================================================================================================
5066 
5067 //*************************************************************************************************
5092 template< typename MT > // Type of the sparse matrix
5093 inline void Row<MT,false,false,true>::append( size_t index, const ElementType& value, bool check )
5094 {
5095  matrix_.append( index, row_, value, check );
5096 }
5098 //*************************************************************************************************
5099 
5100 
5101 
5102 
5103 //=================================================================================================
5104 //
5105 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
5106 //
5107 //=================================================================================================
5108 
5109 //*************************************************************************************************
5120 template< typename MT > // Type of the sparse matrix
5121 template< typename Other > // Data type of the foreign expression
5122 inline bool Row<MT,false,false,true>::canAlias( const Other* alias ) const noexcept
5123 {
5124  return matrix_.isAliased( alias );
5125 }
5127 //*************************************************************************************************
5128 
5129 
5130 //*************************************************************************************************
5141 template< typename MT > // Type of the sparse matrix
5142 template< typename Other > // Data type of the foreign expression
5143 inline bool Row<MT,false,false,true>::isAliased( const Other* alias ) const noexcept
5144 {
5145  return matrix_.isAliased( alias );
5146 }
5148 //*************************************************************************************************
5149 
5150 
5151 //*************************************************************************************************
5163 template< typename MT > // Type of the sparse matrix
5164 template< typename VT > // Type of the right-hand side dense vector
5165 inline void Row<MT,false,false,true>::assign( const DenseVector<VT,true>& rhs )
5166 {
5167  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5168  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
5169 
5170  for( size_t i=0UL; i<size(); ++i )
5171  {
5172  if( matrix_.nonZeros( row_ ) == matrix_.capacity( row_ ) )
5173  matrix_.reserve( row_, extendCapacity() );
5174 
5175  matrix_.append( i, row_, (~rhs)[i], true );
5176  }
5177 }
5179 //*************************************************************************************************
5180 
5181 
5182 //*************************************************************************************************
5194 template< typename MT > // Type of the sparse matrix
5195 template< typename VT > // Type of the right-hand side sparse vector
5196 inline void Row<MT,false,false,true>::assign( const SparseVector<VT,true>& rhs )
5197 {
5198  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5199  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
5200 
5201  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
5202  matrix_.append( element->index(), row_, element->value(), true );
5203  }
5204 }
5206 //*************************************************************************************************
5207 
5208 
5209 //*************************************************************************************************
5221 template< typename MT > // Type of the sparse matrix
5222 template< typename VT > // Type of the right-hand side dense vector
5223 inline void Row<MT,false,false,true>::addAssign( const DenseVector<VT,true>& rhs )
5224 {
5225  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
5226 
5230 
5231  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5232 
5233  const AddType tmp( serial( *this + (~rhs) ) );
5234  matrix_.reset( row_ );
5235  assign( tmp );
5236 }
5238 //*************************************************************************************************
5239 
5240 
5241 //*************************************************************************************************
5253 template< typename MT > // Type of the sparse matrix
5254 template< typename VT > // Type of the right-hand side sparse vector
5255 inline void Row<MT,false,false,true>::addAssign( const SparseVector<VT,true>& rhs )
5256 {
5257  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
5258 
5262 
5263  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5264 
5265  const AddType tmp( serial( *this + (~rhs) ) );
5266  matrix_.reset( row_ );
5267  matrix_.reserve( row_, tmp.nonZeros() );
5268  assign( tmp );
5269 }
5271 //*************************************************************************************************
5272 
5273 
5274 //*************************************************************************************************
5286 template< typename MT > // Type of the sparse matrix
5287 template< typename VT > // Type of the right-hand side dense vector
5288 inline void Row<MT,false,false,true>::subAssign( const DenseVector<VT,true>& rhs )
5289 {
5290  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
5291 
5295 
5296  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5297 
5298  const SubType tmp( serial( *this - (~rhs) ) );
5299  matrix_.reset( row_ );
5300  assign( tmp );
5301 }
5303 //*************************************************************************************************
5304 
5305 
5306 //*************************************************************************************************
5318 template< typename MT > // Type of the sparse matrix
5319 template< typename VT > // Type of the right-hand side sparse vector
5320 inline void Row<MT,false,false,true>::subAssign( const SparseVector<VT,true>& rhs )
5321 {
5322  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
5323 
5327 
5328  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5329 
5330  const SubType tmp( serial( *this - (~rhs) ) );
5331  matrix_.reset( row_ );
5332  matrix_.reserve( row_, tmp.nonZeros() );
5333  assign( tmp );
5334 }
5336 //*************************************************************************************************
5337 
5338 } // namespace blaze
5339 
5340 #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.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7800
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:346
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:653
Header file for basic type definitions.
Header file for the SparseVector base class.
Header file for the View base class.
Header file for the row trait.
Header file for the serial shim.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2643
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2636
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:384
#define BLAZE_CONSTRAINT_MUST_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a symmetric matrix type...
Definition: Symmetric.h:60
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Header file for the IsUniLower type trait.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:126
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:298
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:232
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
Constraint on the data type.
Header file for the implementation of the Row base template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the IsLower type trait.
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:61
Header file for the SparseElement base class.
Constraint on the data type.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
Constraint on the data type.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
Constraint on the data type.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the DerestrictTrait class template.
Constraint on the data type.
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:126
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2642
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the division trait.
Header file for the reset shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the IsReference type trait.
Header file for the RemoveReference type trait.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2637
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2638
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: RowVector.h:61
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
Header file for the IsUpper type trait.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the IsRestricted type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Constraint on the transpose flag of vector types.
Header file for the IsExpression type trait class.