CompressedVector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SPARSE_COMPRESSEDVECTOR_H_
36 #define _BLAZE_MATH_SPARSE_COMPRESSEDVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <utility>
45 #include <blaze/math/Aliases.h>
49 #include <blaze/math/Exception.h>
52 #include <blaze/math/Forward.h>
53 #include <blaze/math/Functions.h>
69 #include <blaze/util/Algorithm.h>
70 #include <blaze/util/Assert.h>
76 #include <blaze/util/EnableIf.h>
77 #include <blaze/util/Memory.h>
78 #include <blaze/util/mpl/If.h>
79 #include <blaze/util/Types.h>
82 
83 
84 namespace blaze {
85 
86 //=================================================================================================
87 //
88 // CLASS DEFINITION
89 //
90 //=================================================================================================
91 
92 //*************************************************************************************************
186 template< typename Type // Data type of the vector
187  , bool TF = defaultTransposeFlag > // Transpose flag
188 class CompressedVector : public SparseVector< CompressedVector<Type,TF>, TF >
189 {
190  private:
191  //**Type definitions****************************************************************************
193  //**********************************************************************************************
194 
195  //**Private class Element***********************************************************************
199  struct Element : public ElementBase
200  {
201  // This operator is required due to a bug in all versions of the the MSVC compiler.
202  // A simple 'using ElementBase::operator=;' statement results in ambiguity problems.
203  template< typename Other >
204  inline Element& operator=( const Other& rhs )
205  {
206  ElementBase::operator=( rhs );
207  return *this;
208  }
209 
210  friend class CompressedVector;
211  };
213  //**********************************************************************************************
214 
215  public:
216  //**Type definitions****************************************************************************
219  typedef This ResultType;
221  typedef Type ElementType;
222  typedef const Type& ReturnType;
225  typedef const Type& ConstReference;
226  typedef Element* Iterator;
227  typedef const Element* ConstIterator;
228  //**********************************************************************************************
229 
230  //**Rebind struct definition********************************************************************
233  template< typename ET > // Data type of the other vector
234  struct Rebind {
236  };
237  //**********************************************************************************************
238 
239  //**Compilation flags***************************************************************************
241 
244  enum : bool { smpAssignable = !IsSMPAssignable<Type>::value };
245  //**********************************************************************************************
246 
247  //**Constructors********************************************************************************
250  explicit inline CompressedVector() noexcept;
251  explicit inline CompressedVector( size_t size ) noexcept;
252  explicit inline CompressedVector( size_t size, size_t nonzeros );
253  inline CompressedVector( const CompressedVector& sv );
254  inline CompressedVector( CompressedVector&& sv ) noexcept;
255  template< typename VT > inline CompressedVector( const DenseVector<VT,TF>& dv );
256  template< typename VT > inline CompressedVector( const SparseVector<VT,TF>& sv );
258  //**********************************************************************************************
259 
260  //**Destructor**********************************************************************************
263  inline ~CompressedVector();
265  //**********************************************************************************************
266 
267  //**Data access functions***********************************************************************
270  inline Reference operator[]( size_t index ) noexcept;
271  inline ConstReference operator[]( size_t index ) const noexcept;
272  inline Reference at( size_t index );
273  inline ConstReference at( size_t index ) const;
274  inline Iterator begin () noexcept;
275  inline ConstIterator begin () const noexcept;
276  inline ConstIterator cbegin() const noexcept;
277  inline Iterator end () noexcept;
278  inline ConstIterator end () const noexcept;
279  inline ConstIterator cend () const noexcept;
281  //**********************************************************************************************
282 
283  //**Assignment operators************************************************************************
286  inline CompressedVector& operator=( const CompressedVector& rhs );
287  inline CompressedVector& operator=( CompressedVector&& rhs ) noexcept;
288 
289  template< typename VT > inline CompressedVector& operator= ( const DenseVector<VT,TF>& rhs );
290  template< typename VT > inline CompressedVector& operator= ( const SparseVector<VT,TF>& rhs );
291  template< typename VT > inline CompressedVector& operator+=( const Vector<VT,TF>& rhs );
292  template< typename VT > inline CompressedVector& operator-=( const Vector<VT,TF>& rhs );
293  template< typename VT > inline CompressedVector& operator*=( const DenseVector<VT,TF>& rhs );
294  template< typename VT > inline CompressedVector& operator*=( const SparseVector<VT,TF>& rhs );
295  template< typename VT > inline CompressedVector& operator/=( const DenseVector<VT,TF>& rhs );
296 
297  template< typename Other >
298  inline EnableIf_< IsNumeric<Other>, CompressedVector >& operator*=( Other rhs );
299 
300  template< typename Other >
301  inline EnableIf_< IsNumeric<Other>, CompressedVector >& operator/=( Other rhs );
303  //**********************************************************************************************
304 
305  //**Utility functions***************************************************************************
308  inline size_t size() const noexcept;
309  inline size_t capacity() const noexcept;
310  inline size_t nonZeros() const;
311  inline void reset();
312  inline void clear();
313  inline Iterator set ( size_t index, const Type& value );
314  inline Iterator insert( size_t index, const Type& value );
315  inline void erase ( size_t index );
316  inline Iterator erase ( Iterator pos );
317  inline Iterator erase ( Iterator first, Iterator last );
318  inline void resize( size_t n, bool preserve=true );
319  void reserve( size_t n );
320  template< typename Other > inline CompressedVector& scale( const Other& scalar );
321  inline void swap( CompressedVector& sv ) noexcept;
323  //**********************************************************************************************
324 
325  //**Lookup functions****************************************************************************
328  inline Iterator find ( size_t index );
329  inline ConstIterator find ( size_t index ) const;
330  inline Iterator lowerBound( size_t index );
331  inline ConstIterator lowerBound( size_t index ) const;
332  inline Iterator upperBound( size_t index );
333  inline ConstIterator upperBound( size_t index ) const;
335  //**********************************************************************************************
336 
337  //**Low-level utility functions*****************************************************************
340  inline void append( size_t index, const Type& value, bool check=false );
342  //**********************************************************************************************
343 
344  //**Expression template evaluation functions****************************************************
347  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
348  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
349 
350  inline bool canSMPAssign() const noexcept;
351 
352  template< typename VT > inline void assign ( const DenseVector <VT,TF>& rhs );
353  template< typename VT > inline void assign ( const SparseVector<VT,TF>& rhs );
354  template< typename VT > inline void addAssign ( const DenseVector <VT,TF>& rhs );
355  template< typename VT > inline void addAssign ( const SparseVector<VT,TF>& rhs );
356  template< typename VT > inline void subAssign ( const DenseVector <VT,TF>& rhs );
357  template< typename VT > inline void subAssign ( const SparseVector<VT,TF>& rhs );
358  template< typename VT > inline void multAssign( const DenseVector <VT,TF>& rhs );
359  template< typename VT > inline void divAssign ( const DenseVector <VT,TF>& rhs );
361  //**********************************************************************************************
362 
363  private:
364  //**Utility functions***************************************************************************
367  Iterator insert( Iterator pos, size_t index, const Type& value );
368  inline size_t extendCapacity() const noexcept;
370  //**********************************************************************************************
371 
372  //**Member variables****************************************************************************
375  size_t size_;
376  size_t capacity_;
377  Iterator begin_;
378  Iterator end_;
379 
380  static const Type zero_;
381 
382  //**********************************************************************************************
383 
384  //**Compile time checks*************************************************************************
390  BLAZE_CONSTRAINT_MUST_HAVE_SAME_SIZE( ElementBase, Element );
392  //**********************************************************************************************
393 };
394 //*************************************************************************************************
395 
396 
397 
398 
399 //=================================================================================================
400 //
401 // DEFINITION AND INITIALIZATION OF THE STATIC MEMBER VARIABLES
402 //
403 //=================================================================================================
404 
405 template< typename Type // Data type of the vector
406  , bool TF > // Transpose flag
407 const Type CompressedVector<Type,TF>::zero_ = Type();
408 
409 
410 
411 
412 //=================================================================================================
413 //
414 // CONSTRUCTORS
415 //
416 //=================================================================================================
417 
418 //*************************************************************************************************
421 template< typename Type // Data type of the vector
422  , bool TF > // Transpose flag
423 inline CompressedVector<Type,TF>::CompressedVector() noexcept
424  : size_ ( 0UL ) // The current size/dimension of the compressed vector
425  , capacity_( 0UL ) // The maximum capacity of the compressed vector
426  , begin_ ( nullptr ) // Pointer to the first non-zero element of the compressed vector
427  , end_ ( nullptr ) // Pointer to the last non-zero element of the compressed vector
428 {}
429 //*************************************************************************************************
430 
431 
432 //*************************************************************************************************
437 template< typename Type // Data type of the vector
438  , bool TF > // Transpose flag
440  : size_ ( n ) // The current size/dimension of the compressed vector
441  , capacity_( 0UL ) // The maximum capacity of the compressed vector
442  , begin_ ( nullptr ) // Pointer to the first non-zero element of the compressed vector
443  , end_ ( nullptr ) // Pointer to the last non-zero element of the compressed vector
444 {}
445 //*************************************************************************************************
446 
447 
448 //*************************************************************************************************
454 template< typename Type // Data type of the vector
455  , bool TF > // Transpose flag
456 inline CompressedVector<Type,TF>::CompressedVector( size_t n, size_t nonzeros )
457  : size_ ( n ) // The current size/dimension of the compressed vector
458  , capacity_( nonzeros ) // The maximum capacity of the compressed vector
459  , begin_ ( allocate<Element>( capacity_ ) ) // Pointer to the first non-zero element of the compressed vector
460  , end_ ( begin_ ) // Pointer to the last non-zero element of the compressed vector
461 {}
462 //*************************************************************************************************
463 
464 
465 //*************************************************************************************************
473 template< typename Type // Data type of the vector
474  , bool TF > // Transpose flag
476  : size_ ( sv.size_ ) // The current size/dimension of the compressed vector
477  , capacity_( sv.nonZeros() ) // The maximum capacity of the compressed vector
478  , begin_ ( allocate<Element>( capacity_ ) ) // Pointer to the first non-zero element of the compressed vector
479  , end_ ( begin_+capacity_ ) // Pointer to the last non-zero element of the compressed vector
480 {
481  std::copy( sv.begin_, sv.end_, begin_ );
482 }
483 //*************************************************************************************************
484 
485 
486 //*************************************************************************************************
491 template< typename Type // Data type of the vector
492  , bool TF > // Transpose flag
494  : size_ ( sv.size_ ) // The current size/dimension of the compressed vector
495  , capacity_( sv.capacity_ ) // The maximum capacity of the compressed vector
496  , begin_ ( sv.begin_ ) // Pointer to the first non-zero element of the compressed vector
497  , end_ ( sv.end_ ) // Pointer to the last non-zero element of the compressed vector
498 {
499  sv.size_ = 0UL;
500  sv.capacity_ = 0UL;
501  sv.begin_ = nullptr;
502  sv.end_ = nullptr;
503 }
504 //*************************************************************************************************
505 
506 
507 //*************************************************************************************************
512 template< typename Type // Data type of the vector
513  , bool TF > // Transpose flag
514 template< typename VT > // Type of the foreign dense vector
516  : size_ ( (~dv).size() ) // The current size/dimension of the compressed vector
517  , capacity_( 0UL ) // The maximum capacity of the compressed vector
518  , begin_ ( nullptr ) // Pointer to the first non-zero element of the compressed vector
519  , end_ ( nullptr ) // Pointer to the last non-zero element of the compressed vector
520 {
521  using blaze::assign;
522  assign( *this, ~dv );
523 }
524 //*************************************************************************************************
525 
526 
527 //*************************************************************************************************
532 template< typename Type // Data type of the vector
533  , bool TF > // Transpose flag
534 template< typename VT > // Type of the foreign sparse vector
536  : size_ ( (~sv).size() ) // The current size/dimension of the compressed vector
537  , capacity_( (~sv).nonZeros() ) // The maximum capacity of the compressed vector
538  , begin_ ( allocate<Element>( capacity_ ) ) // Pointer to the first non-zero element of the compressed vector
539  , end_ ( begin_ ) // Pointer to the last non-zero element of the compressed vector
540 {
541  using blaze::assign;
542  assign( *this, ~sv );
543 }
544 //*************************************************************************************************
545 
546 
547 
548 
549 //=================================================================================================
550 //
551 // DESTRUCTOR
552 //
553 //=================================================================================================
554 
555 //*************************************************************************************************
558 template< typename Type // Data type of the vector
559  , bool TF > // Transpose flag
561 {
562  deallocate( begin_ );
563 }
564 //*************************************************************************************************
565 
566 
567 
568 
569 //=================================================================================================
570 //
571 // DATA ACCESS FUNCTIONS
572 //
573 //=================================================================================================
574 
575 //*************************************************************************************************
586 template< typename Type // Data type of the vector
587  , bool TF > // Transpose flag
589  CompressedVector<Type,TF>::operator[]( size_t index ) noexcept
590 {
591  BLAZE_USER_ASSERT( index < size_, "Invalid compressed vector access index" );
592 
593  return Reference( *this, index );
594 }
595 //*************************************************************************************************
596 
597 
598 //*************************************************************************************************
604 template< typename Type // Data type of the vector
605  , bool TF > // Transpose flag
607  CompressedVector<Type,TF>::operator[]( size_t index ) const noexcept
608 {
609  BLAZE_USER_ASSERT( index < size_, "Invalid compressed vector access index" );
610 
611  const ConstIterator pos( lowerBound( index ) );
612 
613  if( pos == end_ || pos->index_ != index )
614  return zero_;
615  else
616  return pos->value_;
617 }
618 //*************************************************************************************************
619 
620 
621 //*************************************************************************************************
633 template< typename Type // Data type of the vector
634  , bool TF > // Transpose flag
637 {
638  if( index >= size_ ) {
639  BLAZE_THROW_OUT_OF_RANGE( "Invalid compressed vector access index" );
640  }
641  return (*this)[index];
642 }
643 //*************************************************************************************************
644 
645 
646 //*************************************************************************************************
658 template< typename Type // Data type of the vector
659  , bool TF > // Transpose flag
661  CompressedVector<Type,TF>::at( size_t index ) const
662 {
663  if( index >= size_ ) {
664  BLAZE_THROW_OUT_OF_RANGE( "Invalid compressed vector access index" );
665  }
666  return (*this)[index];
667 }
668 //*************************************************************************************************
669 
670 
671 //*************************************************************************************************
676 template< typename Type // Data type of the vector
677  , bool TF > // Transpose flag
679 {
680  return Iterator( begin_ );
681 }
682 //*************************************************************************************************
683 
684 
685 //*************************************************************************************************
690 template< typename Type // Data type of the vector
691  , bool TF > // Transpose flag
694 {
695  return ConstIterator( begin_ );
696 }
697 //*************************************************************************************************
698 
699 
700 //*************************************************************************************************
705 template< typename Type // Data type of the vector
706  , bool TF > // Transpose flag
709 {
710  return ConstIterator( begin_ );
711 }
712 //*************************************************************************************************
713 
714 
715 //*************************************************************************************************
720 template< typename Type // Data type of the vector
721  , bool TF > // Transpose flag
723 {
724  return Iterator( end_ );
725 }
726 //*************************************************************************************************
727 
728 
729 //*************************************************************************************************
734 template< typename Type // Data type of the vector
735  , bool TF > // Transpose flag
738 {
739  return ConstIterator( end_ );
740 }
741 //*************************************************************************************************
742 
743 
744 //*************************************************************************************************
749 template< typename Type // Data type of the vector
750  , bool TF > // Transpose flag
753 {
754  return ConstIterator( end_ );
755 }
756 //*************************************************************************************************
757 
758 
759 
760 
761 //=================================================================================================
762 //
763 // ASSIGNMENT OPERATORS
764 //
765 //=================================================================================================
766 
767 //*************************************************************************************************
776 template< typename Type // Data type of the vector
777  , bool TF > // Transpose flag
780 {
781  if( &rhs == this ) return *this;
782 
783  const size_t nonzeros( rhs.nonZeros() );
784 
785  if( nonzeros > capacity_ ) {
786  Iterator newBegin( allocate<Element>( nonzeros ) );
787  end_ = std::copy( rhs.begin_, rhs.end_, newBegin );
788  std::swap( begin_, newBegin );
789  deallocate( newBegin );
790 
791  size_ = rhs.size_;
792  capacity_ = nonzeros;
793  }
794  else {
795  end_ = std::copy( rhs.begin_, rhs.end_, begin_ );
796  size_ = rhs.size_;
797  }
798 
799  return *this;
800 }
801 //*************************************************************************************************
802 
803 
804 //*************************************************************************************************
810 template< typename Type // Data type of the vector
811  , bool TF > // Transpose flag
814 {
815  deallocate( begin_ );
816 
817  size_ = rhs.size_;
818  capacity_ = rhs.capacity_;
819  begin_ = rhs.begin_;
820  end_ = rhs.end_;
821 
822  rhs.size_ = 0UL;
823  rhs.capacity_ = 0UL;
824  rhs.begin_ = nullptr;
825  rhs.end_ = nullptr;
826 
827  return *this;
828 }
829 //*************************************************************************************************
830 
831 
832 //*************************************************************************************************
841 template< typename Type // Data type of the vector
842  , bool TF > // Transpose flag
843 template< typename VT > // Type of the right-hand side dense vector
846 {
847  using blaze::assign;
848 
849  if( (~rhs).canAlias( this ) ) {
850  CompressedVector tmp( ~rhs );
851  swap( tmp );
852  }
853  else {
854  size_ = (~rhs).size();
855  end_ = begin_;
856  assign( *this, ~rhs );
857  }
858 
859  return *this;
860 }
861 //*************************************************************************************************
862 
863 
864 //*************************************************************************************************
873 template< typename Type // Data type of the vector
874  , bool TF > // Transpose flag
875 template< typename VT > // Type of the right-hand side sparse vector
878 {
879  using blaze::assign;
880 
881  if( (~rhs).canAlias( this ) || (~rhs).nonZeros() > capacity_ ) {
882  CompressedVector tmp( ~rhs );
883  swap( tmp );
884  }
885  else {
886  size_ = (~rhs).size();
887  end_ = begin_;
888  assign( *this, ~rhs );
889  }
890 
891  return *this;
892 }
893 //*************************************************************************************************
894 
895 
896 //*************************************************************************************************
906 template< typename Type // Data type of the vector
907  , bool TF > // Transpose flag
908 template< typename VT > // Type of the right-hand side vector
910 {
911  using blaze::addAssign;
912 
913  if( (~rhs).size() != size_ ) {
914  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
915  }
916 
917  addAssign( *this, ~rhs );
918 
919  return *this;
920 }
921 //*************************************************************************************************
922 
923 
924 //*************************************************************************************************
934 template< typename Type // Data type of the vector
935  , bool TF > // Transpose flag
936 template< typename VT > // Type of the right-hand side vector
938 {
939  using blaze::subAssign;
940 
941  if( (~rhs).size() != size_ ) {
942  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
943  }
944 
945  subAssign( *this, ~rhs );
946 
947  return *this;
948 }
949 //*************************************************************************************************
950 
951 
952 //*************************************************************************************************
963 template< typename Type // Data type of the vector
964  , bool TF > // Transpose flag
965 template< typename VT > // Type of the right-hand side vector
968 {
969  using blaze::multAssign;
970 
971  if( (~rhs).size() != size_ ) {
972  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
973  }
974 
975  if( (~rhs).canAlias( this ) ) {
976  CompressedVector tmp( *this * (~rhs) );
977  swap( tmp );
978  }
979  else {
980  CompositeType_<VT> tmp( ~rhs );
981  multAssign( *this, tmp );
982  }
983 
984  return *this;
985 }
986 //*************************************************************************************************
987 
988 
989 //*************************************************************************************************
1000 template< typename Type // Data type of the vector
1001  , bool TF > // Transpose flag
1002 template< typename VT > // Type of the right-hand side vector
1005 {
1006  if( (~rhs).size() != size_ ) {
1007  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1008  }
1009 
1010  CompressedVector tmp( *this * (~rhs) );
1011  swap( tmp );
1012 
1013  return *this;
1014 }
1015 //*************************************************************************************************
1016 
1017 
1018 //*************************************************************************************************
1028 template< typename Type // Data type of the vector
1029  , bool TF > // Transpose flag
1030 template< typename VT > // Type of the right-hand side vector
1032 {
1033  using blaze::divAssign;
1034 
1035  if( (~rhs).size() != size_ ) {
1036  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1037  }
1038 
1039  if( (~rhs).canAlias( this ) ) {
1040  CompressedVector tmp( *this / (~rhs) );
1041  swap( tmp );
1042  }
1043  else {
1044  CompositeType_<VT> tmp( ~rhs );
1045  divAssign( *this, tmp );
1046  }
1047 
1048  return *this;
1049 }
1050 //*************************************************************************************************
1051 
1052 
1053 //*************************************************************************************************
1064 template< typename Type // Data type of the vector
1065  , bool TF > // Transpose flag
1066 template< typename Other > // Data type of the right-hand side scalar
1069 {
1070  for( Iterator element=begin_; element!=end_; ++element )
1071  element->value_ *= rhs;
1072  return *this;
1073 }
1074 //*************************************************************************************************
1075 
1076 
1077 //*************************************************************************************************
1089 template< typename Type // Data type of the vector
1090  , bool TF > // Transpose flag
1091 template< typename Other > // Data type of the right-hand side scalar
1092 inline EnableIf_< IsNumeric<Other>, CompressedVector<Type,TF> >&
1094 {
1095  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1096 
1097  typedef DivTrait_<Type,Other> DT;
1098  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
1099 
1100  // Depending on the two involved data types, an integer division is applied or a
1101  // floating point division is selected.
1103  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1104  for( Iterator element=begin_; element!=end_; ++element )
1105  element->value_ *= tmp;
1106  }
1107  else {
1108  for( Iterator element=begin_; element!=end_; ++element )
1109  element->value_ /= rhs;
1110  }
1111 
1112  return *this;
1113 }
1114 //*************************************************************************************************
1115 
1116 
1117 
1118 
1119 //=================================================================================================
1120 //
1121 // UTILITY FUNCTIONS
1122 //
1123 //=================================================================================================
1124 
1125 //*************************************************************************************************
1130 template< typename Type // Data type of the vector
1131  , bool TF > // Transpose flag
1132 inline size_t CompressedVector<Type,TF>::size() const noexcept
1133 {
1134  return size_;
1135 }
1136 //*************************************************************************************************
1137 
1138 
1139 //*************************************************************************************************
1144 template< typename Type // Data type of the vector
1145  , bool TF > // Transpose flag
1146 inline size_t CompressedVector<Type,TF>::capacity() const noexcept
1147 {
1148  return capacity_;
1149 }
1150 //*************************************************************************************************
1151 
1152 
1153 //*************************************************************************************************
1161 template< typename Type // Data type of the vector
1162  , bool TF > // Transpose flag
1164 {
1165  return end_ - begin_;
1166 }
1167 //*************************************************************************************************
1168 
1169 
1170 //*************************************************************************************************
1175 template< typename Type // Data type of the vector
1176  , bool TF > // Transpose flag
1178 {
1179  end_ = begin_;
1180 }
1181 //*************************************************************************************************
1182 
1183 
1184 //*************************************************************************************************
1191 template< typename Type // Data type of the vector
1192  , bool TF > // Transpose flag
1194 {
1195  size_ = 0UL;
1196  end_ = begin_;
1197 }
1198 //*************************************************************************************************
1199 
1200 
1201 //*************************************************************************************************
1212 template< typename Type // Data type of the vector
1213  , bool TF > // Transpose flag
1215  CompressedVector<Type,TF>::set( size_t index, const Type& value )
1216 {
1217  BLAZE_USER_ASSERT( index < size_, "Invalid compressed vector access index" );
1218 
1219  const Iterator pos( lowerBound( index ) );
1220 
1221  if( pos != end_ && pos->index_ == index ) {
1222  pos->value() = value;
1223  return pos;
1224  }
1225  else return insert( pos, index, value );
1226 }
1227 //*************************************************************************************************
1228 
1229 
1230 //*************************************************************************************************
1242 template< typename Type // Data type of the vector
1243  , bool TF > // Transpose flag
1245  CompressedVector<Type,TF>::insert( size_t index, const Type& value )
1246 {
1247  BLAZE_USER_ASSERT( index < size_, "Invalid compressed vector access index" );
1248 
1249  const Iterator pos( lowerBound( index ) );
1250 
1251  if( pos != end_ && pos->index_ == index ) {
1252  BLAZE_THROW_INVALID_ARGUMENT( "Bad access index" );
1253  }
1254 
1255  return insert( pos, index, value );
1256 }
1257 //*************************************************************************************************
1258 
1259 
1260 //*************************************************************************************************
1269 template< typename Type // Data type of the vector
1270  , bool TF > // Transpose flag
1272  CompressedVector<Type,TF>::insert( Iterator pos, size_t index, const Type& value )
1273 {
1274  if( nonZeros() != capacity_ ) {
1275  std::move_backward( pos, end_, end_+1 );
1276  pos->value_ = value;
1277  pos->index_ = index;
1278  ++end_;
1279 
1280  return pos;
1281  }
1282  else {
1283  size_t newCapacity( extendCapacity() );
1284 
1285  Iterator newBegin = allocate<Element>( newCapacity );
1286  Iterator tmp = std::move( begin_, pos, newBegin );
1287  tmp->value_ = value;
1288  tmp->index_ = index;
1289  end_ = std::move( pos, end_, tmp+1 );
1290 
1291  std::swap( newBegin, begin_ );
1292  deallocate( newBegin );
1293  capacity_ = newCapacity;
1294 
1295  return tmp;
1296  }
1297 }
1298 //*************************************************************************************************
1299 
1300 
1301 //*************************************************************************************************
1309 template< typename Type // Data type of the vector
1310  , bool TF > // Transpose flag
1311 inline void CompressedVector<Type,TF>::erase( size_t index )
1312 {
1313  BLAZE_USER_ASSERT( index < size_, "Invalid compressed vector access index" );
1314 
1315  const Iterator pos( find( index ) );
1316  if( pos != end_ )
1317  end_ = std::move( pos+1, end_, pos );
1318 }
1319 //*************************************************************************************************
1320 
1321 
1322 //*************************************************************************************************
1330 template< typename Type // Data type of the vector
1331  , bool TF > // Transpose flag
1333 {
1334  BLAZE_USER_ASSERT( pos >= begin_ && pos <= end_, "Invalid compressed vector iterator" );
1335 
1336  if( pos != end_ )
1337  end_ = std::move( pos+1, end_, pos );
1338  return pos;
1339 }
1340 //*************************************************************************************************
1341 
1342 
1343 //*************************************************************************************************
1352 template< typename Type // Data type of the vector
1353  , bool TF > // Transpose flag
1355  CompressedVector<Type,TF>::erase( Iterator first, Iterator last )
1356 {
1357  BLAZE_USER_ASSERT( first <= last, "Invalid iterator range" );
1358  BLAZE_USER_ASSERT( first >= begin_ && first <= end_, "Invalid compressed vector iterator" );
1359  BLAZE_USER_ASSERT( last >= begin_ && last <= end_, "Invalid compressed vector iterator" );
1360 
1361  if( first != last )
1362  end_ = std::move( last, end_, first );
1363  return first;
1364 }
1365 //*************************************************************************************************
1366 
1367 
1368 //*************************************************************************************************
1382 template< typename Type // Data type of the vector
1383  , bool TF > // Transpose flag
1384 inline void CompressedVector<Type,TF>::resize( size_t n, bool preserve )
1385 {
1386  if( preserve ) {
1387  end_ = lowerBound( n );
1388  }
1389  else {
1390  end_ = begin_;
1391  }
1392 
1393  size_ = n;
1394 }
1395 //*************************************************************************************************
1396 
1397 
1398 //*************************************************************************************************
1407 template< typename Type // Data type of the vector
1408  , bool TF > // Transpose flag
1410 {
1411  if( n > capacity_ ) {
1412  const size_t newCapacity( n );
1413 
1414  // Allocating a new data and index array
1415  Iterator newBegin = allocate<Element>( newCapacity );
1416 
1417  // Replacing the old data and index array
1418  end_ = transfer( begin_, end_, newBegin );
1419  std::swap( newBegin, begin_ );
1420  capacity_ = newCapacity;
1421  deallocate( newBegin );
1422  }
1423 }
1424 //*************************************************************************************************
1425 
1426 
1427 //*************************************************************************************************
1433 template< typename Type // Data type of the vector
1434  , bool TF > // Transpose flag
1435 template< typename Other > // Data type of the scalar value
1437 {
1438  for( Iterator element=begin_; element!=end_; ++element )
1439  element->value_ *= scalar;
1440  return *this;
1441 }
1442 //*************************************************************************************************
1443 
1444 
1445 //*************************************************************************************************
1451 template< typename Type // Data type of the vector
1452  , bool TF > // Transpose flag
1454 {
1455  std::swap( size_, sv.size_ );
1456  std::swap( capacity_, sv.capacity_ );
1457  std::swap( begin_, sv.begin_ );
1458  std::swap( end_, sv.end_ );
1459 }
1460 //*************************************************************************************************
1461 
1462 
1463 //*************************************************************************************************
1471 template< typename Type // Data type of the vector
1472  , bool TF > // Transpose flag
1473 inline size_t CompressedVector<Type,TF>::extendCapacity() const noexcept
1474 {
1475  using blaze::max;
1476  using blaze::min;
1477 
1478  size_t nonzeros( 2UL*capacity_+1UL );
1479  nonzeros = max( nonzeros, 7UL );
1480  nonzeros = min( nonzeros, size_ );
1481 
1482  BLAZE_INTERNAL_ASSERT( nonzeros > capacity_, "Invalid capacity value" );
1483 
1484  return nonzeros;
1485 }
1486 //*************************************************************************************************
1487 
1488 
1489 
1490 
1491 //=================================================================================================
1492 //
1493 // LOOKUP FUNCTIONS
1494 //
1495 //=================================================================================================
1496 
1497 //*************************************************************************************************
1510 template< typename Type // Data type of the vector
1511  , bool TF > // Transpose flag
1513 {
1514  return const_cast<Iterator>( const_cast<const This&>( *this ).find( index ) );
1515 }
1516 //*************************************************************************************************
1517 
1518 
1519 //*************************************************************************************************
1532 template< typename Type // Data type of the vector
1533  , bool TF > // Transpose flag
1535 {
1536  const ConstIterator pos( lowerBound( index ) );
1537  if( pos != end_ && pos->index_ == index )
1538  return pos;
1539  else return end_;
1540 }
1541 //*************************************************************************************************
1542 
1543 
1544 //*************************************************************************************************
1556 template< typename Type // Data type of the vector
1557  , bool TF > // Transpose flag
1560 {
1561  return const_cast<Iterator>( const_cast<const This&>( *this ).lowerBound( index ) );
1562 }
1563 //*************************************************************************************************
1564 
1565 
1566 //*************************************************************************************************
1578 template< typename Type // Data type of the vector
1579  , bool TF > // Transpose flag
1582 {
1583  return std::lower_bound( begin_, end_, index,
1584  []( const Element& element, size_t i )
1585  {
1586  return element.index() < i;
1587  } );
1588 }
1589 //*************************************************************************************************
1590 
1591 
1592 //*************************************************************************************************
1604 template< typename Type // Data type of the vector
1605  , bool TF > // Transpose flag
1608 {
1609  return const_cast<Iterator>( const_cast<const This&>( *this ).upperBound( index ) );
1610 }
1611 //*************************************************************************************************
1612 
1613 
1614 //*************************************************************************************************
1626 template< typename Type // Data type of the vector
1627  , bool TF > // Transpose flag
1630 {
1631  return std::upper_bound( begin_, end_, index,
1632  []( size_t i, const Element& element )
1633  {
1634  return i < element.index();
1635  } );
1636 }
1637 //*************************************************************************************************
1638 
1639 
1640 
1641 
1642 //=================================================================================================
1643 //
1644 // LOW-LEVEL UTILITY FUNCTIONS
1645 //
1646 //=================================================================================================
1647 
1648 //*************************************************************************************************
1672 template< typename Type // Data type of the vector
1673  , bool TF > // Transpose flag
1674 inline void CompressedVector<Type,TF>::append( size_t index, const Type& value, bool check )
1675 {
1676  BLAZE_USER_ASSERT( index < size_, "Invalid compressed vector access index" );
1677  BLAZE_USER_ASSERT( nonZeros() < capacity(), "Not enough reserved capacity" );
1678  BLAZE_USER_ASSERT( begin_ == end_ || (end_-1UL)->index_ < index, "Index is not strictly increasing" );
1679 
1680  end_->value_ = value;
1681 
1682  if( !check || !isDefault( end_->value_ ) ) {
1683  end_->index_ = index;
1684  ++end_;
1685  }
1686 }
1687 //*************************************************************************************************
1688 
1689 
1690 
1691 
1692 //=================================================================================================
1693 //
1694 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1695 //
1696 //=================================================================================================
1697 
1698 //*************************************************************************************************
1708 template< typename Type // Data type of the vector
1709  , bool TF > // Transpose flag
1710 template< typename Other > // Data type of the foreign expression
1711 inline bool CompressedVector<Type,TF>::canAlias( const Other* alias ) const noexcept
1712 {
1713  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1714 }
1715 //*************************************************************************************************
1716 
1717 
1718 //*************************************************************************************************
1728 template< typename Type // Data type of the vector
1729  , bool TF > // Transpose flag
1730 template< typename Other > // Data type of the foreign expression
1731 inline bool CompressedVector<Type,TF>::isAliased( const Other* alias ) const noexcept
1732 {
1733  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1734 }
1735 //*************************************************************************************************
1736 
1737 
1738 //*************************************************************************************************
1748 template< typename Type // Data type of the vector
1749  , bool TF > // Transpose flag
1750 inline bool CompressedVector<Type,TF>::canSMPAssign() const noexcept
1751 {
1752  return false;
1753 }
1754 //*************************************************************************************************
1755 
1756 
1757 //*************************************************************************************************
1768 template< typename Type // Data type of the vector
1769  , bool TF > // Transpose flag
1770 template< typename VT > // Type of the right-hand side dense vector
1772 {
1773  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1774  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1775 
1776  size_t nonzeros( 0UL );
1777 
1778  for( size_t i=0UL; i<size_; ++i )
1779  {
1780  if( nonzeros == capacity_ )
1781  reserve( extendCapacity() );
1782 
1783  end_->value_ = (~rhs)[i];
1784 
1785  if( !isDefault( end_->value_ ) ) {
1786  end_->index_ = i;
1787  ++end_;
1788  ++nonzeros;
1789  }
1790  }
1791 }
1792 //*************************************************************************************************
1793 
1794 
1795 //*************************************************************************************************
1806 template< typename Type // Data type of the vector
1807  , bool TF > // Transpose flag
1808 template< typename VT > // Type of the right-hand side sparse vector
1810 {
1811  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1812  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1813 
1814  // Using the following formulation instead of a std::copy function call of the form
1815  //
1816  // end_ = std::copy( (~rhs).begin(), (~rhs).end(), begin_ );
1817  //
1818  // results in much less requirements on the ConstIterator type provided from the right-hand
1819  // sparse vector type
1820  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1821  append( element->index(), element->value() );
1822 }
1823 //*************************************************************************************************
1824 
1825 
1826 //*************************************************************************************************
1837 template< typename Type // Data type of the vector
1838  , bool TF > // Transpose flag
1839 template< typename VT > // Type of the right-hand side dense vector
1841 {
1842  typedef AddTrait_< This, ResultType_<VT> > AddType;
1843 
1847 
1848  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1849 
1850  const AddType tmp( serial( *this + (~rhs) ) );
1851  reset();
1852  assign( tmp );
1853 }
1854 //*************************************************************************************************
1855 
1856 
1857 //*************************************************************************************************
1868 template< typename Type // Data type of the vector
1869  , bool TF > // Transpose flag
1870 template< typename VT > // Type of the right-hand side sparse vector
1872 {
1873  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1874 
1875  CompressedVector tmp( serial( *this + (~rhs) ) );
1876  swap( tmp );
1877 }
1878 //*************************************************************************************************
1879 
1880 
1881 //*************************************************************************************************
1892 template< typename Type // Data type of the vector
1893  , bool TF > // Transpose flag
1894 template< typename VT > // Type of the right-hand side dense vector
1896 {
1897  typedef SubTrait_< This, ResultType_<VT> > SubType;
1898 
1902 
1903  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1904 
1905  const SubType tmp( serial( *this - (~rhs) ) );
1906  reset();
1907  assign( tmp );
1908 }
1909 //*************************************************************************************************
1910 
1911 
1912 //*************************************************************************************************
1923 template< typename Type // Data type of the vector
1924  , bool TF > // Transpose flag
1925 template< typename VT > // Type of the right-hand side sparse vector
1927 {
1928  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1929 
1930  CompressedVector tmp( serial( *this - (~rhs) ) );
1931  swap( tmp );
1932 }
1933 //*************************************************************************************************
1934 
1935 
1936 //*************************************************************************************************
1947 template< typename Type // Data type of the vector
1948  , bool TF > // Transpose flag
1949 template< typename VT > // Type of the right-hand side dense vector
1951 {
1952  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1953 
1955 
1956  for( Iterator element=begin_; element!=end_; ++element ) {
1957  element->value_ *= (~rhs)[element->index_];
1958  }
1959 }
1960 //*************************************************************************************************
1961 
1962 
1963 //*************************************************************************************************
1974 template< typename Type // Data type of the vector
1975  , bool TF > // Transpose flag
1976 template< typename VT > // Type of the right-hand side dense vector
1978 {
1979  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1980 
1982 
1983  for( Iterator element=begin_; element!=end_; ++element ) {
1984  element->value_ /= (~rhs)[element->index_];
1985  }
1986 }
1987 //*************************************************************************************************
1988 
1989 
1990 
1991 
1992 //=================================================================================================
1993 //
1994 // COMPRESSEDVECTOR OPERATORS
1995 //
1996 //=================================================================================================
1997 
1998 //*************************************************************************************************
2001 template< typename Type, bool TF >
2002 inline void reset( CompressedVector<Type,TF>& v );
2003 
2004 template< typename Type, bool TF >
2005 inline void clear( CompressedVector<Type,TF>& v );
2006 
2007 template< typename Type, bool TF >
2008 inline bool isDefault( const CompressedVector<Type,TF>& v );
2009 
2010 template< typename Type, bool TF >
2011 inline bool isIntact( const CompressedVector<Type,TF>& v ) noexcept;
2012 
2013 template< typename Type, bool TF >
2014 inline void swap( CompressedVector<Type,TF>& a, CompressedVector<Type,TF>& b ) noexcept;
2016 //*************************************************************************************************
2017 
2018 
2019 //*************************************************************************************************
2026 template< typename Type // Data type of the vector
2027  , bool TF > // Transpose flag
2029 {
2030  v.reset();
2031 }
2032 //*************************************************************************************************
2033 
2034 
2035 //*************************************************************************************************
2042 template< typename Type // Data type of the vector
2043  , bool TF > // Transpose flag
2045 {
2046  v.clear();
2047 }
2048 //*************************************************************************************************
2049 
2050 
2051 //*************************************************************************************************
2068 template< typename Type // Data type of the vector
2069  , bool TF > // Transpose flag
2070 inline bool isDefault( const CompressedVector<Type,TF>& v )
2071 {
2072  return ( v.size() == 0UL );
2073 }
2074 //*************************************************************************************************
2075 
2076 
2077 //*************************************************************************************************
2095 template< typename Type // Data type of the vector
2096  , bool TF > // Transpose flag
2097 inline bool isIntact( const CompressedVector<Type,TF>& v ) noexcept
2098 {
2099  return ( v.nonZeros() <= v.capacity() );
2100 }
2101 //*************************************************************************************************
2102 
2103 
2104 //*************************************************************************************************
2112 template< typename Type // Data type of the vector
2113  , bool TF > // Transpose flag
2115 {
2116  a.swap( b );
2117 }
2118 //*************************************************************************************************
2119 
2120 
2121 
2122 
2123 //=================================================================================================
2124 //
2125 // ISRESIZABLE SPECIALIZATIONS
2126 //
2127 //=================================================================================================
2128 
2129 //*************************************************************************************************
2131 template< typename T, bool TF >
2132 struct IsResizable< CompressedVector<T,TF> > : public TrueType
2133 {};
2135 //*************************************************************************************************
2136 
2137 
2138 
2139 
2140 //=================================================================================================
2141 //
2142 // ADDTRAIT SPECIALIZATIONS
2143 //
2144 //=================================================================================================
2145 
2146 //*************************************************************************************************
2148 template< typename T1, bool TF, typename T2, size_t N >
2149 struct AddTrait< CompressedVector<T1,TF>, StaticVector<T2,N,TF> >
2150 {
2151  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2152 };
2153 
2154 template< typename T1, size_t N, bool TF, typename T2 >
2155 struct AddTrait< StaticVector<T1,N,TF>, CompressedVector<T2,TF> >
2156 {
2157  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2158 };
2159 
2160 template< typename T1, bool TF, typename T2, size_t N >
2161 struct AddTrait< CompressedVector<T1,TF>, HybridVector<T2,N,TF> >
2162 {
2163  using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
2164 };
2165 
2166 template< typename T1, size_t N, bool TF, typename T2 >
2167 struct AddTrait< HybridVector<T1,N,TF>, CompressedVector<T2,TF> >
2168 {
2169  using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
2170 };
2171 
2172 template< typename T1, bool TF, typename T2 >
2173 struct AddTrait< CompressedVector<T1,TF>, DynamicVector<T2,TF> >
2174 {
2175  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
2176 };
2177 
2178 template< typename T1, bool TF, typename T2 >
2179 struct AddTrait< DynamicVector<T1,TF>, CompressedVector<T2,TF> >
2180 {
2181  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
2182 };
2183 
2184 template< typename T1, bool TF, typename T2, bool AF, bool PF >
2185 struct AddTrait< CompressedVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
2186 {
2187  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
2188 };
2189 
2190 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
2191 struct AddTrait< CustomVector<T1,AF,PF,TF>, CompressedVector<T2,TF> >
2192 {
2193  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
2194 };
2195 
2196 template< typename T1, bool TF, typename T2 >
2197 struct AddTrait< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2198 {
2199  using Type = CompressedVector< AddTrait_<T1,T2>, TF >;
2200 };
2202 //*************************************************************************************************
2203 
2204 
2205 
2206 
2207 //=================================================================================================
2208 //
2209 // SUBTRAIT SPECIALIZATIONS
2210 //
2211 //=================================================================================================
2212 
2213 //*************************************************************************************************
2215 template< typename T1, bool TF, typename T2, size_t N >
2216 struct SubTrait< CompressedVector<T1,TF>, StaticVector<T2,N,TF> >
2217 {
2218  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2219 };
2220 
2221 template< typename T1, size_t N, bool TF, typename T2 >
2222 struct SubTrait< StaticVector<T1,N,TF>, CompressedVector<T2,TF> >
2223 {
2224  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2225 };
2226 
2227 template< typename T1, bool TF, typename T2, size_t N >
2228 struct SubTrait< CompressedVector<T1,TF>, HybridVector<T2,N,TF> >
2229 {
2230  using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
2231 };
2232 
2233 template< typename T1, size_t N, bool TF, typename T2 >
2234 struct SubTrait< HybridVector<T1,N,TF>, CompressedVector<T2,TF> >
2235 {
2236  using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
2237 };
2238 
2239 template< typename T1, bool TF, typename T2 >
2240 struct SubTrait< CompressedVector<T1,TF>, DynamicVector<T2,TF> >
2241 {
2242  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
2243 };
2244 
2245 template< typename T1, bool TF, typename T2 >
2246 struct SubTrait< DynamicVector<T1,TF>, CompressedVector<T2,TF> >
2247 {
2248  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
2249 };
2250 
2251 template< typename T1, bool TF, typename T2, bool AF, bool PF >
2252 struct SubTrait< CompressedVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
2253 {
2254  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
2255 };
2256 
2257 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
2258 struct SubTrait< CustomVector<T1,AF,PF,TF>, CompressedVector<T2,TF> >
2259 {
2260  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
2261 };
2262 
2263 template< typename T1, bool TF, typename T2 >
2264 struct SubTrait< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2265 {
2266  using Type = CompressedVector< SubTrait_<T1,T2>, TF >;
2267 };
2269 //*************************************************************************************************
2270 
2271 
2272 
2273 
2274 //=================================================================================================
2275 //
2276 // MULTTRAIT SPECIALIZATIONS
2277 //
2278 //=================================================================================================
2279 
2280 //*************************************************************************************************
2282 template< typename T1, bool TF, typename T2 >
2283 struct MultTrait< CompressedVector<T1,TF>, T2, EnableIf_< IsNumeric<T2> > >
2284 {
2285  using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2286 };
2287 
2288 template< typename T1, typename T2, bool TF >
2289 struct MultTrait< T1, CompressedVector<T2,TF>, EnableIf_< IsNumeric<T1> > >
2290 {
2291  using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2292 };
2293 
2294 template< typename T1, bool TF, typename T2, size_t N >
2295 struct MultTrait< CompressedVector<T1,TF>, StaticVector<T2,N,TF> >
2296 {
2297  using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2298 };
2299 
2300 template< typename T1, typename T2, size_t N >
2301 struct MultTrait< CompressedVector<T1,false>, StaticVector<T2,N,true> >
2302 {
2303  using Type = CompressedMatrix< MultTrait_<T1,T2>, true >;
2304 };
2305 
2306 template< typename T1, typename T2, size_t N >
2307 struct MultTrait< CompressedVector<T1,true>, StaticVector<T2,N,false> >
2308 {
2309  using Type = MultTrait_<T1,T2>;
2310 };
2311 
2312 template< typename T1, size_t N, bool TF, typename T2 >
2313 struct MultTrait< StaticVector<T1,N,TF>, CompressedVector<T2,TF> >
2314 {
2315  using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2316 };
2317 
2318 template< typename T1, size_t N, typename T2 >
2319 struct MultTrait< StaticVector<T1,N,false>, CompressedVector<T2,true> >
2320 {
2321  using Type = CompressedMatrix< MultTrait_<T1,T2>, false >;
2322 };
2323 
2324 template< typename T1, size_t N, typename T2 >
2325 struct MultTrait< StaticVector<T1,N,true>, CompressedVector<T2,false> >
2326 {
2327  using Type = MultTrait_<T1,T2>;
2328 };
2329 
2330 template< typename T1, bool TF, typename T2, size_t N >
2331 struct MultTrait< CompressedVector<T1,TF>, HybridVector<T2,N,TF> >
2332 {
2333  using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2334 };
2335 
2336 template< typename T1, typename T2, size_t N >
2337 struct MultTrait< CompressedVector<T1,false>, HybridVector<T2,N,true> >
2338 {
2339  using Type = CompressedMatrix< MultTrait_<T1,T2>, true >;
2340 };
2341 
2342 template< typename T1, typename T2, size_t N >
2343 struct MultTrait< CompressedVector<T1,true>, HybridVector<T2,N,false> >
2344 {
2345  using Type = MultTrait_<T1,T2>;
2346 };
2347 
2348 template< typename T1, size_t N, bool TF, typename T2 >
2349 struct MultTrait< HybridVector<T1,N,TF>, CompressedVector<T2,TF> >
2350 {
2351  using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2352 };
2353 
2354 template< typename T1, size_t N, typename T2 >
2355 struct MultTrait< HybridVector<T1,N,false>, CompressedVector<T2,true> >
2356 {
2357  using Type = CompressedMatrix< MultTrait_<T1,T2>, false >;
2358 };
2359 
2360 template< typename T1, size_t N, typename T2 >
2361 struct MultTrait< HybridVector<T1,N,true>, CompressedVector<T2,false> >
2362 {
2363  using Type = MultTrait_<T1,T2>;
2364 };
2365 
2366 template< typename T1, bool TF, typename T2 >
2367 struct MultTrait< CompressedVector<T1,TF>, DynamicVector<T2,TF> >
2368 {
2369  using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2370 };
2371 
2372 template< typename T1, typename T2 >
2373 struct MultTrait< CompressedVector<T1,false>, DynamicVector<T2,true> >
2374 {
2375  using Type = CompressedMatrix< MultTrait_<T1,T2>, true >;
2376 };
2377 
2378 template< typename T1, typename T2 >
2379 struct MultTrait< CompressedVector<T1,true>, DynamicVector<T2,false> >
2380 {
2381  using Type = MultTrait_<T1,T2>;
2382 };
2383 
2384 template< typename T1, bool TF, typename T2 >
2385 struct MultTrait< DynamicVector<T1,TF>, CompressedVector<T2,TF> >
2386 {
2387  using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2388 };
2389 
2390 template< typename T1, typename T2 >
2391 struct MultTrait< DynamicVector<T1,false>, CompressedVector<T2,true> >
2392 {
2393  using Type = CompressedMatrix< MultTrait_<T1,T2>, false >;
2394 };
2395 
2396 template< typename T1, typename T2 >
2397 struct MultTrait< DynamicVector<T1,true>, CompressedVector<T2,false> >
2398 {
2399  using Type = MultTrait_<T1,T2>;
2400 };
2401 
2402 template< typename T1, bool TF, typename T2, bool AF, bool PF >
2403 struct MultTrait< CompressedVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
2404 {
2405  using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2406 };
2407 
2408 template< typename T1, typename T2, bool AF, bool PF >
2409 struct MultTrait< CompressedVector<T1,false>, CustomVector<T2,AF,PF,true> >
2410 {
2411  using Type = CompressedMatrix< MultTrait_<T1,T2>, true >;
2412 };
2413 
2414 template< typename T1, typename T2, bool AF, bool PF >
2415 struct MultTrait< CompressedVector<T1,true>, CustomVector<T2,AF,PF,false> >
2416 {
2417  using Type = MultTrait_<T1,T2>;
2418 };
2419 
2420 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
2421 struct MultTrait< CustomVector<T1,AF,PF,TF>, CompressedVector<T2,TF> >
2422 {
2423  using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2424 };
2425 
2426 template< typename T1, bool AF, bool PF, typename T2 >
2427 struct MultTrait< CustomVector<T1,AF,PF,false>, CompressedVector<T2,true> >
2428 {
2429  using Type = CompressedMatrix< MultTrait_<T1,T2>, false >;
2430 };
2431 
2432 template< typename T1, bool AF, bool PF, typename T2 >
2433 struct MultTrait< CustomVector<T1,AF,PF,true>, CompressedVector<T2,false> >
2434 {
2435  using Type = MultTrait_<T1,T2>;
2436 };
2437 
2438 template< typename T1, bool TF, typename T2 >
2439 struct MultTrait< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2440 {
2441  using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2442 };
2443 
2444 template< typename T1, typename T2 >
2445 struct MultTrait< CompressedVector<T1,false>, CompressedVector<T2,true> >
2446 {
2447  using Type = CompressedMatrix< MultTrait_<T1,T2>, false >;
2448 };
2449 
2450 template< typename T1, typename T2 >
2451 struct MultTrait< CompressedVector<T1,true>, CompressedVector<T2,false> >
2452 {
2453  using Type = MultTrait_<T1,T2>;
2454 };
2456 //*************************************************************************************************
2457 
2458 
2459 
2460 
2461 //=================================================================================================
2462 //
2463 // CROSSTRAIT SPECIALIZATIONS
2464 //
2465 //=================================================================================================
2466 
2467 //*************************************************************************************************
2469 template< typename T1, bool TF, typename T2 >
2470 struct CrossTrait< CompressedVector<T1,TF>, StaticVector<T2,3UL,TF> >
2471 {
2472  private:
2473  using T = MultTrait_<T1,T2>;
2474 
2475  public:
2476  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2477 };
2478 
2479 template< typename T1, bool TF, typename T2 >
2480 struct CrossTrait< StaticVector<T1,3UL,TF>, CompressedVector<T2,TF> >
2481 {
2482  private:
2483  using T = MultTrait_<T1,T2>;
2484 
2485  public:
2486  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2487 };
2488 
2489 template< typename T1, bool TF, typename T2, size_t N >
2490 struct CrossTrait< CompressedVector<T1,TF>, HybridVector<T2,N,TF> >
2491 {
2492  private:
2493  using T = MultTrait_<T1,T2>;
2494 
2495  public:
2496  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2497 };
2498 
2499 template< typename T1, size_t N, bool TF, typename T2 >
2500 struct CrossTrait< HybridVector<T1,N,TF>, CompressedVector<T2,TF> >
2501 {
2502  private:
2503  using T = MultTrait_<T1,T2>;
2504 
2505  public:
2506  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2507 };
2508 
2509 template< typename T1, bool TF, typename T2 >
2510 struct CrossTrait< CompressedVector<T1,TF>, DynamicVector<T2,TF> >
2511 {
2512  private:
2513  using T = MultTrait_<T1,T2>;
2514 
2515  public:
2516  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2517 };
2518 
2519 template< typename T1, bool TF, typename T2 >
2520 struct CrossTrait< DynamicVector<T1,TF>, CompressedVector<T2,TF> >
2521 {
2522  private:
2523  using T = MultTrait_<T1,T2>;
2524 
2525  public:
2526  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2527 };
2528 
2529 template< typename T1, bool TF, typename T2 >
2530 struct CrossTrait< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2531 {
2532  private:
2533  using T = MultTrait_<T1,T2>;
2534 
2535  public:
2536  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2537 };
2539 //*************************************************************************************************
2540 
2541 
2542 
2543 
2544 //=================================================================================================
2545 //
2546 // DIVTRAIT SPECIALIZATIONS
2547 //
2548 //=================================================================================================
2549 
2550 //*************************************************************************************************
2552 template< typename T1, bool TF, typename T2 >
2553 struct DivTrait< CompressedVector<T1,TF>, T2, EnableIf_< IsNumeric<T2> > >
2554 {
2555  using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2556 };
2557 
2558 template< typename T1, bool TF, typename T2, size_t N >
2559 struct DivTrait< CompressedVector<T1,TF>, StaticVector<T2,N,TF> >
2560 {
2561  using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2562 };
2563 
2564 template< typename T1, size_t N, bool TF, typename T2 >
2565 struct DivTrait< StaticVector<T1,N,TF>, CompressedVector<T2,TF> >
2566 {
2567  using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2568 };
2569 
2570 template< typename T1, bool TF, typename T2, size_t N >
2571 struct DivTrait< CompressedVector<T1,TF>, HybridVector<T2,N,TF> >
2572 {
2573  using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2574 };
2575 
2576 template< typename T1, size_t N, bool TF, typename T2 >
2577 struct DivTrait< HybridVector<T1,N,TF>, CompressedVector<T2,TF> >
2578 {
2579  using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2580 };
2581 
2582 template< typename T1, bool TF, typename T2 >
2583 struct DivTrait< CompressedVector<T1,TF>, DynamicVector<T2,TF> >
2584 {
2585  using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2586 };
2587 
2588 template< typename T1, bool TF, typename T2 >
2589 struct DivTrait< DynamicVector<T1,TF>, CompressedVector<T2,TF> >
2590 {
2591  using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2592 };
2593 
2594 template< typename T1, bool TF, typename T2, bool AF, bool PF >
2595 struct DivTrait< CompressedVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
2596 {
2597  using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2598 };
2599 
2600 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
2601 struct DivTrait< CustomVector<T1,AF,PF,TF>, CompressedVector<T2,TF> >
2602 {
2603  using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2604 };
2605 
2606 template< typename T1, bool TF, typename T2 >
2607 struct DivTrait< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2608 {
2609  using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2610 };
2612 //*************************************************************************************************
2613 
2614 
2615 
2616 
2617 //=================================================================================================
2618 //
2619 // MATHTRAIT SPECIALIZATIONS
2620 //
2621 //=================================================================================================
2622 
2623 //*************************************************************************************************
2625 template< typename T1, bool TF, typename T2 >
2626 struct MathTrait< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2627 {
2628  using HighType = CompressedVector< typename MathTrait<T1,T2>::HighType, TF >;
2629  using LowType = CompressedVector< typename MathTrait<T1,T2>::LowType , TF >;
2630 };
2632 //*************************************************************************************************
2633 
2634 
2635 
2636 
2637 //=================================================================================================
2638 //
2639 // SUBVECTORTRAIT SPECIALIZATIONS
2640 //
2641 //=================================================================================================
2642 
2643 //*************************************************************************************************
2645 template< typename T1, bool TF >
2646 struct SubvectorTrait< CompressedVector<T1,TF> >
2647 {
2648  using Type = CompressedVector<T1,TF>;
2649 };
2651 //*************************************************************************************************
2652 
2653 } // namespace blaze
2654 
2655 #endif
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#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
Header file for auxiliary alias declarations.
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:79
Header file for mathematical functions.
#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 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
Header file for basic type definitions.
Header file for the SparseVector base class.
void assign(const DenseVector< VT, TF > &rhs)
Default implementation of the assignment of a dense vector.
Definition: CompressedVector.h:1771
Iterator upperBound(size_t index)
Returns an iterator to the first index greater then the given index.
Definition: CompressedVector.h:1607
Header file for the serial shim.
ValueIndexPair< Type > ElementBase
Base class for the compressed vector element.
Definition: CompressedVector.h:192
CompressedVector< ET, TF > Other
The type of the other CompressedVector.
Definition: CompressedVector.h:235
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
CompressedVector< Type,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedVector.h:220
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
Access proxy for sparse, N-dimensional vectors.The VectorAccessProxy provides safe access to the elem...
Definition: VectorAccessProxy.h:100
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
VectorAccessProxy< This > Reference
Reference to a non-constant vector value.
Definition: CompressedVector.h:224
const Type & ConstReference
Reference to a constant vector value.
Definition: CompressedVector.h:225
OutputIterator transfer(InputIterator first, InputIterator last, OutputIterator dest)
Transfers the elements from the given source range to the destination range.
Definition: Algorithm.h:71
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
Header file for the DenseVector base class.
void addAssign(const DenseVector< VT, TF > &rhs)
Default implementation of the addition assignment of a dense vector.
Definition: CompressedVector.h:1840
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
void clear()
Clearing the compressed vector.
Definition: CompressedVector.h:1193
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
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
Header file for memory allocation and deallocation functionality.
size_t size_
The current size/dimension of the compressed vector.
Definition: CompressedVector.h:375
const CompressedVector & CompositeType
Data type for composite expression templates.
Definition: CompressedVector.h:223
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: CompressedVector.h:1750
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the compressed vector elements.
Definition: CompressedVector.h:589
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
size_t extendCapacity() const noexcept
Calculating a new vector capacity.
Definition: CompressedVector.h:1473
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2807
EnableIf_< IsBuiltin< T >, T * > allocate(size_t size)
Aligned array allocation for built-in data types.
Definition: Memory.h:150
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
Header file for the ValueIndexPair class.
Rebind mechanism to obtain a CompressedVector with different data/element type.
Definition: CompressedVector.h:234
CompressedVector() noexcept
The default constructor for CompressedVector.
Definition: CompressedVector.h:423
Iterator set(size_t index, const Type &value)
Setting an element of the compressed vector.
Definition: CompressedVector.h:1215
void subAssign(const DenseVector< VT, TF > &rhs)
Default implementation of the subtraction assignment of a dense vector.
Definition: CompressedVector.h:1895
void append(size_t index, const Type &value, bool check=false)
Appending an element to the compressed vector.
Definition: CompressedVector.h:1674
Header file for the multiplication trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5148
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
constexpr bool defaultTransposeFlag
The default transpose flag for all vectors of the Blaze library.This value specifies the default tran...
Definition: TransposeFlag.h:56
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
Iterator insert(size_t index, const Type &value)
Inserting an element into the compressed vector.
Definition: CompressedVector.h:1245
#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
Header file for the IsSMPAssignable type trait.
Iterator * end_
Pointers one past the last non-zero element of each column.
Definition: CompressedMatrix.h:2809
Iterator begin_
Pointer to the first non-zero element of the compressed vector.
Definition: CompressedVector.h:377
#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
#define BLAZE_CONSTRAINT_MUST_HAVE_SAME_SIZE(T1, T2)
Constraint on the size of two data types.In case the types T1 and T2 don't have the same size...
Definition: SameSize.h:60
Header file for the subvector trait.
Constraint on the data type.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedVector.h:222
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_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:60
Constraint on the data type.
Header file for the exception macros of the math module.
size_t size() const noexcept
Returns the current size/dimension of the compressed vector.
Definition: CompressedVector.h:1132
Compile time check for floating point data types.This type trait tests whether or not the given templ...
Definition: IsFloatingPoint.h:75
Compile time check for data types.This type trait tests whether or not the given template parameter i...
Definition: IsSMPAssignable.h:119
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
Constraint on the data type.
Headerfile for generic algorithms.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
size_t capacity_
The maximum capacity of the compressed vector.
Definition: CompressedVector.h:376
This ResultType
Result type for expression template evaluations.
Definition: CompressedVector.h:219
void erase(size_t index)
Erasing an element from the compressed vector.
Definition: CompressedVector.h:1311
typename DivTrait< T1, T2 >::Type DivTrait_
Auxiliary alias declaration for the DivTrait class template.The DivTrait_ alias declaration provides ...
Definition: DivTrait.h:245
Iterator lowerBound(size_t index)
Returns an iterator to the first index not less then the given index.
Definition: CompressedVector.h:1559
Iterator find(size_t index)
Searches for a specific vector element.
Definition: CompressedVector.h:1512
Header file for the IsNumeric type trait.
void reset()
Reset to the default initial values.
Definition: CompressedVector.h:1177
void resize(size_t n, bool preserve=true)
Changing the size of the compressed vector.
Definition: CompressedVector.h:1384
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
Constraint on the data type.
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:160
CompressedVector< Type, TF > This
Type of this CompressedVector instance.
Definition: CompressedVector.h:217
Reference at(size_t index)
Checked access to the compressed vector elements.
Definition: CompressedVector.h:636
#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 VectorAccessProxy class.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedVector.h:227
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:258
size_t capacity() const noexcept
Returns the maximum capacity of the compressed vector.
Definition: CompressedVector.h:1146
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedVector.h:226
Constraint on the data type.
Iterator * begin_
Pointers to the first non-zero element of each column.
Definition: CompressedMatrix.h:2808
#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
void multAssign(const DenseVector< VT, TF > &rhs)
Default implementation of the multiplication assignment of a dense vector.
Definition: CompressedVector.h:1950
ConstIterator cend() const noexcept
Returns an iterator just past the last non-zero element of the compressed vector. ...
Definition: CompressedVector.h:752
void divAssign(const DenseVector< VT, TF > &rhs)
Default implementation of the division assignment of a dense vector.
Definition: CompressedVector.h:1977
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: CompressedVector.h:1731
EnableIf_< IsBuiltin< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:225
size_t nonZeros() const
Returns the number of non-zero elements in the compressed vector.
Definition: CompressedVector.h:1163
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Header file for the mathematical trait.
void swap(CompressedVector &sv) noexcept
Swapping the contents of two compressed vectors.
Definition: CompressedVector.h:1453
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
#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
Iterator end() noexcept
Returns an iterator just past the last non-zero element of the compressed vector. ...
Definition: CompressedVector.h:722
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:70
Constraint on the size of two data types.
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:154
Header file for the default transpose flag for all vectors of the Blaze library.
~CompressedVector()
The destructor for CompressedVector.
Definition: CompressedVector.h:560
CompressedVector & operator=(const CompressedVector &rhs)
Copy assignment operator for CompressedVector.
Definition: CompressedVector.h:779
SparseVector< This, TF > BaseType
Base type of this CompressedVector instance.
Definition: CompressedVector.h:218
typename SubTrait< T1, T2 >::Type SubTrait_
Auxiliary alias declaration for the SubTrait class template.The SubTrait_ alias declaration provides ...
Definition: SubTrait.h:245
static const Type zero_
Neutral element for accesses to zero elements.
Definition: CompressedMatrix.h:2811
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:110
Iterator end_
Pointer one past the last non-zero element of the compressed vector.
Definition: CompressedVector.h:378
ConstIterator cbegin() const noexcept
Returns an iterator to the first non-zero element of the compressed vector.
Definition: CompressedVector.h:708
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: CompressedVector.h:1711
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
Iterator begin() noexcept
Returns an iterator to the first non-zero element of the compressed vector.
Definition: CompressedVector.h:678
Type ElementType
Type of the compressed vector elements.
Definition: CompressedVector.h:221
static const Type zero_
Neutral element for accesses to zero elements.
Definition: CompressedVector.h:380
Header file for the IsResizable type trait.
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.In case the given data type T is not a dense or sparse vector type and in...
Definition: TransposeFlag.h:63
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
typename AddTrait< T1, T2 >::Type AddTrait_
Auxiliary alias declaration for the AddTrait class template.The AddTrait_ alias declaration provides ...
Definition: AddTrait.h:245
#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
Efficient implementation of an arbitrary sized sparse vector.The CompressedVector class is the repres...
Definition: CompressedVector.h:188
void reserve(size_t n)
Setting the minimum capacity of the compressed vector.
Definition: CompressedVector.h:1409