Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_COLUMN_SPARSE_H_
36 #define _BLAZE_MATH_VIEWS_COLUMN_SPARSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <blaze/math/Aliases.h>
56 #include <blaze/math/Exception.h>
59 #include <blaze/math/Functions.h>
61 #include <blaze/math/shims/Reset.h>
79 #include <blaze/util/Assert.h>
82 #include <blaze/util/DisableIf.h>
83 #include <blaze/util/EnableIf.h>
84 #include <blaze/util/mpl/If.h>
85 #include <blaze/util/Types.h>
91 #include <blaze/util/Unused.h>
92 
93 
94 namespace blaze {
95 
96 //=================================================================================================
97 //
98 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR SPARSE MATRICES
99 //
100 //=================================================================================================
101 
102 //*************************************************************************************************
110 template< typename MT // Type of the sparse matrix
111  , bool SF > // Symmetry flag
112 class Column<MT,true,false,SF>
113  : public SparseVector< Column<MT,true,false,SF>, false >
114  , private View
115 {
116  private:
117  //**Type definitions****************************************************************************
119  typedef If_< IsExpression<MT>, MT, MT& > Operand;
120  //**********************************************************************************************
121 
122  public:
123  //**Type definitions****************************************************************************
124  typedef Column<MT,true,false,SF> This;
125  typedef SparseVector<This,false> BaseType;
126  typedef ColumnTrait_<MT> ResultType;
127  typedef TransposeType_<ResultType> TransposeType;
128  typedef ElementType_<MT> ElementType;
129  typedef ReturnType_<MT> ReturnType;
130  typedef const Column& CompositeType;
131 
133  typedef ConstReference_<MT> ConstReference;
134 
136  typedef If_< IsConst<MT>, ConstReference, Reference_<MT> > Reference;
137 
139  typedef ConstIterator_<MT> ConstIterator;
140 
142  typedef If_< IsConst<MT>, ConstIterator, Iterator_<MT> > Iterator;
143  //**********************************************************************************************
144 
145  //**Compilation flags***************************************************************************
147  enum : bool { smpAssignable = false };
148  //**********************************************************************************************
149 
150  //**Constructors********************************************************************************
153  explicit inline Column( Operand matrix, size_t index );
154  // No explicitly declared copy constructor.
156  //**********************************************************************************************
157 
158  //**Destructor**********************************************************************************
159  // No explicitly declared destructor.
160  //**********************************************************************************************
161 
162  //**Data access functions***********************************************************************
165  inline Reference operator[]( size_t index );
166  inline ConstReference operator[]( size_t index ) const;
167  inline Reference at( size_t index );
168  inline ConstReference at( size_t index ) const;
169  inline Iterator begin ();
170  inline ConstIterator begin () const;
171  inline ConstIterator cbegin() const;
172  inline Iterator end ();
173  inline ConstIterator end () const;
174  inline ConstIterator cend () const;
176  //**********************************************************************************************
177 
178  //**Assignment operators************************************************************************
181  inline Column& operator=( const Column& rhs );
182 
183  template< typename VT > inline Column& operator= ( const DenseVector<VT,false>& rhs );
184  template< typename VT > inline Column& operator= ( const SparseVector<VT,false>& rhs );
185  template< typename VT > inline Column& operator+=( const DenseVector<VT,false>& rhs );
186  template< typename VT > inline Column& operator+=( const SparseVector<VT,false>& rhs );
187  template< typename VT > inline Column& operator-=( const DenseVector<VT,false>& rhs );
188  template< typename VT > inline Column& operator-=( const SparseVector<VT,false>& rhs );
189  template< typename VT > inline Column& operator*=( const Vector<VT,false>& rhs );
190  template< typename VT > inline Column& operator/=( const DenseVector<VT,false>& rhs );
191 
192  template< typename Other >
193  inline EnableIf_< IsNumeric<Other>, Column >& operator*=( Other rhs );
194 
195  template< typename Other >
196  inline EnableIf_<IsNumeric<Other>, Column >& operator/=( Other rhs );
198  //**********************************************************************************************
199 
200  //**Utility functions***************************************************************************
203  inline size_t size() const noexcept;
204  inline size_t capacity() const noexcept;
205  inline size_t nonZeros() const;
206  inline void reset();
207  inline void reserve( size_t n );
209  //**********************************************************************************************
210 
211  //**Insertion functions*************************************************************************
214  inline Iterator set ( size_t index, const ElementType& value );
215  inline Iterator insert( size_t index, const ElementType& value );
216  inline void append( size_t index, const ElementType& value, bool check=false );
218  //**********************************************************************************************
219 
220  //**Erase functions*****************************************************************************
223  inline void erase( size_t index );
224  inline Iterator erase( Iterator pos );
225  inline Iterator erase( Iterator first, Iterator last );
226 
227  template< typename Pred, typename = DisableIf_< IsIntegral<Pred> > >
228  inline void erase( Pred predicate );
229 
230  template< typename Pred >
231  inline void erase( Iterator first, Iterator last, Pred predicate );
233  //**********************************************************************************************
234 
235  //**Lookup functions****************************************************************************
238  inline Iterator find ( size_t index );
239  inline ConstIterator find ( size_t index ) const;
240  inline Iterator lowerBound( size_t index );
241  inline ConstIterator lowerBound( size_t index ) const;
242  inline Iterator upperBound( size_t index );
243  inline ConstIterator upperBound( size_t index ) const;
245  //**********************************************************************************************
246 
247  //**Numeric functions***************************************************************************
250  template< typename Other > inline Column& scale( const Other& scalar );
252  //**********************************************************************************************
253 
254  //**Expression template evaluation functions****************************************************
257  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
258  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
259 
260  template< typename VT > inline void assign ( const DenseVector <VT,false>& rhs );
261  template< typename VT > inline void assign ( const SparseVector<VT,false>& rhs );
262  template< typename VT > inline void addAssign( const DenseVector <VT,false>& rhs );
263  template< typename VT > inline void addAssign( const SparseVector<VT,false>& rhs );
264  template< typename VT > inline void subAssign( const DenseVector <VT,false>& rhs );
265  template< typename VT > inline void subAssign( const SparseVector<VT,false>& rhs );
267  //**********************************************************************************************
268 
269  private:
270  //**Utility functions***************************************************************************
273  inline size_t extendCapacity() const noexcept;
275  //**********************************************************************************************
276 
277  //**Member variables****************************************************************************
280  Operand matrix_;
281  const size_t col_;
282 
283  //**********************************************************************************************
284 
285  //**Friend declarations*************************************************************************
286  template< typename MT2, bool SO2, bool DF2, bool SF2 >
287  friend bool isIntact( const Column<MT2,SO2,DF2,SF2>& column ) noexcept;
288 
289  template< typename MT2, bool SO2, bool DF2, bool SF2 >
290  friend bool isSame( const Column<MT2,SO2,DF2,SF2>& a, const Column<MT2,SO2,DF2,SF2>& b ) noexcept;
291 
292  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
293  friend bool tryAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
294 
295  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
296  friend bool tryAddAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
297 
298  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
299  friend bool trySubAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
300 
301  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
302  friend bool tryMultAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
303 
304  template< typename MT2, bool SO2, bool DF2, bool SF2 >
305  friend DerestrictTrait_< Column<MT2,SO2,DF2,SF2> > derestrict( Column<MT2,SO2,DF2,SF2>& column );
306  //**********************************************************************************************
307 
308  //**Compile time checks*************************************************************************
315  //**********************************************************************************************
316 };
318 //*************************************************************************************************
319 
320 
321 
322 
323 //=================================================================================================
324 //
325 // CONSTRUCTOR
326 //
327 //=================================================================================================
328 
329 //*************************************************************************************************
337 template< typename MT // Type of the sparse matrix
338  , bool SF > // Symmetry flag
339 inline Column<MT,true,false,SF>::Column( Operand matrix, size_t index )
340  : matrix_( matrix ) // The sparse matrix containing the column
341  , col_ ( index ) // The index of the column in the matrix
342 {
343  if( matrix_.columns() <= index ) {
344  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
345  }
346 }
348 //*************************************************************************************************
349 
350 
351 
352 
353 //=================================================================================================
354 //
355 // DATA ACCESS FUNCTIONS
356 //
357 //=================================================================================================
358 
359 //*************************************************************************************************
369 template< typename MT // Type of the sparse matrix
370  , bool SF > // Symmetry flag
372  Column<MT,true,false,SF>::operator[]( size_t index )
373 {
374  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
375  return matrix_(index,col_);
376 }
378 //*************************************************************************************************
379 
380 
381 //*************************************************************************************************
391 template< typename MT // Type of the sparse matrix
392  , bool SF > // Symmetry flag
394  Column<MT,true,false,SF>::operator[]( size_t index ) const
395 {
396  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
397  return const_cast<const MT&>( matrix_ )(index,col_);
398 }
400 //*************************************************************************************************
401 
402 
403 //*************************************************************************************************
414 template< typename MT // Type of the sparse matrix
415  , bool SF > // Symmetry flag
417  Column<MT,true,false,SF>::at( size_t index )
418 {
419  if( index >= size() ) {
420  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
421  }
422  return (*this)[index];
423 }
425 //*************************************************************************************************
426 
427 
428 //*************************************************************************************************
439 template< typename MT // Type of the sparse matrix
440  , bool SF > // Symmetry flag
442  Column<MT,true,false,SF>::at( size_t index ) const
443 {
444  if( index >= size() ) {
445  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
446  }
447  return (*this)[index];
448 }
450 //*************************************************************************************************
451 
452 
453 //*************************************************************************************************
461 template< typename MT // Type of the sparse matrix
462  , bool SF > // Symmetry flag
464 {
465  return matrix_.begin( col_ );
466 }
468 //*************************************************************************************************
469 
470 
471 //*************************************************************************************************
479 template< typename MT // Type of the sparse matrix
480  , bool SF > // Symmetry flag
482 {
483  return matrix_.cbegin( col_ );
484 }
486 //*************************************************************************************************
487 
488 
489 //*************************************************************************************************
497 template< typename MT // Type of the sparse matrix
498  , bool SF > // Symmetry flag
500 {
501  return matrix_.cbegin( col_ );
502 }
504 //*************************************************************************************************
505 
506 
507 //*************************************************************************************************
515 template< typename MT // Type of the sparse matrix
516  , bool SF > // Symmetry flag
518 {
519  return matrix_.end( col_ );
520 }
522 //*************************************************************************************************
523 
524 
525 //*************************************************************************************************
533 template< typename MT // Type of the sparse matrix
534  , bool SF > // Symmetry flag
536 {
537  return matrix_.cend( col_ );
538 }
540 //*************************************************************************************************
541 
542 
543 //*************************************************************************************************
551 template< typename MT // Type of the sparse matrix
552  , bool SF > // Symmetry flag
554 {
555  return matrix_.cend( col_ );
556 }
558 //*************************************************************************************************
559 
560 
561 
562 
563 //=================================================================================================
564 //
565 // ASSIGNMENT OPERATORS
566 //
567 //=================================================================================================
568 
569 //*************************************************************************************************
583 template< typename MT // Type of the sparse matrix
584  , bool SF > // Symmetry flag
585 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator=( const Column& rhs )
586 {
587  using blaze::assign;
588 
592 
593  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
594  return *this;
595 
596  if( size() != rhs.size() ) {
597  BLAZE_THROW_INVALID_ARGUMENT( "Column sizes do not match" );
598  }
599 
600  if( !tryAssign( matrix_, rhs, 0UL, col_ ) ) {
601  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
602  }
603 
604  DerestrictTrait_<This> left( derestrict( *this ) );
605 
606  if( rhs.canAlias( &matrix_ ) ) {
607  const ResultType tmp( rhs );
608  left.reset();
609  left.reserve( tmp.nonZeros() );
610  assign( left, tmp );
611  }
612  else {
613  left.reset();
614  left.reserve( rhs.nonZeros() );
615  assign( left, rhs );
616  }
617 
618  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
619 
620  return *this;
621 }
623 //*************************************************************************************************
624 
625 
626 //*************************************************************************************************
640 template< typename MT // Type of the sparse matrix
641  , bool SF > // Symmetry flag
642 template< typename VT > // Type of the right-hand side dense vector
643 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator=( const DenseVector<VT,false>& rhs )
644 {
645  using blaze::assign;
646 
647  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
650 
651  if( size() != (~rhs).size() ) {
652  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
653  }
654 
655  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
656  Right right( ~rhs );
657 
658  if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
659  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
660  }
661 
662  DerestrictTrait_<This> left( derestrict( *this ) );
663 
664  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
665  const ResultType_<VT> tmp( right );
666  left.reset();
667  assign( left, tmp );
668  }
669  else {
670  left.reset();
671  assign( left, right );
672  }
673 
674  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
675 
676  return *this;
677 }
679 //*************************************************************************************************
680 
681 
682 //*************************************************************************************************
696 template< typename MT // Type of the sparse matrix
697  , bool SF > // Symmetry flag
698 template< typename VT > // Type of the right-hand side sparse vector
699 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator=( const SparseVector<VT,false>& rhs )
700 {
701  using blaze::assign;
702 
706 
707  if( size() != (~rhs).size() ) {
708  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
709  }
710 
711  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
712  Right right( ~rhs );
713 
714  if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
715  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
716  }
717 
718  DerestrictTrait_<This> left( derestrict( *this ) );
719 
720  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
721  const ResultType_<VT> tmp( right );
722  left.reset();
723  left.reserve( tmp.nonZeros() );
724  assign( left, tmp );
725  }
726  else {
727  left.reset();
728  left.reserve( right.nonZeros() );
729  assign( left, right );
730  }
731 
732  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
733 
734  return *this;
735 }
737 //*************************************************************************************************
738 
739 
740 //*************************************************************************************************
754 template< typename MT // Type of the sparse matrix
755  , bool SF > // Symmetry flag
756 template< typename VT > // Type of the right-hand side dense vector
757 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator+=( const DenseVector<VT,false>& rhs )
758 {
759  using blaze::assign;
760 
764  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
767 
768  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
769 
773 
774  if( size() != (~rhs).size() ) {
775  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
776  }
777 
778  const AddType tmp( *this + (~rhs) );
779 
780  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
781  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
782  }
783 
784  DerestrictTrait_<This> left( derestrict( *this ) );
785 
786  left.reset();
787  assign( left, tmp );
788 
789  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
790 
791  return *this;
792 }
794 //*************************************************************************************************
795 
796 
797 //*************************************************************************************************
811 template< typename MT // Type of the sparse matrix
812  , bool SF > // Symmetry flag
813 template< typename VT > // Type of the right-hand side sparse vector
814 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator+=( const SparseVector<VT,false>& rhs )
815 {
816  using blaze::assign;
817 
824 
825  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
826 
830 
831  if( size() != (~rhs).size() ) {
832  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
833  }
834 
835  const AddType tmp( *this + (~rhs) );
836 
837  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
838  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
839  }
840 
841  DerestrictTrait_<This> left( derestrict( *this ) );
842 
843  left.reset();
844  left.reserve( tmp.nonZeros() );
845  assign( left, tmp );
846 
847  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
848 
849  return *this;
850 }
852 //*************************************************************************************************
853 
854 
855 //*************************************************************************************************
870 template< typename MT // Type of the sparse matrix
871  , bool SF > // Symmetry flag
872 template< typename VT > // Type of the right-hand side dense vector
873 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator-=( const DenseVector<VT,false>& rhs )
874 {
875  using blaze::assign;
876 
880  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
883 
884  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
885 
889 
890  if( size() != (~rhs).size() ) {
891  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
892  }
893 
894  const SubType tmp( *this - (~rhs) );
895 
896  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
897  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
898  }
899 
900  DerestrictTrait_<This> left( derestrict( *this ) );
901 
902  left.reset();
903  assign( left, tmp );
904 
905  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
906 
907  return *this;
908 }
910 //*************************************************************************************************
911 
912 
913 //*************************************************************************************************
928 template< typename MT // Type of the sparse matrix
929  , bool SF > // Symmetry flag
930 template< typename VT > // Type of the right-hand side sparse vector
931 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator-=( const SparseVector<VT,false>& rhs )
932 {
933  using blaze::assign;
934 
941 
942  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
943 
947 
948  if( size() != (~rhs).size() ) {
949  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
950  }
951 
952  const SubType tmp( *this - (~rhs) );
953 
954  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
955  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
956  }
957 
958  DerestrictTrait_<This> left( derestrict( *this ) );
959 
960  left.reset();
961  left.reserve( tmp.nonZeros() );
962  assign( left, tmp );
963 
964  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
965 
966  return *this;
967 }
969 //*************************************************************************************************
970 
971 
972 //*************************************************************************************************
985 template< typename MT // Type of the sparse matrix
986  , bool SF > // Symmetry flag
987 template< typename VT > // Type of the right-hand side vector
988 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator*=( const Vector<VT,false>& rhs )
989 {
990  using blaze::assign;
991 
997 
998  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
999 
1002 
1003  if( size() != (~rhs).size() ) {
1004  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1005  }
1006 
1007  const MultType tmp( *this * (~rhs) );
1008 
1009  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
1010  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1011  }
1012 
1013  DerestrictTrait_<This> left( derestrict( *this ) );
1014 
1015  left.reset();
1016  assign( left, tmp );
1017 
1018  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1019 
1020  return *this;
1021 }
1023 //*************************************************************************************************
1024 
1025 
1026 //*************************************************************************************************
1038 template< typename MT // Type of the sparse matrix
1039  , bool SF > // Symmetry flag
1040 template< typename VT > // Type of the right-hand side vector
1041 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator/=( const DenseVector<VT,false>& rhs )
1042 {
1043  using blaze::assign;
1044 
1048  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
1049  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
1051 
1052  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
1053 
1057 
1058  if( size() != (~rhs).size() ) {
1059  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1060  }
1061 
1062  const DivType tmp( *this / (~rhs) );
1063 
1064  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
1065  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1066  }
1067 
1068  DerestrictTrait_<This> left( derestrict( *this ) );
1069 
1070  left.reset();
1071  assign( left, tmp );
1072 
1073  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1074 
1075  return *this;
1076 }
1078 //*************************************************************************************************
1079 
1080 
1081 //*************************************************************************************************
1096 template< typename MT // Type of the sparse matrix
1097  , bool SF > // Symmetry flag
1098 template< typename Other > // Data type of the right-hand side scalar
1099 inline EnableIf_<IsNumeric<Other>, Column<MT,true,false,SF> >&
1101 {
1103 
1104  for( Iterator element=begin(); element!=end(); ++element )
1105  element->value() *= rhs;
1106  return *this;
1107 }
1109 //*************************************************************************************************
1110 
1111 
1112 //*************************************************************************************************
1130 template< typename MT // Type of the sparse matrix
1131  , bool SF > // Symmetry flag
1132 template< typename Other > // Data type of the right-hand side scalar
1133 inline EnableIf_<IsNumeric<Other>, Column<MT,true,false,SF> >&
1135 {
1137 
1138  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1139 
1140  typedef DivTrait_<ElementType,Other> DT;
1141  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
1142 
1143  // Depending on the two involved data types, an integer division is applied or a
1144  // floating point division is selected.
1145  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
1146  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1147  for( Iterator element=begin(); element!=end(); ++element )
1148  element->value() *= tmp;
1149  }
1150  else {
1151  for( Iterator element=begin(); element!=end(); ++element )
1152  element->value() /= rhs;
1153  }
1154 
1155  return *this;
1156 }
1158 //*************************************************************************************************
1159 
1160 
1161 
1162 
1163 //=================================================================================================
1164 //
1165 // UTILITY FUNCTIONS
1166 //
1167 //=================================================================================================
1168 
1169 //*************************************************************************************************
1175 template< typename MT // Type of the sparse matrix
1176  , bool SF > // Symmetry flag
1177 inline size_t Column<MT,true,false,SF>::size() const noexcept
1178 {
1179  return matrix_.rows();
1180 }
1182 //*************************************************************************************************
1183 
1184 
1185 //*************************************************************************************************
1191 template< typename MT // Type of the sparse matrix
1192  , bool SF > // Symmetry flag
1193 inline size_t Column<MT,true,false,SF>::capacity() const noexcept
1194 {
1195  return matrix_.capacity( col_ );
1196 }
1198 //*************************************************************************************************
1199 
1200 
1201 //*************************************************************************************************
1210 template< typename MT // Type of the sparse matrix
1211  , bool SF > // Symmetry flag
1212 inline size_t Column<MT,true,false,SF>::nonZeros() const
1213 {
1214  return matrix_.nonZeros( col_ );
1215 }
1217 //*************************************************************************************************
1218 
1219 
1220 //*************************************************************************************************
1226 template< typename MT // Type of the sparse matrix
1227  , bool SF > // Symmetry flag
1228 inline void Column<MT,true,false,SF>::reset()
1229 {
1230  matrix_.reset( col_ );
1231 }
1233 //*************************************************************************************************
1234 
1235 
1236 //*************************************************************************************************
1246 template< typename MT // Type of the sparse matrix
1247  , bool SF > // Symmetry flag
1248 void Column<MT,true,false,SF>::reserve( size_t n )
1249 {
1250  matrix_.reserve( col_, n );
1251 }
1253 //*************************************************************************************************
1254 
1255 
1256 //*************************************************************************************************
1265 template< typename MT // Type of the sparse matrix
1266  , bool SF > // Symmetry flag
1267 inline size_t Column<MT,true,false,SF>::extendCapacity() const noexcept
1268 {
1269  using blaze::max;
1270  using blaze::min;
1271 
1272  size_t nonzeros( 2UL*capacity()+1UL );
1273  nonzeros = max( nonzeros, 7UL );
1274  nonzeros = min( nonzeros, size() );
1275 
1276  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
1277 
1278  return nonzeros;
1279 }
1281 //*************************************************************************************************
1282 
1283 
1284 
1285 
1286 //=================================================================================================
1287 //
1288 // INSERTION FUNCTIONS
1289 //
1290 //=================================================================================================
1291 
1292 //*************************************************************************************************
1304 template< typename MT // Type of the sparse matrix
1305  , bool SF > // Symmetry flag
1306 inline typename Column<MT,true,false,SF>::Iterator
1307  Column<MT,true,false,SF>::set( size_t index, const ElementType& value )
1308 {
1309  return matrix_.set( index, col_, value );
1310 }
1312 //*************************************************************************************************
1313 
1314 
1315 //*************************************************************************************************
1328 template< typename MT // Type of the sparse matrix
1329  , bool SF > // Symmetry flag
1330 inline typename Column<MT,true,false,SF>::Iterator
1331  Column<MT,true,false,SF>::insert( size_t index, const ElementType& value )
1332 {
1333  return matrix_.insert( index, col_, value );
1334 }
1336 //*************************************************************************************************
1337 
1338 
1339 //*************************************************************************************************
1364 template< typename MT // Type of the sparse matrix
1365  , bool SF > // Symmetry flag
1366 inline void Column<MT,true,false,SF>::append( size_t index, const ElementType& value, bool check )
1367 {
1368  matrix_.append( index, col_, value, check );
1369 }
1371 //*************************************************************************************************
1372 
1373 
1374 
1375 
1376 //=================================================================================================
1377 //
1378 // ERASE FUNCTIONS
1379 //
1380 //=================================================================================================
1381 
1382 //*************************************************************************************************
1391 template< typename MT // Type of the sparse matrix
1392  , bool SF > // Symmetry flag
1393 inline void Column<MT,true,false,SF>::erase( size_t index )
1394 {
1395  matrix_.erase( index, col_ );
1396 }
1398 //*************************************************************************************************
1399 
1400 
1401 //*************************************************************************************************
1410 template< typename MT // Type of the sparse matrix
1411  , bool SF > // Symmetry flag
1412 inline typename Column<MT,true,false,SF>::Iterator Column<MT,true,false,SF>::erase( Iterator pos )
1413 {
1414  return matrix_.erase( col_, pos );
1415 }
1417 //*************************************************************************************************
1418 
1419 
1420 //*************************************************************************************************
1430 template< typename MT // Type of the sparse matrix
1431  , bool SF > // Symmetry flag
1432 inline typename Column<MT,true,false,SF>::Iterator
1433  Column<MT,true,false,SF>::erase( Iterator first, Iterator last )
1434 {
1435  return matrix_.erase( col_, first, last );
1436 }
1438 //*************************************************************************************************
1439 
1440 
1441 //*************************************************************************************************
1464 template< typename MT // Type of the sparse matrix
1465  , bool SF > // Symmetry flag
1466 template< typename Pred // Type of the unary predicate
1467  , typename > // Type restriction on the unary predicate
1468 inline void Column<MT,true,false,SF>::erase( Pred predicate )
1469 {
1470  matrix_.erase( col_, begin(), end(), predicate );
1471 }
1473 //*************************************************************************************************
1474 
1475 
1476 //*************************************************************************************************
1501 template< typename MT // Type of the sparse matrix
1502  , bool SF > // Symmetry flag
1503 template< typename Pred > // Type of the unary predicate
1504 inline void Column<MT,true,false,SF>::erase( Iterator first, Iterator last, Pred predicate )
1505 {
1506  matrix_.erase( col_, first, last, predicate );
1507 }
1509 //*************************************************************************************************
1510 
1511 
1512 
1513 
1514 //=================================================================================================
1515 //
1516 // LOOKUP FUNCTIONS
1517 //
1518 //=================================================================================================
1519 
1520 //*************************************************************************************************
1534 template< typename MT // Type of the sparse matrix
1535  , bool SF > // Symmetry flag
1536 inline typename Column<MT,true,false,SF>::Iterator Column<MT,true,false,SF>::find( size_t index )
1537 {
1538  return matrix_.find( index, col_ );
1539 }
1541 //*************************************************************************************************
1542 
1543 
1544 //*************************************************************************************************
1558 template< typename MT // Type of the sparse matrix
1559  , bool SF > // Symmetry flag
1561  Column<MT,true,false,SF>::find( size_t index ) const
1562 {
1563  return matrix_.find( index, col_ );
1564 }
1566 //*************************************************************************************************
1567 
1568 
1569 //*************************************************************************************************
1582 template< typename MT // Type of the sparse matrix
1583  , bool SF > // Symmetry flag
1584 inline typename Column<MT,true,false,SF>::Iterator Column<MT,true,false,SF>::lowerBound( size_t index )
1585 {
1586  return matrix_.lowerBound( index, col_ );
1587 }
1589 //*************************************************************************************************
1590 
1591 
1592 //*************************************************************************************************
1605 template< typename MT // Type of the sparse matrix
1606  , bool SF > // Symmetry flag
1608  Column<MT,true,false,SF>::lowerBound( size_t index ) const
1609 {
1610  return matrix_.lowerBound( index, col_ );
1611 }
1613 //*************************************************************************************************
1614 
1615 
1616 //*************************************************************************************************
1629 template< typename MT // Type of the sparse matrix
1630  , bool SF > // Symmetry flag
1631 inline typename Column<MT,true,false,SF>::Iterator Column<MT,true,false,SF>::upperBound( size_t index )
1632 {
1633  return matrix_.upperBound( index, col_ );
1634 }
1636 //*************************************************************************************************
1637 
1638 
1639 //*************************************************************************************************
1652 template< typename MT // Type of the sparse matrix
1653  , bool SF > // Symmetry flag
1655  Column<MT,true,false,SF>::upperBound( size_t index ) const
1656 {
1657  return matrix_.upperBound( index, col_ );
1658 }
1660 //*************************************************************************************************
1661 
1662 
1663 
1664 
1665 //=================================================================================================
1666 //
1667 // NUMERIC FUNCTIONS
1668 //
1669 //=================================================================================================
1670 
1671 //*************************************************************************************************
1682 template< typename MT // Type of the sparse matrix
1683  , bool SF > // Symmetry flag
1684 template< typename Other > // Data type of the scalar value
1685 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::scale( const Other& scalar )
1686 {
1688 
1689  for( Iterator element=begin(); element!=end(); ++element )
1690  element->value() *= scalar;
1691  return *this;
1692 }
1694 //*************************************************************************************************
1695 
1696 
1697 
1698 
1699 //=================================================================================================
1700 //
1701 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1702 //
1703 //=================================================================================================
1704 
1705 //*************************************************************************************************
1716 template< typename MT // Type of the sparse matrix
1717  , bool SF > // Symmetry flag
1718 template< typename Other > // Data type of the foreign expression
1719 inline bool Column<MT,true,false,SF>::canAlias( const Other* alias ) const noexcept
1720 {
1721  return matrix_.isAliased( alias );
1722 }
1724 //*************************************************************************************************
1725 
1726 
1727 //*************************************************************************************************
1738 template< typename MT // Type of the sparse matrix
1739  , bool SF > // Symmetry flag
1740 template< typename Other > // Data type of the foreign expression
1741 inline bool Column<MT,true,false,SF>::isAliased( const Other* alias ) const noexcept
1742 {
1743  return matrix_.isAliased( alias );
1744 }
1746 //*************************************************************************************************
1747 
1748 
1749 //*************************************************************************************************
1761 template< typename MT // Type of the sparse matrix
1762  , bool SF > // Symmetry flag
1763 template< typename VT > // Type of the right-hand side dense vector
1764 inline void Column<MT,true,false,SF>::assign( const DenseVector<VT,false>& rhs )
1765 {
1766  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1767  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1768 
1769  for( size_t i=0UL; i<size(); ++i )
1770  {
1771  if( matrix_.nonZeros( col_ ) == matrix_.capacity( col_ ) )
1772  matrix_.reserve( col_, extendCapacity() );
1773 
1774  matrix_.append( i, col_, (~rhs)[i], true );
1775  }
1776 }
1778 //*************************************************************************************************
1779 
1780 
1781 //*************************************************************************************************
1793 template< typename MT // Type of the sparse matrix
1794  , bool SF > // Symmetry flag
1795 template< typename VT > // Type of the right-hand side sparse vector
1796 inline void Column<MT,true,false,SF>::assign( const SparseVector<VT,false>& rhs )
1797 {
1798  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1799  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1800 
1801  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
1802  matrix_.append( element->index(), col_, element->value(), true );
1803  }
1804 }
1806 //*************************************************************************************************
1807 
1808 
1809 //*************************************************************************************************
1821 template< typename MT // Type of the sparse matrix
1822  , bool SF > // Symmetry flag
1823 template< typename VT > // Type of the right-hand side dense vector
1824 inline void Column<MT,true,false,SF>::addAssign( const DenseVector<VT,false>& rhs )
1825 {
1826  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
1827 
1831 
1832  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1833 
1834  const AddType tmp( serial( *this + (~rhs) ) );
1835  matrix_.reset( col_ );
1836  assign( tmp );
1837 }
1839 //*************************************************************************************************
1840 
1841 
1842 //*************************************************************************************************
1854 template< typename MT // Type of the sparse matrix
1855  , bool SF > // Symmetry flag
1856 template< typename VT > // Type of the right-hand side sparse vector
1857 inline void Column<MT,true,false,SF>::addAssign( const SparseVector<VT,false>& rhs )
1858 {
1859  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
1860 
1864 
1865  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1866 
1867  const AddType tmp( serial( *this + (~rhs) ) );
1868  matrix_.reset( col_ );
1869  matrix_.reserve( col_, tmp.nonZeros() );
1870  assign( tmp );
1871 }
1873 //*************************************************************************************************
1874 
1875 
1876 //*************************************************************************************************
1888 template< typename MT // Type of the sparse matrix
1889  , bool SF > // Symmetry flag
1890 template< typename VT > // Type of the right-hand side dense vector
1891 inline void Column<MT,true,false,SF>::subAssign( const DenseVector<VT,false>& rhs )
1892 {
1893  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
1894 
1898 
1899  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1900 
1901  const SubType tmp( serial( *this - (~rhs) ) );
1902  matrix_.reset( col_ );
1903  assign( tmp );
1904 }
1906 //*************************************************************************************************
1907 
1908 
1909 //*************************************************************************************************
1921 template< typename MT // Type of the sparse matrix
1922  , bool SF > // Symmetry flag
1923 template< typename VT > // Type of the right-hand side sparse vector
1924 inline void Column<MT,true,false,SF>::subAssign( const SparseVector<VT,false>& rhs )
1925 {
1926  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
1927 
1931 
1932  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1933 
1934  const SubType tmp( serial( *this - (~rhs) ) );
1935  matrix_.reset( col_ );
1936  matrix_.reserve( col_, tmp.nonZeros() );
1937  assign( tmp );
1938 }
1940 //*************************************************************************************************
1941 
1942 
1943 
1944 
1945 
1946 
1947 
1948 
1949 //=================================================================================================
1950 //
1951 // CLASS TEMPLATE SPECIALIZATION FOR GENERAL ROW-MAJOR SPARSE MATRICES
1952 //
1953 //=================================================================================================
1954 
1955 //*************************************************************************************************
1963 template< typename MT > // Type of the sparse matrix
1964 class Column<MT,false,false,false>
1965  : public SparseVector< Column<MT,false,false,false>, false >
1966  , private View
1967 {
1968  private:
1969  //**Type definitions****************************************************************************
1971  typedef If_< IsExpression<MT>, MT, MT& > Operand;
1972  //**********************************************************************************************
1973 
1974  public:
1975  //**Type definitions****************************************************************************
1976  typedef Column<MT,false,false,false> This;
1977  typedef SparseVector<This,false> BaseType;
1978  typedef ColumnTrait_<MT> ResultType;
1979  typedef TransposeType_<ResultType> TransposeType;
1980  typedef ElementType_<MT> ElementType;
1981  typedef ReturnType_<MT> ReturnType;
1982  typedef const Column& CompositeType;
1983 
1985  typedef ConstReference_<MT> ConstReference;
1986 
1988  typedef If_< IsConst<MT>, ConstReference, Reference_<MT> > Reference;
1989  //**********************************************************************************************
1990 
1991  //**ColumnElement class definition**************************************************************
1994  template< typename MatrixType // Type of the sparse matrix
1995  , typename IteratorType > // Type of the sparse matrix iterator
1996  class ColumnElement : private SparseElement
1997  {
1998  private:
1999  //*******************************************************************************************
2001 
2006  enum : bool { returnConst = IsConst<MatrixType>::value };
2007  //*******************************************************************************************
2008 
2009  //**Type definitions*************************************************************************
2011  typedef typename std::iterator_traits<IteratorType>::value_type SET;
2012 
2013  typedef Reference_<SET> RT;
2014  typedef ConstReference_<SET> CRT;
2015  //*******************************************************************************************
2016 
2017  public:
2018  //**Type definitions*************************************************************************
2019  typedef ValueType_<SET> ValueType;
2020  typedef size_t IndexType;
2021  typedef IfTrue_<returnConst,CRT,RT> Reference;
2022  typedef CRT ConstReference;
2023  //*******************************************************************************************
2024 
2025  //**Constructor******************************************************************************
2031  inline ColumnElement( IteratorType pos, size_t row )
2032  : pos_( pos ) // Iterator to the current position within the sparse column
2033  , row_( row ) // Index of the according row
2034  {}
2035  //*******************************************************************************************
2036 
2037  //**Assignment operator**********************************************************************
2043  template< typename T > inline ColumnElement& operator=( const T& v ) {
2044  *pos_ = v;
2045  return *this;
2046  }
2047  //*******************************************************************************************
2048 
2049  //**Addition assignment operator*************************************************************
2055  template< typename T > inline ColumnElement& operator+=( const T& v ) {
2056  *pos_ += v;
2057  return *this;
2058  }
2059  //*******************************************************************************************
2060 
2061  //**Subtraction assignment operator**********************************************************
2067  template< typename T > inline ColumnElement& operator-=( const T& v ) {
2068  *pos_ -= v;
2069  return *this;
2070  }
2071  //*******************************************************************************************
2072 
2073  //**Multiplication assignment operator*******************************************************
2079  template< typename T > inline ColumnElement& operator*=( const T& v ) {
2080  *pos_ *= v;
2081  return *this;
2082  }
2083  //*******************************************************************************************
2084 
2085  //**Division assignment operator*************************************************************
2091  template< typename T > inline ColumnElement& operator/=( const T& v ) {
2092  *pos_ /= v;
2093  return *this;
2094  }
2095  //*******************************************************************************************
2096 
2097  //**Element access operator******************************************************************
2102  inline const ColumnElement* operator->() const {
2103  return this;
2104  }
2105  //*******************************************************************************************
2106 
2107  //**Value function***************************************************************************
2112  inline Reference value() const {
2113  return pos_->value();
2114  }
2115  //*******************************************************************************************
2116 
2117  //**Index function***************************************************************************
2122  inline IndexType index() const {
2123  return row_;
2124  }
2125  //*******************************************************************************************
2126 
2127  private:
2128  //**Member variables*************************************************************************
2129  IteratorType pos_;
2130  size_t row_;
2131  //*******************************************************************************************
2132  };
2133  //**********************************************************************************************
2134 
2135  //**ColumnIterator class definition*************************************************************
2138  template< typename MatrixType // Type of the sparse matrix
2139  , typename IteratorType > // Type of the sparse matrix iterator
2140  class ColumnIterator
2141  {
2142  public:
2143  //**Type definitions*************************************************************************
2144  typedef std::forward_iterator_tag IteratorCategory;
2145  typedef ColumnElement<MatrixType,IteratorType> ValueType;
2146  typedef ValueType PointerType;
2147  typedef ValueType ReferenceType;
2148  typedef ptrdiff_t DifferenceType;
2149 
2150  // STL iterator requirements
2151  typedef IteratorCategory iterator_category;
2152  typedef ValueType value_type;
2153  typedef PointerType pointer;
2154  typedef ReferenceType reference;
2155  typedef DifferenceType difference_type;
2156  //*******************************************************************************************
2157 
2158  //**Constructor******************************************************************************
2161  inline ColumnIterator()
2162  : matrix_( nullptr ) // The sparse matrix containing the column.
2163  , row_ ( 0UL ) // The current row index.
2164  , column_( 0UL ) // The current column index.
2165  , pos_ () // Iterator to the current sparse element.
2166  {}
2167  //*******************************************************************************************
2168 
2169  //**Constructor******************************************************************************
2176  inline ColumnIterator( MatrixType& matrix, size_t row, size_t column )
2177  : matrix_( &matrix ) // The sparse matrix containing the column.
2178  , row_ ( row ) // The current row index.
2179  , column_( column ) // The current column index.
2180  , pos_ () // Iterator to the current sparse element.
2181  {
2182  for( ; row_<matrix_->rows(); ++row_ ) {
2183  pos_ = matrix_->find( row_, column_ );
2184  if( pos_ != matrix_->end( row_ ) ) break;
2185  }
2186  }
2187  //*******************************************************************************************
2188 
2189  //**Constructor******************************************************************************
2197  inline ColumnIterator( MatrixType& matrix, size_t row, size_t column, IteratorType pos )
2198  : matrix_( &matrix ) // The sparse matrix containing the column.
2199  , row_ ( row ) // The current row index.
2200  , column_( column ) // The current column index.
2201  , pos_ ( pos ) // Iterator to the current sparse element.
2202  {
2203  BLAZE_INTERNAL_ASSERT( matrix.find( row, column ) == pos, "Invalid initial iterator position" );
2204  }
2205  //*******************************************************************************************
2206 
2207  //**Constructor******************************************************************************
2212  template< typename MatrixType2, typename IteratorType2 >
2213  inline ColumnIterator( const ColumnIterator<MatrixType2,IteratorType2>& it )
2214  : matrix_( it.matrix_ ) // The sparse matrix containing the column.
2215  , row_ ( it.row_ ) // The current row index.
2216  , column_( it.column_ ) // The current column index.
2217  , pos_ ( it.pos_ ) // Iterator to the current sparse element.
2218  {}
2219  //*******************************************************************************************
2220 
2221  //**Prefix increment operator****************************************************************
2226  inline ColumnIterator& operator++() {
2227  ++row_;
2228  for( ; row_<matrix_->rows(); ++row_ ) {
2229  pos_ = matrix_->find( row_, column_ );
2230  if( pos_ != matrix_->end( row_ ) ) break;
2231  }
2232 
2233  return *this;
2234  }
2235  //*******************************************************************************************
2236 
2237  //**Postfix increment operator***************************************************************
2242  inline const ColumnIterator operator++( int ) {
2243  const ColumnIterator tmp( *this );
2244  ++(*this);
2245  return tmp;
2246  }
2247  //*******************************************************************************************
2248 
2249  //**Element access operator******************************************************************
2254  inline ReferenceType operator*() const {
2255  return ReferenceType( pos_, row_ );
2256  }
2257  //*******************************************************************************************
2258 
2259  //**Element access operator******************************************************************
2264  inline PointerType operator->() const {
2265  return PointerType( pos_, row_ );
2266  }
2267  //*******************************************************************************************
2268 
2269  //**Equality operator************************************************************************
2275  template< typename MatrixType2, typename IteratorType2 >
2276  inline bool operator==( const ColumnIterator<MatrixType2,IteratorType2>& rhs ) const {
2277  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
2278  }
2279  //*******************************************************************************************
2280 
2281  //**Inequality operator**********************************************************************
2287  template< typename MatrixType2, typename IteratorType2 >
2288  inline bool operator!=( const ColumnIterator<MatrixType2,IteratorType2>& rhs ) const {
2289  return !( *this == rhs );
2290  }
2291  //*******************************************************************************************
2292 
2293  //**Subtraction operator*********************************************************************
2299  inline DifferenceType operator-( const ColumnIterator& rhs ) const {
2300  size_t counter( 0UL );
2301  for( size_t i=rhs.row_; i<row_; ++i ) {
2302  if( matrix_->find( i, column_ ) != matrix_->end( i ) )
2303  ++counter;
2304  }
2305  return counter;
2306  }
2307  //*******************************************************************************************
2308 
2309  private:
2310  //**Member variables*************************************************************************
2311  MatrixType* matrix_;
2312  size_t row_;
2313  size_t column_;
2314  IteratorType pos_;
2315  //*******************************************************************************************
2316 
2317  //**Friend declarations**********************************************************************
2318  template< typename MatrixType2, typename IteratorType2 > friend class ColumnIterator;
2319  template< typename MT2, bool SO2, bool DF2, bool SF2 > friend class Column;
2320  //*******************************************************************************************
2321  };
2322  //**********************************************************************************************
2323 
2324  //**Type definitions****************************************************************************
2326  typedef ColumnIterator< const MT, ConstIterator_<MT> > ConstIterator;
2327 
2329  typedef If_< IsConst<MT>, ConstIterator, ColumnIterator< MT, Iterator_<MT> > > Iterator;
2330  //**********************************************************************************************
2331 
2332  //**Compilation flags***************************************************************************
2334  enum : bool { smpAssignable = false };
2335  //**********************************************************************************************
2336 
2337  //**Constructors********************************************************************************
2340  explicit inline Column( Operand matrix, size_t index );
2341  // No explicitly declared copy constructor.
2343  //**********************************************************************************************
2344 
2345  //**Destructor**********************************************************************************
2346  // No explicitly declared destructor.
2347  //**********************************************************************************************
2348 
2349  //**Data access functions***********************************************************************
2352  inline Reference operator[]( size_t index );
2353  inline ConstReference operator[]( size_t index ) const;
2354  inline Reference at( size_t index );
2355  inline ConstReference at( size_t index ) const;
2356  inline Iterator begin ();
2357  inline ConstIterator begin () const;
2358  inline ConstIterator cbegin() const;
2359  inline Iterator end ();
2360  inline ConstIterator end () const;
2361  inline ConstIterator cend () const;
2363  //**********************************************************************************************
2364 
2365  //**Assignment operators************************************************************************
2368  inline Column& operator= ( const Column& rhs );
2369  template< typename VT > inline Column& operator= ( const Vector<VT,false>& rhs );
2370  template< typename VT > inline Column& operator+=( const Vector<VT,false>& rhs );
2371  template< typename VT > inline Column& operator-=( const Vector<VT,false>& rhs );
2372  template< typename VT > inline Column& operator*=( const Vector<VT,false>& rhs );
2373  template< typename VT > inline Column& operator/=( const DenseVector<VT,false>& rhs );
2374 
2375  template< typename Other >
2376  inline EnableIf_<IsNumeric<Other>, Column >& operator*=( Other rhs );
2377 
2378  template< typename Other >
2379  inline EnableIf_<IsNumeric<Other>, Column >& operator/=( Other rhs );
2381  //**********************************************************************************************
2382 
2383  //**Utility functions***************************************************************************
2386  inline size_t size() const;
2387  inline size_t capacity() const;
2388  inline size_t nonZeros() const;
2389  inline void reset();
2390  inline void reserve( size_t n );
2392  //**********************************************************************************************
2393 
2394  //**Insertion functions*************************************************************************
2397  inline Iterator set ( size_t index, const ElementType& value );
2398  inline Iterator insert( size_t index, const ElementType& value );
2399  inline void append( size_t index, const ElementType& value, bool check=false );
2401  //**********************************************************************************************
2402 
2403  //**Erase functions*****************************************************************************
2406  inline void erase( size_t index );
2407  inline Iterator erase( Iterator pos );
2408  inline Iterator erase( Iterator first, Iterator last );
2409 
2410  template< typename Pred, typename = DisableIf_< IsIntegral<Pred> > >
2411  inline void erase( Pred predicate );
2412 
2413  template< typename Pred >
2414  inline void erase( Iterator first, Iterator last, Pred predicate );
2416  //**********************************************************************************************
2417 
2418  //**Lookup functions****************************************************************************
2421  inline Iterator find ( size_t index );
2422  inline ConstIterator find ( size_t index ) const;
2423  inline Iterator lowerBound( size_t index );
2424  inline ConstIterator lowerBound( size_t index ) const;
2425  inline Iterator upperBound( size_t index );
2426  inline ConstIterator upperBound( size_t index ) const;
2428  //**********************************************************************************************
2429 
2430  //**Numeric functions***************************************************************************
2433  template< typename Other > inline Column& scale( const Other& scalar );
2435  //**********************************************************************************************
2436 
2437  //**Expression template evaluation functions****************************************************
2440  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2441  template< typename Other > inline bool isAliased( const Other* alias ) const;
2442 
2443  template< typename VT > inline void assign ( const DenseVector <VT,false>& rhs );
2444  template< typename VT > inline void assign ( const SparseVector<VT,false>& rhs );
2445  template< typename VT > inline void addAssign( const Vector<VT,false>& rhs );
2446  template< typename VT > inline void subAssign( const Vector<VT,false>& rhs );
2448  //**********************************************************************************************
2449 
2450  private:
2451  //**Member variables****************************************************************************
2454  Operand matrix_;
2455  const size_t col_;
2456 
2457  //**********************************************************************************************
2458 
2459  //**Friend declarations*************************************************************************
2460  template< typename MT2, bool SO2, bool DF2, bool SF2 >
2461  friend bool isIntact( const Column<MT2,SO2,DF2,SF2>& column ) noexcept;
2462 
2463  template< typename MT2, bool SO2, bool DF2, bool SF2 >
2464  friend bool isSame( const Column<MT2,SO2,DF2,SF2>& a, const Column<MT2,SO2,DF2,SF2>& b ) noexcept;
2465 
2466  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2467  friend bool tryAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
2468 
2469  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2470  friend bool tryAddAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
2471 
2472  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2473  friend bool trySubAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
2474 
2475  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2476  friend bool tryMultAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
2477 
2478  template< typename MT2, bool SO2, bool DF2, bool SF2 >
2479  friend DerestrictTrait_< Column<MT2,SO2,DF2,SF2> > derestrict( Column<MT2,SO2,DF2,SF2>& column );
2480  //**********************************************************************************************
2481 
2482  //**Compile time checks*************************************************************************
2490  //**********************************************************************************************
2491 };
2493 //*************************************************************************************************
2494 
2495 
2496 
2497 
2498 //=================================================================================================
2499 //
2500 // CONSTRUCTOR
2501 //
2502 //=================================================================================================
2503 
2504 //*************************************************************************************************
2512 template< typename MT > // Type of the sparse matrix
2513 inline Column<MT,false,false,false>::Column( Operand matrix, size_t index )
2514  : matrix_( matrix ) // The sparse matrix containing the column
2515  , col_ ( index ) // The index of the column in the matrix
2516 {
2517  if( matrix_.columns() <= index ) {
2518  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
2519  }
2520 }
2522 //*************************************************************************************************
2523 
2524 
2525 
2526 
2527 //=================================================================================================
2528 //
2529 // DATA ACCESS FUNCTIONS
2530 //
2531 //=================================================================================================
2532 
2533 //*************************************************************************************************
2543 template< typename MT > // Type of the sparse matrix
2545  Column<MT,false,false,false>::operator[]( size_t index )
2546 {
2547  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
2548  return matrix_(index,col_);
2549 }
2551 //*************************************************************************************************
2552 
2553 
2554 //*************************************************************************************************
2564 template< typename MT > // Type of the sparse matrix
2566  Column<MT,false,false,false>::operator[]( size_t index ) const
2567 {
2568  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
2569  return const_cast<const MT&>( matrix_ )(index,col_);
2570 }
2572 //*************************************************************************************************
2573 
2574 
2575 //*************************************************************************************************
2586 template< typename MT > // Type of the sparse matrix
2588  Column<MT,false,false,false>::at( size_t index )
2589 {
2590  if( index >= size() ) {
2591  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
2592  }
2593  return (*this)[index];
2594 }
2596 //*************************************************************************************************
2597 
2598 
2599 //*************************************************************************************************
2610 template< typename MT > // Type of the sparse matrix
2612  Column<MT,false,false,false>::at( size_t index ) const
2613 {
2614  if( index >= size() ) {
2615  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
2616  }
2617  return (*this)[index];
2618 }
2620 //*************************************************************************************************
2621 
2622 
2623 //*************************************************************************************************
2631 template< typename MT > // Type of the sparse matrix
2633 {
2634  return Iterator( matrix_, 0UL, col_ );
2635 }
2637 //*************************************************************************************************
2638 
2639 
2640 //*************************************************************************************************
2648 template< typename MT > // Type of the sparse matrix
2651 {
2652  return ConstIterator( matrix_, 0UL, col_ );
2653 }
2655 //*************************************************************************************************
2656 
2657 
2658 //*************************************************************************************************
2666 template< typename MT > // Type of the sparse matrix
2669 {
2670  return ConstIterator( matrix_, 0UL, col_ );
2671 }
2673 //*************************************************************************************************
2674 
2675 
2676 //*************************************************************************************************
2684 template< typename MT > // Type of the sparse matrix
2686 {
2687  return Iterator( matrix_, size(), col_ );
2688 }
2690 //*************************************************************************************************
2691 
2692 
2693 //*************************************************************************************************
2701 template< typename MT > // Type of the sparse matrix
2704 {
2705  return ConstIterator( matrix_, size(), col_ );
2706 }
2708 //*************************************************************************************************
2709 
2710 
2711 //*************************************************************************************************
2719 template< typename MT > // Type of the sparse matrix
2722 {
2723  return ConstIterator( matrix_, size(), col_ );
2724 }
2726 //*************************************************************************************************
2727 
2728 
2729 
2730 
2731 //=================================================================================================
2732 //
2733 // ASSIGNMENT OPERATORS
2734 //
2735 //=================================================================================================
2736 
2737 //*************************************************************************************************
2751 template< typename MT > // Type of the sparse matrix
2752 inline Column<MT,false,false,false>&
2753  Column<MT,false,false,false>::operator=( const Column& rhs )
2754 {
2755  using blaze::assign;
2756 
2760 
2761  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
2762  return *this;
2763 
2764  if( size() != rhs.size() ) {
2765  BLAZE_THROW_INVALID_ARGUMENT( "Column sizes do not match" );
2766  }
2767 
2768  if( !tryAssign( matrix_, rhs, 0UL, col_ ) ) {
2769  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2770  }
2771 
2772  DerestrictTrait_<This> left( derestrict( *this ) );
2773 
2774  if( rhs.canAlias( &matrix_ ) ) {
2775  const ResultType tmp( rhs );
2776  assign( left, tmp );
2777  }
2778  else {
2779  assign( left, rhs );
2780  }
2781 
2782  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2783 
2784  return *this;
2785 }
2787 //*************************************************************************************************
2788 
2789 
2790 //*************************************************************************************************
2804 template< typename MT > // Type of the sparse matrix
2805 template< typename VT > // Type of the right-hand side vector
2806 inline Column<MT,false,false,false>&
2807  Column<MT,false,false,false>::operator=( const Vector<VT,false>& rhs )
2808 {
2809  using blaze::assign;
2810 
2811  if( size() != (~rhs).size() ) {
2812  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2813  }
2814 
2815  const CompositeType_<VT> tmp( ~rhs );
2816 
2817  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
2818  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2819  }
2820 
2821  DerestrictTrait_<This> left( derestrict( *this ) );
2822 
2823  assign( left, tmp );
2824 
2825  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2826 
2827  return *this;
2828 }
2830 //*************************************************************************************************
2831 
2832 
2833 //*************************************************************************************************
2847 template< typename MT > // Type of the sparse matrix
2848 template< typename VT > // Type of the right-hand side vector
2849 inline Column<MT,false,false,false>&
2850  Column<MT,false,false,false>::operator+=( const Vector<VT,false>& rhs )
2851 {
2852  using blaze::assign;
2853 
2857  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
2859 
2860  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
2861 
2864 
2865  if( size() != (~rhs).size() ) {
2866  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2867  }
2868 
2869  const AddType tmp( *this + (~rhs) );
2870 
2871  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
2872  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2873  }
2874 
2875  DerestrictTrait_<This> left( derestrict( *this ) );
2876 
2877  assign( left, tmp );
2878 
2879  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2880 
2881  return *this;
2882 }
2884 //*************************************************************************************************
2885 
2886 
2887 //*************************************************************************************************
2901 template< typename MT > // Type of the sparse matrix
2902 template< typename VT > // Type of the right-hand side vector
2903 inline Column<MT,false,false,false>&
2904  Column<MT,false,false,false>::operator-=( const Vector<VT,false>& rhs )
2905 {
2906  using blaze::assign;
2907 
2911  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
2913 
2914  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
2915 
2918 
2919  if( size() != (~rhs).size() ) {
2920  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2921  }
2922 
2923  const SubType tmp( *this - (~rhs) );
2924 
2925  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
2926  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2927  }
2928 
2929  DerestrictTrait_<This> left( derestrict( *this ) );
2930 
2931  assign( left, tmp );
2932 
2933  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2934 
2935  return *this;
2936 }
2938 //*************************************************************************************************
2939 
2940 
2941 //*************************************************************************************************
2954 template< typename MT > // Type of the sparse matrix
2955 template< typename VT > // Type of the right-hand side vector
2956 inline Column<MT,false,false,false>&
2957  Column<MT,false,false,false>::operator*=( const Vector<VT,false>& rhs )
2958 {
2959  using blaze::assign;
2960 
2964  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
2966 
2967  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
2968 
2971 
2972  if( size() != (~rhs).size() ) {
2973  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2974  }
2975 
2976  const MultType tmp( *this * (~rhs) );
2977 
2978  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
2979  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2980  }
2981 
2982  DerestrictTrait_<This> left( derestrict( *this ) );
2983 
2984  assign( left, tmp );
2985 
2986  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2987 
2988  return *this;
2989 }
2991 //*************************************************************************************************
2992 
2993 
2994 //*************************************************************************************************
3006 template< typename MT > // Type of the sparse matrix
3007 template< typename VT > // Type of the right-hand side vector
3008 inline Column<MT,false,false,false>&
3009  Column<MT,false,false,false>::operator/=( const DenseVector<VT,false>& rhs )
3010 {
3011  using blaze::assign;
3012 
3016  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
3017  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
3019 
3020  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
3021 
3025 
3026  if( size() != (~rhs).size() ) {
3027  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3028  }
3029 
3030  const DivType tmp( *this / (~rhs) );
3031 
3032  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
3033  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3034  }
3035 
3036  DerestrictTrait_<This> left( derestrict( *this ) );
3037 
3038  assign( left, tmp );
3039 
3040  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3041 
3042  return *this;
3043 }
3045 //*************************************************************************************************
3046 
3047 
3048 //*************************************************************************************************
3063 template< typename MT > // Type of the sparse matrix
3064 template< typename Other > // Data type of the right-hand side scalar
3065 inline EnableIf_<IsNumeric<Other>, Column<MT,false,false,false> >&
3067 {
3069 
3070  for( Iterator element=begin(); element!=end(); ++element )
3071  element->value() *= rhs;
3072  return *this;
3073 }
3075 //*************************************************************************************************
3076 
3077 
3078 //*************************************************************************************************
3096 template< typename MT > // Type of the sparse matrix
3097 template< typename Other > // Data type of the right-hand side scalar
3098 inline EnableIf_<IsNumeric<Other>, Column<MT,false,false,false> >&
3100 {
3102 
3103  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3104 
3105  typedef DivTrait_<ElementType,Other> DT;
3106  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
3107 
3108  // Depending on the two involved data types, an integer division is applied or a
3109  // floating point division is selected.
3110  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
3111  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
3112  for( Iterator element=begin(); element!=end(); ++element )
3113  element->value() *= tmp;
3114  }
3115  else {
3116  for( Iterator element=begin(); element!=end(); ++element )
3117  element->value() /= rhs;
3118  }
3119 
3120  return *this;
3121 }
3123 //*************************************************************************************************
3124 
3125 
3126 
3127 
3128 //=================================================================================================
3129 //
3130 // UTILITY FUNCTIONS
3131 //
3132 //=================================================================================================
3133 
3134 //*************************************************************************************************
3140 template< typename MT > // Type of the sparse matrix
3141 inline size_t Column<MT,false,false,false>::size() const
3142 {
3143  return matrix_.rows();
3144 }
3146 //*************************************************************************************************
3147 
3148 
3149 //*************************************************************************************************
3155 template< typename MT > // Type of the sparse matrix
3156 inline size_t Column<MT,false,false,false>::capacity() const
3157 {
3158  return matrix_.rows();
3159 }
3161 //*************************************************************************************************
3162 
3163 
3164 //*************************************************************************************************
3173 template< typename MT > // Type of the sparse matrix
3174 inline size_t Column<MT,false,false,false>::nonZeros() const
3175 {
3176  size_t counter( 0UL );
3177  for( ConstIterator element=begin(); element!=end(); ++element ) {
3178  ++counter;
3179  }
3180  return counter;
3181 }
3183 //*************************************************************************************************
3184 
3185 
3186 //*************************************************************************************************
3192 template< typename MT > // Type of the sparse matrix
3194 {
3195  const size_t ibegin( ( IsLower<MT>::value )
3196  ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3197  ?( col_+1UL )
3198  :( col_ ) )
3199  :( 0UL ) );
3200  const size_t iend ( ( IsUpper<MT>::value )
3201  ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3202  ?( col_ )
3203  :( col_+1UL ) )
3204  :( size() ) );
3205 
3206  for( size_t i=ibegin; i<iend; ++i ) {
3207  matrix_.erase( i, col_ );
3208  }
3209 }
3211 //*************************************************************************************************
3212 
3213 
3214 //*************************************************************************************************
3224 template< typename MT > // Type of the sparse matrix
3225 void Column<MT,false,false,false>::reserve( size_t n )
3226 {
3227  UNUSED_PARAMETER( n );
3228 
3229  return;
3230 }
3232 //*************************************************************************************************
3233 
3234 
3235 
3236 
3237 //=================================================================================================
3238 //
3239 // INSERTION FUNCTIONS
3240 //
3241 //=================================================================================================
3242 
3243 //*************************************************************************************************
3255 template< typename MT > // Type of the sparse matrix
3257  Column<MT,false,false,false>::set( size_t index, const ElementType& value )
3258 {
3259  return Iterator( matrix_, index, col_, matrix_.set( index, col_, value ) );
3260 }
3262 //*************************************************************************************************
3263 
3264 
3265 //*************************************************************************************************
3278 template< typename MT > // Type of the sparse matrix
3280  Column<MT,false,false,false>::insert( size_t index, const ElementType& value )
3281 {
3282  return Iterator( matrix_, index, col_, matrix_.insert( index, col_, value ) );
3283 }
3285 //*************************************************************************************************
3286 
3287 
3288 //*************************************************************************************************
3313 template< typename MT > // Type of the sparse matrix
3314 inline void Column<MT,false,false,false>::append( size_t index, const ElementType& value, bool check )
3315 {
3316  if( !check || !isDefault( value ) )
3317  matrix_.insert( index, col_, value );
3318 }
3320 //*************************************************************************************************
3321 
3322 
3323 
3324 
3325 //=================================================================================================
3326 //
3327 // ERASE FUNCTIONS
3328 //
3329 //=================================================================================================
3330 
3331 //*************************************************************************************************
3340 template< typename MT > // Type of the sparse matrix
3341 inline void Column<MT,false,false,false>::erase( size_t index )
3342 {
3343  matrix_.erase( index, col_ );
3344 }
3346 //*************************************************************************************************
3347 
3348 
3349 //*************************************************************************************************
3358 template< typename MT > // Type of the sparse matrix
3360  Column<MT,false,false,false>::erase( Iterator pos )
3361 {
3362  const size_t row( pos.row_ );
3363 
3364  if( row == size() )
3365  return pos;
3366 
3367  matrix_.erase( row, pos.pos_ );
3368  return Iterator( matrix_, row+1UL, col_ );
3369 }
3371 //*************************************************************************************************
3372 
3373 
3374 //*************************************************************************************************
3384 template< typename MT > // Type of the sparse matrix
3386  Column<MT,false,false,false>::erase( Iterator first, Iterator last )
3387 {
3388  for( ; first!=last; ++first ) {
3389  matrix_.erase( first.row_, first.pos_ );
3390  }
3391  return last;
3392 }
3394 //*************************************************************************************************
3395 
3396 
3397 //*************************************************************************************************
3420 template< typename MT > // Type of the sparse matrix
3421 template< typename Pred // Type of the unary predicate
3422  , typename > // Type restriction on the unary predicate
3423 inline void Column<MT,false,false,false>::erase( Pred predicate )
3424 {
3425  for( Iterator element=begin(); element!=end(); ++element ) {
3426  if( predicate( element->value() ) )
3427  matrix_.erase( element.row_, element.pos_ );
3428  }
3429 }
3431 //*************************************************************************************************
3432 
3433 
3434 //*************************************************************************************************
3460 template< typename MT > // Type of the sparse matrix
3461 template< typename Pred > // Type of the unary predicate
3462 inline void Column<MT,false,false,false>::erase( Iterator first, Iterator last, Pred predicate )
3463 {
3464  for( ; first!=last; ++first ) {
3465  if( predicate( first->value() ) )
3466  matrix_.erase( first.row_, first.pos_ );
3467  }
3468 }
3470 //*************************************************************************************************
3471 
3472 
3473 
3474 
3475 //=================================================================================================
3476 //
3477 // LOOKUP FUNCTIONS
3478 //
3479 //=================================================================================================
3480 
3481 //*************************************************************************************************
3495 template< typename MT > // Type of the sparse matrix
3497  Column<MT,false,false,false>::find( size_t index )
3498 {
3499  const Iterator_<MT> pos( matrix_.find( index, col_ ) );
3500 
3501  if( pos != matrix_.end( index ) )
3502  return Iterator( matrix_, index, col_, pos );
3503  else
3504  return end();
3505 }
3507 //*************************************************************************************************
3508 
3509 
3510 //*************************************************************************************************
3524 template< typename MT > // Type of the sparse matrix
3526  Column<MT,false,false,false>::find( size_t index ) const
3527 {
3528  const ConstIterator_<MT> pos( matrix_.find( index, col_ ) );
3529 
3530  if( pos != matrix_.end( index ) )
3531  return ConstIterator( matrix_, index, col_, pos );
3532  else
3533  return end();
3534 }
3536 //*************************************************************************************************
3537 
3538 
3539 //*************************************************************************************************
3552 template< typename MT > // Type of the sparse matrix
3554  Column<MT,false,false,false>::lowerBound( size_t index )
3555 {
3556  for( size_t i=index; i<size(); ++i )
3557  {
3558  const Iterator_<MT> pos( matrix_.find( i, col_ ) );
3559 
3560  if( pos != matrix_.end( i ) )
3561  return Iterator( matrix_, i, col_, pos );
3562  }
3563 
3564  return end();
3565 }
3567 //*************************************************************************************************
3568 
3569 
3570 //*************************************************************************************************
3583 template< typename MT > // Type of the sparse matrix
3585  Column<MT,false,false,false>::lowerBound( size_t index ) const
3586 {
3587  for( size_t i=index; i<size(); ++i )
3588  {
3589  const ConstIterator_<MT> pos( matrix_.find( i, col_ ) );
3590 
3591  if( pos != matrix_.end( i ) )
3592  return ConstIterator( matrix_, i, col_, pos );
3593  }
3594 
3595  return end();
3596 }
3598 //*************************************************************************************************
3599 
3600 
3601 //*************************************************************************************************
3614 template< typename MT > // Type of the sparse matrix
3616  Column<MT,false,false,false>::upperBound( size_t index )
3617 {
3618  for( size_t i=index+1UL; i<size(); ++i )
3619  {
3620  const Iterator_<MT> pos( matrix_.find( i, col_ ) );
3621 
3622  if( pos != matrix_.end( i ) )
3623  return Iterator( matrix_, i, col_, pos );
3624  }
3625 
3626  return end();
3627 }
3629 //*************************************************************************************************
3630 
3631 
3632 //*************************************************************************************************
3645 template< typename MT > // Type of the sparse matrix
3647  Column<MT,false,false,false>::upperBound( size_t index ) const
3648 {
3649  for( size_t i=index+1UL; i<size(); ++i )
3650  {
3651  const ConstIterator_<MT> pos( matrix_.find( i, col_ ) );
3652 
3653  if( pos != matrix_.end( i ) )
3654  return ConstIterator( matrix_, i, col_, pos );
3655  }
3656 
3657  return end();
3658 }
3660 //*************************************************************************************************
3661 
3662 
3663 
3664 
3665 //=================================================================================================
3666 //
3667 // NUMERIC FUNCTIONS
3668 //
3669 //=================================================================================================
3670 
3671 //*************************************************************************************************
3682 template< typename MT > // Type of the sparse matrix
3683 template< typename Other > // Data type of the scalar value
3684 inline Column<MT,false,false,false>& Column<MT,false,false,false>::scale( const Other& scalar )
3685 {
3687 
3688  for( Iterator element=begin(); element!=end(); ++element )
3689  element->value() *= scalar;
3690  return *this;
3691 }
3693 //*************************************************************************************************
3694 
3695 
3696 
3697 
3698 //=================================================================================================
3699 //
3700 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
3701 //
3702 //=================================================================================================
3703 
3704 //*************************************************************************************************
3715 template< typename MT > // Type of the sparse matrix
3716 template< typename Other > // Data type of the foreign expression
3717 inline bool Column<MT,false,false,false>::canAlias( const Other* alias ) const
3718 {
3719  return matrix_.isAliased( alias );
3720 }
3722 //*************************************************************************************************
3723 
3724 
3725 //*************************************************************************************************
3732 template< typename MT > // Type of the sparse matrix
3733 template< typename Other > // Data type of the foreign expression
3734 inline bool Column<MT,false,false,false>::isAliased( const Other* alias ) const
3735 {
3736  return matrix_.isAliased( alias );
3737 }
3739 //*************************************************************************************************
3740 
3741 
3742 //*************************************************************************************************
3754 template< typename MT > // Type of the sparse matrix
3755 template< typename VT > // Type of the right-hand side dense vector
3756 inline void Column<MT,false,false,false>::assign( const DenseVector<VT,false>& rhs )
3757 {
3758  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3759 
3760  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3761  matrix_(i,col_) = (~rhs)[i];
3762  }
3763 }
3765 //*************************************************************************************************
3766 
3767 
3768 //*************************************************************************************************
3780 template< typename MT > // Type of the sparse matrix
3781 template< typename VT > // Type of the right-hand side sparse vector
3782 inline void Column<MT,false,false,false>::assign( const SparseVector<VT,false>& rhs )
3783 {
3784  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3785 
3786  size_t i( 0UL );
3787 
3788  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
3789  for( ; i<element->index(); ++i )
3790  matrix_.erase( i, col_ );
3791  matrix_(i++,col_) = element->value();
3792  }
3793  for( ; i<size(); ++i ) {
3794  matrix_.erase( i, col_ );
3795  }
3796 }
3798 //*************************************************************************************************
3799 
3800 
3801 //*************************************************************************************************
3813 template< typename MT > // Type of the sparse matrix
3814 template< typename VT > // Type of the right-hand side vector
3815 inline void Column<MT,false,false,false>::addAssign( const Vector<VT,false>& rhs )
3816 {
3817  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
3818 
3821 
3822  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3823 
3824  const AddType tmp( serial( *this + (~rhs) ) );
3825  assign( tmp );
3826 }
3828 //*************************************************************************************************
3829 
3830 
3831 //*************************************************************************************************
3843 template< typename MT > // Type of the sparse matrix
3844 template< typename VT > // Type of the right-hand side vector
3845 inline void Column<MT,false,false,false>::subAssign( const Vector<VT,false>& rhs )
3846 {
3847  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
3848 
3851 
3852  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3853 
3854  const SubType tmp( serial( *this - (~rhs) ) );
3855  assign( tmp );
3856 }
3858 //*************************************************************************************************
3859 
3860 
3861 
3862 
3863 
3864 
3865 
3866 
3867 //=================================================================================================
3868 //
3869 // CLASS TEMPLATE SPECIALIZATION FOR SYMMETRIC ROW-MAJOR SPARSE MATRICES
3870 //
3871 //=================================================================================================
3872 
3873 //*************************************************************************************************
3881 template< typename MT > // Type of the sparse matrix
3882 class Column<MT,false,false,true>
3883  : public SparseVector< Column<MT,false,false,true>, false >
3884  , private View
3885 {
3886  private:
3887  //**Type definitions****************************************************************************
3889  typedef If_< IsExpression<MT>, MT, MT& > Operand;
3890  //**********************************************************************************************
3891 
3892  public:
3893  //**Type definitions****************************************************************************
3894  typedef Column<MT,false,false,true> This;
3895  typedef SparseVector<This,false> BaseType;
3896  typedef ColumnTrait_<MT> ResultType;
3897  typedef TransposeType_<ResultType> TransposeType;
3898  typedef ElementType_<MT> ElementType;
3899  typedef ReturnType_<MT> ReturnType;
3900  typedef const Column& CompositeType;
3901 
3903  typedef ConstReference_<MT> ConstReference;
3904 
3906  typedef If_< IsConst<MT>, ConstReference, Reference_<MT> > Reference;
3907 
3909  typedef ConstIterator_<MT> ConstIterator;
3910 
3912  typedef If_< IsConst<MT>, ConstIterator, Iterator_<MT> > Iterator;
3913  //**********************************************************************************************
3914 
3915  //**Compilation flags***************************************************************************
3917  enum : bool { smpAssignable = false };
3918  //**********************************************************************************************
3919 
3920  //**Constructors********************************************************************************
3923  explicit inline Column( Operand matrix, size_t index );
3924  // No explicitly declared copy constructor.
3926  //**********************************************************************************************
3927 
3928  //**Destructor**********************************************************************************
3929  // No explicitly declared destructor.
3930  //**********************************************************************************************
3931 
3932  //**Data access functions***********************************************************************
3935  inline Reference operator[]( size_t index );
3936  inline ConstReference operator[]( size_t index ) const;
3937  inline Reference at( size_t index );
3938  inline ConstReference at( size_t index ) const;
3939  inline Iterator begin ();
3940  inline ConstIterator begin () const;
3941  inline ConstIterator cbegin() const;
3942  inline Iterator end ();
3943  inline ConstIterator end () const;
3944  inline ConstIterator cend () const;
3946  //**********************************************************************************************
3947 
3948  //**Assignment operators************************************************************************
3951  inline Column& operator=( const Column& rhs );
3952 
3953  template< typename VT > inline Column& operator= ( const DenseVector<VT,false>& rhs );
3954  template< typename VT > inline Column& operator= ( const SparseVector<VT,false>& rhs );
3955  template< typename VT > inline Column& operator+=( const DenseVector<VT,false>& rhs );
3956  template< typename VT > inline Column& operator+=( const SparseVector<VT,false>& rhs );
3957  template< typename VT > inline Column& operator-=( const DenseVector<VT,false>& rhs );
3958  template< typename VT > inline Column& operator-=( const SparseVector<VT,false>& rhs );
3959  template< typename VT > inline Column& operator*=( const Vector<VT,false>& rhs );
3960  template< typename VT > inline Column& operator/=( const DenseVector<VT,false>& rhs );
3961 
3962  template< typename Other >
3963  inline EnableIf_<IsNumeric<Other>, Column >& operator*=( Other rhs );
3964 
3965  template< typename Other >
3966  inline EnableIf_<IsNumeric<Other>, Column >& operator/=( Other rhs );
3968  //**********************************************************************************************
3969 
3970  //**Utility functions***************************************************************************
3973  inline size_t size() const noexcept;
3974  inline size_t capacity() const noexcept;
3975  inline size_t nonZeros() const;
3976  inline void reset();
3977  inline void reserve( size_t n );
3979  //**********************************************************************************************
3980 
3981  //**Insertion functions*************************************************************************
3984  inline Iterator set ( size_t index, const ElementType& value );
3985  inline Iterator insert( size_t index, const ElementType& value );
3986  inline void append( size_t index, const ElementType& value, bool check=false );
3988  //**********************************************************************************************
3989 
3990  //**Erase functions*****************************************************************************
3993  inline void erase( size_t index );
3994  inline Iterator erase( Iterator pos );
3995  inline Iterator erase( Iterator first, Iterator last );
3996 
3997  template< typename Pred, typename = DisableIf_< IsIntegral<Pred> > >
3998  inline void erase( Pred predicate );
3999 
4000  template< typename Pred >
4001  inline void erase( Iterator first, Iterator last, Pred predicate );
4003  //**********************************************************************************************
4004 
4005  //**Lookup functions****************************************************************************
4008  inline Iterator find ( size_t index );
4009  inline ConstIterator find ( size_t index ) const;
4010  inline Iterator lowerBound( size_t index );
4011  inline ConstIterator lowerBound( size_t index ) const;
4012  inline Iterator upperBound( size_t index );
4013  inline ConstIterator upperBound( size_t index ) const;
4015  //**********************************************************************************************
4016 
4017  //**Numeric functions***************************************************************************
4020  template< typename Other > inline Column& scale( const Other& scalar );
4022  //**********************************************************************************************
4023 
4024  //**Expression template evaluation functions****************************************************
4027  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
4028  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
4029 
4030  template< typename VT > inline void assign ( const DenseVector <VT,false>& rhs );
4031  template< typename VT > inline void assign ( const SparseVector<VT,false>& rhs );
4032  template< typename VT > inline void addAssign( const DenseVector <VT,false>& rhs );
4033  template< typename VT > inline void addAssign( const SparseVector<VT,false>& rhs );
4034  template< typename VT > inline void subAssign( const DenseVector <VT,false>& rhs );
4035  template< typename VT > inline void subAssign( const SparseVector<VT,false>& rhs );
4037  //**********************************************************************************************
4038 
4039  private:
4040  //**Utility functions***************************************************************************
4043  inline size_t extendCapacity() const noexcept;
4045  //**********************************************************************************************
4046 
4047  //**Member variables****************************************************************************
4050  Operand matrix_;
4051  const size_t col_;
4052 
4053  //**********************************************************************************************
4054 
4055  //**Friend declarations*************************************************************************
4056  template< typename MT2, bool SO2, bool DF2, bool SF2 >
4057  friend bool isIntact( const Column<MT2,SO2,DF2,SF2>& column ) noexcept;
4058 
4059  template< typename MT2, bool SO2, bool DF2, bool SF2 >
4060  friend bool isSame( const Column<MT2,SO2,DF2,SF2>& a, const Column<MT2,SO2,DF2,SF2>& b ) noexcept;
4061 
4062  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
4063  friend bool tryAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
4064 
4065  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
4066  friend bool tryAddAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
4067 
4068  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
4069  friend bool trySubAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
4070 
4071  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
4072  friend bool tryMultAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
4073 
4074  template< typename MT2, bool SO2, bool DF2, bool SF2 >
4075  friend DerestrictTrait_< Column<MT2,SO2,DF2,SF2> > derestrict( Column<MT2,SO2,DF2,SF2>& column );
4076  //**********************************************************************************************
4077 
4078  //**Compile time checks*************************************************************************
4086  //**********************************************************************************************
4087 };
4089 //*************************************************************************************************
4090 
4091 
4092 
4093 
4094 //=================================================================================================
4095 //
4096 // CONSTRUCTOR
4097 //
4098 //=================================================================================================
4099 
4100 //*************************************************************************************************
4108 template< typename MT > // Type of the sparse matrix
4109 inline Column<MT,false,false,true>::Column( Operand matrix, size_t index )
4110  : matrix_( matrix ) // The sparse matrix containing the column
4111  , col_ ( index ) // The index of the column in the matrix
4112 {
4113  if( matrix_.columns() <= index ) {
4114  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
4115  }
4116 }
4118 //*************************************************************************************************
4119 
4120 
4121 
4122 
4123 //=================================================================================================
4124 //
4125 // DATA ACCESS FUNCTIONS
4126 //
4127 //=================================================================================================
4128 
4129 //*************************************************************************************************
4139 template< typename MT > // Type of the sparse matrix
4141  Column<MT,false,false,true>::operator[]( size_t index )
4142 {
4143  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
4144  return matrix_(col_,index);
4145 }
4147 //*************************************************************************************************
4148 
4149 
4150 //*************************************************************************************************
4160 template< typename MT > // Type of the sparse matrix
4162  Column<MT,false,false,true>::operator[]( size_t index ) const
4163 {
4164  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
4165  return const_cast<const MT&>( matrix_ )(col_,index);
4166 }
4168 //*************************************************************************************************
4169 
4170 
4171 //*************************************************************************************************
4182 template< typename MT > // Type of the sparse matrix
4184  Column<MT,false,false,true>::at( size_t index )
4185 {
4186  if( index >= size() ) {
4187  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
4188  }
4189  return (*this)[index];
4190 }
4192 //*************************************************************************************************
4193 
4194 
4195 //*************************************************************************************************
4206 template< typename MT > // Type of the sparse matrix
4208  Column<MT,false,false,true>::at( size_t index ) const
4209 {
4210  if( index >= size() ) {
4211  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
4212  }
4213  return (*this)[index];
4214 }
4216 //*************************************************************************************************
4217 
4218 
4219 //*************************************************************************************************
4227 template< typename MT > // Type of the sparse matrix
4229 {
4230  return matrix_.begin( col_ );
4231 }
4233 //*************************************************************************************************
4234 
4235 
4236 //*************************************************************************************************
4244 template< typename MT > // Type of the sparse matrix
4247 {
4248  return matrix_.cbegin( col_ );
4249 }
4251 //*************************************************************************************************
4252 
4253 
4254 //*************************************************************************************************
4262 template< typename MT > // Type of the sparse matrix
4265 {
4266  return matrix_.cbegin( col_ );
4267 }
4269 //*************************************************************************************************
4270 
4271 
4272 //*************************************************************************************************
4280 template< typename MT > // Type of the sparse matrix
4282 {
4283  return matrix_.end( col_ );
4284 }
4286 //*************************************************************************************************
4287 
4288 
4289 //*************************************************************************************************
4297 template< typename MT > // Type of the sparse matrix
4300 {
4301  return matrix_.cend( col_ );
4302 }
4304 //*************************************************************************************************
4305 
4306 
4307 //*************************************************************************************************
4315 template< typename MT > // Type of the sparse matrix
4318 {
4319  return matrix_.cend( col_ );
4320 }
4322 //*************************************************************************************************
4323 
4324 
4325 
4326 
4327 //=================================================================================================
4328 //
4329 // ASSIGNMENT OPERATORS
4330 //
4331 //=================================================================================================
4332 
4333 //*************************************************************************************************
4347 template< typename MT > // Type of the sparse matrix
4348 inline Column<MT,false,false,true>& Column<MT,false,false,true>::operator=( const Column& rhs )
4349 {
4350  using blaze::assign;
4351 
4355 
4356  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
4357  return *this;
4358 
4359  if( size() != rhs.size() ) {
4360  BLAZE_THROW_INVALID_ARGUMENT( "Column sizes do not match" );
4361  }
4362 
4363  if( !tryAssign( matrix_, rhs, 0UL, col_ ) ) {
4364  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4365  }
4366 
4367  DerestrictTrait_<This> left( derestrict( *this ) );
4368 
4369  if( rhs.canAlias( &matrix_ ) ) {
4370  const ResultType tmp( rhs );
4371  left.reset();
4372  left.reserve( tmp.nonZeros() );
4373  assign( left, tmp );
4374  }
4375  else {
4376  left.reset();
4377  left.reserve( rhs.nonZeros() );
4378  assign( left, rhs );
4379  }
4380 
4381  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4382 
4383  return *this;
4384 }
4386 //*************************************************************************************************
4387 
4388 
4389 //*************************************************************************************************
4403 template< typename MT > // Type of the sparse matrix
4404 template< typename VT > // Type of the right-hand side dense vector
4405 inline Column<MT,false,false,true>&
4406  Column<MT,false,false,true>::operator=( const DenseVector<VT,false>& rhs )
4407 {
4408  using blaze::assign;
4409 
4410  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4411  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4413 
4414  if( size() != (~rhs).size() ) {
4415  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4416  }
4417 
4418  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
4419  Right right( ~rhs );
4420 
4421  if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
4422  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4423  }
4424 
4425  DerestrictTrait_<This> left( derestrict( *this ) );
4426 
4427  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4428  const ResultType_<VT> tmp( right );
4429  left.reset();
4430  assign( left, tmp );
4431  }
4432  else {
4433  left.reset();
4434  assign( left, right );
4435  }
4436 
4437  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4438 
4439  return *this;
4440 }
4442 //*************************************************************************************************
4443 
4444 
4445 //*************************************************************************************************
4459 template< typename MT > // Type of the sparse matrix
4460 template< typename VT > // Type of the right-hand side sparse vector
4461 inline Column<MT,false,false,true>&
4462  Column<MT,false,false,true>::operator=( const SparseVector<VT,false>& rhs )
4463 {
4464  using blaze::assign;
4465 
4466  BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE ( ResultType_<VT> );
4467  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4469 
4470  if( size() != (~rhs).size() ) {
4471  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4472  }
4473 
4474  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
4475  Right right( ~rhs );
4476 
4477  if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
4478  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4479  }
4480 
4481  DerestrictTrait_<This> left( derestrict( *this ) );
4482 
4483  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4484  const ResultType_<VT> tmp( right);
4485  left.reset();
4486  left.reserve( tmp.nonZeros() );
4487  assign( left, tmp );
4488  }
4489  else {
4490  left.reset();
4491  left.reserve( right.nonZeros() );
4492  assign( left, right );
4493  }
4494 
4495  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4496 
4497  return *this;
4498 }
4500 //*************************************************************************************************
4501 
4502 
4503 //*************************************************************************************************
4517 template< typename MT > // Type of the sparse matrix
4518 template< typename VT > // Type of the right-hand side dense vector
4519 inline Column<MT,false,false,true>&
4520  Column<MT,false,false,true>::operator+=( const DenseVector<VT,false>& rhs )
4521 {
4522  using blaze::assign;
4523 
4527  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4528  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4530 
4531  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
4532 
4536 
4537  if( size() != (~rhs).size() ) {
4538  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4539  }
4540 
4541  const AddType tmp( *this + (~rhs) );
4542 
4543  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
4544  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4545  }
4546 
4547  DerestrictTrait_<This> left( derestrict( *this ) );
4548 
4549  left.reset();
4550  assign( left, tmp );
4551 
4552  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4553 
4554  return *this;
4555 }
4557 //*************************************************************************************************
4558 
4559 
4560 //*************************************************************************************************
4574 template< typename MT > // Type of the sparse matrix
4575 template< typename VT > // Type of the right-hand side sparse vector
4576 inline Column<MT,false,false,true>&
4577  Column<MT,false,false,true>::operator+=( const SparseVector<VT,false>& rhs )
4578 {
4579  using blaze::assign;
4580 
4584  BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE ( ResultType_<VT> );
4585  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4587 
4588  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
4589 
4593 
4594  if( size() != (~rhs).size() ) {
4595  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4596  }
4597 
4598  const AddType tmp( *this + (~rhs) );
4599 
4600  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
4601  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4602  }
4603 
4604  DerestrictTrait_<This> left( derestrict( *this ) );
4605 
4606  left.reset();
4607  left.reserve( tmp.nonZeros() );
4608  assign( left, tmp );
4609 
4610  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4611 
4612  return *this;
4613 }
4615 //*************************************************************************************************
4616 
4617 
4618 //*************************************************************************************************
4633 template< typename MT > // Type of the sparse matrix
4634 template< typename VT > // Type of the right-hand side dense vector
4635 inline Column<MT,false,false,true>&
4636  Column<MT,false,false,true>::operator-=( const DenseVector<VT,false>& rhs )
4637 {
4638  using blaze::assign;
4639 
4643  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4644  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4646 
4647  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
4648 
4652 
4653  if( size() != (~rhs).size() ) {
4654  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4655  }
4656 
4657  const SubType tmp( *this - (~rhs) );
4658 
4659  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
4660  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4661  }
4662 
4663  DerestrictTrait_<This> left( derestrict( *this ) );
4664 
4665  left.reset();
4666  assign( left, tmp );
4667 
4668  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4669 
4670  return *this;
4671 }
4673 //*************************************************************************************************
4674 
4675 
4676 //*************************************************************************************************
4691 template< typename MT > // Type of the sparse matrix
4692 template< typename VT > // Type of the right-hand side sparse vector
4693 inline Column<MT,false,false,true>&
4694  Column<MT,false,false,true>::operator-=( const SparseVector<VT,false>& rhs )
4695 {
4696  using blaze::assign;
4697 
4701  BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE ( ResultType_<VT> );
4702  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4704 
4705  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
4706 
4710 
4711  if( size() != (~rhs).size() ) {
4712  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4713  }
4714 
4715  const SubType tmp( *this - (~rhs) );
4716 
4717  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
4718  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4719  }
4720 
4721  DerestrictTrait_<This> left( derestrict( *this ) );
4722 
4723  left.reset();
4724  left.reserve( tmp.nonZeros() );
4725  assign( left, tmp );
4726 
4727  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4728 
4729  return *this;
4730 }
4732 //*************************************************************************************************
4733 
4734 
4735 //*************************************************************************************************
4748 template< typename MT > // Type of the sparse matrix
4749 template< typename VT > // Type of the right-hand side vector
4750 inline Column<MT,false,false,true>&
4751  Column<MT,false,false,true>::operator*=( const Vector<VT,false>& rhs )
4752 {
4753  using blaze::assign;
4754 
4758  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4760 
4761  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
4762 
4765 
4766  if( size() != (~rhs).size() ) {
4767  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4768  }
4769 
4770  const MultType tmp( *this * (~rhs) );
4771 
4772  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
4773  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4774  }
4775 
4776  DerestrictTrait_<This> left( derestrict( *this ) );
4777 
4778  left.reset();
4779  assign( left, tmp );
4780 
4781  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4782 
4783  return *this;
4784 }
4786 //*************************************************************************************************
4787 
4788 
4789 //*************************************************************************************************
4801 template< typename MT > // Type of the sparse matrix
4802 template< typename VT > // Type of the right-hand side vector
4803 inline Column<MT,false,false,true>&
4804  Column<MT,false,false,true>::operator/=( const DenseVector<VT,false>& rhs )
4805 {
4806  using blaze::assign;
4807 
4811  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4812  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4814 
4815  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
4816 
4820 
4821  if( size() != (~rhs).size() ) {
4822  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4823  }
4824 
4825  const DivType tmp( *this / (~rhs) );
4826 
4827  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
4828  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4829  }
4830 
4831  DerestrictTrait_<This> left( derestrict( *this ) );
4832 
4833  left.reset();
4834  assign( left, tmp );
4835 
4836  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4837 
4838  return *this;
4839 }
4841 //*************************************************************************************************
4842 
4843 
4844 //*************************************************************************************************
4859 template< typename MT > // Type of the sparse matrix
4860 template< typename Other > // Data type of the right-hand side scalar
4861 inline EnableIf_<IsNumeric<Other>, Column<MT,false,false,true> >&
4863 {
4865 
4866  for( Iterator element=begin(); element!=end(); ++element )
4867  element->value() *= rhs;
4868  return *this;
4869 }
4871 //*************************************************************************************************
4872 
4873 
4874 //*************************************************************************************************
4892 template< typename MT > // Type of the sparse matrix
4893 template< typename Other > // Data type of the right-hand side scalar
4894 inline EnableIf_<IsNumeric<Other>, Column<MT,false,false,true> >&
4896 {
4898 
4899  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
4900 
4901  typedef DivTrait_<ElementType,Other> DT;
4902  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
4903 
4904  // Depending on the two involved data types, an integer division is applied or a
4905  // floating point division is selected.
4906  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
4907  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
4908  for( Iterator element=begin(); element!=end(); ++element )
4909  element->value() *= tmp;
4910  }
4911  else {
4912  for( Iterator element=begin(); element!=end(); ++element )
4913  element->value() /= rhs;
4914  }
4915 
4916  return *this;
4917 }
4919 //*************************************************************************************************
4920 
4921 
4922 
4923 
4924 //=================================================================================================
4925 //
4926 // UTILITY FUNCTIONS
4927 //
4928 //=================================================================================================
4929 
4930 //*************************************************************************************************
4936 template< typename MT > // Type of the sparse matrix
4937 inline size_t Column<MT,false,false,true>::size() const noexcept
4938 {
4939  return matrix_.rows();
4940 }
4942 //*************************************************************************************************
4943 
4944 
4945 //*************************************************************************************************
4951 template< typename MT > // Type of the sparse matrix
4952 inline size_t Column<MT,false,false,true>::capacity() const noexcept
4953 {
4954  return matrix_.capacity( col_ );
4955 }
4957 //*************************************************************************************************
4958 
4959 
4960 //*************************************************************************************************
4969 template< typename MT > // Type of the sparse matrix
4970 inline size_t Column<MT,false,false,true>::nonZeros() const
4971 {
4972  return matrix_.nonZeros( col_ );
4973 }
4975 //*************************************************************************************************
4976 
4977 
4978 //*************************************************************************************************
4984 template< typename MT > // Type of the sparse matrix
4986 {
4987  matrix_.reset( col_ );
4988 }
4990 //*************************************************************************************************
4991 
4992 
4993 //*************************************************************************************************
5003 template< typename MT > // Type of the sparse matrix
5004 void Column<MT,false,false,true>::reserve( size_t n )
5005 {
5006  matrix_.reserve( col_, n );
5007 }
5009 //*************************************************************************************************
5010 
5011 
5012 //*************************************************************************************************
5021 template< typename MT > // Type of the sparse matrix
5022 inline size_t Column<MT,false,false,true>::extendCapacity() const noexcept
5023 {
5024  using blaze::max;
5025  using blaze::min;
5026 
5027  size_t nonzeros( 2UL*capacity()+1UL );
5028  nonzeros = max( nonzeros, 7UL );
5029  nonzeros = min( nonzeros, size() );
5030 
5031  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
5032 
5033  return nonzeros;
5034 }
5036 //*************************************************************************************************
5037 
5038 
5039 
5040 
5041 //=================================================================================================
5042 //
5043 // INSERTION FUNCTIONS
5044 //
5045 //=================================================================================================
5046 
5047 //*************************************************************************************************
5059 template< typename MT > // Type of the sparse matrix
5061  Column<MT,false,false,true>::set( size_t index, const ElementType& value )
5062 {
5063  return matrix_.set( col_, index, value );
5064 }
5066 //*************************************************************************************************
5067 
5068 
5069 //*************************************************************************************************
5082 template< typename MT > // Type of the sparse matrix
5084  Column<MT,false,false,true>::insert( size_t index, const ElementType& value )
5085 {
5086  return matrix_.insert( col_, index, value );
5087 }
5089 //*************************************************************************************************
5090 
5091 
5092 //*************************************************************************************************
5117 template< typename MT > // Type of the sparse matrix
5118 inline void Column<MT,false,false,true>::append( size_t index, const ElementType& value, bool check )
5119 {
5120  matrix_.append( col_, index, value, check );
5121 }
5123 //*************************************************************************************************
5124 
5125 
5126 
5127 
5128 //=================================================================================================
5129 //
5130 // ERASE FUNCTIONS
5131 //
5132 //=================================================================================================
5133 
5134 //*************************************************************************************************
5143 template< typename MT > // Type of the sparse matrix
5144 inline void Column<MT,false,false,true>::erase( size_t index )
5145 {
5146  matrix_.erase( col_, index );
5147 }
5149 //*************************************************************************************************
5150 
5151 
5152 //*************************************************************************************************
5161 template< typename MT > // Type of the sparse matrix
5163  Column<MT,false,false,true>::erase( Iterator pos )
5164 {
5165  return matrix_.erase( col_, pos );
5166 }
5168 //*************************************************************************************************
5169 
5170 
5171 //*************************************************************************************************
5181 template< typename MT > // Type of the sparse matrix
5183  Column<MT,false,false,true>::erase( Iterator first, Iterator last )
5184 {
5185  return matrix_.erase( col_, first, last );
5186 }
5188 //*************************************************************************************************
5189 
5190 
5191 //*************************************************************************************************
5214 template< typename MT > // Type of the sparse matrix
5215 template< typename Pred // Type of the unary predicate
5216  , typename > // Type restriction on the unary predicate
5217 inline void Column<MT,false,false,true>::erase( Pred predicate )
5218 {
5219  matrix_.erase( col_, begin(), end(), predicate );
5220 }
5222 //*************************************************************************************************
5223 
5224 
5225 //*************************************************************************************************
5250 template< typename MT > // Type of the sparse matrix
5251 template< typename Pred > // Type of the unary predicate
5252 inline void Column<MT,false,false,true>::erase( Iterator first, Iterator last, Pred predicate )
5253 {
5254  matrix_.erase( col_, first, last, predicate );
5255 }
5257 //*************************************************************************************************
5258 
5259 
5260 
5261 
5262 //=================================================================================================
5263 //
5264 // LOOKUP FUNCTIONS
5265 //
5266 //=================================================================================================
5267 
5268 //*************************************************************************************************
5282 template< typename MT > // Type of the sparse matrix
5284  Column<MT,false,false,true>::find( size_t index )
5285 {
5286  return matrix_.find( col_, index );
5287 }
5289 //*************************************************************************************************
5290 
5291 
5292 //*************************************************************************************************
5306 template< typename MT > // Type of the sparse matrix
5308  Column<MT,false,false,true>::find( size_t index ) const
5309 {
5310  return matrix_.find( col_, index );
5311 }
5313 //*************************************************************************************************
5314 
5315 
5316 //*************************************************************************************************
5329 template< typename MT > // Type of the sparse matrix
5331  Column<MT,false,false,true>::lowerBound( size_t index )
5332 {
5333  return matrix_.lowerBound( col_, index );
5334 }
5336 //*************************************************************************************************
5337 
5338 
5339 //*************************************************************************************************
5352 template< typename MT > // Type of the sparse matrix
5354  Column<MT,false,false,true>::lowerBound( size_t index ) const
5355 {
5356  return matrix_.lowerBound( col_, index );
5357 }
5359 //*************************************************************************************************
5360 
5361 
5362 //*************************************************************************************************
5375 template< typename MT > // Type of the sparse matrix
5377  Column<MT,false,false,true>::upperBound( size_t index )
5378 {
5379  return matrix_.upperBound( col_, index );
5380 }
5382 //*************************************************************************************************
5383 
5384 
5385 //*************************************************************************************************
5398 template< typename MT > // Type of the sparse matrix
5400  Column<MT,false,false,true>::upperBound( size_t index ) const
5401 {
5402  return matrix_.upperBound( col_, index );
5403 }
5405 //*************************************************************************************************
5406 
5407 
5408 
5409 
5410 //=================================================================================================
5411 //
5412 // NUMERIC FUNCTIONS
5413 //
5414 //=================================================================================================
5415 
5416 //*************************************************************************************************
5427 template< typename MT > // Type of the sparse matrix
5428 template< typename Other > // Data type of the scalar value
5429 inline Column<MT,false,false,true>& Column<MT,false,false,true>::scale( const Other& scalar )
5430 {
5432 
5433  for( Iterator element=begin(); element!=end(); ++element )
5434  element->value() *= scalar;
5435  return *this;
5436 }
5438 //*************************************************************************************************
5439 
5440 
5441 
5442 
5443 //=================================================================================================
5444 //
5445 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
5446 //
5447 //=================================================================================================
5448 
5449 //*************************************************************************************************
5460 template< typename MT > // Type of the sparse matrix
5461 template< typename Other > // Data type of the foreign expression
5462 inline bool Column<MT,false,false,true>::canAlias( const Other* alias ) const noexcept
5463 {
5464  return matrix_.isAliased( alias );
5465 }
5467 //*************************************************************************************************
5468 
5469 
5470 //*************************************************************************************************
5481 template< typename MT > // Type of the sparse matrix
5482 template< typename Other > // Data type of the foreign expression
5483 inline bool Column<MT,false,false,true>::isAliased( const Other* alias ) const noexcept
5484 {
5485  return matrix_.isAliased( alias );
5486 }
5488 //*************************************************************************************************
5489 
5490 
5491 //*************************************************************************************************
5503 template< typename MT > // Type of the sparse matrix
5504 template< typename VT > // Type of the right-hand side dense vector
5505 inline void Column<MT,false,false,true>::assign( const DenseVector<VT,false>& rhs )
5506 {
5507  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5508  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
5509 
5510  for( size_t i=0UL; i<size(); ++i )
5511  {
5512  if( matrix_.nonZeros( col_ ) == matrix_.capacity( col_ ) )
5513  matrix_.reserve( col_, extendCapacity() );
5514 
5515  matrix_.append( col_, i, (~rhs)[i], true );
5516  }
5517 }
5519 //*************************************************************************************************
5520 
5521 
5522 //*************************************************************************************************
5534 template< typename MT > // Type of the sparse matrix
5535 template< typename VT > // Type of the right-hand side sparse vector
5536 inline void Column<MT,false,false,true>::assign( const SparseVector<VT,false>& rhs )
5537 {
5538  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5539  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
5540 
5541  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
5542  matrix_.append( col_, element->index(), element->value(), true );
5543  }
5544 }
5546 //*************************************************************************************************
5547 
5548 
5549 //*************************************************************************************************
5561 template< typename MT > // Type of the sparse matrix
5562 template< typename VT > // Type of the right-hand side dense vector
5563 inline void Column<MT,false,false,true>::addAssign( const DenseVector<VT,false>& rhs )
5564 {
5565  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
5566 
5570 
5571  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5572 
5573  const AddType tmp( serial( *this + (~rhs) ) );
5574  matrix_.reset( col_ );
5575  assign( tmp );
5576 }
5578 //*************************************************************************************************
5579 
5580 
5581 //*************************************************************************************************
5593 template< typename MT > // Type of the sparse matrix
5594 template< typename VT > // Type of the right-hand side sparse vector
5595 inline void Column<MT,false,false,true>::addAssign( const SparseVector<VT,false>& rhs )
5596 {
5597  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
5598 
5602 
5603  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5604 
5605  const AddType tmp( serial( *this + (~rhs) ) );
5606  matrix_.reset( col_ );
5607  matrix_.reserve( col_, tmp.nonZeros() );
5608  assign( tmp );
5609 }
5611 //*************************************************************************************************
5612 
5613 
5614 //*************************************************************************************************
5626 template< typename MT > // Type of the sparse matrix
5627 template< typename VT > // Type of the right-hand side dense vector
5628 inline void Column<MT,false,false,true>::subAssign( const DenseVector<VT,false>& rhs )
5629 {
5630  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
5631 
5635 
5636  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5637 
5638  const SubType tmp( serial( *this - (~rhs) ) );
5639  matrix_.reset( col_ );
5640  assign( tmp );
5641 }
5643 //*************************************************************************************************
5644 
5645 
5646 //*************************************************************************************************
5658 template< typename MT > // Type of the sparse matrix
5659 template< typename VT > // Type of the right-hand side sparse vector
5660 inline void Column<MT,false,false,true>::subAssign( const SparseVector<VT,false>& rhs )
5661 {
5662  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
5663 
5667 
5668  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5669 
5670  const SubType tmp( serial( *this - (~rhs) ) );
5671  matrix_.reset( col_ );
5672  matrix_.reserve( col_, tmp.nonZeros() );
5673  assign( tmp );
5674 }
5676 //*************************************************************************************************
5677 
5678 } // namespace blaze
5679 
5680 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
Header file for mathematical functions.
typename DerestrictTrait< T >::Type DerestrictTrait_
Auxiliary alias declaration for the DerestrictTrait type trait.The DerestrictTrait_ alias declaration...
Definition: DerestrictTrait.h:110
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:352
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:721
Header file for basic type definitions.
Header file for the SparseVector base class.
Header file for the View base class.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a column dense or sparse vector type...
Definition: ColumnVector.h:61
Header file for the serial shim.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:261
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:194
Header file for the implementation of the Column base template.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2935
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
Header file for the IsIntegral type trait.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1755
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2928
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:390
#define BLAZE_CONSTRAINT_MUST_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a symmetric matrix type...
Definition: Symmetric.h:60
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Header file for the IsUniLower type trait.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1802
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:304
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:238
Constraint on the data type.
Constraint on the transpose flag of vector types.
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Header file for the IsLower type trait.
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:61
Header file for the SparseElement base class.
Constraint on the data type.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:128
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2932
Constraint on the data type.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:260
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:2933
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Constraint on the data type.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2937
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:128
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the DerestrictTrait class template.
Constraint on the data type.
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2934
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the division trait.
Header file for the reset shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2938
Header file for the column trait.
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the IsReference type trait.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2929
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2930
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:249
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2936
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
Header file for the IsUpper type trait.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the IsRestricted type trait.
const DMatDMatMultExpr< T1, T2, false, false, false, false > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7505
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Header file for the IsExpression type trait class.