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/EnableIf.h>
83 #include <blaze/util/mpl/If.h>
84 #include <blaze/util/Types.h>
89 #include <blaze/util/Unused.h>
90 
91 
92 namespace blaze {
93 
94 //=================================================================================================
95 //
96 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR SPARSE MATRICES
97 //
98 //=================================================================================================
99 
100 //*************************************************************************************************
108 template< typename MT // Type of the sparse matrix
109  , bool SF > // Symmetry flag
110 class Column<MT,true,false,SF>
111  : public SparseVector< Column<MT,true,false,SF>, false >
112  , private View
113 {
114  private:
115  //**Type definitions****************************************************************************
117  typedef If_< IsExpression<MT>, MT, MT& > Operand;
118  //**********************************************************************************************
119 
120  public:
121  //**Type definitions****************************************************************************
122  typedef Column<MT,true,false,SF> This;
123  typedef SparseVector<This,false> BaseType;
124  typedef ColumnTrait_<MT> ResultType;
125  typedef TransposeType_<ResultType> TransposeType;
126  typedef ElementType_<MT> ElementType;
127  typedef ReturnType_<MT> ReturnType;
128  typedef const Column& CompositeType;
129 
131  typedef ConstReference_<MT> ConstReference;
132 
134  typedef If_< IsConst<MT>, ConstReference, Reference_<MT> > Reference;
135 
137  typedef ConstIterator_<MT> ConstIterator;
138 
140  typedef If_< IsConst<MT>, ConstIterator, Iterator_<MT> > Iterator;
141  //**********************************************************************************************
142 
143  //**Compilation flags***************************************************************************
145  enum : bool { smpAssignable = false };
146  //**********************************************************************************************
147 
148  //**Constructors********************************************************************************
151  explicit inline Column( Operand matrix, size_t index );
152  // No explicitly declared copy constructor.
154  //**********************************************************************************************
155 
156  //**Destructor**********************************************************************************
157  // No explicitly declared destructor.
158  //**********************************************************************************************
159 
160  //**Data access functions***********************************************************************
163  inline Reference operator[]( size_t index );
164  inline ConstReference operator[]( size_t index ) const;
165  inline Reference at( size_t index );
166  inline ConstReference at( size_t index ) const;
167  inline Iterator begin ();
168  inline ConstIterator begin () const;
169  inline ConstIterator cbegin() const;
170  inline Iterator end ();
171  inline ConstIterator end () const;
172  inline ConstIterator cend () const;
174  //**********************************************************************************************
175 
176  //**Assignment operators************************************************************************
179  inline Column& operator=( const Column& rhs );
180 
181  template< typename VT > inline Column& operator= ( const DenseVector<VT,false>& rhs );
182  template< typename VT > inline Column& operator= ( const SparseVector<VT,false>& rhs );
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 Vector<VT,false>& rhs );
188  template< typename VT > inline Column& operator/=( const DenseVector<VT,false>& rhs );
189 
190  template< typename Other >
191  inline EnableIf_< IsNumeric<Other>, Column >& operator*=( Other rhs );
192 
193  template< typename Other >
194  inline EnableIf_<IsNumeric<Other>, Column >& operator/=( Other rhs );
196  //**********************************************************************************************
197 
198  //**Utility functions***************************************************************************
201  inline size_t size() const noexcept;
202  inline size_t capacity() const noexcept;
203  inline size_t nonZeros() const;
204  inline void reset();
205  inline Iterator set ( size_t index, const ElementType& value );
206  inline Iterator insert ( size_t index, const ElementType& value );
207  inline void erase ( size_t index );
208  inline Iterator erase ( Iterator pos );
209  inline Iterator erase ( Iterator first, Iterator last );
210  inline void reserve( size_t n );
211  template< typename Other > inline Column& scale ( const Other& scalar );
213  //**********************************************************************************************
214 
215  //**Lookup functions****************************************************************************
218  inline Iterator find ( size_t index );
219  inline ConstIterator find ( size_t index ) const;
220  inline Iterator lowerBound( size_t index );
221  inline ConstIterator lowerBound( size_t index ) const;
222  inline Iterator upperBound( size_t index );
223  inline ConstIterator upperBound( size_t index ) const;
225  //**********************************************************************************************
226 
227  //**Low-level utility functions*****************************************************************
230  inline void append( size_t index, const ElementType& value, bool check=false );
232  //**********************************************************************************************
233 
234  //**Expression template evaluation functions****************************************************
237  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
238  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
239 
240  template< typename VT > inline void assign ( const DenseVector <VT,false>& rhs );
241  template< typename VT > inline void assign ( const SparseVector<VT,false>& rhs );
242  template< typename VT > inline void addAssign( const DenseVector <VT,false>& rhs );
243  template< typename VT > inline void addAssign( const SparseVector<VT,false>& rhs );
244  template< typename VT > inline void subAssign( const DenseVector <VT,false>& rhs );
245  template< typename VT > inline void subAssign( const SparseVector<VT,false>& rhs );
247  //**********************************************************************************************
248 
249  private:
250  //**Utility functions***************************************************************************
253  inline size_t extendCapacity() const noexcept;
255  //**********************************************************************************************
256 
257  //**Member variables****************************************************************************
260  Operand matrix_;
261  const size_t col_;
262 
263  //**********************************************************************************************
264 
265  //**Friend declarations*************************************************************************
266  template< typename MT2, bool SO2, bool DF2, bool SF2 >
267  friend bool isIntact( const Column<MT2,SO2,DF2,SF2>& column ) noexcept;
268 
269  template< typename MT2, bool SO2, bool DF2, bool SF2 >
270  friend bool isSame( const Column<MT2,SO2,DF2,SF2>& a, const Column<MT2,SO2,DF2,SF2>& b ) noexcept;
271 
272  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
273  friend bool tryAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
274 
275  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
276  friend bool tryAddAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
277 
278  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
279  friend bool trySubAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
280 
281  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
282  friend bool tryMultAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
283 
284  template< typename MT2, bool SO2, bool DF2, bool SF2 >
285  friend DerestrictTrait_< Column<MT2,SO2,DF2,SF2> > derestrict( Column<MT2,SO2,DF2,SF2>& column );
286  //**********************************************************************************************
287 
288  //**Compile time checks*************************************************************************
295  //**********************************************************************************************
296 };
298 //*************************************************************************************************
299 
300 
301 
302 
303 //=================================================================================================
304 //
305 // CONSTRUCTOR
306 //
307 //=================================================================================================
308 
309 //*************************************************************************************************
317 template< typename MT // Type of the sparse matrix
318  , bool SF > // Symmetry flag
319 inline Column<MT,true,false,SF>::Column( Operand matrix, size_t index )
320  : matrix_( matrix ) // The sparse matrix containing the column
321  , col_ ( index ) // The index of the column in the matrix
322 {
323  if( matrix_.columns() <= index ) {
324  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
325  }
326 }
328 //*************************************************************************************************
329 
330 
331 
332 
333 //=================================================================================================
334 //
335 // DATA ACCESS FUNCTIONS
336 //
337 //=================================================================================================
338 
339 //*************************************************************************************************
349 template< typename MT // Type of the sparse matrix
350  , bool SF > // Symmetry flag
352  Column<MT,true,false,SF>::operator[]( size_t index )
353 {
354  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
355  return matrix_(index,col_);
356 }
358 //*************************************************************************************************
359 
360 
361 //*************************************************************************************************
371 template< typename MT // Type of the sparse matrix
372  , bool SF > // Symmetry flag
374  Column<MT,true,false,SF>::operator[]( size_t index ) const
375 {
376  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
377  return const_cast<const MT&>( matrix_ )(index,col_);
378 }
380 //*************************************************************************************************
381 
382 
383 //*************************************************************************************************
394 template< typename MT // Type of the sparse matrix
395  , bool SF > // Symmetry flag
397  Column<MT,true,false,SF>::at( size_t index )
398 {
399  if( index >= size() ) {
400  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
401  }
402  return (*this)[index];
403 }
405 //*************************************************************************************************
406 
407 
408 //*************************************************************************************************
419 template< typename MT // Type of the sparse matrix
420  , bool SF > // Symmetry flag
422  Column<MT,true,false,SF>::at( size_t index ) const
423 {
424  if( index >= size() ) {
425  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
426  }
427  return (*this)[index];
428 }
430 //*************************************************************************************************
431 
432 
433 //*************************************************************************************************
441 template< typename MT // Type of the sparse matrix
442  , bool SF > // Symmetry flag
444 {
445  return matrix_.begin( col_ );
446 }
448 //*************************************************************************************************
449 
450 
451 //*************************************************************************************************
459 template< typename MT // Type of the sparse matrix
460  , bool SF > // Symmetry flag
462 {
463  return matrix_.cbegin( col_ );
464 }
466 //*************************************************************************************************
467 
468 
469 //*************************************************************************************************
477 template< typename MT // Type of the sparse matrix
478  , bool SF > // Symmetry flag
480 {
481  return matrix_.cbegin( col_ );
482 }
484 //*************************************************************************************************
485 
486 
487 //*************************************************************************************************
495 template< typename MT // Type of the sparse matrix
496  , bool SF > // Symmetry flag
498 {
499  return matrix_.end( col_ );
500 }
502 //*************************************************************************************************
503 
504 
505 //*************************************************************************************************
513 template< typename MT // Type of the sparse matrix
514  , bool SF > // Symmetry flag
516 {
517  return matrix_.cend( col_ );
518 }
520 //*************************************************************************************************
521 
522 
523 //*************************************************************************************************
531 template< typename MT // Type of the sparse matrix
532  , bool SF > // Symmetry flag
534 {
535  return matrix_.cend( col_ );
536 }
538 //*************************************************************************************************
539 
540 
541 
542 
543 //=================================================================================================
544 //
545 // ASSIGNMENT OPERATORS
546 //
547 //=================================================================================================
548 
549 //*************************************************************************************************
563 template< typename MT // Type of the sparse matrix
564  , bool SF > // Symmetry flag
565 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator=( const Column& rhs )
566 {
567  using blaze::assign;
568 
572 
573  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
574  return *this;
575 
576  if( size() != rhs.size() ) {
577  BLAZE_THROW_INVALID_ARGUMENT( "Column sizes do not match" );
578  }
579 
580  if( !tryAssign( matrix_, rhs, 0UL, col_ ) ) {
581  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
582  }
583 
584  DerestrictTrait_<This> left( derestrict( *this ) );
585 
586  if( rhs.canAlias( &matrix_ ) ) {
587  const ResultType tmp( rhs );
588  left.reset();
589  left.reserve( tmp.nonZeros() );
590  assign( left, tmp );
591  }
592  else {
593  left.reset();
594  left.reserve( rhs.nonZeros() );
595  assign( left, rhs );
596  }
597 
598  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
599 
600  return *this;
601 }
603 //*************************************************************************************************
604 
605 
606 //*************************************************************************************************
620 template< typename MT // Type of the sparse matrix
621  , bool SF > // Symmetry flag
622 template< typename VT > // Type of the right-hand side dense vector
623 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator=( const DenseVector<VT,false>& rhs )
624 {
625  using blaze::assign;
626 
627  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
630 
631  if( size() != (~rhs).size() ) {
632  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
633  }
634 
635  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
636  Right right( ~rhs );
637 
638  if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
639  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
640  }
641 
642  DerestrictTrait_<This> left( derestrict( *this ) );
643 
644  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
645  const ResultType_<VT> tmp( right );
646  left.reset();
647  assign( left, tmp );
648  }
649  else {
650  left.reset();
651  assign( left, right );
652  }
653 
654  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
655 
656  return *this;
657 }
659 //*************************************************************************************************
660 
661 
662 //*************************************************************************************************
676 template< typename MT // Type of the sparse matrix
677  , bool SF > // Symmetry flag
678 template< typename VT > // Type of the right-hand side sparse vector
679 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator=( const SparseVector<VT,false>& rhs )
680 {
681  using blaze::assign;
682 
686 
687  if( size() != (~rhs).size() ) {
688  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
689  }
690 
691  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
692  Right right( ~rhs );
693 
694  if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
695  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
696  }
697 
698  DerestrictTrait_<This> left( derestrict( *this ) );
699 
700  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
701  const ResultType_<VT> tmp( right );
702  left.reset();
703  left.reserve( tmp.nonZeros() );
704  assign( left, tmp );
705  }
706  else {
707  left.reset();
708  left.reserve( right.nonZeros() );
709  assign( left, right );
710  }
711 
712  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
713 
714  return *this;
715 }
717 //*************************************************************************************************
718 
719 
720 //*************************************************************************************************
734 template< typename MT // Type of the sparse matrix
735  , bool SF > // Symmetry flag
736 template< typename VT > // Type of the right-hand side dense vector
737 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator+=( const DenseVector<VT,false>& rhs )
738 {
739  using blaze::assign;
740 
744  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
747 
748  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
749 
753 
754  if( size() != (~rhs).size() ) {
755  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
756  }
757 
758  const AddType tmp( *this + (~rhs) );
759 
760  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
761  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
762  }
763 
764  DerestrictTrait_<This> left( derestrict( *this ) );
765 
766  left.reset();
767  assign( left, tmp );
768 
769  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
770 
771  return *this;
772 }
774 //*************************************************************************************************
775 
776 
777 //*************************************************************************************************
791 template< typename MT // Type of the sparse matrix
792  , bool SF > // Symmetry flag
793 template< typename VT > // Type of the right-hand side sparse vector
794 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator+=( const SparseVector<VT,false>& rhs )
795 {
796  using blaze::assign;
797 
804 
805  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
806 
810 
811  if( size() != (~rhs).size() ) {
812  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
813  }
814 
815  const AddType tmp( *this + (~rhs) );
816 
817  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
818  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
819  }
820 
821  DerestrictTrait_<This> left( derestrict( *this ) );
822 
823  left.reset();
824  left.reserve( tmp.nonZeros() );
825  assign( left, tmp );
826 
827  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
828 
829  return *this;
830 }
832 //*************************************************************************************************
833 
834 
835 //*************************************************************************************************
850 template< typename MT // Type of the sparse matrix
851  , bool SF > // Symmetry flag
852 template< typename VT > // Type of the right-hand side dense vector
853 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator-=( const DenseVector<VT,false>& rhs )
854 {
855  using blaze::assign;
856 
860  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
863 
864  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
865 
869 
870  if( size() != (~rhs).size() ) {
871  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
872  }
873 
874  const SubType tmp( *this - (~rhs) );
875 
876  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
877  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
878  }
879 
880  DerestrictTrait_<This> left( derestrict( *this ) );
881 
882  left.reset();
883  assign( left, tmp );
884 
885  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
886 
887  return *this;
888 }
890 //*************************************************************************************************
891 
892 
893 //*************************************************************************************************
908 template< typename MT // Type of the sparse matrix
909  , bool SF > // Symmetry flag
910 template< typename VT > // Type of the right-hand side sparse vector
911 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator-=( const SparseVector<VT,false>& rhs )
912 {
913  using blaze::assign;
914 
921 
922  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
923 
927 
928  if( size() != (~rhs).size() ) {
929  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
930  }
931 
932  const SubType tmp( *this - (~rhs) );
933 
934  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
935  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
936  }
937 
938  DerestrictTrait_<This> left( derestrict( *this ) );
939 
940  left.reset();
941  left.reserve( tmp.nonZeros() );
942  assign( left, tmp );
943 
944  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
945 
946  return *this;
947 }
949 //*************************************************************************************************
950 
951 
952 //*************************************************************************************************
965 template< typename MT // Type of the sparse matrix
966  , bool SF > // Symmetry flag
967 template< typename VT > // Type of the right-hand side vector
968 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator*=( const Vector<VT,false>& rhs )
969 {
970  using blaze::assign;
971 
977 
978  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
979 
982 
983  if( size() != (~rhs).size() ) {
984  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
985  }
986 
987  const MultType tmp( *this * (~rhs) );
988 
989  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
990  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
991  }
992 
993  DerestrictTrait_<This> left( derestrict( *this ) );
994 
995  left.reset();
996  assign( left, tmp );
997 
998  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
999 
1000  return *this;
1001 }
1003 //*************************************************************************************************
1004 
1005 
1006 //*************************************************************************************************
1018 template< typename MT // Type of the sparse matrix
1019  , bool SF > // Symmetry flag
1020 template< typename VT > // Type of the right-hand side vector
1021 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::operator/=( const DenseVector<VT,false>& rhs )
1022 {
1023  using blaze::assign;
1024 
1028  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
1029  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
1031 
1032  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
1033 
1037 
1038  if( size() != (~rhs).size() ) {
1039  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1040  }
1041 
1042  const DivType tmp( *this / (~rhs) );
1043 
1044  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
1045  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1046  }
1047 
1048  DerestrictTrait_<This> left( derestrict( *this ) );
1049 
1050  left.reset();
1051  assign( left, tmp );
1052 
1053  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1054 
1055  return *this;
1056 }
1058 //*************************************************************************************************
1059 
1060 
1061 //*************************************************************************************************
1076 template< typename MT // Type of the sparse matrix
1077  , bool SF > // Symmetry flag
1078 template< typename Other > // Data type of the right-hand side scalar
1079 inline EnableIf_<IsNumeric<Other>, Column<MT,true,false,SF> >&
1081 {
1083 
1084  for( Iterator element=begin(); element!=end(); ++element )
1085  element->value() *= rhs;
1086  return *this;
1087 }
1089 //*************************************************************************************************
1090 
1091 
1092 //*************************************************************************************************
1110 template< typename MT // Type of the sparse matrix
1111  , bool SF > // Symmetry flag
1112 template< typename Other > // Data type of the right-hand side scalar
1113 inline EnableIf_<IsNumeric<Other>, Column<MT,true,false,SF> >&
1115 {
1117 
1118  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1119 
1120  typedef DivTrait_<ElementType,Other> DT;
1121  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
1122 
1123  // Depending on the two involved data types, an integer division is applied or a
1124  // floating point division is selected.
1125  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
1126  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1127  for( Iterator element=begin(); element!=end(); ++element )
1128  element->value() *= tmp;
1129  }
1130  else {
1131  for( Iterator element=begin(); element!=end(); ++element )
1132  element->value() /= rhs;
1133  }
1134 
1135  return *this;
1136 }
1138 //*************************************************************************************************
1139 
1140 
1141 
1142 
1143 //=================================================================================================
1144 //
1145 // UTILITY FUNCTIONS
1146 //
1147 //=================================================================================================
1148 
1149 //*************************************************************************************************
1155 template< typename MT // Type of the sparse matrix
1156  , bool SF > // Symmetry flag
1157 inline size_t Column<MT,true,false,SF>::size() const noexcept
1158 {
1159  return matrix_.rows();
1160 }
1162 //*************************************************************************************************
1163 
1164 
1165 //*************************************************************************************************
1171 template< typename MT // Type of the sparse matrix
1172  , bool SF > // Symmetry flag
1173 inline size_t Column<MT,true,false,SF>::capacity() const noexcept
1174 {
1175  return matrix_.capacity( col_ );
1176 }
1178 //*************************************************************************************************
1179 
1180 
1181 //*************************************************************************************************
1190 template< typename MT // Type of the sparse matrix
1191  , bool SF > // Symmetry flag
1192 inline size_t Column<MT,true,false,SF>::nonZeros() const
1193 {
1194  return matrix_.nonZeros( col_ );
1195 }
1197 //*************************************************************************************************
1198 
1199 
1200 //*************************************************************************************************
1206 template< typename MT // Type of the sparse matrix
1207  , bool SF > // Symmetry flag
1208 inline void Column<MT,true,false,SF>::reset()
1209 {
1210  matrix_.reset( col_ );
1211 }
1213 //*************************************************************************************************
1214 
1215 
1216 //*************************************************************************************************
1228 template< typename MT // Type of the sparse matrix
1229  , bool SF > // Symmetry flag
1230 inline typename Column<MT,true,false,SF>::Iterator
1231  Column<MT,true,false,SF>::set( size_t index, const ElementType& value )
1232 {
1233  return matrix_.set( index, col_, value );
1234 }
1236 //*************************************************************************************************
1237 
1238 
1239 //*************************************************************************************************
1252 template< typename MT // Type of the sparse matrix
1253  , bool SF > // Symmetry flag
1254 inline typename Column<MT,true,false,SF>::Iterator
1255  Column<MT,true,false,SF>::insert( size_t index, const ElementType& value )
1256 {
1257  return matrix_.insert( index, col_, value );
1258 }
1260 //*************************************************************************************************
1261 
1262 
1263 //*************************************************************************************************
1272 template< typename MT // Type of the sparse matrix
1273  , bool SF > // Symmetry flag
1274 inline void Column<MT,true,false,SF>::erase( size_t index )
1275 {
1276  matrix_.erase( index, col_ );
1277 }
1279 //*************************************************************************************************
1280 
1281 
1282 //*************************************************************************************************
1291 template< typename MT // Type of the sparse matrix
1292  , bool SF > // Symmetry flag
1293 inline typename Column<MT,true,false,SF>::Iterator Column<MT,true,false,SF>::erase( Iterator pos )
1294 {
1295  return matrix_.erase( col_, pos );
1296 }
1298 //*************************************************************************************************
1299 
1300 
1301 //*************************************************************************************************
1311 template< typename MT // Type of the sparse matrix
1312  , bool SF > // Symmetry flag
1313 inline typename Column<MT,true,false,SF>::Iterator
1314  Column<MT,true,false,SF>::erase( Iterator first, Iterator last )
1315 {
1316  return matrix_.erase( col_, first, last );
1317 }
1319 //*************************************************************************************************
1320 
1321 
1322 //*************************************************************************************************
1332 template< typename MT // Type of the sparse matrix
1333  , bool SF > // Symmetry flag
1334 void Column<MT,true,false,SF>::reserve( size_t n )
1335 {
1336  matrix_.reserve( col_, n );
1337 }
1339 //*************************************************************************************************
1340 
1341 
1342 //*************************************************************************************************
1353 template< typename MT // Type of the sparse matrix
1354  , bool SF > // Symmetry flag
1355 template< typename Other > // Data type of the scalar value
1356 inline Column<MT,true,false,SF>& Column<MT,true,false,SF>::scale( const Other& scalar )
1357 {
1359 
1360  for( Iterator element=begin(); element!=end(); ++element )
1361  element->value() *= scalar;
1362  return *this;
1363 }
1365 //*************************************************************************************************
1366 
1367 
1368 //*************************************************************************************************
1377 template< typename MT // Type of the sparse matrix
1378  , bool SF > // Symmetry flag
1379 inline size_t Column<MT,true,false,SF>::extendCapacity() const noexcept
1380 {
1381  using blaze::max;
1382  using blaze::min;
1383 
1384  size_t nonzeros( 2UL*capacity()+1UL );
1385  nonzeros = max( nonzeros, 7UL );
1386  nonzeros = min( nonzeros, size() );
1387 
1388  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
1389 
1390  return nonzeros;
1391 }
1393 //*************************************************************************************************
1394 
1395 
1396 
1397 
1398 //=================================================================================================
1399 //
1400 // LOOKUP FUNCTIONS
1401 //
1402 //=================================================================================================
1403 
1404 //*************************************************************************************************
1418 template< typename MT // Type of the sparse matrix
1419  , bool SF > // Symmetry flag
1420 inline typename Column<MT,true,false,SF>::Iterator Column<MT,true,false,SF>::find( size_t index )
1421 {
1422  return matrix_.find( index, col_ );
1423 }
1425 //*************************************************************************************************
1426 
1427 
1428 //*************************************************************************************************
1442 template< typename MT // Type of the sparse matrix
1443  , bool SF > // Symmetry flag
1445  Column<MT,true,false,SF>::find( size_t index ) const
1446 {
1447  return matrix_.find( index, col_ );
1448 }
1450 //*************************************************************************************************
1451 
1452 
1453 //*************************************************************************************************
1466 template< typename MT // Type of the sparse matrix
1467  , bool SF > // Symmetry flag
1468 inline typename Column<MT,true,false,SF>::Iterator Column<MT,true,false,SF>::lowerBound( size_t index )
1469 {
1470  return matrix_.lowerBound( index, col_ );
1471 }
1473 //*************************************************************************************************
1474 
1475 
1476 //*************************************************************************************************
1489 template< typename MT // Type of the sparse matrix
1490  , bool SF > // Symmetry flag
1492  Column<MT,true,false,SF>::lowerBound( size_t index ) const
1493 {
1494  return matrix_.lowerBound( index, col_ );
1495 }
1497 //*************************************************************************************************
1498 
1499 
1500 //*************************************************************************************************
1513 template< typename MT // Type of the sparse matrix
1514  , bool SF > // Symmetry flag
1515 inline typename Column<MT,true,false,SF>::Iterator Column<MT,true,false,SF>::upperBound( size_t index )
1516 {
1517  return matrix_.upperBound( index, col_ );
1518 }
1520 //*************************************************************************************************
1521 
1522 
1523 //*************************************************************************************************
1536 template< typename MT // Type of the sparse matrix
1537  , bool SF > // Symmetry flag
1539  Column<MT,true,false,SF>::upperBound( size_t index ) const
1540 {
1541  return matrix_.upperBound( index, col_ );
1542 }
1544 //*************************************************************************************************
1545 
1546 
1547 
1548 
1549 //=================================================================================================
1550 //
1551 // LOW-LEVEL UTILITY FUNCTIONS
1552 //
1553 //=================================================================================================
1554 
1555 //*************************************************************************************************
1580 template< typename MT // Type of the sparse matrix
1581  , bool SF > // Symmetry flag
1582 inline void Column<MT,true,false,SF>::append( size_t index, const ElementType& value, bool check )
1583 {
1584  matrix_.append( index, col_, value, check );
1585 }
1587 //*************************************************************************************************
1588 
1589 
1590 
1591 
1592 //=================================================================================================
1593 //
1594 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1595 //
1596 //=================================================================================================
1597 
1598 //*************************************************************************************************
1609 template< typename MT // Type of the sparse matrix
1610  , bool SF > // Symmetry flag
1611 template< typename Other > // Data type of the foreign expression
1612 inline bool Column<MT,true,false,SF>::canAlias( const Other* alias ) const noexcept
1613 {
1614  return matrix_.isAliased( alias );
1615 }
1617 //*************************************************************************************************
1618 
1619 
1620 //*************************************************************************************************
1631 template< typename MT // Type of the sparse matrix
1632  , bool SF > // Symmetry flag
1633 template< typename Other > // Data type of the foreign expression
1634 inline bool Column<MT,true,false,SF>::isAliased( const Other* alias ) const noexcept
1635 {
1636  return matrix_.isAliased( alias );
1637 }
1639 //*************************************************************************************************
1640 
1641 
1642 //*************************************************************************************************
1654 template< typename MT // Type of the sparse matrix
1655  , bool SF > // Symmetry flag
1656 template< typename VT > // Type of the right-hand side dense vector
1657 inline void Column<MT,true,false,SF>::assign( const DenseVector<VT,false>& rhs )
1658 {
1659  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1660  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1661 
1662  for( size_t i=0UL; i<size(); ++i )
1663  {
1664  if( matrix_.nonZeros( col_ ) == matrix_.capacity( col_ ) )
1665  matrix_.reserve( col_, extendCapacity() );
1666 
1667  matrix_.append( i, col_, (~rhs)[i], true );
1668  }
1669 }
1671 //*************************************************************************************************
1672 
1673 
1674 //*************************************************************************************************
1686 template< typename MT // Type of the sparse matrix
1687  , bool SF > // Symmetry flag
1688 template< typename VT > // Type of the right-hand side sparse vector
1689 inline void Column<MT,true,false,SF>::assign( const SparseVector<VT,false>& rhs )
1690 {
1691  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1692  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1693 
1694  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
1695  matrix_.append( element->index(), col_, element->value(), true );
1696  }
1697 }
1699 //*************************************************************************************************
1700 
1701 
1702 //*************************************************************************************************
1714 template< typename MT // Type of the sparse matrix
1715  , bool SF > // Symmetry flag
1716 template< typename VT > // Type of the right-hand side dense vector
1717 inline void Column<MT,true,false,SF>::addAssign( const DenseVector<VT,false>& rhs )
1718 {
1719  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
1720 
1724 
1725  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1726 
1727  const AddType tmp( serial( *this + (~rhs) ) );
1728  matrix_.reset( col_ );
1729  assign( tmp );
1730 }
1732 //*************************************************************************************************
1733 
1734 
1735 //*************************************************************************************************
1747 template< typename MT // Type of the sparse matrix
1748  , bool SF > // Symmetry flag
1749 template< typename VT > // Type of the right-hand side sparse vector
1750 inline void Column<MT,true,false,SF>::addAssign( const SparseVector<VT,false>& rhs )
1751 {
1752  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
1753 
1757 
1758  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1759 
1760  const AddType tmp( serial( *this + (~rhs) ) );
1761  matrix_.reset( col_ );
1762  matrix_.reserve( col_, tmp.nonZeros() );
1763  assign( tmp );
1764 }
1766 //*************************************************************************************************
1767 
1768 
1769 //*************************************************************************************************
1781 template< typename MT // Type of the sparse matrix
1782  , bool SF > // Symmetry flag
1783 template< typename VT > // Type of the right-hand side dense vector
1784 inline void Column<MT,true,false,SF>::subAssign( const DenseVector<VT,false>& rhs )
1785 {
1786  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
1787 
1791 
1792  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1793 
1794  const SubType tmp( serial( *this - (~rhs) ) );
1795  matrix_.reset( col_ );
1796  assign( tmp );
1797 }
1799 //*************************************************************************************************
1800 
1801 
1802 //*************************************************************************************************
1814 template< typename MT // Type of the sparse matrix
1815  , bool SF > // Symmetry flag
1816 template< typename VT > // Type of the right-hand side sparse vector
1817 inline void Column<MT,true,false,SF>::subAssign( const SparseVector<VT,false>& rhs )
1818 {
1819  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
1820 
1824 
1825  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1826 
1827  const SubType tmp( serial( *this - (~rhs) ) );
1828  matrix_.reset( col_ );
1829  matrix_.reserve( col_, tmp.nonZeros() );
1830  assign( tmp );
1831 }
1833 //*************************************************************************************************
1834 
1835 
1836 
1837 
1838 
1839 
1840 
1841 
1842 //=================================================================================================
1843 //
1844 // CLASS TEMPLATE SPECIALIZATION FOR GENERAL ROW-MAJOR SPARSE MATRICES
1845 //
1846 //=================================================================================================
1847 
1848 //*************************************************************************************************
1856 template< typename MT > // Type of the sparse matrix
1857 class Column<MT,false,false,false>
1858  : public SparseVector< Column<MT,false,false,false>, false >
1859  , private View
1860 {
1861  private:
1862  //**Type definitions****************************************************************************
1864  typedef If_< IsExpression<MT>, MT, MT& > Operand;
1865  //**********************************************************************************************
1866 
1867  public:
1868  //**Type definitions****************************************************************************
1869  typedef Column<MT,false,false,false> This;
1870  typedef SparseVector<This,false> BaseType;
1871  typedef ColumnTrait_<MT> ResultType;
1872  typedef TransposeType_<ResultType> TransposeType;
1873  typedef ElementType_<MT> ElementType;
1874  typedef ReturnType_<MT> ReturnType;
1875  typedef const Column& CompositeType;
1876 
1878  typedef ConstReference_<MT> ConstReference;
1879 
1881  typedef If_< IsConst<MT>, ConstReference, Reference_<MT> > Reference;
1882  //**********************************************************************************************
1883 
1884  //**ColumnElement class definition**************************************************************
1887  template< typename MatrixType // Type of the sparse matrix
1888  , typename IteratorType > // Type of the sparse matrix iterator
1889  class ColumnElement : private SparseElement
1890  {
1891  private:
1892  //*******************************************************************************************
1894 
1899  enum : bool { returnConst = IsConst<MatrixType>::value };
1900  //*******************************************************************************************
1901 
1902  //**Type definitions*************************************************************************
1904  typedef typename std::iterator_traits<IteratorType>::value_type SET;
1905 
1906  typedef Reference_<SET> RT;
1907  typedef ConstReference_<SET> CRT;
1908  //*******************************************************************************************
1909 
1910  public:
1911  //**Type definitions*************************************************************************
1912  typedef ValueType_<SET> ValueType;
1913  typedef size_t IndexType;
1914  typedef IfTrue_<returnConst,CRT,RT> Reference;
1915  typedef CRT ConstReference;
1916  //*******************************************************************************************
1917 
1918  //**Constructor******************************************************************************
1924  inline ColumnElement( IteratorType pos, size_t row )
1925  : pos_( pos ) // Iterator to the current position within the sparse column
1926  , row_( row ) // Index of the according row
1927  {}
1928  //*******************************************************************************************
1929 
1930  //**Assignment operator**********************************************************************
1936  template< typename T > inline ColumnElement& operator=( const T& v ) {
1937  *pos_ = v;
1938  return *this;
1939  }
1940  //*******************************************************************************************
1941 
1942  //**Addition assignment operator*************************************************************
1948  template< typename T > inline ColumnElement& operator+=( const T& v ) {
1949  *pos_ += v;
1950  return *this;
1951  }
1952  //*******************************************************************************************
1953 
1954  //**Subtraction assignment operator**********************************************************
1960  template< typename T > inline ColumnElement& operator-=( const T& v ) {
1961  *pos_ -= v;
1962  return *this;
1963  }
1964  //*******************************************************************************************
1965 
1966  //**Multiplication assignment operator*******************************************************
1972  template< typename T > inline ColumnElement& operator*=( const T& v ) {
1973  *pos_ *= v;
1974  return *this;
1975  }
1976  //*******************************************************************************************
1977 
1978  //**Division assignment operator*************************************************************
1984  template< typename T > inline ColumnElement& operator/=( const T& v ) {
1985  *pos_ /= v;
1986  return *this;
1987  }
1988  //*******************************************************************************************
1989 
1990  //**Element access operator******************************************************************
1995  inline const ColumnElement* operator->() const {
1996  return this;
1997  }
1998  //*******************************************************************************************
1999 
2000  //**Value function***************************************************************************
2005  inline Reference value() const {
2006  return pos_->value();
2007  }
2008  //*******************************************************************************************
2009 
2010  //**Index function***************************************************************************
2015  inline IndexType index() const {
2016  return row_;
2017  }
2018  //*******************************************************************************************
2019 
2020  private:
2021  //**Member variables*************************************************************************
2022  IteratorType pos_;
2023  size_t row_;
2024  //*******************************************************************************************
2025  };
2026  //**********************************************************************************************
2027 
2028  //**ColumnIterator class definition*************************************************************
2031  template< typename MatrixType // Type of the sparse matrix
2032  , typename IteratorType > // Type of the sparse matrix iterator
2033  class ColumnIterator
2034  {
2035  public:
2036  //**Type definitions*************************************************************************
2037  typedef std::forward_iterator_tag IteratorCategory;
2038  typedef ColumnElement<MatrixType,IteratorType> ValueType;
2039  typedef ValueType PointerType;
2040  typedef ValueType ReferenceType;
2041  typedef ptrdiff_t DifferenceType;
2042 
2043  // STL iterator requirements
2044  typedef IteratorCategory iterator_category;
2045  typedef ValueType value_type;
2046  typedef PointerType pointer;
2047  typedef ReferenceType reference;
2048  typedef DifferenceType difference_type;
2049  //*******************************************************************************************
2050 
2051  //**Constructor******************************************************************************
2054  inline ColumnIterator()
2055  : matrix_( nullptr ) // The sparse matrix containing the column.
2056  , row_ ( 0UL ) // The current row index.
2057  , column_( 0UL ) // The current column index.
2058  , pos_ () // Iterator to the current sparse element.
2059  {}
2060  //*******************************************************************************************
2061 
2062  //**Constructor******************************************************************************
2069  inline ColumnIterator( MatrixType& matrix, size_t row, size_t column )
2070  : matrix_( &matrix ) // The sparse matrix containing the column.
2071  , row_ ( row ) // The current row index.
2072  , column_( column ) // The current column index.
2073  , pos_ () // Iterator to the current sparse element.
2074  {
2075  for( ; row_<matrix_->rows(); ++row_ ) {
2076  pos_ = matrix_->find( row_, column_ );
2077  if( pos_ != matrix_->end( row_ ) ) break;
2078  }
2079  }
2080  //*******************************************************************************************
2081 
2082  //**Constructor******************************************************************************
2090  inline ColumnIterator( MatrixType& matrix, size_t row, size_t column, IteratorType pos )
2091  : matrix_( &matrix ) // The sparse matrix containing the column.
2092  , row_ ( row ) // The current row index.
2093  , column_( column ) // The current column index.
2094  , pos_ ( pos ) // Iterator to the current sparse element.
2095  {
2096  BLAZE_INTERNAL_ASSERT( matrix.find( row, column ) == pos, "Invalid initial iterator position" );
2097  }
2098  //*******************************************************************************************
2099 
2100  //**Constructor******************************************************************************
2105  template< typename MatrixType2, typename IteratorType2 >
2106  inline ColumnIterator( const ColumnIterator<MatrixType2,IteratorType2>& it )
2107  : matrix_( it.matrix_ ) // The sparse matrix containing the column.
2108  , row_ ( it.row_ ) // The current row index.
2109  , column_( it.column_ ) // The current column index.
2110  , pos_ ( it.pos_ ) // Iterator to the current sparse element.
2111  {}
2112  //*******************************************************************************************
2113 
2114  //**Prefix increment operator****************************************************************
2119  inline ColumnIterator& operator++() {
2120  ++row_;
2121  for( ; row_<matrix_->rows(); ++row_ ) {
2122  pos_ = matrix_->find( row_, column_ );
2123  if( pos_ != matrix_->end( row_ ) ) break;
2124  }
2125 
2126  return *this;
2127  }
2128  //*******************************************************************************************
2129 
2130  //**Postfix increment operator***************************************************************
2135  inline const ColumnIterator operator++( int ) {
2136  const ColumnIterator tmp( *this );
2137  ++(*this);
2138  return tmp;
2139  }
2140  //*******************************************************************************************
2141 
2142  //**Element access operator******************************************************************
2147  inline ReferenceType operator*() const {
2148  return ReferenceType( pos_, row_ );
2149  }
2150  //*******************************************************************************************
2151 
2152  //**Element access operator******************************************************************
2157  inline PointerType operator->() const {
2158  return PointerType( pos_, row_ );
2159  }
2160  //*******************************************************************************************
2161 
2162  //**Equality operator************************************************************************
2168  template< typename MatrixType2, typename IteratorType2 >
2169  inline bool operator==( const ColumnIterator<MatrixType2,IteratorType2>& rhs ) const {
2170  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
2171  }
2172  //*******************************************************************************************
2173 
2174  //**Inequality operator**********************************************************************
2180  template< typename MatrixType2, typename IteratorType2 >
2181  inline bool operator!=( const ColumnIterator<MatrixType2,IteratorType2>& rhs ) const {
2182  return !( *this == rhs );
2183  }
2184  //*******************************************************************************************
2185 
2186  //**Subtraction operator*********************************************************************
2192  inline DifferenceType operator-( const ColumnIterator& rhs ) const {
2193  size_t counter( 0UL );
2194  for( size_t i=rhs.row_; i<row_; ++i ) {
2195  if( matrix_->find( i, column_ ) != matrix_->end( i ) )
2196  ++counter;
2197  }
2198  return counter;
2199  }
2200  //*******************************************************************************************
2201 
2202  private:
2203  //**Member variables*************************************************************************
2204  MatrixType* matrix_;
2205  size_t row_;
2206  size_t column_;
2207  IteratorType pos_;
2208  //*******************************************************************************************
2209 
2210  //**Friend declarations**********************************************************************
2211  template< typename MatrixType2, typename IteratorType2 > friend class ColumnIterator;
2212  template< typename MT2, bool SO2, bool DF2, bool SF2 > friend class Column;
2213  //*******************************************************************************************
2214  };
2215  //**********************************************************************************************
2216 
2217  //**Type definitions****************************************************************************
2219  typedef ColumnIterator< const MT, ConstIterator_<MT> > ConstIterator;
2220 
2222  typedef If_< IsConst<MT>, ConstIterator, ColumnIterator< MT, Iterator_<MT> > > Iterator;
2223  //**********************************************************************************************
2224 
2225  //**Compilation flags***************************************************************************
2227  enum : bool { smpAssignable = false };
2228  //**********************************************************************************************
2229 
2230  //**Constructors********************************************************************************
2233  explicit inline Column( Operand matrix, size_t index );
2234  // No explicitly declared copy constructor.
2236  //**********************************************************************************************
2237 
2238  //**Destructor**********************************************************************************
2239  // No explicitly declared destructor.
2240  //**********************************************************************************************
2241 
2242  //**Data access functions***********************************************************************
2245  inline Reference operator[]( size_t index );
2246  inline ConstReference operator[]( size_t index ) const;
2247  inline Reference at( size_t index );
2248  inline ConstReference at( size_t index ) const;
2249  inline Iterator begin ();
2250  inline ConstIterator begin () const;
2251  inline ConstIterator cbegin() const;
2252  inline Iterator end ();
2253  inline ConstIterator end () const;
2254  inline ConstIterator cend () const;
2256  //**********************************************************************************************
2257 
2258  //**Assignment operators************************************************************************
2261  inline Column& operator= ( const Column& rhs );
2262  template< typename VT > inline Column& operator= ( const Vector<VT,false>& rhs );
2263  template< typename VT > inline Column& operator+=( const Vector<VT,false>& rhs );
2264  template< typename VT > inline Column& operator-=( const Vector<VT,false>& rhs );
2265  template< typename VT > inline Column& operator*=( const Vector<VT,false>& rhs );
2266  template< typename VT > inline Column& operator/=( const DenseVector<VT,false>& rhs );
2267 
2268  template< typename Other >
2269  inline EnableIf_<IsNumeric<Other>, Column >& operator*=( Other rhs );
2270 
2271  template< typename Other >
2272  inline EnableIf_<IsNumeric<Other>, Column >& operator/=( Other rhs );
2274  //**********************************************************************************************
2275 
2276  //**Utility functions***************************************************************************
2279  inline size_t size() const;
2280  inline size_t capacity() const;
2281  inline size_t nonZeros() const;
2282  inline void reset();
2283  inline Iterator set ( size_t index, const ElementType& value );
2284  inline Iterator insert ( size_t index, const ElementType& value );
2285  inline void erase ( size_t index );
2286  inline Iterator erase ( Iterator pos );
2287  inline Iterator erase ( Iterator first, Iterator last );
2288  inline void reserve( size_t n );
2289  template< typename Other > inline Column& scale ( const Other& scalar );
2291  //**********************************************************************************************
2292 
2293  //**Lookup functions****************************************************************************
2296  inline Iterator find ( size_t index );
2297  inline ConstIterator find ( size_t index ) const;
2298  inline Iterator lowerBound( size_t index );
2299  inline ConstIterator lowerBound( size_t index ) const;
2300  inline Iterator upperBound( size_t index );
2301  inline ConstIterator upperBound( size_t index ) const;
2303  //**********************************************************************************************
2304 
2305  //**Low-level utility functions*****************************************************************
2308  inline void append( size_t index, const ElementType& value, bool check=false );
2310  //**********************************************************************************************
2311 
2312  //**Expression template evaluation functions****************************************************
2315  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2316  template< typename Other > inline bool isAliased( const Other* alias ) const;
2317 
2318  template< typename VT > inline void assign ( const DenseVector <VT,false>& rhs );
2319  template< typename VT > inline void assign ( const SparseVector<VT,false>& rhs );
2320  template< typename VT > inline void addAssign( const Vector<VT,false>& rhs );
2321  template< typename VT > inline void subAssign( const Vector<VT,false>& rhs );
2323  //**********************************************************************************************
2324 
2325  private:
2326  //**Member variables****************************************************************************
2329  Operand matrix_;
2330  const size_t col_;
2331 
2332  //**********************************************************************************************
2333 
2334  //**Friend declarations*************************************************************************
2335  template< typename MT2, bool SO2, bool DF2, bool SF2 >
2336  friend bool isIntact( const Column<MT2,SO2,DF2,SF2>& column ) noexcept;
2337 
2338  template< typename MT2, bool SO2, bool DF2, bool SF2 >
2339  friend bool isSame( const Column<MT2,SO2,DF2,SF2>& a, const Column<MT2,SO2,DF2,SF2>& b ) noexcept;
2340 
2341  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2342  friend bool tryAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
2343 
2344  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2345  friend bool tryAddAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
2346 
2347  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2348  friend bool trySubAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
2349 
2350  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
2351  friend bool tryMultAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
2352 
2353  template< typename MT2, bool SO2, bool DF2, bool SF2 >
2354  friend DerestrictTrait_< Column<MT2,SO2,DF2,SF2> > derestrict( Column<MT2,SO2,DF2,SF2>& column );
2355  //**********************************************************************************************
2356 
2357  //**Compile time checks*************************************************************************
2365  //**********************************************************************************************
2366 };
2368 //*************************************************************************************************
2369 
2370 
2371 
2372 
2373 //=================================================================================================
2374 //
2375 // CONSTRUCTOR
2376 //
2377 //=================================================================================================
2378 
2379 //*************************************************************************************************
2387 template< typename MT > // Type of the sparse matrix
2388 inline Column<MT,false,false,false>::Column( Operand matrix, size_t index )
2389  : matrix_( matrix ) // The sparse matrix containing the column
2390  , col_ ( index ) // The index of the column in the matrix
2391 {
2392  if( matrix_.columns() <= index ) {
2393  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
2394  }
2395 }
2397 //*************************************************************************************************
2398 
2399 
2400 
2401 
2402 //=================================================================================================
2403 //
2404 // DATA ACCESS FUNCTIONS
2405 //
2406 //=================================================================================================
2407 
2408 //*************************************************************************************************
2418 template< typename MT > // Type of the sparse matrix
2420  Column<MT,false,false,false>::operator[]( size_t index )
2421 {
2422  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
2423  return matrix_(index,col_);
2424 }
2426 //*************************************************************************************************
2427 
2428 
2429 //*************************************************************************************************
2439 template< typename MT > // Type of the sparse matrix
2441  Column<MT,false,false,false>::operator[]( size_t index ) const
2442 {
2443  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
2444  return const_cast<const MT&>( matrix_ )(index,col_);
2445 }
2447 //*************************************************************************************************
2448 
2449 
2450 //*************************************************************************************************
2461 template< typename MT > // Type of the sparse matrix
2463  Column<MT,false,false,false>::at( size_t index )
2464 {
2465  if( index >= size() ) {
2466  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
2467  }
2468  return (*this)[index];
2469 }
2471 //*************************************************************************************************
2472 
2473 
2474 //*************************************************************************************************
2485 template< typename MT > // Type of the sparse matrix
2487  Column<MT,false,false,false>::at( size_t index ) const
2488 {
2489  if( index >= size() ) {
2490  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
2491  }
2492  return (*this)[index];
2493 }
2495 //*************************************************************************************************
2496 
2497 
2498 //*************************************************************************************************
2506 template< typename MT > // Type of the sparse matrix
2508 {
2509  return Iterator( matrix_, 0UL, col_ );
2510 }
2512 //*************************************************************************************************
2513 
2514 
2515 //*************************************************************************************************
2523 template< typename MT > // Type of the sparse matrix
2526 {
2527  return ConstIterator( matrix_, 0UL, col_ );
2528 }
2530 //*************************************************************************************************
2531 
2532 
2533 //*************************************************************************************************
2541 template< typename MT > // Type of the sparse matrix
2544 {
2545  return ConstIterator( matrix_, 0UL, col_ );
2546 }
2548 //*************************************************************************************************
2549 
2550 
2551 //*************************************************************************************************
2559 template< typename MT > // Type of the sparse matrix
2561 {
2562  return Iterator( matrix_, size(), col_ );
2563 }
2565 //*************************************************************************************************
2566 
2567 
2568 //*************************************************************************************************
2576 template< typename MT > // Type of the sparse matrix
2579 {
2580  return ConstIterator( matrix_, size(), col_ );
2581 }
2583 //*************************************************************************************************
2584 
2585 
2586 //*************************************************************************************************
2594 template< typename MT > // Type of the sparse matrix
2597 {
2598  return ConstIterator( matrix_, size(), col_ );
2599 }
2601 //*************************************************************************************************
2602 
2603 
2604 
2605 
2606 //=================================================================================================
2607 //
2608 // ASSIGNMENT OPERATORS
2609 //
2610 //=================================================================================================
2611 
2612 //*************************************************************************************************
2626 template< typename MT > // Type of the sparse matrix
2627 inline Column<MT,false,false,false>&
2628  Column<MT,false,false,false>::operator=( const Column& rhs )
2629 {
2630  using blaze::assign;
2631 
2635 
2636  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
2637  return *this;
2638 
2639  if( size() != rhs.size() ) {
2640  BLAZE_THROW_INVALID_ARGUMENT( "Column sizes do not match" );
2641  }
2642 
2643  if( !tryAssign( matrix_, rhs, 0UL, col_ ) ) {
2644  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2645  }
2646 
2647  DerestrictTrait_<This> left( derestrict( *this ) );
2648 
2649  if( rhs.canAlias( &matrix_ ) ) {
2650  const ResultType tmp( rhs );
2651  assign( left, tmp );
2652  }
2653  else {
2654  assign( left, rhs );
2655  }
2656 
2657  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2658 
2659  return *this;
2660 }
2662 //*************************************************************************************************
2663 
2664 
2665 //*************************************************************************************************
2679 template< typename MT > // Type of the sparse matrix
2680 template< typename VT > // Type of the right-hand side vector
2681 inline Column<MT,false,false,false>&
2682  Column<MT,false,false,false>::operator=( const Vector<VT,false>& rhs )
2683 {
2684  using blaze::assign;
2685 
2686  if( size() != (~rhs).size() ) {
2687  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2688  }
2689 
2690  const CompositeType_<VT> tmp( ~rhs );
2691 
2692  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
2693  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2694  }
2695 
2696  DerestrictTrait_<This> left( derestrict( *this ) );
2697 
2698  assign( left, tmp );
2699 
2700  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2701 
2702  return *this;
2703 }
2705 //*************************************************************************************************
2706 
2707 
2708 //*************************************************************************************************
2722 template< typename MT > // Type of the sparse matrix
2723 template< typename VT > // Type of the right-hand side vector
2724 inline Column<MT,false,false,false>&
2725  Column<MT,false,false,false>::operator+=( const Vector<VT,false>& rhs )
2726 {
2727  using blaze::assign;
2728 
2732  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
2734 
2735  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
2736 
2739 
2740  if( size() != (~rhs).size() ) {
2741  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2742  }
2743 
2744  const AddType tmp( *this + (~rhs) );
2745 
2746  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
2747  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2748  }
2749 
2750  DerestrictTrait_<This> left( derestrict( *this ) );
2751 
2752  assign( left, tmp );
2753 
2754  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2755 
2756  return *this;
2757 }
2759 //*************************************************************************************************
2760 
2761 
2762 //*************************************************************************************************
2776 template< typename MT > // Type of the sparse matrix
2777 template< typename VT > // Type of the right-hand side vector
2778 inline Column<MT,false,false,false>&
2779  Column<MT,false,false,false>::operator-=( const Vector<VT,false>& rhs )
2780 {
2781  using blaze::assign;
2782 
2786  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
2788 
2789  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
2790 
2793 
2794  if( size() != (~rhs).size() ) {
2795  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2796  }
2797 
2798  const SubType tmp( *this - (~rhs) );
2799 
2800  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
2801  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2802  }
2803 
2804  DerestrictTrait_<This> left( derestrict( *this ) );
2805 
2806  assign( left, tmp );
2807 
2808  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2809 
2810  return *this;
2811 }
2813 //*************************************************************************************************
2814 
2815 
2816 //*************************************************************************************************
2829 template< typename MT > // Type of the sparse matrix
2830 template< typename VT > // Type of the right-hand side vector
2831 inline Column<MT,false,false,false>&
2832  Column<MT,false,false,false>::operator*=( const Vector<VT,false>& rhs )
2833 {
2834  using blaze::assign;
2835 
2839  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
2841 
2842  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
2843 
2846 
2847  if( size() != (~rhs).size() ) {
2848  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2849  }
2850 
2851  const MultType tmp( *this * (~rhs) );
2852 
2853  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
2854  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2855  }
2856 
2857  DerestrictTrait_<This> left( derestrict( *this ) );
2858 
2859  assign( left, tmp );
2860 
2861  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2862 
2863  return *this;
2864 }
2866 //*************************************************************************************************
2867 
2868 
2869 //*************************************************************************************************
2881 template< typename MT > // Type of the sparse matrix
2882 template< typename VT > // Type of the right-hand side vector
2883 inline Column<MT,false,false,false>&
2884  Column<MT,false,false,false>::operator/=( const DenseVector<VT,false>& rhs )
2885 {
2886  using blaze::assign;
2887 
2891  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
2892  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
2894 
2895  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
2896 
2900 
2901  if( size() != (~rhs).size() ) {
2902  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2903  }
2904 
2905  const DivType tmp( *this / (~rhs) );
2906 
2907  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
2908  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2909  }
2910 
2911  DerestrictTrait_<This> left( derestrict( *this ) );
2912 
2913  assign( left, tmp );
2914 
2915  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2916 
2917  return *this;
2918 }
2920 //*************************************************************************************************
2921 
2922 
2923 //*************************************************************************************************
2938 template< typename MT > // Type of the sparse matrix
2939 template< typename Other > // Data type of the right-hand side scalar
2940 inline EnableIf_<IsNumeric<Other>, Column<MT,false,false,false> >&
2942 {
2944 
2945  for( Iterator element=begin(); element!=end(); ++element )
2946  element->value() *= rhs;
2947  return *this;
2948 }
2950 //*************************************************************************************************
2951 
2952 
2953 //*************************************************************************************************
2971 template< typename MT > // Type of the sparse matrix
2972 template< typename Other > // Data type of the right-hand side scalar
2973 inline EnableIf_<IsNumeric<Other>, Column<MT,false,false,false> >&
2975 {
2977 
2978  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
2979 
2980  typedef DivTrait_<ElementType,Other> DT;
2981  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
2982 
2983  // Depending on the two involved data types, an integer division is applied or a
2984  // floating point division is selected.
2985  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2986  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2987  for( Iterator element=begin(); element!=end(); ++element )
2988  element->value() *= tmp;
2989  }
2990  else {
2991  for( Iterator element=begin(); element!=end(); ++element )
2992  element->value() /= rhs;
2993  }
2994 
2995  return *this;
2996 }
2998 //*************************************************************************************************
2999 
3000 
3001 
3002 
3003 //=================================================================================================
3004 //
3005 // UTILITY FUNCTIONS
3006 //
3007 //=================================================================================================
3008 
3009 //*************************************************************************************************
3015 template< typename MT > // Type of the sparse matrix
3016 inline size_t Column<MT,false,false,false>::size() const
3017 {
3018  return matrix_.rows();
3019 }
3021 //*************************************************************************************************
3022 
3023 
3024 //*************************************************************************************************
3030 template< typename MT > // Type of the sparse matrix
3031 inline size_t Column<MT,false,false,false>::capacity() const
3032 {
3033  return matrix_.rows();
3034 }
3036 //*************************************************************************************************
3037 
3038 
3039 //*************************************************************************************************
3048 template< typename MT > // Type of the sparse matrix
3049 inline size_t Column<MT,false,false,false>::nonZeros() const
3050 {
3051  size_t counter( 0UL );
3052  for( ConstIterator element=begin(); element!=end(); ++element ) {
3053  ++counter;
3054  }
3055  return counter;
3056 }
3058 //*************************************************************************************************
3059 
3060 
3061 //*************************************************************************************************
3067 template< typename MT > // Type of the sparse matrix
3069 {
3070  const size_t ibegin( ( IsLower<MT>::value )
3071  ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3072  ?( col_+1UL )
3073  :( col_ ) )
3074  :( 0UL ) );
3075  const size_t iend ( ( IsUpper<MT>::value )
3076  ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3077  ?( col_ )
3078  :( col_+1UL ) )
3079  :( size() ) );
3080 
3081  for( size_t i=ibegin; i<iend; ++i ) {
3082  matrix_.erase( i, col_ );
3083  }
3084 }
3086 //*************************************************************************************************
3087 
3088 
3089 //*************************************************************************************************
3101 template< typename MT > // Type of the sparse matrix
3103  Column<MT,false,false,false>::set( size_t index, const ElementType& value )
3104 {
3105  return Iterator( matrix_, index, col_, matrix_.set( index, col_, value ) );
3106 }
3108 //*************************************************************************************************
3109 
3110 
3111 //*************************************************************************************************
3124 template< typename MT > // Type of the sparse matrix
3126  Column<MT,false,false,false>::insert( size_t index, const ElementType& value )
3127 {
3128  return Iterator( matrix_, index, col_, matrix_.insert( index, col_, value ) );
3129 }
3131 //*************************************************************************************************
3132 
3133 
3134 //*************************************************************************************************
3143 template< typename MT > // Type of the sparse matrix
3144 inline void Column<MT,false,false,false>::erase( size_t index )
3145 {
3146  matrix_.erase( index, col_ );
3147 }
3149 //*************************************************************************************************
3150 
3151 
3152 //*************************************************************************************************
3161 template< typename MT > // Type of the sparse matrix
3163  Column<MT,false,false,false>::erase( Iterator pos )
3164 {
3165  const size_t row( pos.row_ );
3166 
3167  if( row == size() )
3168  return pos;
3169 
3170  matrix_.erase( row, pos.pos_ );
3171  return Iterator( matrix_, row+1UL, col_ );
3172 }
3174 //*************************************************************************************************
3175 
3176 
3177 //*************************************************************************************************
3187 template< typename MT > // Type of the sparse matrix
3189  Column<MT,false,false,false>::erase( Iterator first, Iterator last )
3190 {
3191  for( ; first!=last; ++first ) {
3192  matrix_.erase( first.row_, first.pos_ );
3193  }
3194  return last;
3195 }
3197 //*************************************************************************************************
3198 
3199 
3200 //*************************************************************************************************
3210 template< typename MT > // Type of the sparse matrix
3211 void Column<MT,false,false,false>::reserve( size_t n )
3212 {
3213  UNUSED_PARAMETER( n );
3214 
3215  return;
3216 }
3218 //*************************************************************************************************
3219 
3220 
3221 //*************************************************************************************************
3232 template< typename MT > // Type of the sparse matrix
3233 template< typename Other > // Data type of the scalar value
3234 inline Column<MT,false,false,false>& Column<MT,false,false,false>::scale( const Other& scalar )
3235 {
3237 
3238  for( Iterator element=begin(); element!=end(); ++element )
3239  element->value() *= scalar;
3240  return *this;
3241 }
3243 //*************************************************************************************************
3244 
3245 
3246 
3247 
3248 //=================================================================================================
3249 //
3250 // LOOKUP FUNCTIONS
3251 //
3252 //=================================================================================================
3253 
3254 //*************************************************************************************************
3268 template< typename MT > // Type of the sparse matrix
3270  Column<MT,false,false,false>::find( size_t index )
3271 {
3272  const Iterator_<MT> pos( matrix_.find( index, col_ ) );
3273 
3274  if( pos != matrix_.end( index ) )
3275  return Iterator( matrix_, index, col_, pos );
3276  else
3277  return end();
3278 }
3280 //*************************************************************************************************
3281 
3282 
3283 //*************************************************************************************************
3297 template< typename MT > // Type of the sparse matrix
3299  Column<MT,false,false,false>::find( size_t index ) const
3300 {
3301  const ConstIterator_<MT> pos( matrix_.find( index, col_ ) );
3302 
3303  if( pos != matrix_.end( index ) )
3304  return ConstIterator( matrix_, index, col_, pos );
3305  else
3306  return end();
3307 }
3309 //*************************************************************************************************
3310 
3311 
3312 //*************************************************************************************************
3325 template< typename MT > // Type of the sparse matrix
3327  Column<MT,false,false,false>::lowerBound( size_t index )
3328 {
3329  for( size_t i=index; i<size(); ++i )
3330  {
3331  const Iterator_<MT> pos( matrix_.find( i, col_ ) );
3332 
3333  if( pos != matrix_.end( i ) )
3334  return Iterator( matrix_, i, col_, pos );
3335  }
3336 
3337  return end();
3338 }
3340 //*************************************************************************************************
3341 
3342 
3343 //*************************************************************************************************
3356 template< typename MT > // Type of the sparse matrix
3358  Column<MT,false,false,false>::lowerBound( size_t index ) const
3359 {
3360  for( size_t i=index; i<size(); ++i )
3361  {
3362  const ConstIterator_<MT> pos( matrix_.find( i, col_ ) );
3363 
3364  if( pos != matrix_.end( i ) )
3365  return ConstIterator( matrix_, i, col_, pos );
3366  }
3367 
3368  return end();
3369 }
3371 //*************************************************************************************************
3372 
3373 
3374 //*************************************************************************************************
3387 template< typename MT > // Type of the sparse matrix
3389  Column<MT,false,false,false>::upperBound( size_t index )
3390 {
3391  for( size_t i=index+1UL; i<size(); ++i )
3392  {
3393  const Iterator_<MT> pos( matrix_.find( i, col_ ) );
3394 
3395  if( pos != matrix_.end( i ) )
3396  return Iterator( matrix_, i, col_, pos );
3397  }
3398 
3399  return end();
3400 }
3402 //*************************************************************************************************
3403 
3404 
3405 //*************************************************************************************************
3418 template< typename MT > // Type of the sparse matrix
3420  Column<MT,false,false,false>::upperBound( size_t index ) const
3421 {
3422  for( size_t i=index+1UL; i<size(); ++i )
3423  {
3424  const ConstIterator_<MT> pos( matrix_.find( i, col_ ) );
3425 
3426  if( pos != matrix_.end( i ) )
3427  return ConstIterator( matrix_, i, col_, pos );
3428  }
3429 
3430  return end();
3431 }
3433 //*************************************************************************************************
3434 
3435 
3436 
3437 
3438 //=================================================================================================
3439 //
3440 // LOW-LEVEL UTILITY FUNCTIONS
3441 //
3442 //=================================================================================================
3443 
3444 //*************************************************************************************************
3469 template< typename MT > // Type of the sparse matrix
3470 inline void Column<MT,false,false,false>::append( size_t index, const ElementType& value, bool check )
3471 {
3472  if( !check || !isDefault( value ) )
3473  matrix_.insert( index, col_, value );
3474 }
3476 //*************************************************************************************************
3477 
3478 
3479 
3480 
3481 //=================================================================================================
3482 //
3483 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
3484 //
3485 //=================================================================================================
3486 
3487 //*************************************************************************************************
3498 template< typename MT > // Type of the sparse matrix
3499 template< typename Other > // Data type of the foreign expression
3500 inline bool Column<MT,false,false,false>::canAlias( const Other* alias ) const
3501 {
3502  return matrix_.isAliased( alias );
3503 }
3505 //*************************************************************************************************
3506 
3507 
3508 //*************************************************************************************************
3515 template< typename MT > // Type of the sparse matrix
3516 template< typename Other > // Data type of the foreign expression
3517 inline bool Column<MT,false,false,false>::isAliased( const Other* alias ) const
3518 {
3519  return matrix_.isAliased( alias );
3520 }
3522 //*************************************************************************************************
3523 
3524 
3525 //*************************************************************************************************
3537 template< typename MT > // Type of the sparse matrix
3538 template< typename VT > // Type of the right-hand side dense vector
3539 inline void Column<MT,false,false,false>::assign( const DenseVector<VT,false>& rhs )
3540 {
3541  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3542 
3543  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3544  matrix_(i,col_) = (~rhs)[i];
3545  }
3546 }
3548 //*************************************************************************************************
3549 
3550 
3551 //*************************************************************************************************
3563 template< typename MT > // Type of the sparse matrix
3564 template< typename VT > // Type of the right-hand side sparse vector
3565 inline void Column<MT,false,false,false>::assign( const SparseVector<VT,false>& rhs )
3566 {
3567  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3568 
3569  size_t i( 0UL );
3570 
3571  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
3572  for( ; i<element->index(); ++i )
3573  matrix_.erase( i, col_ );
3574  matrix_(i++,col_) = element->value();
3575  }
3576  for( ; i<size(); ++i ) {
3577  matrix_.erase( i, col_ );
3578  }
3579 }
3581 //*************************************************************************************************
3582 
3583 
3584 //*************************************************************************************************
3596 template< typename MT > // Type of the sparse matrix
3597 template< typename VT > // Type of the right-hand side vector
3598 inline void Column<MT,false,false,false>::addAssign( const Vector<VT,false>& rhs )
3599 {
3600  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
3601 
3604 
3605  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3606 
3607  const AddType tmp( serial( *this + (~rhs) ) );
3608  assign( tmp );
3609 }
3611 //*************************************************************************************************
3612 
3613 
3614 //*************************************************************************************************
3626 template< typename MT > // Type of the sparse matrix
3627 template< typename VT > // Type of the right-hand side vector
3628 inline void Column<MT,false,false,false>::subAssign( const Vector<VT,false>& rhs )
3629 {
3630  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
3631 
3634 
3635  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3636 
3637  const SubType tmp( serial( *this - (~rhs) ) );
3638  assign( tmp );
3639 }
3641 //*************************************************************************************************
3642 
3643 
3644 
3645 
3646 
3647 
3648 
3649 
3650 //=================================================================================================
3651 //
3652 // CLASS TEMPLATE SPECIALIZATION FOR SYMMETRIC ROW-MAJOR SPARSE MATRICES
3653 //
3654 //=================================================================================================
3655 
3656 //*************************************************************************************************
3664 template< typename MT > // Type of the sparse matrix
3665 class Column<MT,false,false,true>
3666  : public SparseVector< Column<MT,false,false,true>, false >
3667  , private View
3668 {
3669  private:
3670  //**Type definitions****************************************************************************
3672  typedef If_< IsExpression<MT>, MT, MT& > Operand;
3673  //**********************************************************************************************
3674 
3675  public:
3676  //**Type definitions****************************************************************************
3677  typedef Column<MT,false,false,true> This;
3678  typedef SparseVector<This,false> BaseType;
3679  typedef ColumnTrait_<MT> ResultType;
3680  typedef TransposeType_<ResultType> TransposeType;
3681  typedef ElementType_<MT> ElementType;
3682  typedef ReturnType_<MT> ReturnType;
3683  typedef const Column& CompositeType;
3684 
3686  typedef ConstReference_<MT> ConstReference;
3687 
3689  typedef If_< IsConst<MT>, ConstReference, Reference_<MT> > Reference;
3690 
3692  typedef ConstIterator_<MT> ConstIterator;
3693 
3695  typedef If_< IsConst<MT>, ConstIterator, Iterator_<MT> > Iterator;
3696  //**********************************************************************************************
3697 
3698  //**Compilation flags***************************************************************************
3700  enum : bool { smpAssignable = false };
3701  //**********************************************************************************************
3702 
3703  //**Constructors********************************************************************************
3706  explicit inline Column( Operand matrix, size_t index );
3707  // No explicitly declared copy constructor.
3709  //**********************************************************************************************
3710 
3711  //**Destructor**********************************************************************************
3712  // No explicitly declared destructor.
3713  //**********************************************************************************************
3714 
3715  //**Data access functions***********************************************************************
3718  inline Reference operator[]( size_t index );
3719  inline ConstReference operator[]( size_t index ) const;
3720  inline Reference at( size_t index );
3721  inline ConstReference at( size_t index ) const;
3722  inline Iterator begin ();
3723  inline ConstIterator begin () const;
3724  inline ConstIterator cbegin() const;
3725  inline Iterator end ();
3726  inline ConstIterator end () const;
3727  inline ConstIterator cend () const;
3729  //**********************************************************************************************
3730 
3731  //**Assignment operators************************************************************************
3734  inline Column& operator=( const Column& rhs );
3735 
3736  template< typename VT > inline Column& operator= ( const DenseVector<VT,false>& rhs );
3737  template< typename VT > inline Column& operator= ( const SparseVector<VT,false>& rhs );
3738  template< typename VT > inline Column& operator+=( const DenseVector<VT,false>& rhs );
3739  template< typename VT > inline Column& operator+=( const SparseVector<VT,false>& rhs );
3740  template< typename VT > inline Column& operator-=( const DenseVector<VT,false>& rhs );
3741  template< typename VT > inline Column& operator-=( const SparseVector<VT,false>& rhs );
3742  template< typename VT > inline Column& operator*=( const Vector<VT,false>& rhs );
3743  template< typename VT > inline Column& operator/=( const DenseVector<VT,false>& rhs );
3744 
3745  template< typename Other >
3746  inline EnableIf_<IsNumeric<Other>, Column >& operator*=( Other rhs );
3747 
3748  template< typename Other >
3749  inline EnableIf_<IsNumeric<Other>, Column >& operator/=( Other rhs );
3751  //**********************************************************************************************
3752 
3753  //**Utility functions***************************************************************************
3756  inline size_t size() const noexcept;
3757  inline size_t capacity() const noexcept;
3758  inline size_t nonZeros() const;
3759  inline void reset();
3760  inline Iterator set ( size_t index, const ElementType& value );
3761  inline Iterator insert ( size_t index, const ElementType& value );
3762  inline void erase ( size_t index );
3763  inline Iterator erase ( Iterator pos );
3764  inline Iterator erase ( Iterator first, Iterator last );
3765  inline void reserve( size_t n );
3766  template< typename Other > inline Column& scale ( const Other& scalar );
3768  //**********************************************************************************************
3769 
3770  //**Lookup functions****************************************************************************
3773  inline Iterator find ( size_t index );
3774  inline ConstIterator find ( size_t index ) const;
3775  inline Iterator lowerBound( size_t index );
3776  inline ConstIterator lowerBound( size_t index ) const;
3777  inline Iterator upperBound( size_t index );
3778  inline ConstIterator upperBound( size_t index ) const;
3780  //**********************************************************************************************
3781 
3782  //**Low-level utility functions*****************************************************************
3785  inline void append( size_t index, const ElementType& value, bool check=false );
3787  //**********************************************************************************************
3788 
3789  //**Expression template evaluation functions****************************************************
3792  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
3793  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
3794 
3795  template< typename VT > inline void assign ( const DenseVector <VT,false>& rhs );
3796  template< typename VT > inline void assign ( const SparseVector<VT,false>& rhs );
3797  template< typename VT > inline void addAssign( const DenseVector <VT,false>& rhs );
3798  template< typename VT > inline void addAssign( const SparseVector<VT,false>& rhs );
3799  template< typename VT > inline void subAssign( const DenseVector <VT,false>& rhs );
3800  template< typename VT > inline void subAssign( const SparseVector<VT,false>& rhs );
3802  //**********************************************************************************************
3803 
3804  private:
3805  //**Utility functions***************************************************************************
3808  inline size_t extendCapacity() const noexcept;
3810  //**********************************************************************************************
3811 
3812  //**Member variables****************************************************************************
3815  Operand matrix_;
3816  const size_t col_;
3817 
3818  //**********************************************************************************************
3819 
3820  //**Friend declarations*************************************************************************
3821  template< typename MT2, bool SO2, bool DF2, bool SF2 >
3822  friend bool isIntact( const Column<MT2,SO2,DF2,SF2>& column ) noexcept;
3823 
3824  template< typename MT2, bool SO2, bool DF2, bool SF2 >
3825  friend bool isSame( const Column<MT2,SO2,DF2,SF2>& a, const Column<MT2,SO2,DF2,SF2>& b ) noexcept;
3826 
3827  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
3828  friend bool tryAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
3829 
3830  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
3831  friend bool tryAddAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
3832 
3833  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
3834  friend bool trySubAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
3835 
3836  template< typename MT2, bool SO2, bool DF2, bool SF2, typename VT >
3837  friend bool tryMultAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs, size_t index );
3838 
3839  template< typename MT2, bool SO2, bool DF2, bool SF2 >
3840  friend DerestrictTrait_< Column<MT2,SO2,DF2,SF2> > derestrict( Column<MT2,SO2,DF2,SF2>& column );
3841  //**********************************************************************************************
3842 
3843  //**Compile time checks*************************************************************************
3851  //**********************************************************************************************
3852 };
3854 //*************************************************************************************************
3855 
3856 
3857 
3858 
3859 //=================================================================================================
3860 //
3861 // CONSTRUCTOR
3862 //
3863 //=================================================================================================
3864 
3865 //*************************************************************************************************
3873 template< typename MT > // Type of the sparse matrix
3874 inline Column<MT,false,false,true>::Column( Operand matrix, size_t index )
3875  : matrix_( matrix ) // The sparse matrix containing the column
3876  , col_ ( index ) // The index of the column in the matrix
3877 {
3878  if( matrix_.columns() <= index ) {
3879  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
3880  }
3881 }
3883 //*************************************************************************************************
3884 
3885 
3886 
3887 
3888 //=================================================================================================
3889 //
3890 // DATA ACCESS FUNCTIONS
3891 //
3892 //=================================================================================================
3893 
3894 //*************************************************************************************************
3904 template< typename MT > // Type of the sparse matrix
3906  Column<MT,false,false,true>::operator[]( size_t index )
3907 {
3908  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
3909  return matrix_(col_,index);
3910 }
3912 //*************************************************************************************************
3913 
3914 
3915 //*************************************************************************************************
3925 template< typename MT > // Type of the sparse matrix
3927  Column<MT,false,false,true>::operator[]( size_t index ) const
3928 {
3929  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
3930  return const_cast<const MT&>( matrix_ )(col_,index);
3931 }
3933 //*************************************************************************************************
3934 
3935 
3936 //*************************************************************************************************
3947 template< typename MT > // Type of the sparse matrix
3949  Column<MT,false,false,true>::at( size_t index )
3950 {
3951  if( index >= size() ) {
3952  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
3953  }
3954  return (*this)[index];
3955 }
3957 //*************************************************************************************************
3958 
3959 
3960 //*************************************************************************************************
3971 template< typename MT > // Type of the sparse matrix
3973  Column<MT,false,false,true>::at( size_t index ) const
3974 {
3975  if( index >= size() ) {
3976  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
3977  }
3978  return (*this)[index];
3979 }
3981 //*************************************************************************************************
3982 
3983 
3984 //*************************************************************************************************
3992 template< typename MT > // Type of the sparse matrix
3994 {
3995  return matrix_.begin( col_ );
3996 }
3998 //*************************************************************************************************
3999 
4000 
4001 //*************************************************************************************************
4009 template< typename MT > // Type of the sparse matrix
4012 {
4013  return matrix_.cbegin( col_ );
4014 }
4016 //*************************************************************************************************
4017 
4018 
4019 //*************************************************************************************************
4027 template< typename MT > // Type of the sparse matrix
4030 {
4031  return matrix_.cbegin( col_ );
4032 }
4034 //*************************************************************************************************
4035 
4036 
4037 //*************************************************************************************************
4045 template< typename MT > // Type of the sparse matrix
4047 {
4048  return matrix_.end( col_ );
4049 }
4051 //*************************************************************************************************
4052 
4053 
4054 //*************************************************************************************************
4062 template< typename MT > // Type of the sparse matrix
4065 {
4066  return matrix_.cend( col_ );
4067 }
4069 //*************************************************************************************************
4070 
4071 
4072 //*************************************************************************************************
4080 template< typename MT > // Type of the sparse matrix
4083 {
4084  return matrix_.cend( col_ );
4085 }
4087 //*************************************************************************************************
4088 
4089 
4090 
4091 
4092 //=================================================================================================
4093 //
4094 // ASSIGNMENT OPERATORS
4095 //
4096 //=================================================================================================
4097 
4098 //*************************************************************************************************
4112 template< typename MT > // Type of the sparse matrix
4113 inline Column<MT,false,false,true>& Column<MT,false,false,true>::operator=( const Column& rhs )
4114 {
4115  using blaze::assign;
4116 
4120 
4121  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
4122  return *this;
4123 
4124  if( size() != rhs.size() ) {
4125  BLAZE_THROW_INVALID_ARGUMENT( "Column sizes do not match" );
4126  }
4127 
4128  if( !tryAssign( matrix_, rhs, 0UL, col_ ) ) {
4129  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4130  }
4131 
4132  DerestrictTrait_<This> left( derestrict( *this ) );
4133 
4134  if( rhs.canAlias( &matrix_ ) ) {
4135  const ResultType tmp( rhs );
4136  left.reset();
4137  left.reserve( tmp.nonZeros() );
4138  assign( left, tmp );
4139  }
4140  else {
4141  left.reset();
4142  left.reserve( rhs.nonZeros() );
4143  assign( left, rhs );
4144  }
4145 
4146  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4147 
4148  return *this;
4149 }
4151 //*************************************************************************************************
4152 
4153 
4154 //*************************************************************************************************
4168 template< typename MT > // Type of the sparse matrix
4169 template< typename VT > // Type of the right-hand side dense vector
4170 inline Column<MT,false,false,true>&
4171  Column<MT,false,false,true>::operator=( const DenseVector<VT,false>& rhs )
4172 {
4173  using blaze::assign;
4174 
4175  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4176  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4178 
4179  if( size() != (~rhs).size() ) {
4180  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4181  }
4182 
4183  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
4184  Right right( ~rhs );
4185 
4186  if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
4187  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4188  }
4189 
4190  DerestrictTrait_<This> left( derestrict( *this ) );
4191 
4192  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4193  const ResultType_<VT> tmp( right );
4194  left.reset();
4195  assign( left, tmp );
4196  }
4197  else {
4198  left.reset();
4199  assign( left, right );
4200  }
4201 
4202  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4203 
4204  return *this;
4205 }
4207 //*************************************************************************************************
4208 
4209 
4210 //*************************************************************************************************
4224 template< typename MT > // Type of the sparse matrix
4225 template< typename VT > // Type of the right-hand side sparse vector
4226 inline Column<MT,false,false,true>&
4227  Column<MT,false,false,true>::operator=( const SparseVector<VT,false>& rhs )
4228 {
4229  using blaze::assign;
4230 
4231  BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE ( ResultType_<VT> );
4232  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4234 
4235  if( size() != (~rhs).size() ) {
4236  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4237  }
4238 
4239  typedef If_< IsRestricted<MT>, CompositeType_<VT>, const VT& > Right;
4240  Right right( ~rhs );
4241 
4242  if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
4243  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4244  }
4245 
4246  DerestrictTrait_<This> left( derestrict( *this ) );
4247 
4248  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4249  const ResultType_<VT> tmp( right);
4250  left.reset();
4251  left.reserve( tmp.nonZeros() );
4252  assign( left, tmp );
4253  }
4254  else {
4255  left.reset();
4256  left.reserve( right.nonZeros() );
4257  assign( left, right );
4258  }
4259 
4260  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4261 
4262  return *this;
4263 }
4265 //*************************************************************************************************
4266 
4267 
4268 //*************************************************************************************************
4282 template< typename MT > // Type of the sparse matrix
4283 template< typename VT > // Type of the right-hand side dense vector
4284 inline Column<MT,false,false,true>&
4285  Column<MT,false,false,true>::operator+=( const DenseVector<VT,false>& rhs )
4286 {
4287  using blaze::assign;
4288 
4292  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4293  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4295 
4296  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
4297 
4301 
4302  if( size() != (~rhs).size() ) {
4303  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4304  }
4305 
4306  const AddType tmp( *this + (~rhs) );
4307 
4308  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
4309  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4310  }
4311 
4312  DerestrictTrait_<This> left( derestrict( *this ) );
4313 
4314  left.reset();
4315  assign( left, tmp );
4316 
4317  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4318 
4319  return *this;
4320 }
4322 //*************************************************************************************************
4323 
4324 
4325 //*************************************************************************************************
4339 template< typename MT > // Type of the sparse matrix
4340 template< typename VT > // Type of the right-hand side sparse vector
4341 inline Column<MT,false,false,true>&
4342  Column<MT,false,false,true>::operator+=( const SparseVector<VT,false>& rhs )
4343 {
4344  using blaze::assign;
4345 
4349  BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE ( ResultType_<VT> );
4350  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4352 
4353  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
4354 
4358 
4359  if( size() != (~rhs).size() ) {
4360  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4361  }
4362 
4363  const AddType tmp( *this + (~rhs) );
4364 
4365  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
4366  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4367  }
4368 
4369  DerestrictTrait_<This> left( derestrict( *this ) );
4370 
4371  left.reset();
4372  left.reserve( tmp.nonZeros() );
4373  assign( left, tmp );
4374 
4375  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4376 
4377  return *this;
4378 }
4380 //*************************************************************************************************
4381 
4382 
4383 //*************************************************************************************************
4398 template< typename MT > // Type of the sparse matrix
4399 template< typename VT > // Type of the right-hand side dense vector
4400 inline Column<MT,false,false,true>&
4401  Column<MT,false,false,true>::operator-=( const DenseVector<VT,false>& rhs )
4402 {
4403  using blaze::assign;
4404 
4408  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4409  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4411 
4412  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
4413 
4417 
4418  if( size() != (~rhs).size() ) {
4419  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4420  }
4421 
4422  const SubType tmp( *this - (~rhs) );
4423 
4424  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
4425  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4426  }
4427 
4428  DerestrictTrait_<This> left( derestrict( *this ) );
4429 
4430  left.reset();
4431  assign( left, tmp );
4432 
4433  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4434 
4435  return *this;
4436 }
4438 //*************************************************************************************************
4439 
4440 
4441 //*************************************************************************************************
4456 template< typename MT > // Type of the sparse matrix
4457 template< typename VT > // Type of the right-hand side sparse vector
4458 inline Column<MT,false,false,true>&
4459  Column<MT,false,false,true>::operator-=( const SparseVector<VT,false>& rhs )
4460 {
4461  using blaze::assign;
4462 
4466  BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE ( ResultType_<VT> );
4467  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4469 
4470  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
4471 
4475 
4476  if( size() != (~rhs).size() ) {
4477  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4478  }
4479 
4480  const SubType tmp( *this - (~rhs) );
4481 
4482  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
4483  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4484  }
4485 
4486  DerestrictTrait_<This> left( derestrict( *this ) );
4487 
4488  left.reset();
4489  left.reserve( tmp.nonZeros() );
4490  assign( left, tmp );
4491 
4492  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4493 
4494  return *this;
4495 }
4497 //*************************************************************************************************
4498 
4499 
4500 //*************************************************************************************************
4513 template< typename MT > // Type of the sparse matrix
4514 template< typename VT > // Type of the right-hand side vector
4515 inline Column<MT,false,false,true>&
4516  Column<MT,false,false,true>::operator*=( const Vector<VT,false>& rhs )
4517 {
4518  using blaze::assign;
4519 
4523  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4525 
4526  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
4527 
4530 
4531  if( size() != (~rhs).size() ) {
4532  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4533  }
4534 
4535  const MultType tmp( *this * (~rhs) );
4536 
4537  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
4538  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4539  }
4540 
4541  DerestrictTrait_<This> left( derestrict( *this ) );
4542 
4543  left.reset();
4544  assign( left, tmp );
4545 
4546  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4547 
4548  return *this;
4549 }
4551 //*************************************************************************************************
4552 
4553 
4554 //*************************************************************************************************
4566 template< typename MT > // Type of the sparse matrix
4567 template< typename VT > // Type of the right-hand side vector
4568 inline Column<MT,false,false,true>&
4569  Column<MT,false,false,true>::operator/=( const DenseVector<VT,false>& rhs )
4570 {
4571  using blaze::assign;
4572 
4576  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT> );
4577  BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE ( ResultType_<VT> );
4579 
4580  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
4581 
4585 
4586  if( size() != (~rhs).size() ) {
4587  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4588  }
4589 
4590  const DivType tmp( *this / (~rhs) );
4591 
4592  if( !tryAssign( matrix_, tmp, 0UL, col_ ) ) {
4593  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4594  }
4595 
4596  DerestrictTrait_<This> left( derestrict( *this ) );
4597 
4598  left.reset();
4599  assign( left, tmp );
4600 
4601  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4602 
4603  return *this;
4604 }
4606 //*************************************************************************************************
4607 
4608 
4609 //*************************************************************************************************
4624 template< typename MT > // Type of the sparse matrix
4625 template< typename Other > // Data type of the right-hand side scalar
4626 inline EnableIf_<IsNumeric<Other>, Column<MT,false,false,true> >&
4628 {
4630 
4631  for( Iterator element=begin(); element!=end(); ++element )
4632  element->value() *= rhs;
4633  return *this;
4634 }
4636 //*************************************************************************************************
4637 
4638 
4639 //*************************************************************************************************
4657 template< typename MT > // Type of the sparse matrix
4658 template< typename Other > // Data type of the right-hand side scalar
4659 inline EnableIf_<IsNumeric<Other>, Column<MT,false,false,true> >&
4661 {
4663 
4664  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
4665 
4666  typedef DivTrait_<ElementType,Other> DT;
4667  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
4668 
4669  // Depending on the two involved data types, an integer division is applied or a
4670  // floating point division is selected.
4671  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
4672  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
4673  for( Iterator element=begin(); element!=end(); ++element )
4674  element->value() *= tmp;
4675  }
4676  else {
4677  for( Iterator element=begin(); element!=end(); ++element )
4678  element->value() /= rhs;
4679  }
4680 
4681  return *this;
4682 }
4684 //*************************************************************************************************
4685 
4686 
4687 
4688 
4689 //=================================================================================================
4690 //
4691 // UTILITY FUNCTIONS
4692 //
4693 //=================================================================================================
4694 
4695 //*************************************************************************************************
4701 template< typename MT > // Type of the sparse matrix
4702 inline size_t Column<MT,false,false,true>::size() const noexcept
4703 {
4704  return matrix_.rows();
4705 }
4707 //*************************************************************************************************
4708 
4709 
4710 //*************************************************************************************************
4716 template< typename MT > // Type of the sparse matrix
4717 inline size_t Column<MT,false,false,true>::capacity() const noexcept
4718 {
4719  return matrix_.capacity( col_ );
4720 }
4722 //*************************************************************************************************
4723 
4724 
4725 //*************************************************************************************************
4734 template< typename MT > // Type of the sparse matrix
4735 inline size_t Column<MT,false,false,true>::nonZeros() const
4736 {
4737  return matrix_.nonZeros( col_ );
4738 }
4740 //*************************************************************************************************
4741 
4742 
4743 //*************************************************************************************************
4749 template< typename MT > // Type of the sparse matrix
4751 {
4752  matrix_.reset( col_ );
4753 }
4755 //*************************************************************************************************
4756 
4757 
4758 //*************************************************************************************************
4770 template< typename MT > // Type of the sparse matrix
4772  Column<MT,false,false,true>::set( size_t index, const ElementType& value )
4773 {
4774  return matrix_.set( col_, index, value );
4775 }
4777 //*************************************************************************************************
4778 
4779 
4780 //*************************************************************************************************
4793 template< typename MT > // Type of the sparse matrix
4795  Column<MT,false,false,true>::insert( size_t index, const ElementType& value )
4796 {
4797  return matrix_.insert( col_, index, value );
4798 }
4800 //*************************************************************************************************
4801 
4802 
4803 //*************************************************************************************************
4812 template< typename MT > // Type of the sparse matrix
4813 inline void Column<MT,false,false,true>::erase( size_t index )
4814 {
4815  matrix_.erase( col_, index );
4816 }
4818 //*************************************************************************************************
4819 
4820 
4821 //*************************************************************************************************
4830 template< typename MT > // Type of the sparse matrix
4832  Column<MT,false,false,true>::erase( Iterator pos )
4833 {
4834  return matrix_.erase( col_, pos );
4835 }
4837 //*************************************************************************************************
4838 
4839 
4840 //*************************************************************************************************
4850 template< typename MT > // Type of the sparse matrix
4852  Column<MT,false,false,true>::erase( Iterator first, Iterator last )
4853 {
4854  return matrix_.erase( col_, first, last );
4855 }
4857 //*************************************************************************************************
4858 
4859 
4860 //*************************************************************************************************
4870 template< typename MT > // Type of the sparse matrix
4871 void Column<MT,false,false,true>::reserve( size_t n )
4872 {
4873  matrix_.reserve( col_, n );
4874 }
4876 //*************************************************************************************************
4877 
4878 
4879 //*************************************************************************************************
4890 template< typename MT > // Type of the sparse matrix
4891 template< typename Other > // Data type of the scalar value
4892 inline Column<MT,false,false,true>& Column<MT,false,false,true>::scale( const Other& scalar )
4893 {
4895 
4896  for( Iterator element=begin(); element!=end(); ++element )
4897  element->value() *= scalar;
4898  return *this;
4899 }
4901 //*************************************************************************************************
4902 
4903 
4904 //*************************************************************************************************
4913 template< typename MT > // Type of the sparse matrix
4914 inline size_t Column<MT,false,false,true>::extendCapacity() const noexcept
4915 {
4916  using blaze::max;
4917  using blaze::min;
4918 
4919  size_t nonzeros( 2UL*capacity()+1UL );
4920  nonzeros = max( nonzeros, 7UL );
4921  nonzeros = min( nonzeros, size() );
4922 
4923  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
4924 
4925  return nonzeros;
4926 }
4928 //*************************************************************************************************
4929 
4930 
4931 
4932 
4933 //=================================================================================================
4934 //
4935 // LOOKUP FUNCTIONS
4936 //
4937 //=================================================================================================
4938 
4939 //*************************************************************************************************
4953 template< typename MT > // Type of the sparse matrix
4955  Column<MT,false,false,true>::find( size_t index )
4956 {
4957  return matrix_.find( col_, index );
4958 }
4960 //*************************************************************************************************
4961 
4962 
4963 //*************************************************************************************************
4977 template< typename MT > // Type of the sparse matrix
4979  Column<MT,false,false,true>::find( size_t index ) const
4980 {
4981  return matrix_.find( col_, index );
4982 }
4984 //*************************************************************************************************
4985 
4986 
4987 //*************************************************************************************************
5000 template< typename MT > // Type of the sparse matrix
5002  Column<MT,false,false,true>::lowerBound( size_t index )
5003 {
5004  return matrix_.lowerBound( col_, index );
5005 }
5007 //*************************************************************************************************
5008 
5009 
5010 //*************************************************************************************************
5023 template< typename MT > // Type of the sparse matrix
5025  Column<MT,false,false,true>::lowerBound( size_t index ) const
5026 {
5027  return matrix_.lowerBound( col_, index );
5028 }
5030 //*************************************************************************************************
5031 
5032 
5033 //*************************************************************************************************
5046 template< typename MT > // Type of the sparse matrix
5048  Column<MT,false,false,true>::upperBound( size_t index )
5049 {
5050  return matrix_.upperBound( col_, index );
5051 }
5053 //*************************************************************************************************
5054 
5055 
5056 //*************************************************************************************************
5069 template< typename MT > // Type of the sparse matrix
5071  Column<MT,false,false,true>::upperBound( size_t index ) const
5072 {
5073  return matrix_.upperBound( col_, index );
5074 }
5076 //*************************************************************************************************
5077 
5078 
5079 
5080 
5081 //=================================================================================================
5082 //
5083 // LOW-LEVEL UTILITY FUNCTIONS
5084 //
5085 //=================================================================================================
5086 
5087 //*************************************************************************************************
5112 template< typename MT > // Type of the sparse matrix
5113 inline void Column<MT,false,false,true>::append( size_t index, const ElementType& value, bool check )
5114 {
5115  matrix_.append( col_, index, value, check );
5116 }
5118 //*************************************************************************************************
5119 
5120 
5121 
5122 
5123 //=================================================================================================
5124 //
5125 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
5126 //
5127 //=================================================================================================
5128 
5129 //*************************************************************************************************
5140 template< typename MT > // Type of the sparse matrix
5141 template< typename Other > // Data type of the foreign expression
5142 inline bool Column<MT,false,false,true>::canAlias( const Other* alias ) const noexcept
5143 {
5144  return matrix_.isAliased( alias );
5145 }
5147 //*************************************************************************************************
5148 
5149 
5150 //*************************************************************************************************
5161 template< typename MT > // Type of the sparse matrix
5162 template< typename Other > // Data type of the foreign expression
5163 inline bool Column<MT,false,false,true>::isAliased( const Other* alias ) const noexcept
5164 {
5165  return matrix_.isAliased( alias );
5166 }
5168 //*************************************************************************************************
5169 
5170 
5171 //*************************************************************************************************
5183 template< typename MT > // Type of the sparse matrix
5184 template< typename VT > // Type of the right-hand side dense vector
5185 inline void Column<MT,false,false,true>::assign( const DenseVector<VT,false>& rhs )
5186 {
5187  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5188  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
5189 
5190  for( size_t i=0UL; i<size(); ++i )
5191  {
5192  if( matrix_.nonZeros( col_ ) == matrix_.capacity( col_ ) )
5193  matrix_.reserve( col_, extendCapacity() );
5194 
5195  matrix_.append( col_, i, (~rhs)[i], true );
5196  }
5197 }
5199 //*************************************************************************************************
5200 
5201 
5202 //*************************************************************************************************
5214 template< typename MT > // Type of the sparse matrix
5215 template< typename VT > // Type of the right-hand side sparse vector
5216 inline void Column<MT,false,false,true>::assign( const SparseVector<VT,false>& rhs )
5217 {
5218  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5219  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
5220 
5221  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
5222  matrix_.append( col_, element->index(), element->value(), true );
5223  }
5224 }
5226 //*************************************************************************************************
5227 
5228 
5229 //*************************************************************************************************
5241 template< typename MT > // Type of the sparse matrix
5242 template< typename VT > // Type of the right-hand side dense vector
5243 inline void Column<MT,false,false,true>::addAssign( const DenseVector<VT,false>& rhs )
5244 {
5245  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
5246 
5250 
5251  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5252 
5253  const AddType tmp( serial( *this + (~rhs) ) );
5254  matrix_.reset( col_ );
5255  assign( tmp );
5256 }
5258 //*************************************************************************************************
5259 
5260 
5261 //*************************************************************************************************
5273 template< typename MT > // Type of the sparse matrix
5274 template< typename VT > // Type of the right-hand side sparse vector
5275 inline void Column<MT,false,false,true>::addAssign( const SparseVector<VT,false>& rhs )
5276 {
5277  typedef AddTrait_< ResultType, ResultType_<VT> > AddType;
5278 
5282 
5283  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5284 
5285  const AddType tmp( serial( *this + (~rhs) ) );
5286  matrix_.reset( col_ );
5287  matrix_.reserve( col_, tmp.nonZeros() );
5288  assign( tmp );
5289 }
5291 //*************************************************************************************************
5292 
5293 
5294 //*************************************************************************************************
5306 template< typename MT > // Type of the sparse matrix
5307 template< typename VT > // Type of the right-hand side dense vector
5308 inline void Column<MT,false,false,true>::subAssign( const DenseVector<VT,false>& rhs )
5309 {
5310  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
5311 
5315 
5316  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5317 
5318  const SubType tmp( serial( *this - (~rhs) ) );
5319  matrix_.reset( col_ );
5320  assign( tmp );
5321 }
5323 //*************************************************************************************************
5324 
5325 
5326 //*************************************************************************************************
5338 template< typename MT > // Type of the sparse matrix
5339 template< typename VT > // Type of the right-hand side sparse vector
5340 inline void Column<MT,false,false,true>::subAssign( const SparseVector<VT,false>& rhs )
5341 {
5342  typedef SubTrait_< ResultType, ResultType_<VT> > SubType;
5343 
5347 
5348  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5349 
5350  const SubType tmp( serial( *this - (~rhs) ) );
5351  matrix_.reset( col_ );
5352  matrix_.reserve( col_, tmp.nonZeros() );
5353  assign( tmp );
5354 }
5356 //*************************************************************************************************
5357 
5358 } // namespace blaze
5359 
5360 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
Header file for mathematical functions.
typename DerestrictTrait< T >::Type DerestrictTrait_
Auxiliary alias declaration for the DerestrictTrait type trait.The DerestrictTrait_ alias declaration...
Definition: DerestrictTrait.h:110
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7800
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:346
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:653
Header file for basic type definitions.
Header file for the SparseVector base class.
Header file for the View base class.
#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:258
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
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:2643
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2636
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:384
#define BLAZE_CONSTRAINT_MUST_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a symmetric matrix type...
Definition: Symmetric.h:60
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Header file for the IsUniLower type trait.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:126
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:298
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:232
Constraint on the data type.
Constraint on the transpose flag of vector types.
Constraint on the data type.
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:5104
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
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5131
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the IsLower type trait.
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:61
Header file for the SparseElement base class.
Constraint on the data type.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
Constraint on the data type.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
Constraint on the data type.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the DerestrictTrait class template.
Constraint on the data type.
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:126
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2642
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the division trait.
Header file for the reset shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Header file for the 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:2637
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2638
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
Header file for the IsUpper type trait.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the IsRestricted type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Header file for the IsExpression type trait class.