Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_ROWS_SPARSE_H_
36 #define _BLAZE_MATH_VIEWS_ROWS_SPARSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <vector>
44 #include <blaze/math/Aliases.h>
57 #include <blaze/math/Exception.h>
78 #include <blaze/math/views/Check.h>
83 #include <blaze/util/Assert.h>
87 #include <blaze/util/mpl/If.h>
88 #include <blaze/util/TypeList.h>
89 #include <blaze/util/Types.h>
92 #include <blaze/util/Unused.h>
93 
94 
95 namespace blaze {
96 
97 //=================================================================================================
98 //
99 // CLASS TEMPLATE SPECIALIZATION FOR ROW-MAJOR SPARSE MATRICES
100 //
101 //=================================================================================================
102 
103 //*************************************************************************************************
111 template< typename MT // Type of the sparse matrix
112  , bool SF // Symmetry flag
113  , typename... CRAs > // Compile time row arguments
114 class Rows<MT,true,false,SF,CRAs...>
115  : public View< SparseMatrix< Rows<MT,true,false,SF,CRAs...>, false > >
116  , private RowsData<CRAs...>
117 {
118  private:
119  //**Type definitions****************************************************************************
120  using DataType = RowsData<CRAs...>;
121  using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
122  //**********************************************************************************************
123 
124  //**Compile time flags**************************************************************************
125  using DataType::N;
126  //**********************************************************************************************
127 
128  public:
129  //**Type definitions****************************************************************************
131  using This = Rows<MT,true,false,SF,CRAs...>;
132 
133  using BaseType = SparseMatrix<This,false>;
134  using ViewedType = MT;
135  using ResultType = RowsTrait_t<MT,N>;
136  using OppositeType = OppositeType_t<ResultType>;
137  using TransposeType = TransposeType_t<ResultType>;
138  using ElementType = ElementType_t<MT>;
139  using ReturnType = ReturnType_t<MT>;
140  using CompositeType = const Rows&;
141 
143  using ConstReference = ConstReference_t<MT>;
144 
146  using Reference = If_t< IsConst_v<MT>, ConstReference, Reference_t<MT> >;
147 
149  using ConstIterator = ConstIterator_t<MT>;
150 
152  using Iterator = If_t< IsConst_v<MT>, ConstIterator, Iterator_t<MT> >;
153  //**********************************************************************************************
154 
155  //**Compilation flags***************************************************************************
157  static constexpr bool smpAssignable = MT::smpAssignable;
158  //**********************************************************************************************
159 
160  //**Constructors********************************************************************************
163  template< typename... RRAs >
164  explicit inline Rows( MT& matrix, RRAs... args );
165 
166  Rows( const Rows& ) = default;
167  Rows( Rows&& ) = default;
169  //**********************************************************************************************
170 
171  //**Destructor**********************************************************************************
174  ~Rows() = default;
176  //**********************************************************************************************
177 
178  //**Data access functions***********************************************************************
181  inline Reference operator()( size_t i, size_t j );
182  inline ConstReference operator()( size_t i, size_t j ) const;
183  inline Reference at( size_t i, size_t j );
184  inline ConstReference at( size_t i, size_t j ) const;
185  inline Iterator begin ( size_t i );
186  inline ConstIterator begin ( size_t i ) const;
187  inline ConstIterator cbegin( size_t i ) const;
188  inline Iterator end ( size_t i );
189  inline ConstIterator end ( size_t i ) const;
190  inline ConstIterator cend ( size_t i ) const;
192  //**********************************************************************************************
193 
194  //**Assignment operators************************************************************************
197  inline Rows& operator=( initializer_list< initializer_list<ElementType> > list );
198  inline Rows& operator=( const Rows& rhs );
199 
200  template< typename MT2, bool SO > inline Rows& operator= ( const Matrix<MT2,SO>& rhs );
201  template< typename MT2, bool SO > inline Rows& operator+=( const Matrix<MT2,SO>& rhs );
202  template< typename MT2, bool SO > inline Rows& operator-=( const Matrix<MT2,SO>& rhs );
203  template< typename MT2, bool SO > inline Rows& operator%=( const Matrix<MT2,SO>& rhs );
205  //**********************************************************************************************
206 
207  //**Utility functions***************************************************************************
210  using DataType::idx;
211  using DataType::idces;
212  using DataType::rows;
213 
214  inline MT& operand() noexcept;
215  inline const MT& operand() const noexcept;
216 
217  inline size_t columns() const noexcept;
218  inline size_t capacity() const noexcept;
219  inline size_t capacity( size_t i ) const noexcept;
220  inline size_t nonZeros() const;
221  inline size_t nonZeros( size_t i ) const;
222  inline void reset();
223  inline void reset( size_t i );
224  inline void reserve( size_t nonzeros );
225  void reserve( size_t i, size_t nonzeros );
226  inline void trim();
227  inline void trim( size_t i );
229  //**********************************************************************************************
230 
231  //**Insertion functions*************************************************************************
234  inline Iterator set ( size_t i, size_t j, const ElementType& value );
235  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
236  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
237  inline void finalize( size_t i );
239  //**********************************************************************************************
240 
241  //**Erase functions*****************************************************************************
244  inline void erase( size_t i, size_t j );
245  inline Iterator erase( size_t i, Iterator pos );
246  inline Iterator erase( size_t i, Iterator first, Iterator last );
247 
248  template< typename Pred >
249  inline void erase( Pred predicate );
250 
251  template< typename Pred >
252  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
254  //**********************************************************************************************
255 
256  //**Lookup functions****************************************************************************
259  inline Iterator find ( size_t i, size_t j );
260  inline ConstIterator find ( size_t i, size_t j ) const;
261  inline Iterator lowerBound( size_t i, size_t j );
262  inline ConstIterator lowerBound( size_t i, size_t j ) const;
263  inline Iterator upperBound( size_t i, size_t j );
264  inline ConstIterator upperBound( size_t i, size_t j ) const;
266  //**********************************************************************************************
267 
268  //**Numeric functions***************************************************************************
271  inline Rows& transpose();
272  inline Rows& ctranspose();
273 
274  template< typename Other > inline Rows& scale( const Other& scalar );
276  //**********************************************************************************************
277 
278  //**Expression template evaluation functions****************************************************
281  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
282  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
283 
284  inline bool canSMPAssign() const noexcept;
285 
286  template< typename MT2, bool SO > inline void assign ( const DenseMatrix<MT2,SO>& rhs );
287  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,false>& rhs );
288  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,true>& rhs );
289  template< typename MT2, bool SO > inline void addAssign ( const Matrix<MT2,SO>& rhs );
290  template< typename MT2, bool SO > inline void subAssign ( const Matrix<MT2,SO>& rhs );
291  template< typename MT2, bool SO > inline void schurAssign( const Matrix<MT2,SO>& rhs );
293  //**********************************************************************************************
294 
295  private:
296  //**Utility functions***************************************************************************
299  inline size_t extendCapacity( size_t i ) const noexcept;
301  //**********************************************************************************************
302 
303  //**Member variables****************************************************************************
306  Operand matrix_;
307 
308  //**********************************************************************************************
309 
310  //**Compile time checks*************************************************************************
319  //**********************************************************************************************
320 };
322 //*************************************************************************************************
323 
324 
325 
326 
327 //=================================================================================================
328 //
329 // CONSTRUCTORS
330 //
331 //=================================================================================================
332 
333 //*************************************************************************************************
346 template< typename MT // Type of the sparse matrix
347  , bool SF // Symmetry flag
348  , typename... CRAs > // Compile time row arguments
349 template< typename... RRAs > // Runtime row arguments
350 inline Rows<MT,true,false,SF,CRAs...>::Rows( MT& matrix, RRAs... args )
351  : DataType( args... ) // Base class initialization
352  , matrix_ ( matrix ) // The matrix containing the rows
353 {
354  if( !Contains_v< TypeList<RRAs...>, Unchecked > ) {
355  for( size_t i=0UL; i<rows(); ++i ) {
356  if( matrix_.rows() <= idx(i) ) {
357  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
358  }
359  }
360  }
361 }
363 //*************************************************************************************************
364 
365 
366 
367 
368 //=================================================================================================
369 //
370 // DATA ACCESS FUNCTIONS
371 //
372 //=================================================================================================
373 
374 //*************************************************************************************************
385 template< typename MT // Type of the sparse matrix
386  , bool SF // Symmetry flag
387  , typename... CRAs > // Compile time row arguments
388 inline typename Rows<MT,true,false,SF,CRAs...>::Reference
389  Rows<MT,true,false,SF,CRAs...>::operator()( size_t i, size_t j )
390 {
391  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
392  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
393 
394  return matrix_(idx(i),j);
395 }
397 //*************************************************************************************************
398 
399 
400 //*************************************************************************************************
411 template< typename MT // Type of the sparse matrix
412  , bool SF // Symmetry flag
413  , typename... CRAs > // Compile time row arguments
414 inline typename Rows<MT,true,false,SF,CRAs...>::ConstReference
415  Rows<MT,true,false,SF,CRAs...>::operator()( size_t i, size_t j ) const
416 {
417  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
418  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
419 
420  return const_cast<const MT&>( matrix_ )(idx(i),j);
421 }
423 //*************************************************************************************************
424 
425 
426 //*************************************************************************************************
438 template< typename MT // Type of the sparse matrix
439  , bool SF // Symmetry flag
440  , typename... CRAs > // Compile time row arguments
441 inline typename Rows<MT,true,false,SF,CRAs...>::Reference
442  Rows<MT,true,false,SF,CRAs...>::at( size_t i, size_t j )
443 {
444  if( i >= rows() ) {
445  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
446  }
447  if( j >= columns() ) {
448  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
449  }
450  return (*this)(i,j);
451 }
453 //*************************************************************************************************
454 
455 
456 //*************************************************************************************************
468 template< typename MT // Type of the sparse matrix
469  , bool SF // Symmetry flag
470  , typename... CRAs > // Compile time row arguments
471 inline typename Rows<MT,true,false,SF,CRAs...>::ConstReference
472  Rows<MT,true,false,SF,CRAs...>::at( size_t i, size_t j ) const
473 {
474  if( i >= rows() ) {
475  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
476  }
477  if( j >= columns() ) {
478  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
479  }
480  return (*this)(i,j);
481 }
483 //*************************************************************************************************
484 
485 
486 //*************************************************************************************************
495 template< typename MT // Type of the sparse matrix
496  , bool SF // Symmetry flag
497  , typename... CRAs > // Compile time row arguments
498 inline typename Rows<MT,true,false,SF,CRAs...>::Iterator
500 {
501  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
502 
503  return matrix_.begin( idx(i) );
504 }
506 //*************************************************************************************************
507 
508 
509 //*************************************************************************************************
518 template< typename MT // Type of the sparse matrix
519  , bool SF // Symmetry flag
520  , typename... CRAs > // Compile time row arguments
521 inline typename Rows<MT,true,false,SF,CRAs...>::ConstIterator
522  Rows<MT,true,false,SF,CRAs...>::begin( size_t i ) const
523 {
524  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
525 
526  return matrix_.cbegin( idx(i) );
527 }
529 //*************************************************************************************************
530 
531 
532 //*************************************************************************************************
541 template< typename MT // Type of the sparse matrix
542  , bool SF // Symmetry flag
543  , typename... CRAs > // Compile time row arguments
544 inline typename Rows<MT,true,false,SF,CRAs...>::ConstIterator
546 {
547  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
548 
549  return matrix_.cbegin( idx(i) );
550 }
552 //*************************************************************************************************
553 
554 
555 //*************************************************************************************************
564 template< typename MT // Type of the sparse matrix
565  , bool SF // Symmetry flag
566  , typename... CRAs > // Compile time row arguments
567 inline typename Rows<MT,true,false,SF,CRAs...>::Iterator
569 {
570  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
571 
572  return matrix_.end( idx(i) );
573 }
575 //*************************************************************************************************
576 
577 
578 //*************************************************************************************************
587 template< typename MT // Type of the sparse matrix
588  , bool SF // Symmetry flag
589  , typename... CRAs > // Compile time row arguments
590 inline typename Rows<MT,true,false,SF,CRAs...>::ConstIterator
591  Rows<MT,true,false,SF,CRAs...>::end( size_t i ) const
592 {
593  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
594 
595  return matrix_.cend( idx(i) );
596 }
598 //*************************************************************************************************
599 
600 
601 //*************************************************************************************************
610 template< typename MT // Type of the sparse matrix
611  , bool SF // Symmetry flag
612  , typename... CRAs > // Compile time row arguments
613 inline typename Rows<MT,true,false,SF,CRAs...>::ConstIterator
614  Rows<MT,true,false,SF,CRAs...>::cend( size_t i ) const
615 {
616  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
617 
618  return matrix_.cend( idx(i) );
619 }
621 //*************************************************************************************************
622 
623 
624 
625 
626 //=================================================================================================
627 //
628 // ASSIGNMENT OPERATORS
629 //
630 //=================================================================================================
631 
632 //*************************************************************************************************
648 template< typename MT // Type of the sparse matrix
649  , bool SF // Symmetry flag
650  , typename... CRAs > // Compile time row arguments
651 inline Rows<MT,true,false,SF,CRAs...>&
652  Rows<MT,true,false,SF,CRAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
653 {
656 
657  if( list.size() != rows() ) {
658  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to row selection" );
659  }
660 
661  const InitializerMatrix<ElementType> tmp( list, columns() );
662 
663  if( IsRestricted_v<MT> ) {
664  for( size_t i=0UL; i<rows(); ++i ) {
665  if( !tryAssign( matrix_, row( tmp, i, unchecked ), i, 0UL ) ) {
666  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
667  }
668  }
669  }
670 
671  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
672 
673  left.reset();
674  smpAssign( left, tmp );
675 
676  return *this;
677 }
679 //*************************************************************************************************
680 
681 
682 //*************************************************************************************************
697 template< typename MT // Type of the sparse matrix
698  , bool SF // Symmetry flag
699  , typename... CRAs > // Compile time row arguments
700 inline Rows<MT,true,false,SF,CRAs...>&
701  Rows<MT,true,false,SF,CRAs...>::operator=( const Rows& rhs )
702 {
705 
708 
709  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && compareIndices( *this, rhs ) ) )
710  return *this;
711 
712  if( rows() != rhs.rows() || columns() != rhs.columns() ) {
713  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
714  }
715 
716  if( IsRestricted_v<MT> ) {
717  for( size_t i=0UL; i<rows(); ++i ) {
718  if( !tryAssign( matrix_, row( rhs, i, unchecked ), idx(i), 0UL ) ) {
719  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
720  }
721  }
722  }
723 
724  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
725 
726  if( rhs.canAlias( &matrix_ ) ) {
727  const ResultType tmp( rhs );
728  left.reset();
729  smpAssign( left, tmp );
730  }
731  else {
732  left.reset();
733  smpAssign( left, rhs );
734  }
735 
736  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
737 
738  return *this;
739 }
741 //*************************************************************************************************
742 
743 
744 //*************************************************************************************************
759 template< typename MT // Type of the sparse matrix
760  , bool SF // Symmetry flag
761  , typename... CRAs > // Compile time row arguments
762 template< typename MT2 // Type of the right-hand side matrix
763  , bool SO > // Storage order of the right-hand side matrix
764 inline Rows<MT,true,false,SF,CRAs...>&
765  Rows<MT,true,false,SF,CRAs...>::operator=( const Matrix<MT2,SO>& rhs )
766 {
769 
771 
772  if( rows() != (~rhs).rows() || columns() != (~rhs).columns() ) {
773  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
774  }
775 
776  using Right = CompositeType_t<MT2>;
777  Right right( ~rhs );
778 
779  if( IsRestricted_v<MT> ) {
780  for( size_t i=0UL; i<rows(); ++i ) {
781  if( !tryAssign( matrix_, row( right, i, unchecked ), idx(i), 0UL ) ) {
782  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
783  }
784  }
785  }
786 
787  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
788 
789  if( IsReference_v<Right> && right.canAlias( &matrix_ ) ) {
790  const ResultType_t<MT2> tmp( right );
791  left.reset();
792  smpAssign( left, tmp );
793  }
794  else {
795  left.reset();
796  smpAssign( left, right );
797  }
798 
799  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
800 
801  return *this;
802 }
804 //*************************************************************************************************
805 
806 
807 //*************************************************************************************************
821 template< typename MT // Type of the sparse matrix
822  , bool SF // Symmetry flag
823  , typename... CRAs > // Compile time row arguments
824 template< typename MT2 // Type of the right-hand side matrix
825  , bool SO > // Storage order of the right-hand side matrix
826 inline Rows<MT,true,false,SF,CRAs...>&
827  Rows<MT,true,false,SF,CRAs...>::operator+=( const Matrix<MT2,SO>& rhs )
828 {
831 
835 
836  using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
837 
839 
840  if( rows() != (~rhs).rows() || columns() != (~rhs).columns() ) {
841  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
842  }
843 
844  const AddType tmp( *this + (~rhs) );
845 
846  if( IsRestricted_v<MT> ) {
847  for( size_t i=0UL; i<rows(); ++i ) {
848  if( !tryAssign( matrix_, row( tmp, i, unchecked ), idx(i), 0UL ) ) {
849  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
850  }
851  }
852  }
853 
854  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
855 
856  left.reset();
857  smpAssign( left, tmp );
858 
859  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
860 
861  return *this;
862 }
864 //*************************************************************************************************
865 
866 
867 //*************************************************************************************************
881 template< typename MT // Type of the sparse matrix
882  , bool SF // Symmetry flag
883  , typename... CRAs > // Compile time row arguments
884 template< typename MT2 // Type of the right-hand side matrix
885  , bool SO > // Storage order of the right-hand side matrix
886 inline Rows<MT,true,false,SF,CRAs...>&
887  Rows<MT,true,false,SF,CRAs...>::operator-=( const Matrix<MT2,SO>& rhs )
888 {
891 
895 
896  using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
897 
899 
900  if( rows() != (~rhs).rows() || columns() != (~rhs).columns() ) {
901  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
902  }
903 
904  const SubType tmp( *this - (~rhs) );
905 
906  if( IsRestricted_v<MT> ) {
907  for( size_t i=0UL; i<rows(); ++i ) {
908  if( !tryAssign( matrix_, row( tmp, i, unchecked ), idx(i), 0UL ) ) {
909  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
910  }
911  }
912  }
913 
914  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
915 
916  left.reset();
917  smpAssign( left, tmp );
918 
919  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
920 
921  return *this;
922 }
924 //*************************************************************************************************
925 
926 
927 //*************************************************************************************************
941 template< typename MT // Type of the sparse matrix
942  , bool SF // Symmetry flag
943  , typename... CRAs > // Compile time row arguments
944 template< typename MT2 // Type of the right-hand side matrix
945  , bool SO > // Storage order of the right-hand side matrix
946 inline Rows<MT,true,false,SF,CRAs...>&
947  Rows<MT,true,false,SF,CRAs...>::operator%=( const Matrix<MT2,SO>& rhs )
948 {
951 
955 
956  using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
957 
959 
960  if( rows() != (~rhs).rows() || columns() != (~rhs).columns() ) {
961  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
962  }
963 
964  const SchurType tmp( *this % (~rhs) );
965 
966  if( IsRestricted_v<MT> ) {
967  for( size_t i=0UL; i<rows(); ++i ) {
968  if( !tryAssign( matrix_, row( tmp, i, unchecked ), idx(i), 0UL ) ) {
969  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
970  }
971  }
972  }
973 
974  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
975 
976  left.reset();
977  smpAssign( left, tmp );
978 
979  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
980 
981  return *this;
982 }
984 //*************************************************************************************************
985 
986 
987 
988 
989 //=================================================================================================
990 //
991 // UTILITY FUNCTIONS
992 //
993 //=================================================================================================
994 
995 //*************************************************************************************************
1001 template< typename MT // Type of the sparse matrix
1002  , bool SF // Symmetry flag
1003  , typename... CRAs > // Compile time row arguments
1004 inline MT& Rows<MT,true,false,SF,CRAs...>::operand() noexcept
1005 {
1006  return matrix_;
1007 }
1009 //*************************************************************************************************
1010 
1011 
1012 //*************************************************************************************************
1018 template< typename MT // Type of the sparse matrix
1019  , bool SF // Symmetry flag
1020  , typename... CRAs > // Compile time row arguments
1021 inline const MT& Rows<MT,true,false,SF,CRAs...>::operand() const noexcept
1022 {
1023  return matrix_;
1024 }
1026 //*************************************************************************************************
1027 
1028 
1029 //*************************************************************************************************
1035 template< typename MT // Type of the sparse matrix
1036  , bool SF // Symmetry flag
1037  , typename... CRAs > // Compile time row arguments
1038 inline size_t Rows<MT,true,false,SF,CRAs...>::columns() const noexcept
1039 {
1040  return matrix_.columns();
1041 }
1043 //*************************************************************************************************
1044 
1045 
1046 //*************************************************************************************************
1052 template< typename MT // Type of the sparse matrix
1053  , bool SF // Symmetry flag
1054  , typename... CRAs > // Compile time row arguments
1055 inline size_t Rows<MT,true,false,SF,CRAs...>::capacity() const noexcept
1056 {
1057  return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
1058 }
1060 //*************************************************************************************************
1061 
1062 
1063 //*************************************************************************************************
1072 template< typename MT // Type of the sparse matrix
1073  , bool SF // Symmetry flag
1074  , typename... CRAs > // Compile time row arguments
1075 inline size_t Rows<MT,true,false,SF,CRAs...>::capacity( size_t i ) const noexcept
1076 {
1077  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1078 
1079  return matrix_.capacity( idx(i) );
1080 }
1082 //*************************************************************************************************
1083 
1084 
1085 //*************************************************************************************************
1091 template< typename MT // Type of the sparse matrix
1092  , bool SF // Symmetry flag
1093  , typename... CRAs > // Compile time row arguments
1094 inline size_t Rows<MT,true,false,SF,CRAs...>::nonZeros() const
1095 {
1096  size_t nonzeros( 0UL );
1097 
1098  for( size_t i=0UL; i<rows(); ++i )
1099  nonzeros += nonZeros( i );
1100 
1101  return nonzeros;
1102 }
1104 //*************************************************************************************************
1105 
1106 
1107 //*************************************************************************************************
1116 template< typename MT // Type of the sparse matrix
1117  , bool SF // Symmetry flag
1118  , typename... CRAs > // Compile time row arguments
1119 inline size_t Rows<MT,true,false,SF,CRAs...>::nonZeros( size_t i ) const
1120 {
1121  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1122 
1123  return matrix_.nonZeros( idx(i) );
1124 }
1126 //*************************************************************************************************
1127 
1128 
1129 //*************************************************************************************************
1135 template< typename MT // Type of the sparse matrix
1136  , bool SF // Symmetry flag
1137  , typename... CRAs > // Compile time row arguments
1139 {
1140  for( size_t i=0UL; i<rows(); ++i ) {
1141  matrix_.reset( idx(i) );
1142  }
1143 }
1145 //*************************************************************************************************
1146 
1147 
1148 //*************************************************************************************************
1158 template< typename MT // Type of the sparse matrix
1159  , bool SF // Symmetry flag
1160  , typename... CRAs > // Compile time row arguments
1161 inline void Rows<MT,true,false,SF,CRAs...>::reset( size_t i )
1162 {
1163  matrix_.reset( idx(i) );
1164 }
1166 //*************************************************************************************************
1167 
1168 
1169 //*************************************************************************************************
1180 template< typename MT // Type of the sparse matrix
1181  , bool SF // Symmetry flag
1182  , typename... CRAs > // Compile time row arguments
1183 inline void Rows<MT,true,false,SF,CRAs...>::reserve( size_t nonzeros )
1184 {
1185  const size_t current( capacity() );
1186 
1187  if( nonzeros > current ) {
1188  matrix_.reserve( matrix_.capacity() + nonzeros - current );
1189  }
1190 }
1192 //*************************************************************************************************
1193 
1194 
1195 //*************************************************************************************************
1208 template< typename MT // Type of the sparse matrix
1209  , bool SF // Symmetry flag
1210  , typename... CRAs > // Compile time row arguments
1211 void Rows<MT,true,false,SF,CRAs...>::reserve( size_t i, size_t nonzeros )
1212 {
1213  matrix_.reserve( idx(i), nonzeros );
1214 }
1216 //*************************************************************************************************
1217 
1218 
1219 //*************************************************************************************************
1229 template< typename MT // Type of the sparse matrix
1230  , bool SF // Symmetry flag
1231  , typename... CRAs > // Compile time row arguments
1232 void Rows<MT,true,false,SF,CRAs...>::trim()
1233 {
1234  for( size_t i=0UL; i<rows(); ++i ) {
1235  trim( i );
1236  }
1237 }
1239 //*************************************************************************************************
1240 
1241 
1242 //*************************************************************************************************
1253 template< typename MT // Type of the sparse matrix
1254  , bool SF // Symmetry flag
1255  , typename... CRAs > // Compile time row arguments
1256 void Rows<MT,true,false,SF,CRAs...>::trim( size_t i )
1257 {
1258  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1259 
1260  matrix_.trim( idx(i) );
1261 }
1263 //*************************************************************************************************
1264 
1265 
1266 //*************************************************************************************************
1276 template< typename MT // Type of the sparse matrix
1277  , bool SF // Symmetry flag
1278  , typename... CRAs > // Compile time row arguments
1279 inline size_t Rows<MT,true,false,SF,CRAs...>::extendCapacity( size_t i ) const noexcept
1280 {
1281  using blaze::max;
1282  using blaze::min;
1283 
1284  size_t nonzeros( 2UL*capacity( i )+1UL );
1285  nonzeros = max( nonzeros, 7UL );
1286  nonzeros = min( nonzeros, columns() );
1287 
1288  BLAZE_INTERNAL_ASSERT( nonzeros > capacity( i ), "Invalid capacity value" );
1289 
1290  return nonzeros;
1291 }
1293 //*************************************************************************************************
1294 
1295 
1296 
1297 
1298 //=================================================================================================
1299 //
1300 // INSERTION FUNCTIONS
1301 //
1302 //=================================================================================================
1303 
1304 //*************************************************************************************************
1317 template< typename MT // Type of the sparse matrix
1318  , bool SF // Symmetry flag
1319  , typename... CRAs > // Compile time row arguments
1320 inline typename Rows<MT,true,false,SF,CRAs...>::Iterator
1321  Rows<MT,true,false,SF,CRAs...>::set( size_t i, size_t j, const ElementType& value )
1322 {
1323  return matrix_.set( idx(i), j, value );
1324 }
1326 //*************************************************************************************************
1327 
1328 
1329 //*************************************************************************************************
1343 template< typename MT // Type of the sparse matrix
1344  , bool SF // Symmetry flag
1345  , typename... CRAs > // Compile time row arguments
1346 inline typename Rows<MT,true,false,SF,CRAs...>::Iterator
1347  Rows<MT,true,false,SF,CRAs...>::insert( size_t i, size_t j, const ElementType& value )
1348 {
1349  return matrix_.insert( idx(i), j, value );
1350 }
1352 //*************************************************************************************************
1353 
1354 
1355 //*************************************************************************************************
1399 template< typename MT // Type of the sparse matrix
1400  , bool SF // Symmetry flag
1401  , typename... CRAs > // Compile time row arguments
1402 inline void Rows<MT,true,false,SF,CRAs...>::append( size_t i, size_t j, const ElementType& value, bool check )
1403 {
1404  if( !check || !isDefault<strict>( value ) )
1405  matrix_.insert( idx(i), j, value );
1406 }
1408 //*************************************************************************************************
1409 
1410 
1411 //*************************************************************************************************
1425 template< typename MT // Type of the sparse matrix
1426  , bool SF // Symmetry flag
1427  , typename... CRAs > // Compile time row arguments
1428 inline void Rows<MT,true,false,SF,CRAs...>::finalize( size_t i )
1429 {
1430  UNUSED_PARAMETER( i );
1431 
1432  return;
1433 }
1435 //*************************************************************************************************
1436 
1437 
1438 
1439 
1440 //=================================================================================================
1441 //
1442 // ERASE FUNCTIONS
1443 //
1444 //=================================================================================================
1445 
1446 //*************************************************************************************************
1456 template< typename MT // Type of the sparse matrix
1457  , bool SF // Symmetry flag
1458  , typename... CRAs > // Compile time row arguments
1459 inline void Rows<MT,true,false,SF,CRAs...>::erase( size_t i, size_t j )
1460 {
1461  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
1462  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
1463 
1464  matrix_.erase( idx(i), j );
1465 }
1467 //*************************************************************************************************
1468 
1469 
1470 //*************************************************************************************************
1480 template< typename MT // Type of the sparse matrix
1481  , bool SF // Symmetry flag
1482  , typename... CRAs > // Compile time row arguments
1483 inline typename Rows<MT,true,false,SF,CRAs...>::Iterator
1484  Rows<MT,true,false,SF,CRAs...>::erase( size_t i, Iterator pos )
1485 {
1486  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1487 
1488  return matrix_.erase( idx(i), pos );
1489 }
1491 //*************************************************************************************************
1492 
1493 
1494 //*************************************************************************************************
1505 template< typename MT // Type of the sparse matrix
1506  , bool SF // Symmetry flag
1507  , typename... CRAs > // Compile time row arguments
1508 inline typename Rows<MT,true,false,SF,CRAs...>::Iterator
1509  Rows<MT,true,false,SF,CRAs...>::erase( size_t i, Iterator first, Iterator last )
1510 {
1511  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1512 
1513  return matrix_.erase( idx(i), first, last );
1514 }
1516 //*************************************************************************************************
1517 
1518 
1519 //*************************************************************************************************
1542 template< typename MT // Type of the sparse matrix
1543  , bool SF // Symmetry flag
1544  , typename... CRAs > // Compile time row arguments
1545 template< typename Pred > // Type of the unary predicate
1546 inline void Rows<MT,true,false,SF,CRAs...>::erase( Pred predicate )
1547 {
1548  for( size_t i=0UL; i<rows(); ++i ) {
1549  matrix_.erase( idx(i), begin(i), end(i), predicate );
1550  }
1551 }
1553 //*************************************************************************************************
1554 
1555 
1556 //*************************************************************************************************
1583 template< typename MT // Type of the sparse matrix
1584  , bool SF // Symmetry flag
1585  , typename... CRAs > // Compile time row arguments
1586 template< typename Pred > // Type of the unary predicate
1587 inline void Rows<MT,true,false,SF,CRAs...>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
1588 {
1589  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1590 
1591  matrix_.erase( idx(i), first, last, predicate );
1592 }
1594 //*************************************************************************************************
1595 
1596 
1597 
1598 
1599 //=================================================================================================
1600 //
1601 // LOOKUP FUNCTIONS
1602 //
1603 //=================================================================================================
1604 
1605 //*************************************************************************************************
1620 template< typename MT // Type of the sparse matrix
1621  , bool SF // Symmetry flag
1622  , typename... CRAs > // Compile time row arguments
1623 inline typename Rows<MT,true,false,SF,CRAs...>::Iterator
1624  Rows<MT,true,false,SF,CRAs...>::find( size_t i, size_t j )
1625 {
1626  return matrix_.find( idx(i), j );
1627 }
1629 //*************************************************************************************************
1630 
1631 
1632 //*************************************************************************************************
1647 template< typename MT // Type of the sparse matrix
1648  , bool SF // Symmetry flag
1649  , typename... CRAs > // Compile time row arguments
1650 inline typename Rows<MT,true,false,SF,CRAs...>::ConstIterator
1651  Rows<MT,true,false,SF,CRAs...>::find( size_t i, size_t j ) const
1652 {
1653  return matrix_.find( idx(i), j );
1654 }
1656 //*************************************************************************************************
1657 
1658 
1659 //*************************************************************************************************
1673 template< typename MT // Type of the sparse matrix
1674  , bool SF // Symmetry flag
1675  , typename... CRAs > // Compile time row arguments
1676 inline typename Rows<MT,true,false,SF,CRAs...>::Iterator
1677  Rows<MT,true,false,SF,CRAs...>::lowerBound( size_t i, size_t j )
1678 {
1679  return matrix_.lowerBound( idx(i), j );
1680 }
1682 //*************************************************************************************************
1683 
1684 
1685 //*************************************************************************************************
1699 template< typename MT // Type of the sparse matrix
1700  , bool SF // Symmetry flag
1701  , typename... CRAs > // Compile time row arguments
1702 inline typename Rows<MT,true,false,SF,CRAs...>::ConstIterator
1703  Rows<MT,true,false,SF,CRAs...>::lowerBound( size_t i, size_t j ) const
1704 {
1705  return matrix_.lowerBound( idx(i), j );
1706 }
1708 //*************************************************************************************************
1709 
1710 
1711 //*************************************************************************************************
1725 template< typename MT // Type of the sparse matrix
1726  , bool SF // Symmetry flag
1727  , typename... CRAs > // Compile time row arguments
1728 inline typename Rows<MT,true,false,SF,CRAs...>::Iterator
1729  Rows<MT,true,false,SF,CRAs...>::upperBound( size_t i, size_t j )
1730 {
1731  return matrix_.upperBound( idx(i), j );
1732 }
1734 //*************************************************************************************************
1735 
1736 
1737 //*************************************************************************************************
1751 template< typename MT // Type of the sparse matrix
1752  , bool SF // Symmetry flag
1753  , typename... CRAs > // Compile time row arguments
1754 inline typename Rows<MT,true,false,SF,CRAs...>::ConstIterator
1755  Rows<MT,true,false,SF,CRAs...>::upperBound( size_t i, size_t j ) const
1756 {
1757  return matrix_.upperBound( idx(i), j );
1758 }
1760 //*************************************************************************************************
1761 
1762 
1763 
1764 
1765 //=================================================================================================
1766 //
1767 // NUMERIC FUNCTIONS
1768 //
1769 //=================================================================================================
1770 
1771 //*************************************************************************************************
1784 template< typename MT // Type of the sparse matrix
1785  , bool SF // Symmetry flag
1786  , typename... CRAs > // Compile time row arguments
1787 inline Rows<MT,true,false,SF,CRAs...>&
1789 {
1792 
1793  if( rows() != columns() ) {
1794  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose of a non-quadratic matrix" );
1795  }
1796 
1797  const ResultType tmp( trans( *this ) );
1798 
1799  if( IsRestricted_v<MT> ) {
1800  for( size_t i=0UL; i<rows(); ++i ) {
1801  if( !tryAssign( matrix_, row( tmp, i, unchecked ), idx(i), 0UL ) ) {
1802  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose operation" );
1803  }
1804  }
1805  }
1806 
1807  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
1808 
1809  left.reset();
1810  smpAssign( left, tmp );
1811 
1812  return *this;
1813 }
1815 //*************************************************************************************************
1816 
1817 
1818 //*************************************************************************************************
1831 template< typename MT // Type of the sparse matrix
1832  , bool SF // Symmetry flag
1833  , typename... CRAs > // Compile time row arguments
1834 inline Rows<MT,true,false,SF,CRAs...>&
1836 {
1839 
1840  if( rows() != columns() ) {
1841  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose of a non-quadratic matrix" );
1842  }
1843 
1844  const ResultType tmp( ctrans( *this ) );
1845 
1846  if( IsRestricted_v<MT> ) {
1847  for( size_t i=0UL; i<rows(); ++i ) {
1848  if( !tryAssign( matrix_, row( tmp, i, unchecked ), idx(i), 0UL ) ) {
1849  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose operation" );
1850  }
1851  }
1852  }
1853 
1854  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
1855 
1856  left.reset();
1857  smpAssign( left, tmp );
1858 
1859  return *this;
1860 }
1862 //*************************************************************************************************
1863 
1864 
1865 //*************************************************************************************************
1878 template< typename MT // Type of the sparse matrix
1879  , bool SF // Symmetry flag
1880  , typename... CRAs > // Compile time row arguments
1881 template< typename Other > // Data type of the scalar value
1882 inline Rows<MT,true,false,SF,CRAs...>&
1883  Rows<MT,true,false,SF,CRAs...>::scale( const Other& scalar )
1884 {
1888 
1889  for( size_t i=0UL; i<rows(); ++i ) {
1890  const Iterator last( end(i) );
1891  for( Iterator element=begin(i); element!=last; ++element )
1892  element->value() *= scalar;
1893  }
1894 
1895  return *this;
1896 }
1898 //*************************************************************************************************
1899 
1900 
1901 
1902 
1903 //=================================================================================================
1904 //
1905 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1906 //
1907 //=================================================================================================
1908 
1909 //*************************************************************************************************
1920 template< typename MT // Type of the sparse matrix
1921  , bool SF // Symmetry flag
1922  , typename... CRAs > // Compile time row arguments
1923 template< typename Other > // Data type of the foreign expression
1924 inline bool Rows<MT,true,false,SF,CRAs...>::canAlias( const Other* alias ) const noexcept
1925 {
1926  return matrix_.isAliased( alias );
1927 }
1929 //*************************************************************************************************
1930 
1931 
1932 //*************************************************************************************************
1943 template< typename MT // Type of the sparse matrix
1944  , bool SF // Symmetry flag
1945  , typename... CRAs > // Compile time row arguments
1946 template< typename Other > // Data type of the foreign expression
1947 inline bool Rows<MT,true,false,SF,CRAs...>::isAliased( const Other* alias ) const noexcept
1948 {
1949  return matrix_.isAliased( alias );
1950 }
1952 //*************************************************************************************************
1953 
1954 
1955 //*************************************************************************************************
1966 template< typename MT // Type of the sparse matrix
1967  , bool SF // Symmetry flag
1968  , typename... CRAs > // Compile time row arguments
1969 inline bool Rows<MT,true,false,SF,CRAs...>::canSMPAssign() const noexcept
1970 {
1971  return false;
1972 }
1974 //*************************************************************************************************
1975 
1976 
1977 //*************************************************************************************************
1989 template< typename MT // Type of the sparse matrix
1990  , bool SF // Symmetry flag
1991  , typename... CRAs > // Compile time row arguments
1992 template< typename MT2 // Type of the right-hand side dense matrix
1993  , bool SO > // Storage order of the right-hand side dense matrix
1994 inline void Rows<MT,true,false,SF,CRAs...>::assign( const DenseMatrix<MT2,SO>& rhs )
1995 {
1998 
1999  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2000  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2001  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
2002 
2003  for( size_t i=0UL; i<rows(); ++i )
2004  {
2005  const size_t index( idx(i) );
2006  size_t remaining( matrix_.capacity( index ) );
2007 
2008  for( size_t j=0UL; j<columns(); ++j )
2009  {
2010  if( remaining == 0UL ) {
2011  matrix_.reserve( index, extendCapacity( i ) );
2012  remaining = matrix_.capacity( index ) - matrix_.nonZeros( index );
2013  }
2014 
2015  matrix_.append( index, j, (~rhs)(i,j), true );
2016  --remaining;
2017  }
2018  }
2019 }
2021 //*************************************************************************************************
2022 
2023 
2024 //*************************************************************************************************
2036 template< typename MT // Type of the sparse matrix
2037  , bool SF // Symmetry flag
2038  , typename... CRAs > // Compile time row arguments
2039 template< typename MT2 > // Type of the right-hand side sparse matrix
2040 inline void Rows<MT,true,false,SF,CRAs...>::assign( const SparseMatrix<MT2,false>& rhs )
2041 {
2044 
2045  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2046  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2047  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
2048 
2049  for( size_t i=0UL; i<rows(); ++i )
2050  {
2051  const size_t index( idx(i) );
2052  size_t remaining( matrix_.capacity( index ) );
2053 
2054  for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2055  {
2056  if( remaining == 0UL ) {
2057  matrix_.reserve( index, extendCapacity( i ) );
2058  remaining = matrix_.capacity( index ) - matrix_.nonZeros( index );
2059  }
2060 
2061  matrix_.append( index, element->index(), element->value(), true );
2062  --remaining;
2063  }
2064  }
2065 }
2067 //*************************************************************************************************
2068 
2069 
2070 //*************************************************************************************************
2082 template< typename MT // Type of the sparse matrix
2083  , bool SF // Symmetry flag
2084  , typename... CRAs > // Compile time row arguments
2085 template< typename MT2 > // Type of the right-hand side sparse matrix
2086 inline void Rows<MT,true,false,SF,CRAs...>::assign( const SparseMatrix<MT2,true>& rhs )
2087 {
2090 
2092 
2093  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2094  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2095  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
2096 
2097  // Counting the number of elements per row
2098  std::vector<size_t> rowLengths( rows(), 0UL );
2099  for( size_t j=0UL; j<columns(); ++j ) {
2100  for( auto element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2101  ++rowLengths[element->index()];
2102  }
2103 
2104  // Resizing the sparse matrix
2105  for( size_t i=0UL; i<rows(); ++i ) {
2106  reserve( i, rowLengths[i] );
2107  }
2108 
2109  // Appending the elements to the rows of the sparse row selection
2110  for( size_t j=0UL; j<columns(); ++j ) {
2111  for( auto element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2112  append( element->index(), j, element->value(), true );
2113  }
2114 }
2116 //*************************************************************************************************
2117 
2118 
2119 //*************************************************************************************************
2131 template< typename MT // Type of the sparse matrix
2132  , bool SF // Symmetry flag
2133  , typename... CRAs > // Compile time row arguments
2134 template< typename MT2 // Type of the right-hand side matrix
2135  , bool SO > // Storage order of the right-hand side matrix
2136 inline void Rows<MT,true,false,SF,CRAs...>::addAssign( const Matrix<MT2,SO>& rhs )
2137 {
2140 
2141  using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
2142 
2144 
2145  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2146  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2147 
2148  const AddType tmp( serial( *this + (~rhs) ) );
2149  reset();
2150  assign( tmp );
2151 }
2153 //*************************************************************************************************
2154 
2155 
2156 //*************************************************************************************************
2168 template< typename MT // Type of the sparse matrix
2169  , bool SF // Symmetry flag
2170  , typename... CRAs > // Compile time row arguments
2171 template< typename MT2 // Type of the right-hand side matrix
2172  , bool SO > // Storage order of the right-hand side matrix
2173 inline void Rows<MT,true,false,SF,CRAs...>::subAssign( const Matrix<MT2,SO>& rhs )
2174 {
2177 
2178  using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
2179 
2181 
2182  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2183  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2184 
2185  const SubType tmp( serial( *this - (~rhs) ) );
2186  reset();
2187  assign( tmp );
2188 }
2190 //*************************************************************************************************
2191 
2192 
2193 //*************************************************************************************************
2205 template< typename MT // Type of the sparse matrix
2206  , bool SF // Symmetry flag
2207  , typename... CRAs > // Compile time row arguments
2208 template< typename MT2 // Type of the right-hand side matrix
2209  , bool SO > // Storage order of the right-hand side matrix
2210 inline void Rows<MT,true,false,SF,CRAs...>::schurAssign( const Matrix<MT2,SO>& rhs )
2211 {
2214 
2215  using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
2216 
2219 
2220  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2221  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2222 
2223  const SchurType tmp( serial( *this % (~rhs) ) );
2224  reset();
2225  assign( tmp );
2226 }
2228 //*************************************************************************************************
2229 
2230 
2231 
2232 
2233 
2234 
2235 
2236 
2237 //=================================================================================================
2238 //
2239 // CLASS TEMPLATE SPECIALIZATION FOR GENERAL COLUMN-MAJOR SPARSE MATRICES
2240 //
2241 //=================================================================================================
2242 
2243 //*************************************************************************************************
2251 template< typename MT // Type of the sparse matrix
2252  , typename... CRAs > // Compile time row arguments
2253 class Rows<MT,false,false,false,CRAs...>
2254  : public View< SparseMatrix< Rows<MT,false,false,false,CRAs...>, false > >
2255  , private RowsData<CRAs...>
2256 {
2257  private:
2258  //**Type definitions****************************************************************************
2259  using DataType = RowsData<CRAs...>;
2260  using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
2261  //**********************************************************************************************
2262 
2263  //**Compile time flags**************************************************************************
2264  using DataType::N;
2265  //**********************************************************************************************
2266 
2267  public:
2268  //**Type definitions****************************************************************************
2270  using This = Rows<MT,false,false,false,CRAs...>;
2271 
2272  using BaseType = SparseMatrix<This,false>;
2273  using ViewedType = MT;
2274  using ResultType = RowsTrait_t<MT,N>;
2275  using OppositeType = OppositeType_t<ResultType>;
2276  using TransposeType = TransposeType_t<ResultType>;
2277  using ElementType = ElementType_t<MT>;
2278  using ReturnType = ReturnType_t<MT>;
2279  using CompositeType = const Rows&;
2280 
2282  using ConstReference = ConstReference_t<MT>;
2283 
2285  using Reference = If_t< IsConst_v<MT>, ConstReference, Reference_t<MT> >;
2286  //**********************************************************************************************
2287 
2288  //**RowsElement class definition****************************************************************
2291  template< typename MatrixType // Type of the sparse matrix
2292  , typename IteratorType > // Type of the sparse matrix iterator
2293  class RowsElement
2294  : private SparseElement
2295  {
2296  public:
2297  //**Constructor******************************************************************************
2303  inline RowsElement( IteratorType pos, size_t column )
2304  : pos_ ( pos ) // Iterator to the current position of the sparse row element
2305  , column_( column ) // Index of the according column
2306  {}
2307  //*******************************************************************************************
2308 
2309  //**Assignment operator**********************************************************************
2315  template< typename T > inline RowsElement& operator=( const T& v ) {
2316  *pos_ = v;
2317  return *this;
2318  }
2319  //*******************************************************************************************
2320 
2321  //**Addition assignment operator*************************************************************
2327  template< typename T > inline RowsElement& operator+=( const T& v ) {
2328  *pos_ += v;
2329  return *this;
2330  }
2331  //*******************************************************************************************
2332 
2333  //**Subtraction assignment operator**********************************************************
2339  template< typename T > inline RowsElement& operator-=( const T& v ) {
2340  *pos_ -= v;
2341  return *this;
2342  }
2343  //*******************************************************************************************
2344 
2345  //**Multiplication assignment operator*******************************************************
2351  template< typename T > inline RowsElement& operator*=( const T& v ) {
2352  *pos_ *= v;
2353  return *this;
2354  }
2355  //*******************************************************************************************
2356 
2357  //**Division assignment operator*************************************************************
2363  template< typename T > inline RowsElement& operator/=( const T& v ) {
2364  *pos_ /= v;
2365  return *this;
2366  }
2367  //*******************************************************************************************
2368 
2369  //**Element access operator******************************************************************
2374  inline const RowsElement* operator->() const {
2375  return this;
2376  }
2377  //*******************************************************************************************
2378 
2379  //**Value function***************************************************************************
2384  inline decltype(auto) value() const {
2385  return pos_->value();
2386  }
2387  //*******************************************************************************************
2388 
2389  //**Index function***************************************************************************
2394  inline size_t index() const {
2395  return column_;
2396  }
2397  //*******************************************************************************************
2398 
2399  private:
2400  //**Member variables*************************************************************************
2401  IteratorType pos_;
2402  size_t column_;
2403  //*******************************************************************************************
2404  };
2405  //**********************************************************************************************
2406 
2407  //**RowsIterator class definition***************************************************************
2410  template< typename MatrixType // Type of the sparse matrix
2411  , typename IteratorType > // Type of the sparse matrix iterator
2412  class RowsIterator
2413  {
2414  public:
2415  //**Type definitions*************************************************************************
2416  using IteratorCategory = std::forward_iterator_tag;
2417  using ValueType = RowsElement<MatrixType,IteratorType>;
2418  using PointerType = ValueType;
2419  using ReferenceType = ValueType;
2420  using DifferenceType = ptrdiff_t;
2421 
2422  // STL iterator requirements
2423  using iterator_category = IteratorCategory;
2424  using value_type = ValueType;
2425  using pointer = PointerType;
2426  using reference = ReferenceType;
2427  using difference_type = DifferenceType;
2428  //*******************************************************************************************
2429 
2430  //**Constructor******************************************************************************
2433  inline RowsIterator()
2434  : matrix_( nullptr ) // The sparse matrix containing the selected row
2435  , row_ ( 0UL ) // The current row index
2436  , column_( 0UL ) // The current column index
2437  , pos_ () // Iterator to the current sparse element
2438  {}
2439  //*******************************************************************************************
2440 
2441  //**Constructor******************************************************************************
2448  inline RowsIterator( MatrixType& matrix, size_t row, size_t column )
2449  : matrix_( &matrix ) // The sparse matrix containing the selected row
2450  , row_ ( row ) // The current row index
2451  , column_( column ) // The current column index
2452  , pos_ () // Iterator to the current sparse element
2453  {
2454  for( ; column_<matrix_->columns(); ++column_ ) {
2455  pos_ = matrix_->find( row_, column_ );
2456  if( pos_ != matrix_->end( column_ ) ) break;
2457  }
2458  }
2459  //*******************************************************************************************
2460 
2461  //**Constructor******************************************************************************
2469  inline RowsIterator( MatrixType& matrix, size_t row, size_t column, IteratorType pos )
2470  : matrix_( &matrix ) // The sparse matrix containing the selected row
2471  , row_ ( row ) // The current row index
2472  , column_( column ) // The current column index
2473  , pos_ ( pos ) // Iterator to the current sparse element
2474  {
2475  BLAZE_INTERNAL_ASSERT( matrix.find( row, column ) == pos, "Invalid initial iterator position" );
2476  }
2477  //*******************************************************************************************
2478 
2479  //**Constructor******************************************************************************
2484  template< typename MatrixType2, typename IteratorType2 >
2485  inline RowsIterator( const RowsIterator<MatrixType2,IteratorType2>& it )
2486  : matrix_( it.matrix_ ) // The sparse matrix containing the selected row
2487  , row_ ( it.row_ ) // The current row index
2488  , column_( it.column_ ) // The current column index
2489  , pos_ ( it.pos_ ) // Iterator to the current sparse element
2490  {}
2491  //*******************************************************************************************
2492 
2493  //**Prefix increment operator****************************************************************
2498  inline RowsIterator& operator++() {
2499  ++column_;
2500  for( ; column_<matrix_->columns(); ++column_ ) {
2501  pos_ = matrix_->find( row_, column_ );
2502  if( pos_ != matrix_->end( column_ ) ) break;
2503  }
2504 
2505  return *this;
2506  }
2507  //*******************************************************************************************
2508 
2509  //**Postfix increment operator***************************************************************
2514  inline const RowsIterator operator++( int ) {
2515  const RowsIterator tmp( *this );
2516  ++(*this);
2517  return tmp;
2518  }
2519  //*******************************************************************************************
2520 
2521  //**Element access operator******************************************************************
2526  inline ReferenceType operator*() const {
2527  return ReferenceType( pos_, column_ );
2528  }
2529  //*******************************************************************************************
2530 
2531  //**Element access operator******************************************************************
2536  inline PointerType operator->() const {
2537  return PointerType( pos_, column_ );
2538  }
2539  //*******************************************************************************************
2540 
2541  //**Equality operator************************************************************************
2547  template< typename MatrixType2, typename IteratorType2 >
2548  inline bool operator==( const RowsIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
2549  return column_ == rhs.column_;
2550  }
2551  //*******************************************************************************************
2552 
2553  //**Inequality operator**********************************************************************
2559  template< typename MatrixType2, typename IteratorType2 >
2560  inline bool operator!=( const RowsIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
2561  return !( *this == rhs );
2562  }
2563  //*******************************************************************************************
2564 
2565  //**Subtraction operator*********************************************************************
2571  inline DifferenceType operator-( const RowsIterator& rhs ) const {
2572  size_t counter( 0UL );
2573  for( size_t j=rhs.column_; j<column_; ++j ) {
2574  if( matrix_->find( row_, j ) != matrix_->end( j ) )
2575  ++counter;
2576  }
2577  return counter;
2578  }
2579  //*******************************************************************************************
2580 
2581  private:
2582  //**Member variables*************************************************************************
2583  MatrixType* matrix_;
2584  size_t row_;
2585  size_t column_;
2586  IteratorType pos_;
2587  //*******************************************************************************************
2588 
2589  //**Friend declarations**********************************************************************
2590  template< typename MatrixType2, typename IteratorType2 > friend class RowsIterator;
2591  template< typename MT2, bool SO2, bool DF2, bool SF2, typename... CRAs2 > friend class Rows;
2592  //*******************************************************************************************
2593  };
2594  //**********************************************************************************************
2595 
2596  //**Type definitions****************************************************************************
2598  using ConstIterator = RowsIterator< const MT, ConstIterator_t<MT> >;
2599 
2601  using Iterator = If_t< IsConst_v<MT>, ConstIterator, RowsIterator< MT, Iterator_t<MT> > >;
2602  //**********************************************************************************************
2603 
2604  //**Compilation flags***************************************************************************
2606  static constexpr bool smpAssignable = MT::smpAssignable;
2607  //**********************************************************************************************
2608 
2609  //**Constructors********************************************************************************
2612  template< typename... RRAs >
2613  explicit inline Rows( MT& matrix, RRAs... args );
2614 
2615  Rows( const Rows& ) = default;
2616  Rows( Rows&& ) = default;
2618  //**********************************************************************************************
2619 
2620  //**Destructor**********************************************************************************
2623  ~Rows() = default;
2625  //**********************************************************************************************
2626 
2627  //**Data access functions***********************************************************************
2630  inline Reference operator()( size_t i, size_t j );
2631  inline ConstReference operator()( size_t i, size_t j ) const;
2632  inline Reference at( size_t i, size_t j );
2633  inline ConstReference at( size_t i, size_t j ) const;
2634  inline Iterator begin ( size_t i );
2635  inline ConstIterator begin ( size_t i ) const;
2636  inline ConstIterator cbegin( size_t i ) const;
2637  inline Iterator end ( size_t i );
2638  inline ConstIterator end ( size_t i ) const;
2639  inline ConstIterator cend ( size_t i ) const;
2641  //**********************************************************************************************
2642 
2643  //**Assignment operators************************************************************************
2646  inline Rows& operator=( initializer_list< initializer_list<ElementType> > list );
2647  inline Rows& operator=( const Rows& rhs );
2648 
2649  template< typename MT2, bool SO > inline Rows& operator= ( const Matrix<MT2,SO>& rhs );
2650  template< typename MT2, bool SO > inline Rows& operator+=( const Matrix<MT2,SO>& rhs );
2651  template< typename MT2, bool SO > inline Rows& operator-=( const Matrix<MT2,SO>& rhs );
2652  template< typename MT2, bool SO > inline Rows& operator%=( const Matrix<MT2,SO>& rhs );
2654  //**********************************************************************************************
2655 
2656  //**Utility functions***************************************************************************
2659  using DataType::idx;
2660  using DataType::idces;
2661  using DataType::rows;
2662 
2663  inline MT& operand() noexcept;
2664  inline const MT& operand() const noexcept;
2665 
2666  inline size_t columns() const noexcept;
2667  inline size_t capacity() const noexcept;
2668  inline size_t capacity( size_t i ) const noexcept;
2669  inline size_t nonZeros() const;
2670  inline size_t nonZeros( size_t i ) const;
2671  inline void reset();
2672  inline void reset( size_t i );
2673  inline void reserve( size_t nonzeros );
2674  void reserve( size_t i, size_t nonzeros );
2675  inline void trim();
2676  inline void trim( size_t j );
2678  //**********************************************************************************************
2679 
2680  //**Insertion functions*************************************************************************
2683  inline Iterator set ( size_t i, size_t j, const ElementType& value );
2684  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
2685  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
2686  inline void finalize( size_t i );
2688  //**********************************************************************************************
2689 
2690  //**Erase functions*****************************************************************************
2693  inline void erase( size_t i, size_t j );
2694  inline Iterator erase( size_t i, Iterator pos );
2695  inline Iterator erase( size_t i, Iterator first, Iterator last );
2696 
2697  template< typename Pred >
2698  inline void erase( Pred predicate );
2699 
2700  template< typename Pred >
2701  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
2703  //**********************************************************************************************
2704 
2705  //**Lookup functions****************************************************************************
2708  inline Iterator find ( size_t i, size_t j );
2709  inline ConstIterator find ( size_t i, size_t j ) const;
2710  inline Iterator lowerBound( size_t i, size_t j );
2711  inline ConstIterator lowerBound( size_t i, size_t j ) const;
2712  inline Iterator upperBound( size_t i, size_t j );
2713  inline ConstIterator upperBound( size_t i, size_t j ) const;
2715  //**********************************************************************************************
2716 
2717  //**Numeric functions***************************************************************************
2720  inline Rows& transpose();
2721  inline Rows& ctranspose();
2722 
2723  template< typename Other > inline Rows& scale( const Other& scalar );
2725  //**********************************************************************************************
2726 
2727  //**Expression template evaluation functions****************************************************
2730  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
2731  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
2732 
2733  inline bool canSMPAssign() const noexcept;
2734 
2735  template< typename MT2, bool SO > inline void assign ( const DenseMatrix<MT2,SO>& rhs );
2736  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,true>& rhs );
2737  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,false>& rhs );
2738  template< typename MT2, bool SO > inline void addAssign ( const Matrix<MT2,SO>& rhs );
2739  template< typename MT2, bool SO > inline void subAssign ( const Matrix<MT2,SO>& rhs );
2740  template< typename MT2, bool SO > inline void schurAssign( const Matrix<MT2,SO>& rhs );
2742  //**********************************************************************************************
2743 
2744  private:
2745  //**Member variables****************************************************************************
2748  Operand matrix_;
2749 
2750  //**********************************************************************************************
2751 
2752  //**Compile time checks*************************************************************************
2762  //**********************************************************************************************
2763 };
2765 //*************************************************************************************************
2766 
2767 
2768 
2769 
2770 //=================================================================================================
2771 //
2772 // CONSTRUCTORS
2773 //
2774 //=================================================================================================
2775 
2776 //*************************************************************************************************
2789 template< typename MT // Type of the sparse matrix
2790  , typename... CRAs > // Compile time row arguments
2791 template< typename... RRAs > // Runtime row arguments
2792 inline Rows<MT,false,false,false,CRAs...>::Rows( MT& matrix, RRAs... args )
2793  : DataType( args... ) // Base class initialization
2794  , matrix_ ( matrix ) // The matrix containing the rows
2795 {
2796  if( !Contains_v< TypeList<RRAs...>, Unchecked > ) {
2797  for( size_t i=0UL; i<rows(); ++i ) {
2798  if( matrix_.rows() <= idx(i) ) {
2799  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
2800  }
2801  }
2802  }
2803 }
2805 //*************************************************************************************************
2806 
2807 
2808 
2809 
2810 //=================================================================================================
2811 //
2812 // DATA ACCESS FUNCTIONS
2813 //
2814 //=================================================================================================
2815 
2816 //*************************************************************************************************
2827 template< typename MT // Type of the sparse matrix
2828  , typename... CRAs > // Compile time row arguments
2829 inline typename Rows<MT,false,false,false,CRAs...>::Reference
2830  Rows<MT,false,false,false,CRAs...>::operator()( size_t i, size_t j )
2831 {
2832  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
2833  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
2834 
2835  return matrix_(idx(i),j);
2836 }
2838 //*************************************************************************************************
2839 
2840 
2841 //*************************************************************************************************
2852 template< typename MT // Type of the sparse matrix
2853  , typename... CRAs > // Compile time row arguments
2854 inline typename Rows<MT,false,false,false,CRAs...>::ConstReference
2855  Rows<MT,false,false,false,CRAs...>::operator()( size_t i, size_t j ) const
2856 {
2857  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
2858  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
2859 
2860  return const_cast<const MT&>( matrix_ )(idx(i),j);
2861 }
2863 //*************************************************************************************************
2864 
2865 
2866 //*************************************************************************************************
2878 template< typename MT // Type of the sparse matrix
2879  , typename... CRAs > // Compile time row arguments
2880 inline typename Rows<MT,false,false,false,CRAs...>::Reference
2881  Rows<MT,false,false,false,CRAs...>::at( size_t i, size_t j )
2882 {
2883  if( i >= rows() ) {
2884  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
2885  }
2886  if( j >= columns() ) {
2887  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
2888  }
2889  return (*this)(i,j);
2890 }
2892 //*************************************************************************************************
2893 
2894 
2895 //*************************************************************************************************
2907 template< typename MT // Type of the sparse matrix
2908  , typename... CRAs > // Compile time row arguments
2909 inline typename Rows<MT,false,false,false,CRAs...>::ConstReference
2910  Rows<MT,false,false,false,CRAs...>::at( size_t i, size_t j ) const
2911 {
2912  if( i >= rows() ) {
2913  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
2914  }
2915  if( j >= columns() ) {
2916  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
2917  }
2918  return (*this)(i,j);
2919 }
2921 //*************************************************************************************************
2922 
2923 
2924 //*************************************************************************************************
2933 template< typename MT // Type of the sparse matrix
2934  , typename... CRAs > // Compile time row arguments
2935 inline typename Rows<MT,false,false,false,CRAs...>::Iterator
2937 {
2938  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2939 
2940  return Iterator( matrix_, idx(i), 0UL );
2941 }
2943 //*************************************************************************************************
2944 
2945 
2946 //*************************************************************************************************
2955 template< typename MT // Type of the sparse matrix
2956  , typename... CRAs > // Compile time row arguments
2957 inline typename Rows<MT,false,false,false,CRAs...>::ConstIterator
2959 {
2960  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2961 
2962  return ConstIterator( matrix_, idx(i), 0UL );
2963 }
2965 //*************************************************************************************************
2966 
2967 
2968 //*************************************************************************************************
2977 template< typename MT // Type of the sparse matrix
2978  , typename... CRAs > // Compile time row arguments
2979 inline typename Rows<MT,false,false,false,CRAs...>::ConstIterator
2981 {
2982  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2983 
2984  return ConstIterator( matrix_, idx(i), 0UL );
2985 }
2987 //*************************************************************************************************
2988 
2989 
2990 //*************************************************************************************************
2999 template< typename MT // Type of the sparse matrix
3000  , typename... CRAs > // Compile time row arguments
3001 inline typename Rows<MT,false,false,false,CRAs...>::Iterator
3003 {
3004  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
3005 
3006  return Iterator( matrix_, idx(i), columns() );
3007 }
3009 //*************************************************************************************************
3010 
3011 
3012 //*************************************************************************************************
3021 template< typename MT // Type of the sparse matrix
3022  , typename... CRAs > // Compile time row arguments
3023 inline typename Rows<MT,false,false,false,CRAs...>::ConstIterator
3024  Rows<MT,false,false,false,CRAs...>::end( size_t i ) const
3025 {
3026  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
3027 
3028  return ConstIterator( matrix_, idx(i), columns() );
3029 }
3031 //*************************************************************************************************
3032 
3033 
3034 //*************************************************************************************************
3043 template< typename MT // Type of the sparse matrix
3044  , typename... CRAs > // Compile time row arguments
3045 inline typename Rows<MT,false,false,false,CRAs...>::ConstIterator
3047 {
3048  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
3049 
3050  return ConstIterator( matrix_, idx(i), columns() );
3051 }
3053 //*************************************************************************************************
3054 
3055 
3056 
3057 
3058 //=================================================================================================
3059 //
3060 // ASSIGNMENT OPERATORS
3061 //
3062 //=================================================================================================
3063 
3064 //*************************************************************************************************
3080 template< typename MT // Type of the sparse matrix
3081  , typename... CRAs > // Compile time row arguments
3082 inline Rows<MT,false,false,false,CRAs...>&
3083  Rows<MT,false,false,false,CRAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
3084 {
3087 
3088  if( list.size() != rows() ) {
3089  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to row selection" );
3090  }
3091 
3092  const InitializerMatrix<ElementType> tmp( list, columns() );
3093 
3094  if( IsRestricted_v<MT> ) {
3095  for( size_t i=0UL; i<rows(); ++i ) {
3096  if( !tryAssign( matrix_, row( tmp, i, unchecked ), i, 0UL ) ) {
3097  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3098  }
3099  }
3100  }
3101 
3102  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
3103 
3104  smpAssign( left, tmp );
3105 
3106  return *this;
3107 }
3109 //*************************************************************************************************
3110 
3111 
3112 //*************************************************************************************************
3127 template< typename MT // Type of the sparse matrix
3128  , typename... CRAs > // Compile time row arguments
3129 inline Rows<MT,false,false,false,CRAs...>&
3130  Rows<MT,false,false,false,CRAs...>::operator=( const Rows& rhs )
3131 {
3134 
3137 
3138  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && compareIndices( *this, rhs ) ) )
3139  return *this;
3140 
3141  if( rows() != rhs.rows() || columns() != rhs.columns() ) {
3142  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3143  }
3144 
3145  if( IsRestricted_v<MT> ) {
3146  for( size_t i=0UL; i<rows(); ++i ) {
3147  if( !tryAssign( matrix_, row( rhs, i, unchecked ), idx(i), 0UL ) ) {
3148  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3149  }
3150  }
3151  }
3152 
3153  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
3154 
3155  if( rhs.canAlias( &matrix_ ) ) {
3156  const ResultType tmp( rhs );
3157  left.reset();
3158  smpAssign( left, tmp );
3159  }
3160  else {
3161  left.reset();
3162  smpAssign( left, rhs );
3163  }
3164 
3165  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3166 
3167  return *this;
3168 }
3170 //*************************************************************************************************
3171 
3172 
3173 //*************************************************************************************************
3188 template< typename MT // Type of the sparse matrix
3189  , typename... CRAs > // Compile time row arguments
3190 template< typename MT2 // Type of the right-hand side matrix
3191  , bool SO > // Storage order of the right-hand side matrix
3192 inline Rows<MT,false,false,false,CRAs...>&
3193  Rows<MT,false,false,false,CRAs...>::operator=( const Matrix<MT2,SO>& rhs )
3194 {
3197 
3198  BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( ResultType_t<MT2> );
3199 
3200  if( rows() != (~rhs).rows() || columns() != (~rhs).columns() ) {
3201  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3202  }
3203 
3204  using Right = CompositeType_t<MT2>;
3205  Right right( ~rhs );
3206 
3207  if( IsRestricted_v<MT> ) {
3208  for( size_t i=0UL; i<rows(); ++i ) {
3209  if( !tryAssign( matrix_, row( right, i, unchecked ), idx(i), 0UL ) ) {
3210  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3211  }
3212  }
3213  }
3214 
3215  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
3216 
3217  if( IsReference_v<Right> && right.canAlias( &matrix_ ) ) {
3218  const ResultType_t<MT2> tmp( right );
3219  if( IsSparseMatrix_v< ResultType_t<MT2> > )
3220  left.reset();
3221  smpAssign( left, tmp );
3222  }
3223  else {
3224  if( IsSparseMatrix_v<MT2> )
3225  left.reset();
3226  smpAssign( left, right );
3227  }
3228 
3229  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3230 
3231  return *this;
3232 }
3234 //*************************************************************************************************
3235 
3236 
3237 //*************************************************************************************************
3251 template< typename MT // Type of the sparse matrix
3252  , typename... CRAs > // Compile time row arguments
3253 template< typename MT2 // Type of the right-hand side matrix
3254  , bool SO > // Storage order of the right-hand side matrix
3255 inline Rows<MT,false,false,false,CRAs...>&
3256  Rows<MT,false,false,false,CRAs...>::operator+=( const Matrix<MT2,SO>& rhs )
3257 {
3260 
3263  BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( ResultType_t<MT2> );
3264 
3265  using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
3266 
3268 
3269  if( rows() != (~rhs).rows() || columns() != (~rhs).columns() ) {
3270  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3271  }
3272 
3273  const AddType tmp( *this + (~rhs) );
3274 
3275  if( IsRestricted_v<MT> ) {
3276  for( size_t i=0UL; i<rows(); ++i ) {
3277  if( !tryAssign( matrix_, row( tmp, i, unchecked ), idx(i), 0UL ) ) {
3278  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3279  }
3280  }
3281  }
3282 
3283  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
3284 
3285  if( IsSparseMatrix_v<AddType> ) {
3286  left.reset();
3287  }
3288 
3289  smpAssign( left, tmp );
3290 
3291  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3292 
3293  return *this;
3294 }
3296 //*************************************************************************************************
3297 
3298 
3299 //*************************************************************************************************
3313 template< typename MT // Type of the sparse matrix
3314  , typename... CRAs > // Compile time row arguments
3315 template< typename MT2 // Type of the right-hand side matrix
3316  , bool SO > // Storage order of the right-hand side matrix
3317 inline Rows<MT,false,false,false,CRAs...>&
3318  Rows<MT,false,false,false,CRAs...>::operator-=( const Matrix<MT2,SO>& rhs )
3319 {
3322 
3325  BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( ResultType_t<MT2> );
3326 
3327  using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
3328 
3330 
3331  if( rows() != (~rhs).rows() || columns() != (~rhs).columns() ) {
3332  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3333  }
3334 
3335  const SubType tmp( *this - (~rhs) );
3336 
3337  if( IsRestricted_v<MT> ) {
3338  for( size_t i=0UL; i<rows(); ++i ) {
3339  if( !tryAssign( matrix_, row( tmp, i, unchecked ), idx(i), 0UL ) ) {
3340  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3341  }
3342  }
3343  }
3344 
3345  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
3346 
3347  if( IsSparseMatrix_v<SubType> ) {
3348  left.reset();
3349  }
3350 
3351  smpAssign( left, tmp );
3352 
3353  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3354 
3355  return *this;
3356 }
3358 //*************************************************************************************************
3359 
3360 
3361 //*************************************************************************************************
3375 template< typename MT // Type of the sparse matrix
3376  , typename... CRAs > // Compile time row arguments
3377 template< typename MT2 // Type of the right-hand side matrix
3378  , bool SO > // Storage order of the right-hand side matrix
3379 inline Rows<MT,false,false,false,CRAs...>&
3380  Rows<MT,false,false,false,CRAs...>::operator%=( const Matrix<MT2,SO>& rhs )
3381 {
3384 
3387  BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( ResultType_t<MT2> );
3388 
3389  using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
3390 
3392 
3393  if( rows() != (~rhs).rows() || columns() != (~rhs).columns() ) {
3394  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3395  }
3396 
3397  const SchurType tmp( *this % (~rhs) );
3398 
3399  if( IsRestricted_v<MT> ) {
3400  for( size_t i=0UL; i<rows(); ++i ) {
3401  if( !tryAssign( matrix_, row( tmp, i, unchecked ), idx(i), 0UL ) ) {
3402  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3403  }
3404  }
3405  }
3406 
3407  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
3408 
3409  if( IsSparseMatrix_v<SchurType> ) {
3410  left.reset();
3411  }
3412 
3413  smpAssign( left, tmp );
3414 
3415  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3416 
3417  return *this;
3418 }
3420 //*************************************************************************************************
3421 
3422 
3423 
3424 
3425 //=================================================================================================
3426 //
3427 // UTILITY FUNCTIONS
3428 //
3429 //=================================================================================================
3430 
3431 //*************************************************************************************************
3437 template< typename MT // Type of the sparse matrix
3438  , typename... CRAs > // Compile time row arguments
3439 inline MT& Rows<MT,false,false,false,CRAs...>::operand() noexcept
3440 {
3441  return matrix_;
3442 }
3444 //*************************************************************************************************
3445 
3446 
3447 //*************************************************************************************************
3453 template< typename MT // Type of the sparse matrix
3454  , typename... CRAs > // Compile time row arguments
3455 inline const MT& Rows<MT,false,false,false,CRAs...>::operand() const noexcept
3456 {
3457  return matrix_;
3458 }
3460 //*************************************************************************************************
3461 
3462 
3463 //*************************************************************************************************
3469 template< typename MT // Type of the sparse matrix
3470  , typename... CRAs > // Compile time row arguments
3471 inline size_t Rows<MT,false,false,false,CRAs...>::columns() const noexcept
3472 {
3473  return matrix_.columns();
3474 }
3476 //*************************************************************************************************
3477 
3478 
3479 //*************************************************************************************************
3485 template< typename MT // Type of the sparse matrix
3486  , typename... CRAs > // Compile time row arguments
3487 inline size_t Rows<MT,false,false,false,CRAs...>::capacity() const noexcept
3488 {
3489  return rows() * columns();
3490 }
3492 //*************************************************************************************************
3493 
3494 
3495 //*************************************************************************************************
3504 template< typename MT // Type of the sparse matrix
3505  , typename... CRAs > // Compile time row arguments
3506 inline size_t Rows<MT,false,false,false,CRAs...>::capacity( size_t i ) const noexcept
3507 {
3508  UNUSED_PARAMETER( i );
3509 
3510  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
3511 
3512  return columns();
3513 }
3515 //*************************************************************************************************
3516 
3517 
3518 //*************************************************************************************************
3524 template< typename MT // Type of the sparse matrix
3525  , typename... CRAs > // Compile time row arguments
3527 {
3528  size_t nonzeros( 0UL );
3529 
3530  for( size_t j=0UL; j<columns(); ++j ) {
3531  const auto end( matrix_.end( j ) );
3532  for( size_t i=0UL; i<rows(); ++i ) {
3533  auto pos = matrix_.find( idx(i), j );
3534  if( pos != end ) {
3535  ++nonzeros;
3536  }
3537  }
3538  }
3539 
3540  return nonzeros;
3541 }
3543 //*************************************************************************************************
3544 
3545 
3546 //*************************************************************************************************
3555 template< typename MT // Type of the sparse matrix
3556  , typename... CRAs > // Compile time row arguments
3557 inline size_t Rows<MT,false,false,false,CRAs...>::nonZeros( size_t i ) const
3558 {
3559  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
3560 
3561  size_t counter( 0UL );
3562 
3563  const ConstIterator last( end(i) );
3564  for( ConstIterator element=begin(i); element!=last; ++element ) {
3565  ++counter;
3566  }
3567 
3568  return counter;
3569 }
3571 //*************************************************************************************************
3572 
3573 
3574 //*************************************************************************************************
3580 template< typename MT // Type of the sparse matrix
3581  , typename... CRAs > // Compile time row arguments
3583 {
3584  for( size_t i=0UL; i<rows(); ++i ) {
3585  reset( i );
3586  }
3587 }
3589 //*************************************************************************************************
3590 
3591 
3592 //*************************************************************************************************
3602 template< typename MT // Type of the sparse matrix
3603  , typename... CRAs > // Compile time row arguments
3604 inline void Rows<MT,false,false,false,CRAs...>::reset( size_t i )
3605 {
3606  const size_t index( idx(i) );
3607 
3608  const size_t jbegin( ( IsUpper_v<MT> )
3609  ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
3610  ?( index+1UL )
3611  :( index ) )
3612  :( 0UL ) );
3613  const size_t jend ( ( IsLower_v<MT> )
3614  ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
3615  ?( index )
3616  :( index+1UL ) )
3617  :( columns() ) );
3618 
3619  for( size_t j=jbegin; j<jend; ++j ) {
3620  matrix_.erase( index, j );
3621  }
3622 }
3624 //*************************************************************************************************
3625 
3626 
3627 //*************************************************************************************************
3638 template< typename MT // Type of the sparse matrix
3639  , typename... CRAs > // Compile time row arguments
3640 inline void Rows<MT,false,false,false,CRAs...>::reserve( size_t nonzeros )
3641 {
3642  UNUSED_PARAMETER( nonzeros );
3643 
3644  return;
3645 }
3647 //*************************************************************************************************
3648 
3649 
3650 //*************************************************************************************************
3663 template< typename MT // Type of the sparse matrix
3664  , typename... CRAs > // Compile time row arguments
3665 void Rows<MT,false,false,false,CRAs...>::reserve( size_t i, size_t nonzeros )
3666 {
3667  UNUSED_PARAMETER( i, nonzeros );
3668 
3669  return;
3670 }
3672 //*************************************************************************************************
3673 
3674 
3675 //*************************************************************************************************
3685 template< typename MT // Type of the sparse matrix
3686  , typename... CRAs > // Compile time row arguments
3687 void Rows<MT,false,false,false,CRAs...>::trim()
3688 {
3689  return;
3690 }
3692 //*************************************************************************************************
3693 
3694 
3695 //*************************************************************************************************
3706 template< typename MT // Type of the sparse matrix
3707  , typename... CRAs > // Compile time row arguments
3708 void Rows<MT,false,false,false,CRAs...>::trim( size_t i )
3709 {
3710  UNUSED_PARAMETER( i );
3711 
3712  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
3713 
3714  return;
3715 }
3717 //*************************************************************************************************
3718 
3719 
3720 
3721 
3722 //=================================================================================================
3723 //
3724 // INSERTION FUNCTIONS
3725 //
3726 //=================================================================================================
3727 
3728 //*************************************************************************************************
3741 template< typename MT // Type of the sparse matrix
3742  , typename... CRAs > // Compile time row arguments
3743 inline typename Rows<MT,false,false,false,CRAs...>::Iterator
3744  Rows<MT,false,false,false,CRAs...>::set( size_t i, size_t j, const ElementType& value )
3745 {
3746  return Iterator( matrix_, idx(i), j, matrix_.set( idx(i), j, value ) );
3747 }
3749 //*************************************************************************************************
3750 
3751 
3752 //*************************************************************************************************
3766 template< typename MT // Type of the sparse matrix
3767  , typename... CRAs > // Compile time row arguments
3768 inline typename Rows<MT,false,false,false,CRAs...>::Iterator
3769  Rows<MT,false,false,false,CRAs...>::insert( size_t i, size_t j, const ElementType& value )
3770 {
3771  return Iterator( matrix_, idx(i), j, matrix_.insert( idx(i), j, value ) );
3772 }
3774 //*************************************************************************************************
3775 
3776 
3777 //*************************************************************************************************
3821 template< typename MT // Type of the sparse matrix
3822  , typename... CRAs > // Compile time row arguments
3823 inline void Rows<MT,false,false,false,CRAs...>::append( size_t i, size_t j, const ElementType& value, bool check )
3824 {
3825  if( !check || !isDefault<strict>( value ) )
3826  matrix_.insert( idx(i), j, value );
3827 }
3829 //*************************************************************************************************
3830 
3831 
3832 //*************************************************************************************************
3846 template< typename MT // Type of the sparse matrix
3847  , typename... CRAs > // Compile time row arguments
3848 inline void Rows<MT,false,false,false,CRAs...>::finalize( size_t i )
3849 {
3850  UNUSED_PARAMETER( i );
3851 
3852  return;
3853 }
3855 //*************************************************************************************************
3856 
3857 
3858 
3859 
3860 //=================================================================================================
3861 //
3862 // ERASE FUNCTIONS
3863 //
3864 //=================================================================================================
3865 
3866 //*************************************************************************************************
3876 template< typename MT // Type of the sparse matrix
3877  , typename... CRAs > // Compile time row arguments
3878 inline void Rows<MT,false,false,false,CRAs...>::erase( size_t i, size_t j )
3879 {
3880  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
3881  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3882 
3883  matrix_.erase( idx(i), j );
3884 }
3886 //*************************************************************************************************
3887 
3888 
3889 //*************************************************************************************************
3899 template< typename MT // Type of the sparse matrix
3900  , typename... CRAs > // Compile time row arguments
3901 inline typename Rows<MT,false,false,false,CRAs...>::Iterator
3902  Rows<MT,false,false,false,CRAs...>::erase( size_t i, Iterator pos )
3903 {
3904  const size_t column( pos.column_ );
3905 
3906  if( column == columns() )
3907  return pos;
3908 
3909  matrix_.erase( column, pos.pos_ );
3910  return Iterator( matrix_, idx(i), column+1UL );
3911 }
3913 //*************************************************************************************************
3914 
3915 
3916 //*************************************************************************************************
3927 template< typename MT // Type of the sparse matrix
3928  , typename... CRAs > // Compile time row arguments
3929 inline typename Rows<MT,false,false,false,CRAs...>::Iterator
3930  Rows<MT,false,false,false,CRAs...>::erase( size_t i, Iterator first, Iterator last )
3931 {
3932  UNUSED_PARAMETER( i );
3933 
3934  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
3935 
3936  for( ; first!=last; ++first ) {
3937  matrix_.erase( first.column_, first.pos_ );
3938  }
3939 
3940  return last;
3941 }
3943 //*************************************************************************************************
3944 
3945 
3946 //*************************************************************************************************
3969 template< typename MT // Type of the sparse matrix
3970  , typename... CRAs > // Compile time row arguments
3971 template< typename Pred > // Type of the unary predicate
3972 inline void Rows<MT,false,false,false,CRAs...>::erase( Pred predicate )
3973 {
3974  for( size_t i=0UL; i<rows(); ++i ) {
3975  for( Iterator element=begin(i); element!=end(i); ++element ) {
3976  if( predicate( element->value() ) )
3977  matrix_.erase( element.column_, element.pos_ );
3978  }
3979  }
3980 }
3982 //*************************************************************************************************
3983 
3984 
3985 //*************************************************************************************************
4012 template< typename MT // Type of the sparse matrix
4013  , typename... CRAs > // Compile time row arguments
4014 template< typename Pred > // Type of the unary predicate
4015 inline void Rows<MT,false,false,false,CRAs...>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
4016 {
4017  UNUSED_PARAMETER( i );
4018 
4019  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
4020 
4021  for( ; first!=last; ++first ) {
4022  if( predicate( first->value() ) )
4023  matrix_.erase( first.column_, first.pos_ );
4024  }
4025 }
4027 //*************************************************************************************************
4028 
4029 
4030 
4031 
4032 //=================================================================================================
4033 //
4034 // LOOKUP FUNCTIONS
4035 //
4036 //=================================================================================================
4037 
4038 //*************************************************************************************************
4053 template< typename MT // Type of the sparse matrix
4054  , typename... CRAs > // Compile time row arguments
4055 inline typename Rows<MT,false,false,false,CRAs...>::Iterator
4056  Rows<MT,false,false,false,CRAs...>::find( size_t i, size_t j )
4057 {
4058  const size_t index( idx(i) );
4059  const Iterator_t<MT> pos( matrix_.find( index, j ) );
4060 
4061  if( pos != matrix_.end( j ) )
4062  return Iterator( matrix_, index, j, pos );
4063  else
4064  return end( i );
4065 }
4067 //*************************************************************************************************
4068 
4069 
4070 //*************************************************************************************************
4085 template< typename MT // Type of the sparse matrix
4086  , typename... CRAs > // Compile time row arguments
4087 inline typename Rows<MT,false,false,false,CRAs...>::ConstIterator
4088  Rows<MT,false,false,false,CRAs...>::find( size_t i, size_t j ) const
4089 {
4090  const size_t index( idx(i) );
4091  const ConstIterator_t<MT> pos( matrix_.find( index, j ) );
4092 
4093  if( pos != matrix_.end( j ) )
4094  return ConstIterator( matrix_, index, j, pos );
4095  else
4096  return end( i );
4097 }
4099 //*************************************************************************************************
4100 
4101 
4102 //*************************************************************************************************
4116 template< typename MT // Type of the sparse matrix
4117  , typename... CRAs > // Compile time row arguments
4118 inline typename Rows<MT,false,false,false,CRAs...>::Iterator
4119  Rows<MT,false,false,false,CRAs...>::lowerBound( size_t i, size_t j )
4120 {
4121  const size_t index( idx(i) );
4122 
4123  for( ; j<columns(); ++j )
4124  {
4125  const Iterator_t<MT> pos( matrix_.find( index, j ) );
4126 
4127  if( pos != matrix_.end( j ) )
4128  return Iterator( matrix_, index, j, pos );
4129  }
4130 
4131  return end( i );
4132 }
4134 //*************************************************************************************************
4135 
4136 
4137 //*************************************************************************************************
4151 template< typename MT // Type of the sparse matrix
4152  , typename... CRAs > // Compile time row arguments
4153 inline typename Rows<MT,false,false,false,CRAs...>::ConstIterator
4154  Rows<MT,false,false,false,CRAs...>::lowerBound( size_t i, size_t j ) const
4155 {
4156  const size_t index( idx(i) );
4157 
4158  for( ; j<columns(); ++j )
4159  {
4160  const ConstIterator_t<MT> pos( matrix_.find( index, j ) );
4161 
4162  if( pos != matrix_.end( j ) )
4163  return ConstIterator( matrix_, index, j, pos );
4164  }
4165 
4166  return end( i );
4167 }
4169 //*************************************************************************************************
4170 
4171 
4172 //*************************************************************************************************
4186 template< typename MT // Type of the sparse matrix
4187  , typename... CRAs > // Compile time row arguments
4188 inline typename Rows<MT,false,false,false,CRAs...>::Iterator
4189  Rows<MT,false,false,false,CRAs...>::upperBound( size_t i, size_t j )
4190 {
4191  return lowerBound( i, j+1UL );
4192 }
4194 //*************************************************************************************************
4195 
4196 
4197 //*************************************************************************************************
4211 template< typename MT // Type of the sparse matrix
4212  , typename... CRAs > // Compile time row arguments
4213 inline typename Rows<MT,false,false,false,CRAs...>::ConstIterator
4214  Rows<MT,false,false,false,CRAs...>::upperBound( size_t i, size_t j ) const
4215 {
4216  return lowerBound( i, j+1UL );
4217 }
4219 //*************************************************************************************************
4220 
4221 
4222 
4223 
4224 //=================================================================================================
4225 //
4226 // NUMERIC FUNCTIONS
4227 //
4228 //=================================================================================================
4229 
4230 //*************************************************************************************************
4243 template< typename MT // Type of the sparse matrix
4244  , typename... CRAs > // Compile time row arguments
4245 inline Rows<MT,false,false,false,CRAs...>&
4247 {
4250 
4251  if( rows() != columns() ) {
4252  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose of a non-quadratic matrix" );
4253  }
4254 
4255  const ResultType tmp( trans( *this ) );
4256 
4257  if( IsRestricted_v<MT> ) {
4258  for( size_t i=0UL; i<rows(); ++i ) {
4259  if( !tryAssign( matrix_, row( tmp, i, unchecked ), idx(i), 0UL ) ) {
4260  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose operation" );
4261  }
4262  }
4263  }
4264 
4265  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
4266 
4267  left.reset();
4268  smpAssign( left, tmp );
4269 
4270  return *this;
4271 }
4273 //*************************************************************************************************
4274 
4275 
4276 //*************************************************************************************************
4289 template< typename MT // Type of the sparse matrix
4290  , typename... CRAs > // Compile time row arguments
4291 inline Rows<MT,false,false,false,CRAs...>&
4293 {
4296 
4297  if( rows() != columns() ) {
4298  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose of a non-quadratic matrix" );
4299  }
4300 
4301  const ResultType tmp( ctrans( *this ) );
4302 
4303  if( IsRestricted_v<MT> ) {
4304  for( size_t i=0UL; i<rows(); ++i ) {
4305  if( !tryAssign( matrix_, row( tmp, i, unchecked ), idx(i), 0UL ) ) {
4306  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose operation" );
4307  }
4308  }
4309  }
4310 
4311  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
4312 
4313  left.reset();
4314  smpAssign( left, tmp );
4315 
4316  return *this;
4317 }
4319 //*************************************************************************************************
4320 
4321 
4322 //*************************************************************************************************
4335 template< typename MT // Type of the sparse matrix
4336  , typename... CRAs > // Compile time row arguments
4337 template< typename Other > // Data type of the scalar value
4338 inline Rows<MT,false,false,false,CRAs...>&
4339  Rows<MT,false,false,false,CRAs...>::scale( const Other& scalar )
4340 {
4344 
4345  for( size_t j=0UL; j<columns(); ++j ) {
4346  const auto end( matrix_.end( j ) );
4347  for( size_t i=0UL; i<rows(); ++i ) {
4348  auto pos = matrix_.find( idx(i), j );
4349  if( pos != end ) {
4350  pos->value() *= scalar;
4351  }
4352  }
4353  }
4354 
4355  return *this;
4356 }
4358 //*************************************************************************************************
4359 
4360 
4361 
4362 
4363 //=================================================================================================
4364 //
4365 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
4366 //
4367 //=================================================================================================
4368 
4369 //*************************************************************************************************
4380 template< typename MT // Type of the sparse matrix
4381  , typename... CRAs > // Compile time row arguments
4382 template< typename Other > // Data type of the foreign expression
4383 inline bool Rows<MT,false,false,false,CRAs...>::canAlias( const Other* alias ) const noexcept
4384 {
4385  return matrix_.isAliased( alias );
4386 }
4388 //*************************************************************************************************
4389 
4390 
4391 //*************************************************************************************************
4402 template< typename MT // Type of the sparse matrix
4403  , typename... CRAs > // Compile time row arguments
4404 template< typename Other > // Data type of the foreign expression
4405 inline bool Rows<MT,false,false,false,CRAs...>::isAliased( const Other* alias ) const noexcept
4406 {
4407  return matrix_.isAliased( alias );
4408 }
4410 //*************************************************************************************************
4411 
4412 
4413 //*************************************************************************************************
4424 template< typename MT // Type of the sparse matrix
4425  , typename... CRAs > // Compile time row arguments
4426 inline bool Rows<MT,false,false,false,CRAs...>::canSMPAssign() const noexcept
4427 {
4428  return false;
4429 }
4431 //*************************************************************************************************
4432 
4433 
4434 //*************************************************************************************************
4446 template< typename MT // Type of the sparse matrix
4447  , typename... CRAs > // Compile time row arguments
4448 template< typename MT2 // Type of the right-hand side dense matrix
4449  , bool SO > // Storage order of the right-hand side dense matrix
4450 inline void Rows<MT,false,false,false,CRAs...>::assign( const DenseMatrix<MT2,SO>& rhs )
4451 {
4454 
4455  using RT = If_t< IsComputation_v<MT2>, ElementType_t<MT>, const ElementType_t<MT2>& >;
4456 
4457  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
4458  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
4459 
4460  for( size_t j=0UL; j<columns(); ++j ) {
4461  for( size_t i=0UL; i<rows(); ++i ) {
4462  RT value( (~rhs)(i,j) );
4463  if( !isDefault<strict>( value ) )
4464  matrix_.set( idx(i), j, std::move( value ) );
4465  else matrix_.erase( idx(i), j );
4466  }
4467  }
4468 }
4470 //*************************************************************************************************
4471 
4472 
4473 //*************************************************************************************************
4485 template< typename MT // Type of the sparse matrix
4486  , typename... CRAs > // Compile time row arguments
4487 template< typename MT2 > // Type of the right-hand side sparse matrix
4488 inline void Rows<MT,false,false,false,CRAs...>::assign( const SparseMatrix<MT2,false>& rhs )
4489 {
4492 
4493  using RT = If_t< IsComputation_v<MT2>, ElementType_t<MT>, const ElementType_t<MT2>& >;
4494 
4495  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
4496  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
4497  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
4498 
4499  for( size_t i=0UL; i<rows(); ++i ) {
4500  const size_t index( idx(i) );
4501  for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).end(i); ++element ) {
4502  RT value( element->value() );
4503  if( !isDefault<strict>( value ) )
4504  matrix_.set( index, element->index(), std::move( value ) );
4505  else matrix_.erase( index, element->index() );
4506  }
4507  }
4508 }
4510 //*************************************************************************************************
4511 
4512 
4513 //*************************************************************************************************
4525 template< typename MT // Type of the sparse matrix
4526  , typename... CRAs > // Compile time row arguments
4527 template< typename MT2 > // Type of the right-hand side sparse matrix
4528 inline void Rows<MT,false,false,false,CRAs...>::assign( const SparseMatrix<MT2,true>& rhs )
4529 {
4532 
4534 
4535  using RT = If_t< IsComputation_v<MT2>, ElementType_t<MT>, const ElementType_t<MT2>& >;
4536 
4537  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
4538  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
4539  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
4540 
4541  for( size_t j=0UL; j<columns(); ++j ) {
4542  for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).end(j); ++element ) {
4543  RT value( element->value() );
4544  if( !isDefault<strict>( value ) )
4545  matrix_.set( idx( element->index() ), j, std::move( value ) );
4546  else matrix_.erase( idx( element->index() ), j );
4547  }
4548  }
4549 }
4551 //*************************************************************************************************
4552 
4553 
4554 //*************************************************************************************************
4566 template< typename MT // Type of the sparse matrix
4567  , typename... CRAs > // Compile time row arguments
4568 template< typename MT2 // Type of the right-hand side matrix
4569  , bool SO > // Storage order of the right-hand side matrix
4570 inline void Rows<MT,false,false,false,CRAs...>::addAssign( const Matrix<MT2,SO>& rhs )
4571 {
4574 
4575  using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
4576 
4578 
4579  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
4580  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
4581 
4582  const AddType tmp( serial( *this + (~rhs) ) );
4583  reset();
4584  assign( tmp );
4585 }
4587 //*************************************************************************************************
4588 
4589 
4590 //*************************************************************************************************
4602 template< typename MT // Type of the sparse matrix
4603  , typename... CRAs > // Compile time row arguments
4604 template< typename MT2 // Type of the right-hand side matrix
4605  , bool SO > // Storage order of the right-hand side matrix
4606 inline void Rows<MT,false,false,false,CRAs...>::subAssign( const Matrix<MT2,SO>& rhs )
4607 {
4610 
4611  using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
4612 
4614 
4615  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
4616  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
4617 
4618  const SubType tmp( serial( *this - (~rhs) ) );
4619  reset();
4620  assign( tmp );
4621 }
4623 //*************************************************************************************************
4624 
4625 
4626 //*************************************************************************************************
4638 template< typename MT // Type of the sparse matrix
4639  , typename... CRAs > // Compile time row arguments
4640 template< typename MT2 // Type of the right-hand side matrix
4641  , bool SO > // Storage order of the right-hand side matrix
4642 inline void Rows<MT,false,false,false,CRAs...>::schurAssign( const Matrix<MT2,SO>& rhs )
4643 {
4646 
4647  using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
4648 
4651 
4652  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
4653  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
4654 
4655  const SchurType tmp( serial( *this % (~rhs) ) );
4656  reset();
4657  assign( tmp );
4658 }
4660 //*************************************************************************************************
4661 
4662 
4663 
4664 
4665 
4666 
4667 
4668 
4669 //=================================================================================================
4670 //
4671 // CLASS TEMPLATE SPECIALIZATION FOR SYMMETRIC COLUMN-MAJOR SPARSE MATRICES
4672 //
4673 //=================================================================================================
4674 
4675 //*************************************************************************************************
4683 template< typename MT // Type of the sparse matrix
4684  , typename... CRAs > // Compile time row arguments
4685 class Rows<MT,false,false,true,CRAs...>
4686  : public View< SparseMatrix< Rows<MT,false,false,true,CRAs...>, false > >
4687  , private RowsData<CRAs...>
4688 {
4689  private:
4690  //**Type definitions****************************************************************************
4691  using DataType = RowsData<CRAs...>;
4692  using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
4693  //**********************************************************************************************
4694 
4695  //**Compile time flags**************************************************************************
4696  using DataType::N;
4697  //**********************************************************************************************
4698 
4699  public:
4700  //**Type definitions****************************************************************************
4702  using This = Rows<MT,false,false,true,CRAs...>;
4703 
4704  using BaseType = SparseMatrix<This,false>;
4705  using ViewedType = MT;
4706  using ResultType = RowsTrait_t<MT,N>;
4707  using OppositeType = OppositeType_t<ResultType>;
4708  using TransposeType = TransposeType_t<ResultType>;
4709  using ElementType = ElementType_t<MT>;
4710  using ReturnType = ReturnType_t<MT>;
4711  using CompositeType = const Rows&;
4712 
4714  using ConstReference = ConstReference_t<MT>;
4715 
4717  using Reference = If_t< IsConst_v<MT>, ConstReference, Reference_t<MT> >;
4718 
4720  using ConstIterator = ConstIterator_t<MT>;
4721 
4723  using Iterator = If_t< IsConst_v<MT>, ConstIterator, Iterator_t<MT> >;
4724  //**********************************************************************************************
4725 
4726  //**Compilation flags***************************************************************************
4728  static constexpr bool smpAssignable = MT::smpAssignable;
4729  //**********************************************************************************************
4730 
4731  //**Constructors********************************************************************************
4734  template< typename... RRAs >
4735  explicit inline Rows( MT& matrix, RRAs... args );
4736 
4737  Rows( const Rows& ) = default;
4738  Rows( Rows&& ) = default;
4740  //**********************************************************************************************
4741 
4742  //**Destructor**********************************************************************************
4745  ~Rows() = default;
4747  //**********************************************************************************************
4748 
4749  //**Data access functions***********************************************************************
4752  inline Reference operator()( size_t i, size_t j );
4753  inline ConstReference operator()( size_t i, size_t j ) const;
4754  inline Reference at( size_t i, size_t j );
4755  inline ConstReference at( size_t i, size_t j ) const;
4756  inline Iterator begin ( size_t i );
4757  inline ConstIterator begin ( size_t i ) const;
4758  inline ConstIterator cbegin( size_t i ) const;
4759  inline Iterator end ( size_t i );
4760  inline ConstIterator end ( size_t i ) const;
4761  inline ConstIterator cend ( size_t i ) const;
4763  //**********************************************************************************************
4764 
4765  //**Assignment operators************************************************************************
4768  Rows& operator=( const Rows& ) = delete;
4770  //**********************************************************************************************
4771 
4772  //**Utility functions***************************************************************************
4775  using DataType::idx;
4776  using DataType::idces;
4777  using DataType::rows;
4778 
4779  inline MT& operand() noexcept;
4780  inline const MT& operand() const noexcept;
4781 
4782  inline size_t columns() const noexcept;
4783  inline size_t capacity() const noexcept;
4784  inline size_t capacity( size_t i ) const noexcept;
4785  inline size_t nonZeros() const;
4786  inline size_t nonZeros( size_t i ) const;
4787  inline void reset();
4788  inline void reset( size_t i );
4789  inline void reserve( size_t nonzeros );
4790  void reserve( size_t i, size_t nonzeros );
4791  inline void trim();
4792  inline void trim( size_t i );
4794  //**********************************************************************************************
4795 
4796  //**Insertion functions*************************************************************************
4799  inline Iterator set ( size_t i, size_t j, const ElementType& value );
4800  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
4801  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
4802  inline void finalize( size_t i );
4804  //**********************************************************************************************
4805 
4806  //**Erase functions*****************************************************************************
4809  inline void erase( size_t i, size_t j );
4810  inline Iterator erase( size_t i, Iterator pos );
4811  inline Iterator erase( size_t i, Iterator first, Iterator last );
4812 
4813  template< typename Pred >
4814  inline void erase( Pred predicate );
4815 
4816  template< typename Pred >
4817  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
4819  //**********************************************************************************************
4820 
4821  //**Lookup functions****************************************************************************
4824  inline Iterator find ( size_t i, size_t j );
4825  inline ConstIterator find ( size_t i, size_t j ) const;
4826  inline Iterator lowerBound( size_t i, size_t j );
4827  inline ConstIterator lowerBound( size_t i, size_t j ) const;
4828  inline Iterator upperBound( size_t i, size_t j );
4829  inline ConstIterator upperBound( size_t i, size_t j ) const;
4831  //**********************************************************************************************
4832 
4833  //**Expression template evaluation functions****************************************************
4836  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
4837  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
4838 
4839  inline bool canSMPAssign() const noexcept;
4841  //**********************************************************************************************
4842 
4843  private:
4844  //**Member variables****************************************************************************
4847  Operand matrix_;
4848 
4849  //**********************************************************************************************
4850 
4851  //**Compile time checks*************************************************************************
4861  //**********************************************************************************************
4862 };
4864 //*************************************************************************************************
4865 
4866 
4867 
4868 
4869 //=================================================================================================
4870 //
4871 // CONSTRUCTORS
4872 //
4873 //=================================================================================================
4874 
4875 //*************************************************************************************************
4888 template< typename MT // Type of the sparse matrix
4889  , typename... CRAs > // Compile time row arguments
4890 template< typename... RRAs > // Runtime row arguments
4891 inline Rows<MT,false,false,true,CRAs...>::Rows( MT& matrix, RRAs... args )
4892  : DataType( args... ) // Base class initialization
4893  , matrix_ ( matrix ) // The matrix containing the rows
4894 {
4895  if( !Contains_v< TypeList<RRAs...>, Unchecked > ) {
4896  for( size_t i=0UL; i<rows(); ++i ) {
4897  if( matrix_.rows() <= idx(i) ) {
4898  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
4899  }
4900  }
4901  }
4902 }
4904 //*************************************************************************************************
4905 
4906 
4907 
4908 
4909 //=================================================================================================
4910 //
4911 // DATA ACCESS FUNCTIONS
4912 //
4913 //=================================================================================================
4914 
4915 //*************************************************************************************************
4926 template< typename MT // Type of the sparse matrix
4927  , typename... CRAs > // Compile time row arguments
4928 inline typename Rows<MT,false,false,true,CRAs...>::Reference
4929  Rows<MT,false,false,true,CRAs...>::operator()( size_t i, size_t j )
4930 {
4931  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
4932  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4933 
4934  return matrix_(j,idx(i));
4935 }
4937 //*************************************************************************************************
4938 
4939 
4940 //*************************************************************************************************
4951 template< typename MT // Type of the sparse matrix
4952  , typename... CRAs > // Compile time row arguments
4953 inline typename Rows<MT,false,false,true,CRAs...>::ConstReference
4954  Rows<MT,false,false,true,CRAs...>::operator()( size_t i, size_t j ) const
4955 {
4956  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
4957  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4958 
4959  return const_cast<const MT&>( matrix_ )(j,idx(i));
4960 }
4962 //*************************************************************************************************
4963 
4964 
4965 //*************************************************************************************************
4977 template< typename MT // Type of the sparse matrix
4978  , typename... CRAs > // Compile time row arguments
4979 inline typename Rows<MT,false,false,true,CRAs...>::Reference
4980  Rows<MT,false,false,true,CRAs...>::at( size_t i, size_t j )
4981 {
4982  if( i >= rows() ) {
4983  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
4984  }
4985  if( j >= columns() ) {
4986  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
4987  }
4988  return (*this)(i,j);
4989 }
4991 //*************************************************************************************************
4992 
4993 
4994 //*************************************************************************************************
5006 template< typename MT // Type of the sparse matrix
5007  , typename... CRAs > // Compile time row arguments
5008 inline typename Rows<MT,false,false,true,CRAs...>::ConstReference
5009  Rows<MT,false,false,true,CRAs...>::at( size_t i, size_t j ) const
5010 {
5011  if( i >= rows() ) {
5012  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
5013  }
5014  if( j >= columns() ) {
5015  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
5016  }
5017  return (*this)(i,j);
5018 }
5020 //*************************************************************************************************
5021 
5022 
5023 //*************************************************************************************************
5032 template< typename MT // Type of the sparse matrix
5033  , typename... CRAs > // Compile time row arguments
5034 inline typename Rows<MT,false,false,true,CRAs...>::Iterator
5036 {
5037  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
5038 
5039  return matrix_.begin( idx(i) );
5040 }
5042 //*************************************************************************************************
5043 
5044 
5045 //*************************************************************************************************
5054 template< typename MT // Type of the sparse matrix
5055  , typename... CRAs > // Compile time row arguments
5056 inline typename Rows<MT,false,false,true,CRAs...>::ConstIterator
5058 {
5059  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
5060 
5061  return matrix_.cbegin( idx(i) );
5062 }
5064 //*************************************************************************************************
5065 
5066 
5067 //*************************************************************************************************
5076 template< typename MT // Type of the sparse matrix
5077  , typename... CRAs > // Compile time row arguments
5078 inline typename Rows<MT,false,false,true,CRAs...>::ConstIterator
5080 {
5081  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
5082 
5083  return matrix_.cbegin( idx(i) );
5084 }
5086 //*************************************************************************************************
5087 
5088 
5089 //*************************************************************************************************
5098 template< typename MT // Type of the sparse matrix
5099  , typename... CRAs > // Compile time row arguments
5100 inline typename Rows<MT,false,false,true,CRAs...>::Iterator
5102 {
5103  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
5104 
5105  return matrix_.end( idx(i) );
5106 }
5108 //*************************************************************************************************
5109 
5110 
5111 //*************************************************************************************************
5120 template< typename MT // Type of the sparse matrix
5121  , typename... CRAs > // Compile time row arguments
5122 inline typename Rows<MT,false,false,true,CRAs...>::ConstIterator
5123  Rows<MT,false,false,true,CRAs...>::end( size_t i ) const
5124 {
5125  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
5126 
5127  return matrix_.cend( idx(i) );
5128 }
5130 //*************************************************************************************************
5131 
5132 
5133 //*************************************************************************************************
5142 template< typename MT // Type of the sparse matrix
5143  , typename... CRAs > // Compile time row arguments
5144 inline typename Rows<MT,false,false,true,CRAs...>::ConstIterator
5145  Rows<MT,false,false,true,CRAs...>::cend( size_t i ) const
5146 {
5147  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
5148 
5149  return matrix_.cend( idx(i) );
5150 }
5152 //*************************************************************************************************
5153 
5154 
5155 
5156 
5157 //=================================================================================================
5158 //
5159 // UTILITY FUNCTIONS
5160 //
5161 //=================================================================================================
5162 
5163 //*************************************************************************************************
5169 template< typename MT // Type of the sparse matrix
5170  , typename... CRAs > // Compile time row arguments
5171 inline MT& Rows<MT,false,false,true,CRAs...>::operand() noexcept
5172 {
5173  return matrix_;
5174 }
5176 //*************************************************************************************************
5177 
5178 
5179 //*************************************************************************************************
5185 template< typename MT // Type of the sparse matrix
5186  , typename... CRAs > // Compile time row arguments
5187 inline const MT& Rows<MT,false,false,true,CRAs...>::operand() const noexcept
5188 {
5189  return matrix_;
5190 }
5192 //*************************************************************************************************
5193 
5194 
5195 //*************************************************************************************************
5201 template< typename MT // Type of the sparse matrix
5202  , typename... CRAs > // Compile time row arguments
5203 inline size_t Rows<MT,false,false,true,CRAs...>::columns() const noexcept
5204 {
5205  return matrix_.columns();
5206 }
5208 //*************************************************************************************************
5209 
5210 
5211 //*************************************************************************************************
5217 template< typename MT // Type of the sparse matrix
5218  , typename... CRAs > // Compile time row arguments
5219 inline size_t Rows<MT,false,false,true,CRAs...>::capacity() const noexcept
5220 {
5221  return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
5222 }
5224 //*************************************************************************************************
5225 
5226 
5227 //*************************************************************************************************
5236 template< typename MT // Type of the sparse matrix
5237  , typename... CRAs > // Compile time row arguments
5238 inline size_t Rows<MT,false,false,true,CRAs...>::capacity( size_t i ) const noexcept
5239 {
5240  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
5241 
5242  return matrix_.capacity( idx(i) );
5243 }
5245 //*************************************************************************************************
5246 
5247 
5248 //*************************************************************************************************
5254 template< typename MT // Type of the sparse matrix
5255  , typename... CRAs > // Compile time row arguments
5256 inline size_t Rows<MT,false,false,true,CRAs...>::nonZeros() const
5257 {
5258  size_t nonzeros( 0UL );
5259 
5260  for( size_t i=0UL; i<rows(); ++i )
5261  nonzeros += nonZeros( i );
5262 
5263  return nonzeros;
5264 }
5266 //*************************************************************************************************
5267 
5268 
5269 //*************************************************************************************************
5278 template< typename MT // Type of the sparse matrix
5279  , typename... CRAs > // Compile time row arguments
5280 inline size_t Rows<MT,false,false,true,CRAs...>::nonZeros( size_t i ) const
5281 {
5282  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
5283 
5284  return matrix_.nonZeros( idx(i) );
5285 }
5287 //*************************************************************************************************
5288 
5289 
5290 //*************************************************************************************************
5296 template< typename MT // Type of the sparse matrix
5297  , typename... CRAs > // Compile time row arguments
5299 {
5300  for( size_t i=0UL; i<rows(); ++i ) {
5301  matrix_.reset( idx(i) );
5302  }
5303 }
5305 //*************************************************************************************************
5306 
5307 
5308 //*************************************************************************************************
5318 template< typename MT // Type of the sparse matrix
5319  , typename... CRAs > // Compile time row arguments
5320 inline void Rows<MT,false,false,true,CRAs...>::reset( size_t i )
5321 {
5322  matrix_.reset( idx(i) );
5323 }
5325 //*************************************************************************************************
5326 
5327 
5328 //*************************************************************************************************
5339 template< typename MT // Type of the sparse matrix
5340  , typename... CRAs > // Compile time row arguments
5341 inline void Rows<MT,false,false,true,CRAs...>::reserve( size_t nonzeros )
5342 {
5343  const size_t current( capacity() );
5344 
5345  if( nonzeros > current ) {
5346  matrix_.reserve( matrix_.capacity() + nonzeros - current );
5347  }
5348 }
5350 //*************************************************************************************************
5351 
5352 
5353 //*************************************************************************************************
5366 template< typename MT // Type of the sparse matrix
5367  , typename... CRAs > // Compile time row arguments
5368 void Rows<MT,false,false,true,CRAs...>::reserve( size_t i, size_t nonzeros )
5369 {
5370  matrix_.reserve( idx(i), nonzeros );
5371 }
5373 //*************************************************************************************************
5374 
5375 
5376 //*************************************************************************************************
5386 template< typename MT // Type of the sparse matrix
5387  , typename... CRAs > // Compile time row arguments
5388 void Rows<MT,false,false,true,CRAs...>::trim()
5389 {
5390  for( size_t i=0UL; i<rows(); ++i ) {
5391  trim( i );
5392  }
5393 }
5395 //*************************************************************************************************
5396 
5397 
5398 //*************************************************************************************************
5409 template< typename MT // Type of the sparse matrix
5410  , typename... CRAs > // Compile time row arguments
5411 void Rows<MT,false,false,true,CRAs...>::trim( size_t i )
5412 {
5413  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
5414 
5415  matrix_.trim( idx(i) );
5416 }
5418 //*************************************************************************************************
5419 
5420 
5421 
5422 
5423 //=================================================================================================
5424 //
5425 // INSERTION FUNCTIONS
5426 //
5427 //=================================================================================================
5428 
5429 //*************************************************************************************************
5442 template< typename MT // Type of the sparse matrix
5443  , typename... CRAs > // Compile time row arguments
5444 inline typename Rows<MT,false,false,true,CRAs...>::Iterator
5445  Rows<MT,false,false,true,CRAs...>::set( size_t i, size_t j, const ElementType& value )
5446 {
5447  return matrix_.set( j, idx(i), value );
5448 }
5450 //*************************************************************************************************
5451 
5452 
5453 //*************************************************************************************************
5467 template< typename MT // Type of the sparse matrix
5468  , typename... CRAs > // Compile time row arguments
5469 inline typename Rows<MT,false,false,true,CRAs...>::Iterator
5470  Rows<MT,false,false,true,CRAs...>::insert( size_t i, size_t j, const ElementType& value )
5471 {
5472  return matrix_.insert( j, idx(i), value );
5473 }
5475 //*************************************************************************************************
5476 
5477 
5478 //*************************************************************************************************
5522 template< typename MT // Type of the sparse matrix
5523  , typename... CRAs > // Compile time row arguments
5524 inline void Rows<MT,false,false,true,CRAs...>::append( size_t i, size_t j, const ElementType& value, bool check )
5525 {
5526  if( !check || !isDefault<strict>( value ) )
5527  matrix_.insert( j, idx(i), value );
5528 }
5530 //*************************************************************************************************
5531 
5532 
5533 //*************************************************************************************************
5547 template< typename MT // Type of the sparse matrix
5548  , typename... CRAs > // Compile time row arguments
5549 inline void Rows<MT,false,false,true,CRAs...>::finalize( size_t i )
5550 {
5551  UNUSED_PARAMETER( i );
5552 
5553  return;
5554 }
5556 //*************************************************************************************************
5557 
5558 
5559 
5560 
5561 //=================================================================================================
5562 //
5563 // ERASE FUNCTIONS
5564 //
5565 //=================================================================================================
5566 
5567 //*************************************************************************************************
5577 template< typename MT // Type of the sparse matrix
5578  , typename... CRAs > // Compile time row arguments
5579 inline void Rows<MT,false,false,true,CRAs...>::erase( size_t i, size_t j )
5580 {
5581  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
5582  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5583 
5584  matrix_.erase( j, idx(i) );
5585 }
5587 //*************************************************************************************************
5588 
5589 
5590 //*************************************************************************************************
5600 template< typename MT // Type of the sparse matrix
5601  , typename... CRAs > // Compile time row arguments
5602 inline typename Rows<MT,false,false,true,CRAs...>::Iterator
5603  Rows<MT,false,false,true,CRAs...>::erase( size_t i, Iterator pos )
5604 {
5605  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
5606 
5607  return matrix_.erase( idx(i), pos );
5608 }
5610 //*************************************************************************************************
5611 
5612 
5613 //*************************************************************************************************
5624 template< typename MT // Type of the sparse matrix
5625  , typename... CRAs > // Compile time row arguments
5626 inline typename Rows<MT,false,false,true,CRAs...>::Iterator
5627  Rows<MT,false,false,true,CRAs...>::erase( size_t i, Iterator first, Iterator last )
5628 {
5629  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
5630 
5631  return matrix_.erase( idx(i), first, last );
5632 }
5634 //*************************************************************************************************
5635 
5636 
5637 //*************************************************************************************************
5660 template< typename MT // Type of the sparse matrix
5661  , typename... CRAs > // Compile time row arguments
5662 template< typename Pred > // Type of the unary predicate
5663 inline void Rows<MT,false,false,true,CRAs...>::erase( Pred predicate )
5664 {
5665  for( size_t i=0UL; i<rows(); ++i ) {
5666  matrix_.erase( idx(i), begin(i), end(i), predicate );
5667  }
5668 }
5670 //*************************************************************************************************
5671 
5672 
5673 //*************************************************************************************************
5700 template< typename MT // Type of the sparse matrix
5701  , typename... CRAs > // Compile time row arguments
5702 template< typename Pred > // Type of the unary predicate
5703 inline void Rows<MT,false,false,true,CRAs...>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
5704 {
5705  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
5706 
5707  matrix_.erase( idx(i), first, last, predicate );
5708 }
5710 //*************************************************************************************************
5711 
5712 
5713 
5714 
5715 //=================================================================================================
5716 //
5717 // LOOKUP FUNCTIONS
5718 //
5719 //=================================================================================================
5720 
5721 //*************************************************************************************************
5736 template< typename MT // Type of the sparse matrix
5737  , typename... CRAs > // Compile time row arguments
5738 inline typename Rows<MT,false,false,true,CRAs...>::Iterator
5739  Rows<MT,false,false,true,CRAs...>::find( size_t i, size_t j )
5740 {
5741  return matrix_.find( j, idx(i) );
5742 }
5744 //*************************************************************************************************
5745 
5746 
5747 //*************************************************************************************************
5762 template< typename MT // Type of the sparse matrix
5763  , typename... CRAs > // Compile time row arguments
5764 inline typename Rows<MT,false,false,true,CRAs...>::ConstIterator
5765  Rows<MT,false,false,true,CRAs...>::find( size_t i, size_t j ) const
5766 {
5767  return matrix_.find( j, idx(i) );
5768 }
5770 //*************************************************************************************************
5771 
5772 
5773 //*************************************************************************************************
5787 template< typename MT // Type of the sparse matrix
5788  , typename... CRAs > // Compile time row arguments
5789 inline typename Rows<MT,false,false,true,CRAs...>::Iterator
5790  Rows<MT,false,false,true,CRAs...>::lowerBound( size_t i, size_t j )
5791 {
5792  return matrix_.lowerBound( j, idx(i) );
5793 }
5795 //*************************************************************************************************
5796 
5797 
5798 //*************************************************************************************************
5812 template< typename MT // Type of the sparse matrix
5813  , typename... CRAs > // Compile time row arguments
5814 inline typename Rows<MT,false,false,true,CRAs...>::ConstIterator
5815  Rows<MT,false,false,true,CRAs...>::lowerBound( size_t i, size_t j ) const
5816 {
5817  return matrix_.lowerBound( j, idx(i) );
5818 }
5820 //*************************************************************************************************
5821 
5822 
5823 //*************************************************************************************************
5837 template< typename MT // Type of the sparse matrix
5838  , typename... CRAs > // Compile time row arguments
5839 inline typename Rows<MT,false,false,true,CRAs...>::Iterator
5840  Rows<MT,false,false,true,CRAs...>::upperBound( size_t i, size_t j )
5841 {
5842  return matrix_.upperBound( j, idx(i) );
5843 }
5845 //*************************************************************************************************
5846 
5847 
5848 //*************************************************************************************************
5862 template< typename MT // Type of the sparse matrix
5863  , typename... CRAs > // Compile time row arguments
5864 inline typename Rows<MT,false,false,true,CRAs...>::ConstIterator
5865  Rows<MT,false,false,true,CRAs...>::upperBound( size_t i, size_t j ) const
5866 {
5867  return matrix_.upperBound( j, idx(i) );
5868 }
5870 //*************************************************************************************************
5871 
5872 
5873 
5874 
5875 //=================================================================================================
5876 //
5877 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
5878 //
5879 //=================================================================================================
5880 
5881 //*************************************************************************************************
5892 template< typename MT // Type of the sparse matrix
5893  , typename... CRAs > // Compile time row arguments
5894 template< typename Other > // Data type of the foreign expression
5895 inline bool Rows<MT,false,false,true,CRAs...>::canAlias( const Other* alias ) const noexcept
5896 {
5897  return matrix_.isAliased( alias );
5898 }
5900 //*************************************************************************************************
5901 
5902 
5903 //*************************************************************************************************
5914 template< typename MT // Type of the sparse matrix
5915  , typename... CRAs > // Compile time row arguments
5916 template< typename Other > // Data type of the foreign expression
5917 inline bool Rows<MT,false,false,true,CRAs...>::isAliased( const Other* alias ) const noexcept
5918 {
5919  return matrix_.isAliased( alias );
5920 }
5922 //*************************************************************************************************
5923 
5924 
5925 //*************************************************************************************************
5936 template< typename MT // Type of the sparse matrix
5937  , typename... CRAs > // Compile time row arguments
5938 inline bool Rows<MT,false,false,true,CRAs...>::canSMPAssign() const noexcept
5939 {
5940  return false;
5941 }
5943 //*************************************************************************************************
5944 
5945 } // namespace blaze
5946 
5947 #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.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Headerfile for the generic min algorithm.
Header file for the blaze::checked and blaze::unchecked instances.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3078
Header file for the Schur product trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ROWS_TYPE(T)
Constraint on the data type.In case the given data type T is a row selection type (i...
Definition: Rows.h:81
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:354
constexpr bool IsSparseMatrix_v
Auxiliary variable template for the IsSparseMatrix type trait.The IsSparseMatrix_v variable template ...
Definition: IsSparseMatrix.h:139
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
Header file for the subtraction trait.
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
constexpr const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:750
Header file for the View base class.
Header file for the IsSparseMatrix type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3079
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SUBMATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a submatrix type (i.e. a dense or sparse submatrix), a compilation error is created.
Definition: Submatrix.h:81
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
#define BLAZE_CONSTRAINT_MUST_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a symmetric matrix type...
Definition: Symmetric.h:60
Header file for the decltype(auto) workaround.
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
Header file for the extended initializer_list functionality.
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the IsUniLower type trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:482
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:416
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Constraint on the data type.
Header file for the implementation of a matrix representation of an initializer list.
Headerfile for the generic max algorithm.
Header file for the IsStrictlyUpper type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
decltype(auto) ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatMapExpr.h:1364
Header file for the If class template.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3080
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:253
constexpr bool Contains_v
Auxiliary variable template for the Contains type trait.The Contains_v variable template provides a c...
Definition: Contains.h:139
Header file for the IsLower type trait.
Header file for the SparseElement base class.
Constraint on the data type.
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1179
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8908
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
Constraint on the data type.
Header file for the IsStrictlyLower type trait.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Header file for run time assertion macros.
Header file for the relaxation flag types.
Header file for the addition trait.
Header file for the Unique class template.
Check< false > Unchecked
Type of the blaze::unchecked instance.blaze::Unchecked is the type of the blaze::unchecked instance...
Definition: Check.h:96
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Header file for the isDefault shim.
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
Constraint on the data type.
Constraint on the data type.
Constraints on the storage order of matrix types.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the IsReference type trait.
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the rows trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
Constraint on the data type.
Header file for the implementation of the RowsData class template.
Header file for the IsComputation type trait class.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3082
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:290
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
#define BLAZE_THROW_LOGIC_ERROR(MESSAGE)
Macro for the emission of a std::logic_error exception.This macro encapsulates the default way of Bla...
Definition: Exception.h:187
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
Header file for the IsUpper type trait.
Header file for the implementation of the Rows base template.
Header file for the IsRestricted type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Header file for the IsExpression type trait class.
Constraint on the data type.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825