Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_COLUMNS_SPARSE_H_
36 #define _BLAZE_MATH_VIEWS_COLUMNS_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 COLUMN-MAJOR SPARSE MATRICES
100 //
101 //=================================================================================================
102 
103 //*************************************************************************************************
111 template< typename MT // Type of the sparse matrix
112  , bool SF // Symmetry flag
113  , typename... CCAs > // Compile time column arguments
114 class Columns<MT,true,false,SF,CCAs...>
115  : public View< SparseMatrix< Columns<MT,true,false,SF,CCAs...>, true > >
116  , private ColumnsData<CCAs...>
117 {
118  private:
119  //**Type definitions****************************************************************************
120  using DataType = ColumnsData<CCAs...>;
121  using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
122  //**********************************************************************************************
123 
124  //**Compile time flags**************************************************************************
125  static constexpr size_t N = sizeof...( CCAs );
126  //**********************************************************************************************
127 
128  public:
129  //**Type definitions****************************************************************************
131  using This = Columns<MT,true,false,SF,CCAs...>;
132 
133  using BaseType = SparseMatrix<This,true>;
134  using ViewedType = MT;
135  using ResultType = ColumnsTrait_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 Columns&;
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... RCAs >
164  explicit inline Columns( MT& matrix, RCAs... args );
165 
166  Columns( const Columns& ) = default;
167  Columns( Columns&& ) = default;
169  //**********************************************************************************************
170 
171  //**Destructor**********************************************************************************
174  ~Columns() = 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 j );
186  inline ConstIterator begin ( size_t j ) const;
187  inline ConstIterator cbegin( size_t j ) const;
188  inline Iterator end ( size_t j );
189  inline ConstIterator end ( size_t j ) const;
190  inline ConstIterator cend ( size_t j ) const;
192  //**********************************************************************************************
193 
194  //**Assignment operators************************************************************************
197  inline Columns& operator=( initializer_list< initializer_list<ElementType> > list );
198  inline Columns& operator=( const Columns& rhs );
199 
200  template< typename MT2, bool SO > inline Columns& operator= ( const Matrix<MT2,SO>& rhs );
201  template< typename MT2, bool SO > inline Columns& operator+=( const Matrix<MT2,SO>& rhs );
202  template< typename MT2, bool SO > inline Columns& operator-=( const Matrix<MT2,SO>& rhs );
203  template< typename MT2, bool SO > inline Columns& operator%=( const Matrix<MT2,SO>& rhs );
205  //**********************************************************************************************
206 
207  //**Utility functions***************************************************************************
210  using DataType::idx;
211  using DataType::idces;
212  using DataType::columns;
213 
214  inline MT& operand() noexcept;
215  inline const MT& operand() const noexcept;
216 
217  inline size_t rows() const noexcept;
218  inline size_t capacity() const noexcept;
219  inline size_t capacity( size_t j ) const noexcept;
220  inline size_t nonZeros() const;
221  inline size_t nonZeros( size_t j ) const;
222  inline void reset();
223  inline void reset( size_t j );
224  inline void reserve( size_t nonzeros );
225  void reserve( size_t j, size_t nonzeros );
226  inline void trim();
227  inline void trim( size_t j );
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 j );
239  //**********************************************************************************************
240 
241  //**Erase functions*****************************************************************************
244  inline void erase( size_t i, size_t j );
245  inline Iterator erase( size_t j, Iterator pos );
246  inline Iterator erase( size_t j, 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 j, 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 Columns& transpose();
272  inline Columns& ctranspose();
273 
274  template< typename Other > inline Columns& 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,true>& rhs );
288  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,false>& 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 j ) 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... CCAs > // Compile time column arguments
349 template< typename... RCAs > // Runtime column arguments
350 inline Columns<MT,true,false,SF,CCAs...>::Columns( MT& matrix, RCAs... args )
351  : DataType( args... ) // Base class initialization
352  , matrix_ ( matrix ) // The matrix containing the columns
353 {
354  if( !Contains_v< TypeList<RCAs...>, Unchecked > ) {
355  for( size_t j=0UL; j<columns(); ++j ) {
356  if( matrix_.columns() <= idx(j) ) {
357  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column 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... CCAs > // Compile time column arguments
388 inline typename Columns<MT,true,false,SF,CCAs...>::Reference
389  Columns<MT,true,false,SF,CCAs...>::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_(i,idx(j));
395 }
397 //*************************************************************************************************
398 
399 
400 //*************************************************************************************************
411 template< typename MT // Type of the sparse matrix
412  , bool SF // Symmetry flag
413  , typename... CCAs > // Compile time column arguments
414 inline typename Columns<MT,true,false,SF,CCAs...>::ConstReference
415  Columns<MT,true,false,SF,CCAs...>::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_ )(i,idx(j));
421 }
423 //*************************************************************************************************
424 
425 
426 //*************************************************************************************************
438 template< typename MT // Type of the sparse matrix
439  , bool SF // Symmetry flag
440  , typename... CCAs > // Compile time column arguments
441 inline typename Columns<MT,true,false,SF,CCAs...>::Reference
442  Columns<MT,true,false,SF,CCAs...>::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... CCAs > // Compile time column arguments
471 inline typename Columns<MT,true,false,SF,CCAs...>::ConstReference
472  Columns<MT,true,false,SF,CCAs...>::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... CCAs > // Compile time column arguments
498 inline typename Columns<MT,true,false,SF,CCAs...>::Iterator
500 {
501  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
502 
503  return matrix_.begin( idx(j) );
504 }
506 //*************************************************************************************************
507 
508 
509 //*************************************************************************************************
518 template< typename MT // Type of the sparse matrix
519  , bool SF // Symmetry flag
520  , typename... CCAs > // Compile time column arguments
521 inline typename Columns<MT,true,false,SF,CCAs...>::ConstIterator
523 {
524  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
525 
526  return matrix_.cbegin( idx(j) );
527 }
529 //*************************************************************************************************
530 
531 
532 //*************************************************************************************************
541 template< typename MT // Type of the sparse matrix
542  , bool SF // Symmetry flag
543  , typename... CCAs > // Compile time column arguments
544 inline typename Columns<MT,true,false,SF,CCAs...>::ConstIterator
546 {
547  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
548 
549  return matrix_.cbegin( idx(j) );
550 }
552 //*************************************************************************************************
553 
554 
555 //*************************************************************************************************
564 template< typename MT // Type of the sparse matrix
565  , bool SF // Symmetry flag
566  , typename... CCAs > // Compile time column arguments
567 inline typename Columns<MT,true,false,SF,CCAs...>::Iterator
569 {
570  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
571 
572  return matrix_.end( idx(j) );
573 }
575 //*************************************************************************************************
576 
577 
578 //*************************************************************************************************
587 template< typename MT // Type of the sparse matrix
588  , bool SF // Symmetry flag
589  , typename... CCAs > // Compile time column arguments
590 inline typename Columns<MT,true,false,SF,CCAs...>::ConstIterator
592 {
593  BLAZE_USER_ASSERT( j < columns(), "Invalid row access index" );
594 
595  return matrix_.cend( idx(j) );
596 }
598 //*************************************************************************************************
599 
600 
601 //*************************************************************************************************
610 template< typename MT // Type of the sparse matrix
611  , bool SF // Symmetry flag
612  , typename... CCAs > // Compile time column arguments
613 inline typename Columns<MT,true,false,SF,CCAs...>::ConstIterator
615 {
616  BLAZE_USER_ASSERT( j < columns(), "Invalid row access index" );
617 
618  return matrix_.cend( idx(j) );
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... CCAs > // Compile time column arguments
651 inline Columns<MT,true,false,SF,CCAs...>&
652  Columns<MT,true,false,SF,CCAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
653 {
656 
657  if( list.size() != rows() ) {
658  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to column selection" );
659  }
660 
661  const InitializerMatrix<ElementType> tmp( list, columns() );
662 
663  if( IsRestricted_v<MT> ) {
664  for( size_t j=0UL; j<columns(); ++j ) {
665  if( !tryAssign( matrix_, column( tmp, j, unchecked ), 0UL, j ) ) {
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... CCAs > // Compile time column arguments
700 inline Columns<MT,true,false,SF,CCAs...>&
701  Columns<MT,true,false,SF,CCAs...>::operator=( const Columns& 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 j=0UL; j<columns(); ++j ) {
718  if( !tryAssign( matrix_, column( rhs, j, unchecked ), 0UL, idx(j) ) ) {
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... CCAs > // Compile time column 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 Columns<MT,true,false,SF,CCAs...>&
765  Columns<MT,true,false,SF,CCAs...>::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 j=0UL; j<columns(); ++j ) {
781  if( !tryAssign( matrix_, column( right, j, unchecked ), 0UL, idx(j) ) ) {
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... CCAs > // Compile time column 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 Columns<MT,true,false,SF,CCAs...>&
827  Columns<MT,true,false,SF,CCAs...>::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 j=0UL; j<columns(); ++j ) {
848  if( !tryAssign( matrix_, column( tmp, j, unchecked ), 0UL, idx(j) ) ) {
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... CCAs > // Compile time column 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 Columns<MT,true,false,SF,CCAs...>&
887  Columns<MT,true,false,SF,CCAs...>::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 j=0UL; j<columns(); ++j ) {
908  if( !tryAssign( matrix_, column( tmp, j, unchecked ), 0UL, idx(j) ) ) {
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... CCAs > // Compile time column 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 Columns<MT,true,false,SF,CCAs...>&
947  Columns<MT,true,false,SF,CCAs...>::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 j=0UL; j<columns(); ++j ) {
968  if( !tryAssign( matrix_, column( tmp, j, unchecked ), 0UL, idx(j) ) ) {
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... CCAs > // Compile time column arguments
1004 inline MT& Columns<MT,true,false,SF,CCAs...>::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... CCAs > // Compile time column arguments
1021 inline const MT& Columns<MT,true,false,SF,CCAs...>::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... CCAs > // Compile time column arguments
1038 inline size_t Columns<MT,true,false,SF,CCAs...>::rows() const noexcept
1039 {
1040  return matrix_.rows();
1041 }
1043 //*************************************************************************************************
1044 
1045 
1046 //*************************************************************************************************
1052 template< typename MT // Type of the sparse matrix
1053  , bool SF // Symmetry flag
1054  , typename... CCAs > // Compile time column arguments
1055 inline size_t Columns<MT,true,false,SF,CCAs...>::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... CCAs > // Compile time column arguments
1075 inline size_t Columns<MT,true,false,SF,CCAs...>::capacity( size_t j ) const noexcept
1076 {
1077  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
1078 
1079  return matrix_.capacity( idx(j) );
1080 }
1082 //*************************************************************************************************
1083 
1084 
1085 //*************************************************************************************************
1091 template< typename MT // Type of the sparse matrix
1092  , bool SF // Symmetry flag
1093  , typename... CCAs > // Compile time column arguments
1094 inline size_t Columns<MT,true,false,SF,CCAs...>::nonZeros() const
1095 {
1096  size_t nonzeros( 0UL );
1097 
1098  for( size_t j=0UL; j<columns(); ++j )
1099  nonzeros += nonZeros( j );
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... CCAs > // Compile time column arguments
1119 inline size_t Columns<MT,true,false,SF,CCAs...>::nonZeros( size_t j ) const
1120 {
1121  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
1122 
1123  return matrix_.nonZeros( idx(j) );
1124 }
1126 //*************************************************************************************************
1127 
1128 
1129 //*************************************************************************************************
1135 template< typename MT // Type of the sparse matrix
1136  , bool SF // Symmetry flag
1137  , typename... CCAs > // Compile time column arguments
1139 {
1140  for( size_t j=0UL; j<columns(); ++j ) {
1141  matrix_.reset( idx(j) );
1142  }
1143 }
1145 //*************************************************************************************************
1146 
1147 
1148 //*************************************************************************************************
1158 template< typename MT // Type of the sparse matrix
1159  , bool SF // Symmetry flag
1160  , typename... CCAs > // Compile time column arguments
1161 inline void Columns<MT,true,false,SF,CCAs...>::reset( size_t j )
1162 {
1163  matrix_.reset( idx(j) );
1164 }
1166 //*************************************************************************************************
1167 
1168 
1169 //*************************************************************************************************
1180 template< typename MT // Type of the sparse matrix
1181  , bool SF // Symmetry flag
1182  , typename... CCAs > // Compile time column arguments
1183 inline void Columns<MT,true,false,SF,CCAs...>::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... CCAs > // Compile time column arguments
1211 void Columns<MT,true,false,SF,CCAs...>::reserve( size_t j, size_t nonzeros )
1212 {
1213  matrix_.reserve( idx(j), nonzeros );
1214 }
1216 //*************************************************************************************************
1217 
1218 
1219 //*************************************************************************************************
1229 template< typename MT // Type of the sparse matrix
1230  , bool SF // Symmetry flag
1231  , typename... CCAs > // Compile time column arguments
1232 void Columns<MT,true,false,SF,CCAs...>::trim()
1233 {
1234  for( size_t j=0UL; j<columns(); ++j ) {
1235  trim( j );
1236  }
1237 }
1239 //*************************************************************************************************
1240 
1241 
1242 //*************************************************************************************************
1253 template< typename MT // Type of the sparse matrix
1254  , bool SF // Symmetry flag
1255  , typename... CCAs > // Compile time column arguments
1256 void Columns<MT,true,false,SF,CCAs...>::trim( size_t j )
1257 {
1258  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
1259 
1260  matrix_.trim( idx(j) );
1261 }
1263 //*************************************************************************************************
1264 
1265 
1266 //*************************************************************************************************
1276 template< typename MT // Type of the sparse matrix
1277  , bool SF // Symmetry flag
1278  , typename... CCAs > // Compile time column arguments
1279 inline size_t Columns<MT,true,false,SF,CCAs...>::extendCapacity( size_t j ) const noexcept
1280 {
1281  using blaze::max;
1282  using blaze::min;
1283 
1284  size_t nonzeros( 2UL*capacity( j )+1UL );
1285  nonzeros = max( nonzeros, 7UL );
1286  nonzeros = min( nonzeros, rows() );
1287 
1288  BLAZE_INTERNAL_ASSERT( nonzeros > capacity( j ), "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... CCAs > // Compile time column arguments
1320 inline typename Columns<MT,true,false,SF,CCAs...>::Iterator
1321  Columns<MT,true,false,SF,CCAs...>::set( size_t i, size_t j, const ElementType& value )
1322 {
1323  return matrix_.set( i, idx(j), value );
1324 }
1326 //*************************************************************************************************
1327 
1328 
1329 //*************************************************************************************************
1343 template< typename MT // Type of the sparse matrix
1344  , bool SF // Symmetry flag
1345  , typename... CCAs > // Compile time column arguments
1346 inline typename Columns<MT,true,false,SF,CCAs...>::Iterator
1347  Columns<MT,true,false,SF,CCAs...>::insert( size_t i, size_t j, const ElementType& value )
1348 {
1349  return matrix_.insert( i, idx(j), value );
1350 }
1352 //*************************************************************************************************
1353 
1354 
1355 //*************************************************************************************************
1399 template< typename MT // Type of the sparse matrix
1400  , bool SF // Symmetry flag
1401  , typename... CCAs > // Compile time column arguments
1402 inline void Columns<MT,true,false,SF,CCAs...>::append( size_t i, size_t j, const ElementType& value, bool check )
1403 {
1404  if( !check || !isDefault<strict>( value ) )
1405  matrix_.insert( i, idx(j), value );
1406 }
1408 //*************************************************************************************************
1409 
1410 
1411 //*************************************************************************************************
1425 template< typename MT // Type of the sparse matrix
1426  , bool SF // Symmetry flag
1427  , typename... CCAs > // Compile time column arguments
1428 inline void Columns<MT,true,false,SF,CCAs...>::finalize( size_t j )
1429 {
1430  UNUSED_PARAMETER( j );
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... CCAs > // Compile time column arguments
1459 inline void Columns<MT,true,false,SF,CCAs...>::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( i, idx(j) );
1465 }
1467 //*************************************************************************************************
1468 
1469 
1470 //*************************************************************************************************
1480 template< typename MT // Type of the sparse matrix
1481  , bool SF // Symmetry flag
1482  , typename... CCAs > // Compile time column arguments
1483 inline typename Columns<MT,true,false,SF,CCAs...>::Iterator
1484  Columns<MT,true,false,SF,CCAs...>::erase( size_t j, Iterator pos )
1485 {
1486  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
1487 
1488  return matrix_.erase( idx(j), pos );
1489 }
1491 //*************************************************************************************************
1492 
1493 
1494 //*************************************************************************************************
1505 template< typename MT // Type of the sparse matrix
1506  , bool SF // Symmetry flag
1507  , typename... CCAs > // Compile time column arguments
1508 inline typename Columns<MT,true,false,SF,CCAs...>::Iterator
1509  Columns<MT,true,false,SF,CCAs...>::erase( size_t j, Iterator first, Iterator last )
1510 {
1511  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
1512 
1513  return matrix_.erase( idx(j), first, last );
1514 }
1516 //*************************************************************************************************
1517 
1518 
1519 //*************************************************************************************************
1542 template< typename MT // Type of the sparse matrix
1543  , bool SF // Symmetry flag
1544  , typename... CCAs > // Compile time column arguments
1545 template< typename Pred > // Type of the unary predicate
1546 inline void Columns<MT,true,false,SF,CCAs...>::erase( Pred predicate )
1547 {
1548  for( size_t j=0UL; j<columns(); ++j ) {
1549  matrix_.erase( idx(j), begin(j), end(j), predicate );
1550  }
1551 }
1553 //*************************************************************************************************
1554 
1555 
1556 //*************************************************************************************************
1583 template< typename MT // Type of the sparse matrix
1584  , bool SF // Symmetry flag
1585  , typename... CCAs > // Compile time column arguments
1586 template< typename Pred > // Type of the unary predicate
1587 inline void Columns<MT,true,false,SF,CCAs...>::erase( size_t j, Iterator first, Iterator last, Pred predicate )
1588 {
1589  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
1590 
1591  matrix_.erase( idx(j), 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... CCAs > // Compile time column arguments
1623 inline typename Columns<MT,true,false,SF,CCAs...>::Iterator
1624  Columns<MT,true,false,SF,CCAs...>::find( size_t i, size_t j )
1625 {
1626  return matrix_.find( i, idx(j) );
1627 }
1629 //*************************************************************************************************
1630 
1631 
1632 //*************************************************************************************************
1647 template< typename MT // Type of the sparse matrix
1648  , bool SF // Symmetry flag
1649  , typename... CCAs > // Compile time column arguments
1650 inline typename Columns<MT,true,false,SF,CCAs...>::ConstIterator
1651  Columns<MT,true,false,SF,CCAs...>::find( size_t i, size_t j ) const
1652 {
1653  return matrix_.find( i, idx(j) );
1654 }
1656 //*************************************************************************************************
1657 
1658 
1659 //*************************************************************************************************
1673 template< typename MT // Type of the sparse matrix
1674  , bool SF // Symmetry flag
1675  , typename... CCAs > // Compile time column arguments
1676 inline typename Columns<MT,true,false,SF,CCAs...>::Iterator
1677  Columns<MT,true,false,SF,CCAs...>::lowerBound( size_t i, size_t j )
1678 {
1679  return matrix_.lowerBound( i, idx(j) );
1680 }
1682 //*************************************************************************************************
1683 
1684 
1685 //*************************************************************************************************
1699 template< typename MT // Type of the sparse matrix
1700  , bool SF // Symmetry flag
1701  , typename... CCAs > // Compile time column arguments
1702 inline typename Columns<MT,true,false,SF,CCAs...>::ConstIterator
1703  Columns<MT,true,false,SF,CCAs...>::lowerBound( size_t i, size_t j ) const
1704 {
1705  return matrix_.lowerBound( i, idx(j) );
1706 }
1708 //*************************************************************************************************
1709 
1710 
1711 //*************************************************************************************************
1725 template< typename MT // Type of the sparse matrix
1726  , bool SF // Symmetry flag
1727  , typename... CCAs > // Compile time column arguments
1728 inline typename Columns<MT,true,false,SF,CCAs...>::Iterator
1729  Columns<MT,true,false,SF,CCAs...>::upperBound( size_t i, size_t j )
1730 {
1731  return matrix_.upperBound( i, idx(j) );
1732 }
1734 //*************************************************************************************************
1735 
1736 
1737 //*************************************************************************************************
1751 template< typename MT // Type of the sparse matrix
1752  , bool SF // Symmetry flag
1753  , typename... CCAs > // Compile time column arguments
1754 inline typename Columns<MT,true,false,SF,CCAs...>::ConstIterator
1755  Columns<MT,true,false,SF,CCAs...>::upperBound( size_t i, size_t j ) const
1756 {
1757  return matrix_.upperBound( i, idx(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... CCAs > // Compile time column arguments
1787 inline Columns<MT,true,false,SF,CCAs...>&
1789 {
1790  if( rows() != columns() ) {
1791  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose of a non-quadratic matrix" );
1792  }
1793 
1794  const ResultType tmp( trans( *this ) );
1795 
1796  if( IsRestricted_v<MT> ) {
1797  for( size_t j=0UL; j<columns(); ++j ) {
1798  if( !tryAssign( matrix_, column( tmp, j, unchecked ), 0UL, idx(j) ) ) {
1799  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose operation" );
1800  }
1801  }
1802  }
1803 
1804  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
1805 
1806  left.reset();
1807  smpAssign( left, tmp );
1808 
1809  return *this;
1810 }
1812 //*************************************************************************************************
1813 
1814 
1815 //*************************************************************************************************
1828 template< typename MT // Type of the sparse matrix
1829  , bool SF // Symmetry flag
1830  , typename... CCAs > // Compile time column arguments
1831 inline Columns<MT,true,false,SF,CCAs...>&
1833 {
1834  if( rows() != columns() ) {
1835  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose of a non-quadratic matrix" );
1836  }
1837 
1838  const ResultType tmp( ctrans( *this ) );
1839 
1840  if( IsRestricted_v<MT> ) {
1841  for( size_t j=0UL; j<columns(); ++j ) {
1842  if( !tryAssign( matrix_, column( tmp, j, unchecked ), 0UL, idx(j) ) ) {
1843  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose operation" );
1844  }
1845  }
1846  }
1847 
1848  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
1849 
1850  left.reset();
1851  smpAssign( left, tmp );
1852 
1853  return *this;
1854 }
1856 //*************************************************************************************************
1857 
1858 
1859 //*************************************************************************************************
1872 template< typename MT // Type of the sparse matrix
1873  , bool SF // Symmetry flag
1874  , typename... CCAs > // Compile time column arguments
1875 template< typename Other > // Data type of the scalar value
1876 inline Columns<MT,true,false,SF,CCAs...>&
1877  Columns<MT,true,false,SF,CCAs...>::scale( const Other& scalar )
1878 {
1880 
1881  for( size_t j=0UL; j<columns(); ++j ) {
1882  const Iterator last( end(j) );
1883  for( Iterator element=begin(j); element!=last; ++element )
1884  element->value() *= scalar;
1885  }
1886 
1887  return *this;
1888 }
1890 //*************************************************************************************************
1891 
1892 
1893 
1894 
1895 //=================================================================================================
1896 //
1897 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1898 //
1899 //=================================================================================================
1900 
1901 //*************************************************************************************************
1912 template< typename MT // Type of the sparse matrix
1913  , bool SF // Symmetry flag
1914  , typename... CCAs > // Compile time column arguments
1915 template< typename Other > // Data type of the foreign expression
1916 inline bool Columns<MT,true,false,SF,CCAs...>::canAlias( const Other* alias ) const noexcept
1917 {
1918  return matrix_.isAliased( alias );
1919 }
1921 //*************************************************************************************************
1922 
1923 
1924 //*************************************************************************************************
1935 template< typename MT // Type of the sparse matrix
1936  , bool SF // Symmetry flag
1937  , typename... CCAs > // Compile time column arguments
1938 template< typename Other > // Data type of the foreign expression
1939 inline bool Columns<MT,true,false,SF,CCAs...>::isAliased( const Other* alias ) const noexcept
1940 {
1941  return matrix_.isAliased( alias );
1942 }
1944 //*************************************************************************************************
1945 
1946 
1947 //*************************************************************************************************
1958 template< typename MT // Type of the sparse matrix
1959  , bool SF // Symmetry flag
1960  , typename... CCAs > // Compile time column arguments
1961 inline bool Columns<MT,true,false,SF,CCAs...>::canSMPAssign() const noexcept
1962 {
1963  return false;
1964 }
1966 //*************************************************************************************************
1967 
1968 
1969 //*************************************************************************************************
1981 template< typename MT // Type of the sparse matrix
1982  , bool SF // Symmetry flag
1983  , typename... CCAs > // Compile time column arguments
1984 template< typename MT2 // Type of the right-hand side dense matrix
1985  , bool SO > // Storage order of the right-hand side dense matrix
1986 inline void Columns<MT,true,false,SF,CCAs...>::assign( const DenseMatrix<MT2,SO>& rhs )
1987 {
1990 
1991  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
1992  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
1993  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1994 
1995  for( size_t j=0UL; j<columns(); ++j )
1996  {
1997  const size_t index( idx(j) );
1998  size_t remaining( matrix_.capacity( index ) );
1999 
2000  for( size_t i=0UL; i<rows(); ++i )
2001  {
2002  if( remaining == 0UL ) {
2003  matrix_.reserve( index, extendCapacity( j ) );
2004  remaining = matrix_.capacity( index ) - matrix_.nonZeros( index );
2005  }
2006 
2007  matrix_.append( i, index, (~rhs)(i,j), true );
2008  --remaining;
2009  }
2010  }
2011 }
2013 //*************************************************************************************************
2014 
2015 
2016 //*************************************************************************************************
2028 template< typename MT // Type of the sparse matrix
2029  , bool SF // Symmetry flag
2030  , typename... CCAs > // Compile time column arguments
2031 template< typename MT2 > // Type of the right-hand side sparse matrix
2032 inline void Columns<MT,true,false,SF,CCAs...>::assign( const SparseMatrix<MT2,true>& rhs )
2033 {
2036 
2037  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2038  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2039  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
2040 
2041  for( size_t j=0UL; j<columns(); ++j )
2042  {
2043  const size_t index( idx(j) );
2044  size_t remaining( matrix_.capacity( index ) );
2045 
2046  for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2047  {
2048  if( remaining == 0UL ) {
2049  matrix_.reserve( index, extendCapacity( j ) );
2050  remaining = matrix_.capacity( index ) - matrix_.nonZeros( index );
2051  }
2052 
2053  matrix_.append( element->index(), index, element->value(), true );
2054  --remaining;
2055  }
2056  }
2057 }
2059 //*************************************************************************************************
2060 
2061 
2062 //*************************************************************************************************
2074 template< typename MT // Type of the sparse matrix
2075  , bool SF // Symmetry flag
2076  , typename... CCAs > // Compile time column arguments
2077 template< typename MT2 > // Type of the right-hand side sparse matrix
2078 inline void Columns<MT,true,false,SF,CCAs...>::assign( const SparseMatrix<MT2,false>& rhs )
2079 {
2082 
2084 
2085  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2086  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2087  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
2088 
2089  // Counting the number of elements per column
2090  std::vector<size_t> columnLengths( columns(), 0UL );
2091  for( size_t i=0UL; i<rows(); ++i ) {
2092  for( auto element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2093  ++columnLengths[element->index()];
2094  }
2095 
2096  // Resizing the sparse matrix
2097  for( size_t j=0UL; j<columns(); ++j ) {
2098  reserve( j, columnLengths[j] );
2099  }
2100 
2101  // Appending the elements to the columns of the sparse column selection
2102  for( size_t i=0UL; i<rows(); ++i ) {
2103  for( auto element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2104  append( i, element->index(), element->value(), true );
2105  }
2106 }
2108 //*************************************************************************************************
2109 
2110 
2111 //*************************************************************************************************
2123 template< typename MT // Type of the sparse matrix
2124  , bool SF // Symmetry flag
2125  , typename... CCAs > // Compile time column arguments
2126 template< typename MT2 // Type of the right-hand side matrix
2127  , bool SO > // Storage order of the right-hand side matrix
2128 inline void Columns<MT,true,false,SF,CCAs...>::addAssign( const Matrix<MT2,SO>& rhs )
2129 {
2132 
2133  using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
2134 
2136 
2137  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2138  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2139 
2140  const AddType tmp( serial( *this + (~rhs) ) );
2141  reset();
2142  assign( tmp );
2143 }
2145 //*************************************************************************************************
2146 
2147 
2148 //*************************************************************************************************
2160 template< typename MT // Type of the sparse matrix
2161  , bool SF // Symmetry flag
2162  , typename... CCAs > // Compile time column arguments
2163 template< typename MT2 // Type of the right-hand side matrix
2164  , bool SO > // Storage order of the right-hand side matrix
2165 inline void Columns<MT,true,false,SF,CCAs...>::subAssign( const Matrix<MT2,SO>& rhs )
2166 {
2169 
2170  using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
2171 
2173 
2174  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2175  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2176 
2177  const SubType tmp( serial( *this - (~rhs) ) );
2178  reset();
2179  assign( tmp );
2180 }
2182 //*************************************************************************************************
2183 
2184 
2185 //*************************************************************************************************
2197 template< typename MT // Type of the sparse matrix
2198  , bool SF // Symmetry flag
2199  , typename... CCAs > // Compile time column arguments
2200 template< typename MT2 // Type of the right-hand side matrix
2201  , bool SO > // Storage order of the right-hand side matrix
2202 inline void Columns<MT,true,false,SF,CCAs...>::schurAssign( const Matrix<MT2,SO>& rhs )
2203 {
2206 
2207  using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
2208 
2211 
2212  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2213  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2214 
2215  const SchurType tmp( serial( *this % (~rhs) ) );
2216  reset();
2217  assign( tmp );
2218 }
2220 //*************************************************************************************************
2221 
2222 
2223 
2224 
2225 
2226 
2227 
2228 
2229 //=================================================================================================
2230 //
2231 // CLASS TEMPLATE SPECIALIZATION FOR GENERAL ROW-MAJOR SPARSE MATRICES
2232 //
2233 //=================================================================================================
2234 
2235 //*************************************************************************************************
2243 template< typename MT // Type of the sparse matrix
2244  , typename... CCAs > // Compile time column arguments
2245 class Columns<MT,false,false,false,CCAs...>
2246  : public View< SparseMatrix< Columns<MT,false,false,false,CCAs...>, true > >
2247  , private ColumnsData<CCAs...>
2248 {
2249  private:
2250  //**Type definitions****************************************************************************
2251  using DataType = ColumnsData<CCAs...>;
2252  using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
2253  //**********************************************************************************************
2254 
2255  //**Compile time flags**************************************************************************
2256  static constexpr size_t N = sizeof...( CCAs );
2257  //**********************************************************************************************
2258 
2259  public:
2260  //**Type definitions****************************************************************************
2262  using This = Columns<MT,false,false,false,CCAs...>;
2263 
2264  using BaseType = SparseMatrix<This,true>;
2265  using ViewedType = MT;
2266  using ResultType = ColumnsTrait_t<MT,N>;
2267  using OppositeType = OppositeType_t<ResultType>;
2268  using TransposeType = TransposeType_t<ResultType>;
2269  using ElementType = ElementType_t<MT>;
2270  using ReturnType = ReturnType_t<MT>;
2271  using CompositeType = const Columns&;
2272 
2274  using ConstReference = ConstReference_t<MT>;
2275 
2277  using Reference = If_t< IsConst_v<MT>, ConstReference, Reference_t<MT> >;
2278  //**********************************************************************************************
2279 
2280  //**ColumnsElement class definition*************************************************************
2283  template< typename MatrixType // Type of the sparse matrix
2284  , typename IteratorType > // Type of the sparse matrix iterator
2285  class ColumnsElement
2286  : private SparseElement
2287  {
2288  public:
2289  //**Constructor******************************************************************************
2295  inline ColumnsElement( IteratorType pos, size_t row )
2296  : pos_( pos ) // Iterator to the current position of the sparse column element
2297  , row_( row ) // Index of the according row
2298  {}
2299  //*******************************************************************************************
2300 
2301  //**Assignment operator**********************************************************************
2307  template< typename T > inline ColumnsElement& operator=( const T& v ) {
2308  *pos_ = v;
2309  return *this;
2310  }
2311  //*******************************************************************************************
2312 
2313  //**Addition assignment operator*************************************************************
2319  template< typename T > inline ColumnsElement& operator+=( const T& v ) {
2320  *pos_ += v;
2321  return *this;
2322  }
2323  //*******************************************************************************************
2324 
2325  //**Subtraction assignment operator**********************************************************
2331  template< typename T > inline ColumnsElement& operator-=( const T& v ) {
2332  *pos_ -= v;
2333  return *this;
2334  }
2335  //*******************************************************************************************
2336 
2337  //**Multiplication assignment operator*******************************************************
2343  template< typename T > inline ColumnsElement& operator*=( const T& v ) {
2344  *pos_ *= v;
2345  return *this;
2346  }
2347  //*******************************************************************************************
2348 
2349  //**Division assignment operator*************************************************************
2355  template< typename T > inline ColumnsElement& operator/=( const T& v ) {
2356  *pos_ /= v;
2357  return *this;
2358  }
2359  //*******************************************************************************************
2360 
2361  //**Element access operator******************************************************************
2366  inline const ColumnsElement* operator->() const {
2367  return this;
2368  }
2369  //*******************************************************************************************
2370 
2371  //**Value function***************************************************************************
2376  inline decltype(auto) value() const {
2377  return pos_->value();
2378  }
2379  //*******************************************************************************************
2380 
2381  //**Index function***************************************************************************
2386  inline size_t index() const {
2387  return row_;
2388  }
2389  //*******************************************************************************************
2390 
2391  private:
2392  //**Member variables*************************************************************************
2393  IteratorType pos_;
2394  size_t row_;
2395  //*******************************************************************************************
2396  };
2397  //**********************************************************************************************
2398 
2399  //**ColumnsIterator class definition************************************************************
2402  template< typename MatrixType // Type of the sparse matrix
2403  , typename IteratorType > // Type of the sparse matrix iterator
2404  class ColumnsIterator
2405  {
2406  public:
2407  //**Type definitions*************************************************************************
2408  using IteratorCategory = std::forward_iterator_tag;
2409  using ValueType = ColumnsElement<MatrixType,IteratorType>;
2410  using PointerType = ValueType;
2411  using ReferenceType = ValueType;
2412  using DifferenceType = ptrdiff_t;
2413 
2414  // STL iterator requirements
2415  using iterator_category = IteratorCategory;
2416  using value_type = ValueType;
2417  using pointer = PointerType;
2418  using reference = ReferenceType;
2419  using difference_type = DifferenceType;
2420  //*******************************************************************************************
2421 
2422  //**Constructor******************************************************************************
2425  inline ColumnsIterator()
2426  : matrix_( nullptr ) // The sparse matrix containing the selected column
2427  , row_ ( 0UL ) // The current row index
2428  , column_( 0UL ) // The current column index
2429  , pos_ () // Iterator to the current sparse element
2430  {}
2431  //*******************************************************************************************
2432 
2433  //**Constructor******************************************************************************
2440  inline ColumnsIterator( MatrixType& matrix, size_t row, size_t column )
2441  : matrix_( &matrix ) // The sparse matrix containing the selected column
2442  , row_ ( row ) // The current row index
2443  , column_( column ) // The current column index
2444  , pos_ () // Iterator to the current sparse element
2445  {
2446  for( ; row_<matrix_->rows(); ++row_ ) {
2447  pos_ = matrix_->find( row_, column_ );
2448  if( pos_ != matrix_->end( row_ ) ) break;
2449  }
2450  }
2451  //*******************************************************************************************
2452 
2453  //**Constructor******************************************************************************
2461  inline ColumnsIterator( MatrixType& matrix, size_t row, size_t column, IteratorType pos )
2462  : matrix_( &matrix ) // The sparse matrix containing the selected column
2463  , row_ ( row ) // The current row index
2464  , column_( column ) // The current column index
2465  , pos_ ( pos ) // Iterator to the current sparse element
2466  {
2467  BLAZE_INTERNAL_ASSERT( matrix.find( row, column ) == pos, "Invalid initial iterator position" );
2468  }
2469  //*******************************************************************************************
2470 
2471  //**Constructor******************************************************************************
2476  template< typename MatrixType2, typename IteratorType2 >
2477  inline ColumnsIterator( const ColumnsIterator<MatrixType2,IteratorType2>& it )
2478  : matrix_( it.matrix_ ) // The sparse matrix containing the selected column
2479  , row_ ( it.row_ ) // The current row index
2480  , column_( it.column_ ) // The current column index
2481  , pos_ ( it.pos_ ) // Iterator to the current sparse element
2482  {}
2483  //*******************************************************************************************
2484 
2485  //**Prefix increment operator****************************************************************
2490  inline ColumnsIterator& operator++() {
2491  ++row_;
2492  for( ; row_<matrix_->rows(); ++row_ ) {
2493  pos_ = matrix_->find( row_, column_ );
2494  if( pos_ != matrix_->end( row_ ) ) break;
2495  }
2496 
2497  return *this;
2498  }
2499  //*******************************************************************************************
2500 
2501  //**Postfix increment operator***************************************************************
2506  inline const ColumnsIterator operator++( int ) {
2507  const ColumnsIterator tmp( *this );
2508  ++(*this);
2509  return tmp;
2510  }
2511  //*******************************************************************************************
2512 
2513  //**Element access operator******************************************************************
2518  inline ReferenceType operator*() const {
2519  return ReferenceType( pos_, row_ );
2520  }
2521  //*******************************************************************************************
2522 
2523  //**Element access operator******************************************************************
2528  inline PointerType operator->() const {
2529  return PointerType( pos_, row_ );
2530  }
2531  //*******************************************************************************************
2532 
2533  //**Equality operator************************************************************************
2539  template< typename MatrixType2, typename IteratorType2 >
2540  inline bool operator==( const ColumnsIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
2541  return row_ == rhs.row_;
2542  }
2543  //*******************************************************************************************
2544 
2545  //**Inequality operator**********************************************************************
2551  template< typename MatrixType2, typename IteratorType2 >
2552  inline bool operator!=( const ColumnsIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
2553  return !( *this == rhs );
2554  }
2555  //*******************************************************************************************
2556 
2557  //**Subtraction operator*********************************************************************
2563  inline DifferenceType operator-( const ColumnsIterator& rhs ) const {
2564  size_t counter( 0UL );
2565  for( size_t i=rhs.row_; i<row_; ++i ) {
2566  if( matrix_->find( i, column_ ) != matrix_->end( i ) )
2567  ++counter;
2568  }
2569  return counter;
2570  }
2571  //*******************************************************************************************
2572 
2573  private:
2574  //**Member variables*************************************************************************
2575  MatrixType* matrix_;
2576  size_t row_;
2577  size_t column_;
2578  IteratorType pos_;
2579  //*******************************************************************************************
2580 
2581  //**Friend declarations**********************************************************************
2582  template< typename MatrixType2, typename IteratorType2 > friend class ColumnsIterator;
2583  template< typename MT2, bool SO2, bool DF2, bool SF2, typename... CCAs2 > friend class Columns;
2584  //*******************************************************************************************
2585  };
2586  //**********************************************************************************************
2587 
2588  //**Type definitions****************************************************************************
2590  using ConstIterator = ColumnsIterator< const MT, ConstIterator_t<MT> >;
2591 
2593  using Iterator = If_t< IsConst_v<MT>, ConstIterator, ColumnsIterator< MT, Iterator_t<MT> > >;
2594  //**********************************************************************************************
2595 
2596  //**Compilation flags***************************************************************************
2598  static constexpr bool smpAssignable = MT::smpAssignable;
2599  //**********************************************************************************************
2600 
2601  //**Constructors********************************************************************************
2604  template< typename... RCAs >
2605  explicit inline Columns( MT& matrix, RCAs... args );
2606 
2607  Columns( const Columns& ) = default;
2608  Columns( Columns&& ) = default;
2610  //**********************************************************************************************
2611 
2612  //**Destructor**********************************************************************************
2615  ~Columns() = default;
2617  //**********************************************************************************************
2618 
2619  //**Data access functions***********************************************************************
2622  inline Reference operator()( size_t i, size_t j );
2623  inline ConstReference operator()( size_t i, size_t j ) const;
2624  inline Reference at( size_t i, size_t j );
2625  inline ConstReference at( size_t i, size_t j ) const;
2626  inline Iterator begin ( size_t j );
2627  inline ConstIterator begin ( size_t j ) const;
2628  inline ConstIterator cbegin( size_t j ) const;
2629  inline Iterator end ( size_t j );
2630  inline ConstIterator end ( size_t j ) const;
2631  inline ConstIterator cend ( size_t j ) const;
2633  //**********************************************************************************************
2634 
2635  //**Assignment operators************************************************************************
2638  inline Columns& operator=( initializer_list< initializer_list<ElementType> > list );
2639  inline Columns& operator=( const Columns& rhs );
2640 
2641  template< typename MT2, bool SO > inline Columns& operator= ( const Matrix<MT2,SO>& rhs );
2642  template< typename MT2, bool SO > inline Columns& operator+=( const Matrix<MT2,SO>& rhs );
2643  template< typename MT2, bool SO > inline Columns& operator-=( const Matrix<MT2,SO>& rhs );
2644  template< typename MT2, bool SO > inline Columns& operator%=( const Matrix<MT2,SO>& rhs );
2646  //**********************************************************************************************
2647 
2648  //**Utility functions***************************************************************************
2651  using DataType::idx;
2652  using DataType::idces;
2653  using DataType::columns;
2654 
2655  inline MT& operand() noexcept;
2656  inline const MT& operand() const noexcept;
2657 
2658  inline size_t rows() const noexcept;
2659  inline size_t capacity() const noexcept;
2660  inline size_t capacity( size_t j ) const noexcept;
2661  inline size_t nonZeros() const;
2662  inline size_t nonZeros( size_t j ) const;
2663  inline void reset();
2664  inline void reset( size_t j );
2665  inline void reserve( size_t nonzeros );
2666  void reserve( size_t j, size_t nonzeros );
2667  inline void trim();
2668  inline void trim( size_t j );
2670  //**********************************************************************************************
2671 
2672  //**Insertion functions*************************************************************************
2675  inline Iterator set ( size_t i, size_t j, const ElementType& value );
2676  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
2677  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
2678  inline void finalize( size_t j );
2680  //**********************************************************************************************
2681 
2682  //**Erase functions*****************************************************************************
2685  inline void erase( size_t i, size_t j );
2686  inline Iterator erase( size_t j, Iterator pos );
2687  inline Iterator erase( size_t j, Iterator first, Iterator last );
2688 
2689  template< typename Pred >
2690  inline void erase( Pred predicate );
2691 
2692  template< typename Pred >
2693  inline void erase( size_t j, Iterator first, Iterator last, Pred predicate );
2695  //**********************************************************************************************
2696 
2697  //**Lookup functions****************************************************************************
2700  inline Iterator find ( size_t i, size_t j );
2701  inline ConstIterator find ( size_t i, size_t j ) const;
2702  inline Iterator lowerBound( size_t i, size_t j );
2703  inline ConstIterator lowerBound( size_t i, size_t j ) const;
2704  inline Iterator upperBound( size_t i, size_t j );
2705  inline ConstIterator upperBound( size_t i, size_t j ) const;
2707  //**********************************************************************************************
2708 
2709  //**Numeric functions***************************************************************************
2712  inline Columns& transpose();
2713  inline Columns& ctranspose();
2714 
2715  template< typename Other > inline Columns& scale( const Other& scalar );
2717  //**********************************************************************************************
2718 
2719  //**Expression template evaluation functions****************************************************
2722  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
2723  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
2724 
2725  inline bool canSMPAssign() const noexcept;
2726 
2727  template< typename MT2, bool SO > inline void assign ( const DenseMatrix<MT2,SO>& rhs );
2728  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,false>& rhs );
2729  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,true>& rhs );
2730  template< typename MT2, bool SO > inline void addAssign ( const Matrix<MT2,SO>& rhs );
2731  template< typename MT2, bool SO > inline void subAssign ( const Matrix<MT2,SO>& rhs );
2732  template< typename MT2, bool SO > inline void schurAssign( const Matrix<MT2,SO>& rhs );
2734  //**********************************************************************************************
2735 
2736  private:
2737  //**Member variables****************************************************************************
2740  Operand matrix_;
2741 
2742  //**********************************************************************************************
2743 
2744  //**Compile time checks*************************************************************************
2754  //**********************************************************************************************
2755 };
2757 //*************************************************************************************************
2758 
2759 
2760 
2761 
2762 //=================================================================================================
2763 //
2764 // CONSTRUCTORS
2765 //
2766 //=================================================================================================
2767 
2768 //*************************************************************************************************
2781 template< typename MT // Type of the sparse matrix
2782  , typename... CCAs > // Compile time column arguments
2783 template< typename... RCAs > // Runtime column arguments
2784 inline Columns<MT,false,false,false,CCAs...>::Columns( MT& matrix, RCAs... args )
2785  : DataType( args... ) // Base class initialization
2786  , matrix_ ( matrix ) // The matrix containing the columns
2787 {
2788  if( !Contains_v< TypeList<RCAs...>, Unchecked > ) {
2789  for( size_t j=0UL; j<columns(); ++j ) {
2790  if( matrix_.columns() <= idx(j) ) {
2791  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
2792  }
2793  }
2794  }
2795 }
2797 //*************************************************************************************************
2798 
2799 
2800 
2801 
2802 //=================================================================================================
2803 //
2804 // DATA ACCESS FUNCTIONS
2805 //
2806 //=================================================================================================
2807 
2808 //*************************************************************************************************
2819 template< typename MT // Type of the sparse matrix
2820  , typename... CCAs > // Compile time column arguments
2821 inline typename Columns<MT,false,false,false,CCAs...>::Reference
2822  Columns<MT,false,false,false,CCAs...>::operator()( size_t i, size_t j )
2823 {
2824  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
2825  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
2826 
2827  return matrix_(i,idx(j));
2828 }
2830 //*************************************************************************************************
2831 
2832 
2833 //*************************************************************************************************
2844 template< typename MT // Type of the sparse matrix
2845  , typename... CCAs > // Compile time column arguments
2846 inline typename Columns<MT,false,false,false,CCAs...>::ConstReference
2847  Columns<MT,false,false,false,CCAs...>::operator()( size_t i, size_t j ) const
2848 {
2849  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
2850  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
2851 
2852  return const_cast<const MT&>( matrix_ )(i,idx(j));
2853 }
2855 //*************************************************************************************************
2856 
2857 
2858 //*************************************************************************************************
2870 template< typename MT // Type of the sparse matrix
2871  , typename... CCAs > // Compile time column arguments
2872 inline typename Columns<MT,false,false,false,CCAs...>::Reference
2873  Columns<MT,false,false,false,CCAs...>::at( size_t i, size_t j )
2874 {
2875  if( i >= rows() ) {
2876  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
2877  }
2878  if( j >= columns() ) {
2879  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
2880  }
2881  return (*this)(i,j);
2882 }
2884 //*************************************************************************************************
2885 
2886 
2887 //*************************************************************************************************
2899 template< typename MT // Type of the sparse matrix
2900  , typename... CCAs > // Compile time column arguments
2901 inline typename Columns<MT,false,false,false,CCAs...>::ConstReference
2902  Columns<MT,false,false,false,CCAs...>::at( size_t i, size_t j ) const
2903 {
2904  if( i >= rows() ) {
2905  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
2906  }
2907  if( j >= columns() ) {
2908  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
2909  }
2910  return (*this)(i,j);
2911 }
2913 //*************************************************************************************************
2914 
2915 
2916 //*************************************************************************************************
2925 template< typename MT // Type of the sparse matrix
2926  , typename... CCAs > // Compile time column arguments
2927 inline typename Columns<MT,false,false,false,CCAs...>::Iterator
2929 {
2930  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
2931 
2932  return Iterator( matrix_, 0UL, idx(j) );
2933 }
2935 //*************************************************************************************************
2936 
2937 
2938 //*************************************************************************************************
2947 template< typename MT // Type of the sparse matrix
2948  , typename... CCAs > // Compile time column arguments
2949 inline typename Columns<MT,false,false,false,CCAs...>::ConstIterator
2951 {
2952  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
2953 
2954  return ConstIterator( matrix_, 0UL, idx(j) );
2955 }
2957 //*************************************************************************************************
2958 
2959 
2960 //*************************************************************************************************
2969 template< typename MT // Type of the sparse matrix
2970  , typename... CCAs > // Compile time column arguments
2971 inline typename Columns<MT,false,false,false,CCAs...>::ConstIterator
2973 {
2974  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
2975 
2976  return ConstIterator( matrix_, 0UL, idx(j) );
2977 }
2979 //*************************************************************************************************
2980 
2981 
2982 //*************************************************************************************************
2991 template< typename MT // Type of the sparse matrix
2992  , typename... CCAs > // Compile time column arguments
2993 inline typename Columns<MT,false,false,false,CCAs...>::Iterator
2995 {
2996  BLAZE_USER_ASSERT( j < columns(), "Invalid row access index" );
2997 
2998  return Iterator( matrix_, rows(), idx(j) );
2999 }
3001 //*************************************************************************************************
3002 
3003 
3004 //*************************************************************************************************
3013 template< typename MT // Type of the sparse matrix
3014  , typename... CCAs > // Compile time column arguments
3015 inline typename Columns<MT,false,false,false,CCAs...>::ConstIterator
3017 {
3018  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3019 
3020  return ConstIterator( matrix_, rows(), idx(j) );
3021 }
3023 //*************************************************************************************************
3024 
3025 
3026 //*************************************************************************************************
3035 template< typename MT // Type of the sparse matrix
3036  , typename... CCAs > // Compile time column arguments
3037 inline typename Columns<MT,false,false,false,CCAs...>::ConstIterator
3039 {
3040  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3041 
3042  return ConstIterator( matrix_, rows(), idx(j) );
3043 }
3045 //*************************************************************************************************
3046 
3047 
3048 
3049 
3050 //=================================================================================================
3051 //
3052 // ASSIGNMENT OPERATORS
3053 //
3054 //=================================================================================================
3055 
3056 //*************************************************************************************************
3072 template< typename MT // Type of the sparse matrix
3073  , typename... CCAs > // Compile time column arguments
3074 inline Columns<MT,false,false,false,CCAs...>&
3075  Columns<MT,false,false,false,CCAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
3076 {
3079 
3080  if( list.size() != rows() ) {
3081  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to column selection" );
3082  }
3083 
3084  const InitializerMatrix<ElementType> tmp( list, columns() );
3085 
3086  if( IsRestricted_v<MT> ) {
3087  for( size_t j=0UL; j<columns(); ++j ) {
3088  if( !tryAssign( matrix_, column( tmp, j, unchecked ), 0UL, j ) ) {
3089  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3090  }
3091  }
3092  }
3093 
3094  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
3095 
3096  smpAssign( left, tmp );
3097 
3098  return *this;
3099 }
3101 //*************************************************************************************************
3102 
3103 
3104 //*************************************************************************************************
3119 template< typename MT // Type of the sparse matrix
3120  , typename... CCAs > // Compile time column arguments
3121 inline Columns<MT,false,false,false,CCAs...>&
3122  Columns<MT,false,false,false,CCAs...>::operator=( const Columns& rhs )
3123 {
3126 
3129 
3130  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && compareIndices( *this, rhs ) ) )
3131  return *this;
3132 
3133  if( rows() != rhs.rows() || columns() != rhs.columns() ) {
3134  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3135  }
3136 
3137  if( IsRestricted_v<MT> ) {
3138  for( size_t j=0UL; j<columns(); ++j ) {
3139  if( !tryAssign( matrix_, column( rhs, j, unchecked ), 0UL, idx(j) ) ) {
3140  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3141  }
3142  }
3143  }
3144 
3145  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
3146 
3147  if( rhs.canAlias( &matrix_ ) ) {
3148  const ResultType tmp( rhs );
3149  left.reset();
3150  smpAssign( left, tmp );
3151  }
3152  else {
3153  left.reset();
3154  smpAssign( left, rhs );
3155  }
3156 
3157  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3158 
3159  return *this;
3160 }
3162 //*************************************************************************************************
3163 
3164 
3165 //*************************************************************************************************
3180 template< typename MT // Type of the sparse matrix
3181  , typename... CCAs > // Compile time column arguments
3182 template< typename MT2 // Type of the right-hand side matrix
3183  , bool SO > // Storage order of the right-hand side matrix
3184 inline Columns<MT,false,false,false,CCAs...>&
3185  Columns<MT,false,false,false,CCAs...>::operator=( const Matrix<MT2,SO>& rhs )
3186 {
3189 
3190  BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( ResultType_t<MT2> );
3191 
3192  if( rows() != (~rhs).rows() || columns() != (~rhs).columns() ) {
3193  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3194  }
3195 
3196  using Right = CompositeType_t<MT2>;
3197  Right right( ~rhs );
3198 
3199  if( IsRestricted_v<MT> ) {
3200  for( size_t j=0UL; j<columns(); ++j ) {
3201  if( !tryAssign( matrix_, column( right, j, unchecked ), 0UL, idx(j) ) ) {
3202  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3203  }
3204  }
3205  }
3206 
3207  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
3208 
3209  if( IsReference_v<Right> && right.canAlias( &matrix_ ) ) {
3210  const ResultType_t<MT2> tmp( right );
3211  if( IsSparseMatrix_v< ResultType_t<MT2> > )
3212  left.reset();
3213  smpAssign( left, tmp );
3214  }
3215  else {
3216  if( IsSparseMatrix_v<MT2> )
3217  left.reset();
3218  smpAssign( left, right );
3219  }
3220 
3221  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3222 
3223  return *this;
3224 }
3226 //*************************************************************************************************
3227 
3228 
3229 //*************************************************************************************************
3243 template< typename MT // Type of the sparse matrix
3244  , typename... CCAs > // Compile time column arguments
3245 template< typename MT2 // Type of the right-hand side matrix
3246  , bool SO > // Storage order of the right-hand side matrix
3247 inline Columns<MT,false,false,false,CCAs...>&
3248  Columns<MT,false,false,false,CCAs...>::operator+=( const Matrix<MT2,SO>& rhs )
3249 {
3252 
3255  BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( ResultType_t<MT2> );
3256 
3257  using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
3258 
3260 
3261  if( rows() != (~rhs).rows() || columns() != (~rhs).columns() ) {
3262  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3263  }
3264 
3265  const AddType tmp( *this + (~rhs) );
3266 
3267  if( IsRestricted_v<MT> ) {
3268  for( size_t j=0UL; j<columns(); ++j ) {
3269  if( !tryAssign( matrix_, column( tmp, j, unchecked ), 0UL, idx(j) ) ) {
3270  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3271  }
3272  }
3273  }
3274 
3275  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
3276 
3277  if( IsSparseMatrix_v<AddType> ) {
3278  left.reset();
3279  }
3280 
3281  smpAssign( left, tmp );
3282 
3283  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3284 
3285  return *this;
3286 }
3288 //*************************************************************************************************
3289 
3290 
3291 //*************************************************************************************************
3305 template< typename MT // Type of the sparse matrix
3306  , typename... CCAs > // Compile time column arguments
3307 template< typename MT2 // Type of the right-hand side matrix
3308  , bool SO > // Storage order of the right-hand side matrix
3309 inline Columns<MT,false,false,false,CCAs...>&
3310  Columns<MT,false,false,false,CCAs...>::operator-=( const Matrix<MT2,SO>& rhs )
3311 {
3314 
3317  BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( ResultType_t<MT2> );
3318 
3319  using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
3320 
3322 
3323  if( rows() != (~rhs).rows() || columns() != (~rhs).columns() ) {
3324  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3325  }
3326 
3327  const SubType tmp( *this - (~rhs) );
3328 
3329  if( IsRestricted_v<MT> ) {
3330  for( size_t j=0UL; j<columns(); ++j ) {
3331  if( !tryAssign( matrix_, column( tmp, j, unchecked ), 0UL, idx(j) ) ) {
3332  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3333  }
3334  }
3335  }
3336 
3337  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
3338 
3339  if( IsSparseMatrix_v<SubType> ) {
3340  left.reset();
3341  }
3342 
3343  smpAssign( left, tmp );
3344 
3345  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3346 
3347  return *this;
3348 }
3350 //*************************************************************************************************
3351 
3352 
3353 //*************************************************************************************************
3367 template< typename MT // Type of the sparse matrix
3368  , typename... CCAs > // Compile time column arguments
3369 template< typename MT2 // Type of the right-hand side matrix
3370  , bool SO > // Storage order of the right-hand side matrix
3371 inline Columns<MT,false,false,false,CCAs...>&
3372  Columns<MT,false,false,false,CCAs...>::operator%=( const Matrix<MT2,SO>& rhs )
3373 {
3376 
3379  BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( ResultType_t<MT2> );
3380 
3381  using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
3382 
3384 
3385  if( rows() != (~rhs).rows() || columns() != (~rhs).columns() ) {
3386  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3387  }
3388 
3389  const SchurType tmp( *this % (~rhs) );
3390 
3391  if( IsRestricted_v<MT> ) {
3392  for( size_t j=0UL; j<columns(); ++j ) {
3393  if( !tryAssign( matrix_, column( tmp, j, unchecked ), 0UL, idx(j) ) ) {
3394  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3395  }
3396  }
3397  }
3398 
3399  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
3400 
3401  if( IsSparseMatrix_v<SchurType> ) {
3402  left.reset();
3403  }
3404 
3405  smpAssign( left, tmp );
3406 
3407  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3408 
3409  return *this;
3410 }
3412 //*************************************************************************************************
3413 
3414 
3415 
3416 
3417 //=================================================================================================
3418 //
3419 // UTILITY FUNCTIONS
3420 //
3421 //=================================================================================================
3422 
3423 //*************************************************************************************************
3429 template< typename MT // Type of the sparse matrix
3430  , typename... CCAs > // Compile time column arguments
3431 inline MT& Columns<MT,false,false,false,CCAs...>::operand() noexcept
3432 {
3433  return matrix_;
3434 }
3436 //*************************************************************************************************
3437 
3438 
3439 //*************************************************************************************************
3445 template< typename MT // Type of the sparse matrix
3446  , typename... CCAs > // Compile time column arguments
3447 inline const MT& Columns<MT,false,false,false,CCAs...>::operand() const noexcept
3448 {
3449  return matrix_;
3450 }
3452 //*************************************************************************************************
3453 
3454 
3455 //*************************************************************************************************
3461 template< typename MT // Type of the sparse matrix
3462  , typename... CCAs > // Compile time column arguments
3463 inline size_t Columns<MT,false,false,false,CCAs...>::rows() const noexcept
3464 {
3465  return matrix_.rows();
3466 }
3468 //*************************************************************************************************
3469 
3470 
3471 //*************************************************************************************************
3477 template< typename MT // Type of the sparse matrix
3478  , typename... CCAs > // Compile time column arguments
3479 inline size_t Columns<MT,false,false,false,CCAs...>::capacity() const noexcept
3480 {
3481  return rows() * columns();
3482 }
3484 //*************************************************************************************************
3485 
3486 
3487 //*************************************************************************************************
3496 template< typename MT // Type of the sparse matrix
3497  , typename... CCAs > // Compile time column arguments
3498 inline size_t Columns<MT,false,false,false,CCAs...>::capacity( size_t j ) const noexcept
3499 {
3500  UNUSED_PARAMETER( j );
3501 
3502  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3503 
3504  return rows();
3505 }
3507 //*************************************************************************************************
3508 
3509 
3510 //*************************************************************************************************
3516 template< typename MT // Type of the sparse matrix
3517  , typename... CCAs > // Compile time column arguments
3519 {
3520  size_t nonzeros( 0UL );
3521 
3522  for( size_t i=0UL; i<rows(); ++i ) {
3523  const auto end( matrix_.end( i ) );
3524  for( size_t j=0UL; j<columns(); ++j ) {
3525  auto pos = matrix_.find( i, idx(j) );
3526  if( pos != end ) {
3527  ++nonzeros;
3528  }
3529  }
3530  }
3531 
3532  return nonzeros;
3533 }
3535 //*************************************************************************************************
3536 
3537 
3538 //*************************************************************************************************
3547 template< typename MT // Type of the sparse matrix
3548  , typename... CCAs > // Compile time column arguments
3549 inline size_t Columns<MT,false,false,false,CCAs...>::nonZeros( size_t j ) const
3550 {
3551  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3552 
3553  size_t counter( 0UL );
3554 
3555  const ConstIterator last( end(j) );
3556  for( ConstIterator element=begin(j); element!=last; ++element ) {
3557  ++counter;
3558  }
3559 
3560  return counter;
3561 }
3563 //*************************************************************************************************
3564 
3565 
3566 //*************************************************************************************************
3572 template< typename MT // Type of the sparse matrix
3573  , typename... CCAs > // Compile time column arguments
3575 {
3576  for( size_t j=0UL; j<columns(); ++j ) {
3577  reset( j );
3578  }
3579 }
3581 //*************************************************************************************************
3582 
3583 
3584 //*************************************************************************************************
3594 template< typename MT // Type of the sparse matrix
3595  , typename... CCAs > // Compile time column arguments
3596 inline void Columns<MT,false,false,false,CCAs...>::reset( size_t j )
3597 {
3598  const size_t index( idx(j) );
3599 
3600  const size_t ibegin( ( IsLower_v<MT> )
3601  ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
3602  ?( index+1UL )
3603  :( index ) )
3604  :( 0UL ) );
3605  const size_t iend ( ( IsUpper_v<MT> )
3606  ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
3607  ?( index )
3608  :( index+1UL ) )
3609  :( rows() ) );
3610 
3611  for( size_t i=ibegin; i<iend; ++i ) {
3612  matrix_.erase( i, index );
3613  }
3614 }
3616 //*************************************************************************************************
3617 
3618 
3619 //*************************************************************************************************
3630 template< typename MT // Type of the sparse matrix
3631  , typename... CCAs > // Compile time column arguments
3632 inline void Columns<MT,false,false,false,CCAs...>::reserve( size_t nonzeros )
3633 {
3634  UNUSED_PARAMETER( nonzeros );
3635 
3636  return;
3637 }
3639 //*************************************************************************************************
3640 
3641 
3642 //*************************************************************************************************
3655 template< typename MT // Type of the sparse matrix
3656  , typename... CCAs > // Compile time column arguments
3657 void Columns<MT,false,false,false,CCAs...>::reserve( size_t j, size_t nonzeros )
3658 {
3659  UNUSED_PARAMETER( j, nonzeros );
3660 
3661  return;
3662 }
3664 //*************************************************************************************************
3665 
3666 
3667 //*************************************************************************************************
3677 template< typename MT // Type of the sparse matrix
3678  , typename... CCAs > // Compile time column arguments
3679 void Columns<MT,false,false,false,CCAs...>::trim()
3680 {
3681  return;
3682 }
3684 //*************************************************************************************************
3685 
3686 
3687 //*************************************************************************************************
3698 template< typename MT // Type of the sparse matrix
3699  , typename... CCAs > // Compile time column arguments
3700 void Columns<MT,false,false,false,CCAs...>::trim( size_t j )
3701 {
3702  UNUSED_PARAMETER( j );
3703 
3704  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3705 
3706  return;
3707 }
3709 //*************************************************************************************************
3710 
3711 
3712 
3713 
3714 //=================================================================================================
3715 //
3716 // INSERTION FUNCTIONS
3717 //
3718 //=================================================================================================
3719 
3720 //*************************************************************************************************
3733 template< typename MT // Type of the sparse matrix
3734  , typename... CCAs > // Compile time column arguments
3735 inline typename Columns<MT,false,false,false,CCAs...>::Iterator
3736  Columns<MT,false,false,false,CCAs...>::set( size_t i, size_t j, const ElementType& value )
3737 {
3738  return Iterator( matrix_, i, idx(j), matrix_.set( i, idx(j), value ) );
3739 }
3741 //*************************************************************************************************
3742 
3743 
3744 //*************************************************************************************************
3758 template< typename MT // Type of the sparse matrix
3759  , typename... CCAs > // Compile time column arguments
3760 inline typename Columns<MT,false,false,false,CCAs...>::Iterator
3761  Columns<MT,false,false,false,CCAs...>::insert( size_t i, size_t j, const ElementType& value )
3762 {
3763  return Iterator( matrix_, i, idx(j), matrix_.insert( i, idx(j), value ) );
3764 }
3766 //*************************************************************************************************
3767 
3768 
3769 //*************************************************************************************************
3813 template< typename MT // Type of the sparse matrix
3814  , typename... CCAs > // Compile time column arguments
3815 inline void Columns<MT,false,false,false,CCAs...>::append( size_t i, size_t j, const ElementType& value, bool check )
3816 {
3817  if( !check || !isDefault<strict>( value ) )
3818  matrix_.insert( i, idx(j), value );
3819 }
3821 //*************************************************************************************************
3822 
3823 
3824 //*************************************************************************************************
3838 template< typename MT // Type of the sparse matrix
3839  , typename... CCAs > // Compile time column arguments
3840 inline void Columns<MT,false,false,false,CCAs...>::finalize( size_t j )
3841 {
3842  UNUSED_PARAMETER( j );
3843 
3844  return;
3845 }
3847 //*************************************************************************************************
3848 
3849 
3850 
3851 
3852 //=================================================================================================
3853 //
3854 // ERASE FUNCTIONS
3855 //
3856 //=================================================================================================
3857 
3858 //*************************************************************************************************
3868 template< typename MT // Type of the sparse matrix
3869  , typename... CCAs > // Compile time column arguments
3870 inline void Columns<MT,false,false,false,CCAs...>::erase( size_t i, size_t j )
3871 {
3872  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
3873  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3874 
3875  matrix_.erase( i, idx(j) );
3876 }
3878 //*************************************************************************************************
3879 
3880 
3881 //*************************************************************************************************
3891 template< typename MT // Type of the sparse matrix
3892  , typename... CCAs > // Compile time column arguments
3893 inline typename Columns<MT,false,false,false,CCAs...>::Iterator
3894  Columns<MT,false,false,false,CCAs...>::erase( size_t j, Iterator pos )
3895 {
3896  const size_t row( pos.row_ );
3897 
3898  if( row == rows() )
3899  return pos;
3900 
3901  matrix_.erase( row, pos.pos_ );
3902  return Iterator( matrix_, row+1UL, idx(j) );
3903 }
3905 //*************************************************************************************************
3906 
3907 
3908 //*************************************************************************************************
3919 template< typename MT // Type of the sparse matrix
3920  , typename... CCAs > // Compile time column arguments
3921 inline typename Columns<MT,false,false,false,CCAs...>::Iterator
3922  Columns<MT,false,false,false,CCAs...>::erase( size_t j, Iterator first, Iterator last )
3923 {
3924  UNUSED_PARAMETER( j );
3925 
3926  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3927 
3928  for( ; first!=last; ++first ) {
3929  matrix_.erase( first.row_, first.pos_ );
3930  }
3931 
3932  return last;
3933 }
3935 //*************************************************************************************************
3936 
3937 
3938 //*************************************************************************************************
3961 template< typename MT // Type of the sparse matrix
3962  , typename... CCAs > // Compile time column arguments
3963 template< typename Pred > // Type of the unary predicate
3964 inline void Columns<MT,false,false,false,CCAs...>::erase( Pred predicate )
3965 {
3966  for( size_t j=0UL; j<columns(); ++j ) {
3967  for( Iterator element=begin(j); element!=end(j); ++element ) {
3968  if( predicate( element->value() ) )
3969  matrix_.erase( element.row_, element.pos_ );
3970  }
3971  }
3972 }
3974 //*************************************************************************************************
3975 
3976 
3977 //*************************************************************************************************
4004 template< typename MT // Type of the sparse matrix
4005  , typename... CCAs > // Compile time column arguments
4006 template< typename Pred > // Type of the unary predicate
4007 inline void Columns<MT,false,false,false,CCAs...>::erase( size_t j, Iterator first, Iterator last, Pred predicate )
4008 {
4009  UNUSED_PARAMETER( j );
4010 
4011  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4012 
4013  for( ; first!=last; ++first ) {
4014  if( predicate( first->value() ) )
4015  matrix_.erase( first.row_, first.pos_ );
4016  }
4017 }
4019 //*************************************************************************************************
4020 
4021 
4022 
4023 
4024 //=================================================================================================
4025 //
4026 // LOOKUP FUNCTIONS
4027 //
4028 //=================================================================================================
4029 
4030 //*************************************************************************************************
4045 template< typename MT // Type of the sparse matrix
4046  , typename... CCAs > // Compile time column arguments
4047 inline typename Columns<MT,false,false,false,CCAs...>::Iterator
4048  Columns<MT,false,false,false,CCAs...>::find( size_t i, size_t j )
4049 {
4050  const size_t index( idx(j) );
4051  const Iterator_t<MT> pos( matrix_.find( i, index ) );
4052 
4053  if( pos != matrix_.end( i ) )
4054  return Iterator( matrix_, i, index, pos );
4055  else
4056  return end( j );
4057 }
4059 //*************************************************************************************************
4060 
4061 
4062 //*************************************************************************************************
4077 template< typename MT // Type of the sparse matrix
4078  , typename... CCAs > // Compile time column arguments
4079 inline typename Columns<MT,false,false,false,CCAs...>::ConstIterator
4080  Columns<MT,false,false,false,CCAs...>::find( size_t i, size_t j ) const
4081 {
4082  const size_t index( idx(j) );
4083  const ConstIterator_t<MT> pos( matrix_.find( i, index ) );
4084 
4085  if( pos != matrix_.end( i ) )
4086  return ConstIterator( matrix_, i, index, pos );
4087  else
4088  return end( j );
4089 }
4091 //*************************************************************************************************
4092 
4093 
4094 //*************************************************************************************************
4108 template< typename MT // Type of the sparse matrix
4109  , typename... CCAs > // Compile time column arguments
4110 inline typename Columns<MT,false,false,false,CCAs...>::Iterator
4111  Columns<MT,false,false,false,CCAs...>::lowerBound( size_t i, size_t j )
4112 {
4113  const size_t index( idx(j) );
4114 
4115  for( ; i<rows(); ++i )
4116  {
4117  const Iterator_t<MT> pos( matrix_.find( i, index ) );
4118 
4119  if( pos != matrix_.end( i ) )
4120  return Iterator( matrix_, i, index, pos );
4121  }
4122 
4123  return end( j );
4124 }
4126 //*************************************************************************************************
4127 
4128 
4129 //*************************************************************************************************
4143 template< typename MT // Type of the sparse matrix
4144  , typename... CCAs > // Compile time column arguments
4145 inline typename Columns<MT,false,false,false,CCAs...>::ConstIterator
4146  Columns<MT,false,false,false,CCAs...>::lowerBound( size_t i, size_t j ) const
4147 {
4148  const size_t index( idx(j) );
4149 
4150  for( ; i<rows(); ++i )
4151  {
4152  const ConstIterator_t<MT> pos( matrix_.find( i, index ) );
4153 
4154  if( pos != matrix_.end( i ) )
4155  return ConstIterator( matrix_, i, index, pos );
4156  }
4157 
4158  return end( j );
4159 }
4161 //*************************************************************************************************
4162 
4163 
4164 //*************************************************************************************************
4178 template< typename MT // Type of the sparse matrix
4179  , typename... CCAs > // Compile time column arguments
4180 inline typename Columns<MT,false,false,false,CCAs...>::Iterator
4181  Columns<MT,false,false,false,CCAs...>::upperBound( size_t i, size_t j )
4182 {
4183  return lowerBound( i+1UL, j );
4184 }
4186 //*************************************************************************************************
4187 
4188 
4189 //*************************************************************************************************
4203 template< typename MT // Type of the sparse matrix
4204  , typename... CCAs > // Compile time column arguments
4205 inline typename Columns<MT,false,false,false,CCAs...>::ConstIterator
4206  Columns<MT,false,false,false,CCAs...>::upperBound( size_t i, size_t j ) const
4207 {
4208  return lowerBound( i+1UL, j );
4209 }
4211 //*************************************************************************************************
4212 
4213 
4214 
4215 
4216 //=================================================================================================
4217 //
4218 // NUMERIC FUNCTIONS
4219 //
4220 //=================================================================================================
4221 
4222 //*************************************************************************************************
4235 template< typename MT // Type of the sparse matrix
4236  , typename... CCAs > // Compile time column arguments
4237 inline Columns<MT,false,false,false,CCAs...>&
4239 {
4242 
4243  if( rows() != columns() ) {
4244  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose of a non-quadratic matrix" );
4245  }
4246 
4247  const ResultType tmp( trans( *this ) );
4248 
4249  if( IsRestricted_v<MT> ) {
4250  for( size_t j=0UL; j<columns(); ++j ) {
4251  if( !tryAssign( matrix_, column( tmp, j, unchecked ), 0UL, idx(j) ) ) {
4252  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose operation" );
4253  }
4254  }
4255  }
4256 
4257  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
4258 
4259  left.reset();
4260  smpAssign( left, tmp );
4261 
4262  return *this;
4263 }
4265 //*************************************************************************************************
4266 
4267 
4268 //*************************************************************************************************
4281 template< typename MT // Type of the sparse matrix
4282  , typename... CCAs > // Compile time column arguments
4283 inline Columns<MT,false,false,false,CCAs...>&
4285 {
4288 
4289  if( rows() != columns() ) {
4290  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose of a non-quadratic matrix" );
4291  }
4292 
4293  const ResultType tmp( ctrans( *this ) );
4294 
4295  if( IsRestricted_v<MT> ) {
4296  for( size_t j=0UL; j<columns(); ++j ) {
4297  if( !tryAssign( matrix_, column( tmp, j, unchecked ), 0UL, idx(j) ) ) {
4298  BLAZE_THROW_LOGIC_ERROR( "Invalid transpose operation" );
4299  }
4300  }
4301  }
4302 
4303  BLAZE_DECLTYPE_AUTO( left, derestrict( *this ) );
4304 
4305  left.reset();
4306  smpAssign( left, tmp );
4307 
4308  return *this;
4309 }
4311 //*************************************************************************************************
4312 
4313 
4314 //*************************************************************************************************
4327 template< typename MT // Type of the sparse matrix
4328  , typename... CCAs > // Compile time column arguments
4329 template< typename Other > // Data type of the scalar value
4330 inline Columns<MT,false,false,false,CCAs...>&
4331  Columns<MT,false,false,false,CCAs...>::scale( const Other& scalar )
4332 {
4336 
4337  for( size_t i=0UL; i<rows(); ++i ) {
4338  const auto end( matrix_.end( i ) );
4339  for( size_t j=0UL; j<columns(); ++j ) {
4340  auto pos = matrix_.find( i, idx(j) );
4341  if( pos != end ) {
4342  pos->value() *= scalar;
4343  }
4344  }
4345  }
4346 
4347  return *this;
4348 }
4350 //*************************************************************************************************
4351 
4352 
4353 
4354 
4355 //=================================================================================================
4356 //
4357 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
4358 //
4359 //=================================================================================================
4360 
4361 //*************************************************************************************************
4372 template< typename MT // Type of the sparse matrix
4373  , typename... CCAs > // Compile time column arguments
4374 template< typename Other > // Data type of the foreign expression
4375 inline bool Columns<MT,false,false,false,CCAs...>::canAlias( const Other* alias ) const noexcept
4376 {
4377  return matrix_.isAliased( alias );
4378 }
4380 //*************************************************************************************************
4381 
4382 
4383 //*************************************************************************************************
4394 template< typename MT // Type of the sparse matrix
4395  , typename... CCAs > // Compile time column arguments
4396 template< typename Other > // Data type of the foreign expression
4397 inline bool Columns<MT,false,false,false,CCAs...>::isAliased( const Other* alias ) const noexcept
4398 {
4399  return matrix_.isAliased( alias );
4400 }
4402 //*************************************************************************************************
4403 
4404 
4405 //*************************************************************************************************
4416 template< typename MT // Type of the sparse matrix
4417  , typename... CCAs > // Compile time column arguments
4418 inline bool Columns<MT,false,false,false,CCAs...>::canSMPAssign() const noexcept
4419 {
4420  return false;
4421 }
4423 //*************************************************************************************************
4424 
4425 
4426 //*************************************************************************************************
4438 template< typename MT // Type of the sparse matrix
4439  , typename... CCAs > // Compile time column arguments
4440 template< typename MT2 // Type of the right-hand side dense matrix
4441  , bool SO > // Storage order of the right-hand side dense matrix
4442 inline void Columns<MT,false,false,false,CCAs...>::assign( const DenseMatrix<MT2,SO>& rhs )
4443 {
4446 
4447  using RT = If_t< IsComputation_v<MT2>, ElementType_t<MT>, const ElementType_t<MT2>& >;
4448 
4449  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
4450  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
4451 
4452  for( size_t i=0UL; i<rows(); ++i ) {
4453  for( size_t j=0UL; j<columns(); ++j ) {
4454  RT value( (~rhs)(i,j) );
4455  if( !isDefault<strict>( value ) )
4456  matrix_.set( i, idx(j), std::move( value ) );
4457  else matrix_.erase( i, idx(j) );
4458  }
4459  }
4460 }
4462 //*************************************************************************************************
4463 
4464 
4465 //*************************************************************************************************
4477 template< typename MT // Type of the sparse matrix
4478  , typename... CCAs > // Compile time column arguments
4479 template< typename MT2 > // Type of the right-hand side sparse matrix
4480 inline void Columns<MT,false,false,false,CCAs...>::assign( const SparseMatrix<MT2,false>& rhs )
4481 {
4484 
4486 
4487  using RT = If_t< IsComputation_v<MT2>, ElementType_t<MT>, const ElementType_t<MT2>& >;
4488 
4489  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
4490  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
4491  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
4492 
4493  for( size_t i=0UL; i<rows(); ++i ) {
4494  for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).end(i); ++element ) {
4495  RT value( element->value() );
4496  if( !isDefault<strict>( value ) )
4497  matrix_.set( i, idx( element->index() ), std::move( value ) );
4498  else matrix_.erase( i, idx( element->index() ) );
4499  }
4500  }
4501 }
4503 //*************************************************************************************************
4504 
4505 
4506 //*************************************************************************************************
4518 template< typename MT // Type of the sparse matrix
4519  , typename... CCAs > // Compile time column arguments
4520 template< typename MT2 > // Type of the right-hand side sparse matrix
4521 inline void Columns<MT,false,false,false,CCAs...>::assign( const SparseMatrix<MT2,true>& rhs )
4522 {
4525 
4526  using RT = If_t< IsComputation_v<MT2>, ElementType_t<MT>, const ElementType_t<MT2>& >;
4527 
4528  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
4529  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
4530  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
4531 
4532  for( size_t j=0UL; j<columns(); ++j ) {
4533  const size_t index( idx(j) );
4534  for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).end(j); ++element ) {
4535  RT value( element->value() );
4536  if( !isDefault<strict>( value ) )
4537  matrix_.set( element->index(), index, std::move( value ) );
4538  else matrix_.erase( element->index(), index );
4539  }
4540  }
4541 }
4543 //*************************************************************************************************
4544 
4545 
4546 //*************************************************************************************************
4558 template< typename MT // Type of the sparse matrix
4559  , typename... CCAs > // Compile time column arguments
4560 template< typename MT2 // Type of the right-hand side matrix
4561  , bool SO > // Storage order of the right-hand side matrix
4562 inline void Columns<MT,false,false,false,CCAs...>::addAssign( const Matrix<MT2,SO>& rhs )
4563 {
4566 
4567  using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
4568 
4570 
4571  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
4572  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
4573 
4574  const AddType tmp( serial( *this + (~rhs) ) );
4575  reset();
4576  assign( tmp );
4577 }
4579 //*************************************************************************************************
4580 
4581 
4582 //*************************************************************************************************
4594 template< typename MT // Type of the sparse matrix
4595  , typename... CCAs > // Compile time column arguments
4596 template< typename MT2 // Type of the right-hand side matrix
4597  , bool SO > // Storage order of the right-hand side matrix
4598 inline void Columns<MT,false,false,false,CCAs...>::subAssign( const Matrix<MT2,SO>& rhs )
4599 {
4602 
4603  using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
4604 
4606 
4607  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
4608  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
4609 
4610  const SubType tmp( serial( *this - (~rhs) ) );
4611  reset();
4612  assign( tmp );
4613 }
4615 //*************************************************************************************************
4616 
4617 
4618 //*************************************************************************************************
4630 template< typename MT // Type of the sparse matrix
4631  , typename... CCAs > // Compile time column arguments
4632 template< typename MT2 // Type of the right-hand side matrix
4633  , bool SO > // Storage order of the right-hand side matrix
4634 inline void Columns<MT,false,false,false,CCAs...>::schurAssign( const Matrix<MT2,SO>& rhs )
4635 {
4638 
4639  using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
4640 
4643 
4644  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
4645  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
4646 
4647  const SchurType tmp( serial( *this % (~rhs) ) );
4648  reset();
4649  assign( tmp );
4650 }
4652 //*************************************************************************************************
4653 
4654 
4655 
4656 
4657 
4658 
4659 
4660 
4661 //=================================================================================================
4662 //
4663 // CLASS TEMPLATE SPECIALIZATION FOR SYMMETRIC ROW-MAJOR SPARSE MATRICES
4664 //
4665 //=================================================================================================
4666 
4667 //*************************************************************************************************
4675 template< typename MT // Type of the sparse matrix
4676  , typename... CCAs > // Compile time column arguments
4677 class Columns<MT,false,false,true,CCAs...>
4678  : public View< SparseMatrix< Columns<MT,false,false,true,CCAs...>, true > >
4679  , private ColumnsData<CCAs...>
4680 {
4681  private:
4682  //**Type definitions****************************************************************************
4683  using DataType = ColumnsData<CCAs...>;
4684  using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
4685  //**********************************************************************************************
4686 
4687  //**Compile time flags**************************************************************************
4688  static constexpr size_t N = sizeof...( CCAs );
4689  //**********************************************************************************************
4690 
4691  public:
4692  //**Type definitions****************************************************************************
4694  using This = Columns<MT,false,false,true,CCAs...>;
4695 
4696  using BaseType = SparseMatrix<This,true>;
4697  using ViewedType = MT;
4698  using ResultType = ColumnsTrait_t<MT,N>;
4699  using OppositeType = OppositeType_t<ResultType>;
4700  using TransposeType = TransposeType_t<ResultType>;
4701  using ElementType = ElementType_t<MT>;
4702  using ReturnType = ReturnType_t<MT>;
4703  using CompositeType = const Columns&;
4704 
4706  using ConstReference = ConstReference_t<MT>;
4707 
4709  using Reference = If_t< IsConst_v<MT>, ConstReference, Reference_t<MT> >;
4710 
4712  using ConstIterator = ConstIterator_t<MT>;
4713 
4715  using Iterator = If_t< IsConst_v<MT>, ConstIterator, Iterator_t<MT> >;
4716  //**********************************************************************************************
4717 
4718  //**Compilation flags***************************************************************************
4720  static constexpr bool smpAssignable = MT::smpAssignable;
4721  //**********************************************************************************************
4722 
4723  //**Constructors********************************************************************************
4726  template< typename... RCAs >
4727  explicit inline Columns( MT& matrix, RCAs... args );
4728 
4729  Columns( const Columns& ) = default;
4730  Columns( Columns&& ) = default;
4732  //**********************************************************************************************
4733 
4734  //**Destructor**********************************************************************************
4737  ~Columns() = default;
4739  //**********************************************************************************************
4740 
4741  //**Data access functions***********************************************************************
4744  inline Reference operator()( size_t i, size_t j );
4745  inline ConstReference operator()( size_t i, size_t j ) const;
4746  inline Reference at( size_t i, size_t j );
4747  inline ConstReference at( size_t i, size_t j ) const;
4748  inline Iterator begin ( size_t j );
4749  inline ConstIterator begin ( size_t j ) const;
4750  inline ConstIterator cbegin( size_t j ) const;
4751  inline Iterator end ( size_t j );
4752  inline ConstIterator end ( size_t j ) const;
4753  inline ConstIterator cend ( size_t j ) const;
4755  //**********************************************************************************************
4756 
4757  //**Assignment operators************************************************************************
4760  Columns& operator=( const Columns& ) = delete;
4762  //**********************************************************************************************
4763 
4764  //**Utility functions***************************************************************************
4767  using DataType::idx;
4768  using DataType::idces;
4769  using DataType::columns;
4770 
4771  inline MT& operand() noexcept;
4772  inline const MT& operand() const noexcept;
4773 
4774  inline size_t rows() const noexcept;
4775  inline size_t capacity() const noexcept;
4776  inline size_t capacity( size_t j ) const noexcept;
4777  inline size_t nonZeros() const;
4778  inline size_t nonZeros( size_t j ) const;
4779  inline void reset();
4780  inline void reset( size_t j );
4781  inline void reserve( size_t nonzeros );
4782  void reserve( size_t j, size_t nonzeros );
4783  inline void trim();
4784  inline void trim( size_t j );
4786  //**********************************************************************************************
4787 
4788  //**Insertion functions*************************************************************************
4791  inline Iterator set ( size_t i, size_t j, const ElementType& value );
4792  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
4793  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
4794  inline void finalize( size_t j );
4796  //**********************************************************************************************
4797 
4798  //**Erase functions*****************************************************************************
4801  inline void erase( size_t i, size_t j );
4802  inline Iterator erase( size_t j, Iterator pos );
4803  inline Iterator erase( size_t j, Iterator first, Iterator last );
4804 
4805  template< typename Pred >
4806  inline void erase( Pred predicate );
4807 
4808  template< typename Pred >
4809  inline void erase( size_t j, Iterator first, Iterator last, Pred predicate );
4811  //**********************************************************************************************
4812 
4813  //**Lookup functions****************************************************************************
4816  inline Iterator find ( size_t i, size_t j );
4817  inline ConstIterator find ( size_t i, size_t j ) const;
4818  inline Iterator lowerBound( size_t i, size_t j );
4819  inline ConstIterator lowerBound( size_t i, size_t j ) const;
4820  inline Iterator upperBound( size_t i, size_t j );
4821  inline ConstIterator upperBound( size_t i, size_t j ) const;
4823  //**********************************************************************************************
4824 
4825  //**Expression template evaluation functions****************************************************
4828  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
4829  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
4830 
4831  inline bool canSMPAssign() const noexcept;
4833  //**********************************************************************************************
4834 
4835  private:
4836  //**Member variables****************************************************************************
4839  Operand matrix_;
4840 
4841  //**********************************************************************************************
4842 
4843  //**Compile time checks*************************************************************************
4853  //**********************************************************************************************
4854 };
4856 //*************************************************************************************************
4857 
4858 
4859 
4860 
4861 //=================================================================================================
4862 //
4863 // CONSTRUCTORS
4864 //
4865 //=================================================================================================
4866 
4867 //*************************************************************************************************
4880 template< typename MT // Type of the sparse matrix
4881  , typename... CCAs > // Compile time column arguments
4882 template< typename... RCAs > // Runtime column arguments
4883 inline Columns<MT,false,false,true,CCAs...>::Columns( MT& matrix, RCAs... args )
4884  : DataType( args... ) // Base class initialization
4885  , matrix_ ( matrix ) // The matrix containing the columns
4886 {
4887  if( !Contains_v< TypeList<RCAs...>, Unchecked > ) {
4888  for( size_t j=0UL; j<columns(); ++j ) {
4889  if( matrix_.columns() <= idx(j) ) {
4890  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
4891  }
4892  }
4893  }
4894 }
4896 //*************************************************************************************************
4897 
4898 
4899 
4900 
4901 //=================================================================================================
4902 //
4903 // DATA ACCESS FUNCTIONS
4904 //
4905 //=================================================================================================
4906 
4907 //*************************************************************************************************
4918 template< typename MT // Type of the sparse matrix
4919  , typename... CCAs > // Compile time column arguments
4920 inline typename Columns<MT,false,false,true,CCAs...>::Reference
4921  Columns<MT,false,false,true,CCAs...>::operator()( size_t i, size_t j )
4922 {
4923  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
4924  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4925 
4926  return matrix_(idx(j),i);
4927 }
4929 //*************************************************************************************************
4930 
4931 
4932 //*************************************************************************************************
4943 template< typename MT // Type of the sparse matrix
4944  , typename... CCAs > // Compile time column arguments
4945 inline typename Columns<MT,false,false,true,CCAs...>::ConstReference
4946  Columns<MT,false,false,true,CCAs...>::operator()( size_t i, size_t j ) const
4947 {
4948  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
4949  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4950 
4951  return const_cast<const MT&>( matrix_ )(idx(j),i);
4952 }
4954 //*************************************************************************************************
4955 
4956 
4957 //*************************************************************************************************
4969 template< typename MT // Type of the sparse matrix
4970  , typename... CCAs > // Compile time column arguments
4971 inline typename Columns<MT,false,false,true,CCAs...>::Reference
4972  Columns<MT,false,false,true,CCAs...>::at( size_t i, size_t j )
4973 {
4974  if( i >= rows() ) {
4975  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
4976  }
4977  if( j >= columns() ) {
4978  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
4979  }
4980  return (*this)(i,j);
4981 }
4983 //*************************************************************************************************
4984 
4985 
4986 //*************************************************************************************************
4998 template< typename MT // Type of the sparse matrix
4999  , typename... CCAs > // Compile time column arguments
5000 inline typename Columns<MT,false,false,true,CCAs...>::ConstReference
5001  Columns<MT,false,false,true,CCAs...>::at( size_t i, size_t j ) const
5002 {
5003  if( i >= rows() ) {
5004  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
5005  }
5006  if( j >= columns() ) {
5007  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
5008  }
5009  return (*this)(i,j);
5010 }
5012 //*************************************************************************************************
5013 
5014 
5015 //*************************************************************************************************
5024 template< typename MT // Type of the sparse matrix
5025  , typename... CCAs > // Compile time column arguments
5026 inline typename Columns<MT,false,false,true,CCAs...>::Iterator
5028 {
5029  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5030 
5031  return matrix_.begin( idx(j) );
5032 }
5034 //*************************************************************************************************
5035 
5036 
5037 //*************************************************************************************************
5046 template< typename MT // Type of the sparse matrix
5047  , typename... CCAs > // Compile time column arguments
5048 inline typename Columns<MT,false,false,true,CCAs...>::ConstIterator
5050 {
5051  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5052 
5053  return matrix_.cbegin( idx(j) );
5054 }
5056 //*************************************************************************************************
5057 
5058 
5059 //*************************************************************************************************
5068 template< typename MT // Type of the sparse matrix
5069  , typename... CCAs > // Compile time column arguments
5070 inline typename Columns<MT,false,false,true,CCAs...>::ConstIterator
5072 {
5073  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5074 
5075  return matrix_.cbegin( idx(j) );
5076 }
5078 //*************************************************************************************************
5079 
5080 
5081 //*************************************************************************************************
5090 template< typename MT // Type of the sparse matrix
5091  , typename... CCAs > // Compile time column arguments
5092 inline typename Columns<MT,false,false,true,CCAs...>::Iterator
5094 {
5095  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5096 
5097  return matrix_.end( idx(j) );
5098 }
5100 //*************************************************************************************************
5101 
5102 
5103 //*************************************************************************************************
5112 template< typename MT // Type of the sparse matrix
5113  , typename... CCAs > // Compile time column arguments
5114 inline typename Columns<MT,false,false,true,CCAs...>::ConstIterator
5116 {
5117  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5118 
5119  return matrix_.cend( idx(j) );
5120 }
5122 //*************************************************************************************************
5123 
5124 
5125 //*************************************************************************************************
5134 template< typename MT // Type of the sparse matrix
5135  , typename... CCAs > // Compile time column arguments
5136 inline typename Columns<MT,false,false,true,CCAs...>::ConstIterator
5138 {
5139  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5140 
5141  return matrix_.cend( idx(j) );
5142 }
5144 //*************************************************************************************************
5145 
5146 
5147 
5148 
5149 //=================================================================================================
5150 //
5151 // UTILITY FUNCTIONS
5152 //
5153 //=================================================================================================
5154 
5155 //*************************************************************************************************
5161 template< typename MT // Type of the sparse matrix
5162  , typename... CCAs > // Compile time column arguments
5163 inline MT& Columns<MT,false,false,true,CCAs...>::operand() noexcept
5164 {
5165  return matrix_;
5166 }
5168 //*************************************************************************************************
5169 
5170 
5171 //*************************************************************************************************
5177 template< typename MT // Type of the sparse matrix
5178  , typename... CCAs > // Compile time column arguments
5179 inline const MT& Columns<MT,false,false,true,CCAs...>::operand() const noexcept
5180 {
5181  return matrix_;
5182 }
5184 //*************************************************************************************************
5185 
5186 
5187 //*************************************************************************************************
5193 template< typename MT // Type of the sparse matrix
5194  , typename... CCAs > // Compile time column arguments
5195 inline size_t Columns<MT,false,false,true,CCAs...>::rows() const noexcept
5196 {
5197  return matrix_.rows();
5198 }
5200 //*************************************************************************************************
5201 
5202 
5203 //*************************************************************************************************
5209 template< typename MT // Type of the sparse matrix
5210  , typename... CCAs > // Compile time column arguments
5211 inline size_t Columns<MT,false,false,true,CCAs...>::capacity() const noexcept
5212 {
5213  return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
5214 }
5216 //*************************************************************************************************
5217 
5218 
5219 //*************************************************************************************************
5228 template< typename MT // Type of the sparse matrix
5229  , typename... CCAs > // Compile time column arguments
5230 inline size_t Columns<MT,false,false,true,CCAs...>::capacity( size_t j ) const noexcept
5231 {
5232  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5233 
5234  return matrix_.capacity( idx(j) );
5235 }
5237 //*************************************************************************************************
5238 
5239 
5240 //*************************************************************************************************
5246 template< typename MT // Type of the sparse matrix
5247  , typename... CCAs > // Compile time column arguments
5249 {
5250  size_t nonzeros( 0UL );
5251 
5252  for( size_t j=0UL; j<columns(); ++j )
5253  nonzeros += nonZeros( j );
5254 
5255  return nonzeros;
5256 }
5258 //*************************************************************************************************
5259 
5260 
5261 //*************************************************************************************************
5270 template< typename MT // Type of the sparse matrix
5271  , typename... CCAs > // Compile time column arguments
5272 inline size_t Columns<MT,false,false,true,CCAs...>::nonZeros( size_t j ) const
5273 {
5274  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5275 
5276  return matrix_.nonZeros( idx(j) );
5277 }
5279 //*************************************************************************************************
5280 
5281 
5282 //*************************************************************************************************
5288 template< typename MT // Type of the sparse matrix
5289  , typename... CCAs > // Compile time column arguments
5291 {
5292  for( size_t j=0UL; j<columns(); ++j ) {
5293  matrix_.reset( idx(j) );
5294  }
5295 }
5297 //*************************************************************************************************
5298 
5299 
5300 //*************************************************************************************************
5310 template< typename MT // Type of the sparse matrix
5311  , typename... CCAs > // Compile time column arguments
5312 inline void Columns<MT,false,false,true,CCAs...>::reset( size_t j )
5313 {
5314  matrix_.reset( idx(j) );
5315 }
5317 //*************************************************************************************************
5318 
5319 
5320 //*************************************************************************************************
5331 template< typename MT // Type of the sparse matrix
5332  , typename... CCAs > // Compile time column arguments
5333 inline void Columns<MT,false,false,true,CCAs...>::reserve( size_t nonzeros )
5334 {
5335  const size_t current( capacity() );
5336 
5337  if( nonzeros > current ) {
5338  matrix_.reserve( matrix_.capacity() + nonzeros - current );
5339  }
5340 }
5342 //*************************************************************************************************
5343 
5344 
5345 //*************************************************************************************************
5357 template< typename MT // Type of the sparse matrix
5358  , typename... CCAs > // Compile time column arguments
5359 void Columns<MT,false,false,true,CCAs...>::reserve( size_t j, size_t nonzeros )
5360 {
5361  matrix_.reserve( idx(j), nonzeros );
5362 }
5364 //*************************************************************************************************
5365 
5366 
5367 //*************************************************************************************************
5377 template< typename MT // Type of the sparse matrix
5378  , typename... CCAs > // Compile time column arguments
5379 void Columns<MT,false,false,true,CCAs...>::trim()
5380 {
5381  for( size_t j=0UL; j<columns(); ++j ) {
5382  trim( j );
5383  }
5384 }
5386 //*************************************************************************************************
5387 
5388 
5389 //*************************************************************************************************
5400 template< typename MT // Type of the sparse matrix
5401  , typename... CCAs > // Compile time column arguments
5402 void Columns<MT,false,false,true,CCAs...>::trim( size_t j )
5403 {
5404  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5405 
5406  matrix_.trim( idx(j) );
5407 }
5409 //*************************************************************************************************
5410 
5411 
5412 
5413 
5414 //=================================================================================================
5415 //
5416 // INSERTION FUNCTIONS
5417 //
5418 //=================================================================================================
5419 
5420 //*************************************************************************************************
5433 template< typename MT // Type of the sparse matrix
5434  , typename... CCAs > // Compile time column arguments
5435 inline typename Columns<MT,false,false,true,CCAs...>::Iterator
5436  Columns<MT,false,false,true,CCAs...>::set( size_t i, size_t j, const ElementType& value )
5437 {
5438  return matrix_.set( idx(j), i, value );
5439 }
5441 //*************************************************************************************************
5442 
5443 
5444 //*************************************************************************************************
5458 template< typename MT // Type of the sparse matrix
5459  , typename... CCAs > // Compile time column arguments
5460 inline typename Columns<MT,false,false,true,CCAs...>::Iterator
5461  Columns<MT,false,false,true,CCAs...>::insert( size_t i, size_t j, const ElementType& value )
5462 {
5463  return matrix_.insert( idx(j), i, value );
5464 }
5466 //*************************************************************************************************
5467 
5468 
5469 //*************************************************************************************************
5513 template< typename MT // Type of the sparse matrix
5514  , typename... CCAs > // Compile time column arguments
5515 inline void Columns<MT,false,false,true,CCAs...>::append( size_t i, size_t j, const ElementType& value, bool check )
5516 {
5517  if( !check || !isDefault<strict>( value ) )
5518  matrix_.insert( idx(j), i, value );
5519 }
5521 //*************************************************************************************************
5522 
5523 
5524 //*************************************************************************************************
5538 template< typename MT // Type of the sparse matrix
5539  , typename... CCAs > // Compile time column arguments
5540 inline void Columns<MT,false,false,true,CCAs...>::finalize( size_t j )
5541 {
5542  UNUSED_PARAMETER( j );
5543 
5544  return;
5545 }
5547 //*************************************************************************************************
5548 
5549 
5550 
5551 
5552 //=================================================================================================
5553 //
5554 // ERASE FUNCTIONS
5555 //
5556 //=================================================================================================
5557 
5558 //*************************************************************************************************
5568 template< typename MT // Type of the sparse matrix
5569  , typename... CCAs > // Compile time column arguments
5570 inline void Columns<MT,false,false,true,CCAs...>::erase( size_t i, size_t j )
5571 {
5572  BLAZE_USER_ASSERT( i < rows() , "Invalid row access index" );
5573  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5574 
5575  matrix_.erase( idx(j), i );
5576 }
5578 //*************************************************************************************************
5579 
5580 
5581 //*************************************************************************************************
5591 template< typename MT // Type of the sparse matrix
5592  , typename... CCAs > // Compile time column arguments
5593 inline typename Columns<MT,false,false,true,CCAs...>::Iterator
5594  Columns<MT,false,false,true,CCAs...>::erase( size_t j, Iterator pos )
5595 {
5596  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5597 
5598  return matrix_.erase( idx(j), pos );
5599 }
5601 //*************************************************************************************************
5602 
5603 
5604 //*************************************************************************************************
5615 template< typename MT // Type of the sparse matrix
5616  , typename... CCAs > // Compile time column arguments
5617 inline typename Columns<MT,false,false,true,CCAs...>::Iterator
5618  Columns<MT,false,false,true,CCAs...>::erase( size_t j, Iterator first, Iterator last )
5619 {
5620  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5621 
5622  return matrix_.erase( idx(j), first, last );
5623 }
5625 //*************************************************************************************************
5626 
5627 
5628 //*************************************************************************************************
5651 template< typename MT // Type of the sparse matrix
5652  , typename... CCAs > // Compile time column arguments
5653 template< typename Pred > // Type of the unary predicate
5654 inline void Columns<MT,false,false,true,CCAs...>::erase( Pred predicate )
5655 {
5656  for( size_t j=0UL; j<columns(); ++j ) {
5657  matrix_.erase( idx(j), begin(j), end(j), predicate );
5658  }
5659 }
5661 //*************************************************************************************************
5662 
5663 
5664 //*************************************************************************************************
5691 template< typename MT // Type of the sparse matrix
5692  , typename... CCAs > // Compile time column arguments
5693 template< typename Pred > // Type of the unary predicate
5694 inline void Columns<MT,false,false,true,CCAs...>::erase( size_t j, Iterator first, Iterator last, Pred predicate )
5695 {
5696  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5697 
5698  matrix_.erase( idx(j), first, last, predicate );
5699 }
5701 //*************************************************************************************************
5702 
5703 
5704 
5705 
5706 //=================================================================================================
5707 //
5708 // LOOKUP FUNCTIONS
5709 //
5710 //=================================================================================================
5711 
5712 //*************************************************************************************************
5727 template< typename MT // Type of the sparse matrix
5728  , typename... CCAs > // Compile time column arguments
5729 inline typename Columns<MT,false,false,true,CCAs...>::Iterator
5730  Columns<MT,false,false,true,CCAs...>::find( size_t i, size_t j )
5731 {
5732  return matrix_.find( idx(j), i );
5733 }
5735 //*************************************************************************************************
5736 
5737 
5738 //*************************************************************************************************
5753 template< typename MT // Type of the sparse matrix
5754  , typename... CCAs > // Compile time column arguments
5755 inline typename Columns<MT,false,false,true,CCAs...>::ConstIterator
5756  Columns<MT,false,false,true,CCAs...>::find( size_t i, size_t j ) const
5757 {
5758  return matrix_.find( idx(j), i );
5759 }
5761 //*************************************************************************************************
5762 
5763 
5764 //*************************************************************************************************
5778 template< typename MT // Type of the sparse matrix
5779  , typename... CCAs > // Compile time column arguments
5780 inline typename Columns<MT,false,false,true,CCAs...>::Iterator
5781  Columns<MT,false,false,true,CCAs...>::lowerBound( size_t i, size_t j )
5782 {
5783  return matrix_.lowerBound( idx(j), i );
5784 }
5786 //*************************************************************************************************
5787 
5788 
5789 //*************************************************************************************************
5803 template< typename MT // Type of the sparse matrix
5804  , typename... CCAs > // Compile time column arguments
5805 inline typename Columns<MT,false,false,true,CCAs...>::ConstIterator
5806  Columns<MT,false,false,true,CCAs...>::lowerBound( size_t i, size_t j ) const
5807 {
5808  return matrix_.lowerBound( idx(j), i );
5809 }
5811 //*************************************************************************************************
5812 
5813 
5814 //*************************************************************************************************
5828 template< typename MT // Type of the sparse matrix
5829  , typename... CCAs > // Compile time column arguments
5830 inline typename Columns<MT,false,false,true,CCAs...>::Iterator
5831  Columns<MT,false,false,true,CCAs...>::upperBound( size_t i, size_t j )
5832 {
5833  return matrix_.upperBound( idx(j), i );
5834 }
5836 //*************************************************************************************************
5837 
5838 
5839 //*************************************************************************************************
5853 template< typename MT // Type of the sparse matrix
5854  , typename... CCAs > // Compile time column arguments
5855 inline typename Columns<MT,false,false,true,CCAs...>::ConstIterator
5856  Columns<MT,false,false,true,CCAs...>::upperBound( size_t i, size_t j ) const
5857 {
5858  return matrix_.upperBound( idx(j), i );
5859 }
5861 //*************************************************************************************************
5862 
5863 
5864 
5865 
5866 //=================================================================================================
5867 //
5868 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
5869 //
5870 //=================================================================================================
5871 
5872 //*************************************************************************************************
5883 template< typename MT // Type of the sparse matrix
5884  , typename... CCAs > // Compile time column arguments
5885 template< typename Other > // Data type of the foreign expression
5886 inline bool Columns<MT,false,false,true,CCAs...>::canAlias( const Other* alias ) const noexcept
5887 {
5888  return matrix_.isAliased( alias );
5889 }
5891 //*************************************************************************************************
5892 
5893 
5894 //*************************************************************************************************
5905 template< typename MT // Type of the sparse matrix
5906  , typename... CCAs > // Compile time column arguments
5907 template< typename Other > // Data type of the foreign expression
5908 inline bool Columns<MT,false,false,true,CCAs...>::isAliased( const Other* alias ) const noexcept
5909 {
5910  return matrix_.isAliased( alias );
5911 }
5913 //*************************************************************************************************
5914 
5915 
5916 //*************************************************************************************************
5927 template< typename MT // Type of the sparse matrix
5928  , typename... CCAs > // Compile time column arguments
5929 inline bool Columns<MT,false,false,true,CCAs...>::canSMPAssign() const noexcept
5930 {
5931  return false;
5932 }
5934 //*************************************************************************************************
5935 
5936 } // namespace blaze
5937 
5938 #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.
Header file for the implementation of the Columns base template.
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_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
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COLUMNS_TYPE(T)
Constraint on the data type.In case the given data type T is a column selection type (i...
Definition: Columns.h:81
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
Header file for the columns trait.
Constraint on the data type.
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
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
Header file for the implementation of the ColumnsData 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 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