Blaze  3.6
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>
89 #include <blaze/util/Assert.h>
95 #include <blaze/util/DisableIf.h>
96 #include <blaze/util/EnableIf.h>
98 #include <blaze/util/Memory.h>
99 #include <blaze/util/Types.h>
104 
105 
106 namespace blaze {
107 
108 //=================================================================================================
109 //
110 // CLASS DEFINITION
111 //
112 //=================================================================================================
113 
114 //*************************************************************************************************
208 template< typename Type // Data type of the vector
209  , bool TF = defaultTransposeFlag > // Transpose flag
211  : public SparseVector< CompressedVector<Type,TF>, TF >
212 {
213  private:
214  //**Type definitions****************************************************************************
217  //**********************************************************************************************
218 
219  //**Private class Element***********************************************************************
226  struct Element
227  : public ElementBase
228  {
229  //**Constructors*****************************************************************************
230  explicit Element() = default;
231  Element( const Element& rhs ) = default;
232  Element( Element&& rhs ) = default;
233  //*******************************************************************************************
234 
235  //**Assignment operators*********************************************************************
236  inline Element& operator=( const Element& rhs )
237  {
238  this->value_ = rhs.value_;
239  return *this;
240  }
241 
242  inline Element& operator=( Element&& rhs )
243  {
244  this->value_ = std::move( rhs.value_ );
245  return *this;
246  }
247 
248  template< typename Other >
249  inline auto operator=( const Other& rhs )
251  {
252  this->value_ = rhs.value();
253  return *this;
254  }
255 
256  template< typename Other >
257  inline auto operator=( Other&& rhs )
259  IsRValueReference_v<Other&&>, Element& >
260  {
261  this->value_ = std::move( rhs.value() );
262  return *this;
263  }
264 
265  template< typename Other >
266  inline auto operator=( const Other& v )
268  {
269  this->value_ = v;
270  return *this;
271  }
272 
273  template< typename Other >
274  inline auto operator=( Other&& v )
276  IsRValueReference_v<Other&&>, Element& >
277  {
278  this->value_ = std::move( v );
279  return *this;
280  }
281  //*******************************************************************************************
282 
283  //**Friend declarations**********************************************************************
284  friend class CompressedVector;
285  //*******************************************************************************************
286  };
288  //**********************************************************************************************
289 
290  public:
291  //**Type definitions****************************************************************************
294  using ResultType = This;
296  using ElementType = Type;
297  using ReturnType = const Type&;
300  using ConstReference = const Type&;
301  using Iterator = Element*;
302  using ConstIterator = const Element*;
303  //**********************************************************************************************
304 
305  //**Rebind struct definition********************************************************************
308  template< typename NewType > // Data type of the other vector
309  struct Rebind {
311  };
312  //**********************************************************************************************
313 
314  //**Resize struct definition********************************************************************
317  template< size_t NewN > // Number of elements of the other vector
318  struct Resize {
320  };
321  //**********************************************************************************************
322 
323  //**Compilation flags***************************************************************************
325 
328  static constexpr bool smpAssignable = !IsSMPAssignable_v<Type>;
329  //**********************************************************************************************
330 
331  //**Constructors********************************************************************************
334  explicit inline CompressedVector() noexcept;
335  explicit inline CompressedVector( size_t size ) noexcept;
336  explicit inline CompressedVector( size_t size, size_t nonzeros );
337  inline CompressedVector( initializer_list<Type> list );
338 
339  inline CompressedVector( const CompressedVector& sv );
340  inline CompressedVector( CompressedVector&& sv ) noexcept;
341 
342  template< typename VT > inline CompressedVector( const DenseVector<VT,TF>& dv );
343  template< typename VT > inline CompressedVector( const SparseVector<VT,TF>& sv );
345  //**********************************************************************************************
346 
347  //**Destructor**********************************************************************************
350  inline ~CompressedVector();
352  //**********************************************************************************************
353 
354  //**Data access functions***********************************************************************
357  inline Reference operator[]( size_t index ) noexcept;
358  inline ConstReference operator[]( size_t index ) const noexcept;
359  inline Reference at( size_t index );
360  inline ConstReference at( size_t index ) const;
361  inline Iterator begin () noexcept;
362  inline ConstIterator begin () const noexcept;
363  inline ConstIterator cbegin() const noexcept;
364  inline Iterator end () noexcept;
365  inline ConstIterator end () const noexcept;
366  inline ConstIterator cend () const noexcept;
368  //**********************************************************************************************
369 
370  //**Assignment operators************************************************************************
373  inline CompressedVector& operator=( initializer_list<Type> list );
374  inline CompressedVector& operator=( const CompressedVector& rhs );
375  inline CompressedVector& operator=( CompressedVector&& rhs ) noexcept;
376 
377  template< typename VT > inline CompressedVector& operator= ( const DenseVector<VT,TF>& rhs );
378  template< typename VT > inline CompressedVector& operator= ( const SparseVector<VT,TF>& rhs );
379  template< typename VT > inline CompressedVector& operator+=( const Vector<VT,TF>& rhs );
380  template< typename VT > inline CompressedVector& operator-=( const Vector<VT,TF>& rhs );
381  template< typename VT > inline CompressedVector& operator*=( const DenseVector<VT,TF>& rhs );
382  template< typename VT > inline CompressedVector& operator*=( const SparseVector<VT,TF>& rhs );
383  template< typename VT > inline CompressedVector& operator/=( const DenseVector<VT,TF>& rhs );
384  template< typename VT > inline CompressedVector& operator%=( const Vector<VT,TF>& rhs );
386  //**********************************************************************************************
387 
388  //**Utility functions***************************************************************************
391  inline size_t size() const noexcept;
392  inline size_t capacity() const noexcept;
393  inline size_t nonZeros() const;
394  inline void reset();
395  inline void clear();
396  inline void resize( size_t n, bool preserve=true );
397  void reserve( size_t n );
398  inline void shrinkToFit();
399  inline void swap( CompressedVector& sv ) noexcept;
401  //**********************************************************************************************
402 
403  //**Insertion functions*************************************************************************
406  inline Iterator set ( size_t index, const Type& value );
407  inline Iterator insert( size_t index, const Type& value );
408  inline void append( size_t index, const Type& value, bool check=false );
410  //**********************************************************************************************
411 
412  //**Erase functions*****************************************************************************
415  inline void erase( size_t index );
416  inline Iterator erase( Iterator pos );
417  inline Iterator erase( Iterator first, Iterator last );
418 
419  template< typename Pred, typename = DisableIf_t< IsIntegral_v<Pred> > >
420  inline void erase( Pred predicate );
421 
422  template< typename Pred >
423  inline void erase( Iterator first, Iterator last, Pred predicate );
425  //**********************************************************************************************
426 
427  //**Lookup functions****************************************************************************
430  inline Iterator find ( size_t index );
431  inline ConstIterator find ( size_t index ) const;
432  inline Iterator lowerBound( size_t index );
433  inline ConstIterator lowerBound( size_t index ) const;
434  inline Iterator upperBound( size_t index );
435  inline ConstIterator upperBound( size_t index ) const;
437  //**********************************************************************************************
438 
439  //**Numeric functions***************************************************************************
442  template< typename Other > inline CompressedVector& scale( const Other& scalar );
444  //**********************************************************************************************
445 
446  //**Expression template evaluation functions****************************************************
449  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
450  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
451 
452  inline bool canSMPAssign() const noexcept;
453 
454  template< typename VT > inline void assign ( const DenseVector <VT,TF>& rhs );
455  template< typename VT > inline void assign ( const SparseVector<VT,TF>& rhs );
456  template< typename VT > inline void addAssign ( const DenseVector <VT,TF>& rhs );
457  template< typename VT > inline void addAssign ( const SparseVector<VT,TF>& rhs );
458  template< typename VT > inline void subAssign ( const DenseVector <VT,TF>& rhs );
459  template< typename VT > inline void subAssign ( const SparseVector<VT,TF>& rhs );
460  template< typename VT > inline void multAssign( const DenseVector <VT,TF>& rhs );
461  template< typename VT > inline void divAssign ( const DenseVector <VT,TF>& rhs );
463  //**********************************************************************************************
464 
465  private:
466  //**Utility functions***************************************************************************
469  inline size_t extendCapacity() const noexcept;
470  inline Iterator castDown( IteratorBase it ) const noexcept;
471  inline IteratorBase castUp ( Iterator it ) const noexcept;
473  //**********************************************************************************************
474 
475  //**Insertion functions***************************************************************************
478  Iterator insert( Iterator pos, size_t index, const Type& value );
480  //**********************************************************************************************
481 
482  //**Member variables****************************************************************************
485  size_t size_;
486  size_t capacity_;
489 
490  static const Type zero_;
491 
492  //**********************************************************************************************
493 
494  //**Compile time checks*************************************************************************
502  //**********************************************************************************************
503 };
504 //*************************************************************************************************
505 
506 
507 
508 
509 //=================================================================================================
510 //
511 // DEFINITION AND INITIALIZATION OF THE STATIC MEMBER VARIABLES
512 //
513 //=================================================================================================
514 
515 template< typename Type // Data type of the vector
516  , bool TF > // Transpose flag
517 const Type CompressedVector<Type,TF>::zero_{};
518 
519 
520 
521 
522 //=================================================================================================
523 //
524 // CONSTRUCTORS
525 //
526 //=================================================================================================
527 
528 //*************************************************************************************************
531 template< typename Type // Data type of the vector
532  , bool TF > // Transpose flag
534  : size_ ( 0UL ) // The current size/dimension of the compressed vector
535  , capacity_( 0UL ) // The maximum capacity of the compressed vector
536  , begin_ ( nullptr ) // Pointer to the first non-zero element of the compressed vector
537  , end_ ( nullptr ) // Pointer to the last non-zero element of the compressed vector
538 {}
539 //*************************************************************************************************
540 
541 
542 //*************************************************************************************************
547 template< typename Type // Data type of the vector
548  , bool TF > // Transpose flag
550  : size_ ( n ) // The current size/dimension of the compressed vector
551  , capacity_( 0UL ) // The maximum capacity of the compressed vector
552  , begin_ ( nullptr ) // Pointer to the first non-zero element of the compressed vector
553  , end_ ( nullptr ) // Pointer to the last non-zero element of the compressed vector
554 {}
555 //*************************************************************************************************
556 
557 
558 //*************************************************************************************************
564 template< typename Type // Data type of the vector
565  , bool TF > // Transpose flag
566 inline CompressedVector<Type,TF>::CompressedVector( size_t n, size_t nonzeros )
567  : size_ ( n ) // The current size/dimension of the compressed vector
568  , capacity_( nonzeros ) // The maximum capacity of the compressed vector
569  , begin_ ( allocate<Element>( capacity_ ) ) // Pointer to the first non-zero element of the compressed vector
570  , end_ ( begin_ ) // Pointer to the last non-zero element of the compressed vector
571 {}
572 //*************************************************************************************************
573 
574 
575 //*************************************************************************************************
590 template< typename Type // Data type of the vector
591  , bool TF > // Transpose flag
593  : CompressedVector( list.size(), blaze::nonZeros( list ) )
594 {
595  size_t i( 0UL );
596 
597  for( const Type& element : list ) {
598  if( !isDefault<strict>( element ) )
599  append( i, element );
600  ++i;
601  }
602 }
603 //*************************************************************************************************
604 
605 
606 //*************************************************************************************************
614 template< typename Type // Data type of the vector
615  , bool TF > // Transpose flag
617  : CompressedVector( sv.size_, sv.nonZeros() )
618 {
619  end_ = begin_ + capacity_;
620  std::copy( sv.begin_, sv.end_, castUp( begin_ ) );
621 }
622 //*************************************************************************************************
623 
624 
625 //*************************************************************************************************
630 template< typename Type // Data type of the vector
631  , bool TF > // Transpose flag
633  : size_ ( sv.size_ ) // The current size/dimension of the compressed vector
634  , capacity_( sv.capacity_ ) // The maximum capacity of the compressed vector
635  , begin_ ( sv.begin_ ) // Pointer to the first non-zero element of the compressed vector
636  , end_ ( sv.end_ ) // Pointer to the last non-zero element of the compressed vector
637 {
638  sv.size_ = 0UL;
639  sv.capacity_ = 0UL;
640  sv.begin_ = nullptr;
641  sv.end_ = nullptr;
642 }
643 //*************************************************************************************************
644 
645 
646 //*************************************************************************************************
651 template< typename Type // Data type of the vector
652  , bool TF > // Transpose flag
653 template< typename VT > // Type of the foreign dense vector
655  : CompressedVector( (~dv).size() )
656 {
657  using blaze::assign;
658 
659  assign( *this, ~dv );
660 }
661 //*************************************************************************************************
662 
663 
664 //*************************************************************************************************
669 template< typename Type // Data type of the vector
670  , bool TF > // Transpose flag
671 template< typename VT > // Type of the foreign sparse vector
673  : CompressedVector( (~sv).size(), (~sv).nonZeros() )
674 {
675  using blaze::assign;
676 
677  assign( *this, ~sv );
678 }
679 //*************************************************************************************************
680 
681 
682 
683 
684 //=================================================================================================
685 //
686 // DESTRUCTOR
687 //
688 //=================================================================================================
689 
690 //*************************************************************************************************
693 template< typename Type // Data type of the vector
694  , bool TF > // Transpose flag
696 {
697  deallocate( begin_ );
698 }
699 //*************************************************************************************************
700 
701 
702 
703 
704 //=================================================================================================
705 //
706 // DATA ACCESS FUNCTIONS
707 //
708 //=================================================================================================
709 
710 //*************************************************************************************************
721 template< typename Type // Data type of the vector
722  , bool TF > // Transpose flag
724  CompressedVector<Type,TF>::operator[]( size_t index ) noexcept
725 {
726  BLAZE_USER_ASSERT( index < size_, "Invalid compressed vector access index" );
727 
728  return Reference( *this, index );
729 }
730 //*************************************************************************************************
731 
732 
733 //*************************************************************************************************
739 template< typename Type // Data type of the vector
740  , bool TF > // Transpose flag
742  CompressedVector<Type,TF>::operator[]( size_t index ) const noexcept
743 {
744  BLAZE_USER_ASSERT( index < size_, "Invalid compressed vector access index" );
745 
746  const ConstIterator pos( lowerBound( index ) );
747 
748  if( pos == end_ || pos->index_ != index )
749  return zero_;
750  else
751  return pos->value_;
752 }
753 //*************************************************************************************************
754 
755 
756 //*************************************************************************************************
768 template< typename Type // Data type of the vector
769  , bool TF > // Transpose flag
772 {
773  if( index >= size_ ) {
774  BLAZE_THROW_OUT_OF_RANGE( "Invalid compressed vector access index" );
775  }
776  return (*this)[index];
777 }
778 //*************************************************************************************************
779 
780 
781 //*************************************************************************************************
791 template< typename Type // Data type of the vector
792  , bool TF > // Transpose flag
794  CompressedVector<Type,TF>::at( size_t index ) const
795 {
796  if( index >= size_ ) {
797  BLAZE_THROW_OUT_OF_RANGE( "Invalid compressed vector access index" );
798  }
799  return (*this)[index];
800 }
801 //*************************************************************************************************
802 
803 
804 //*************************************************************************************************
809 template< typename Type // Data type of the vector
810  , bool TF > // Transpose flag
812 {
813  return Iterator( begin_ );
814 }
815 //*************************************************************************************************
816 
817 
818 //*************************************************************************************************
823 template< typename Type // Data type of the vector
824  , bool TF > // Transpose flag
827 {
828  return ConstIterator( begin_ );
829 }
830 //*************************************************************************************************
831 
832 
833 //*************************************************************************************************
838 template< typename Type // Data type of the vector
839  , bool TF > // Transpose flag
842 {
843  return ConstIterator( begin_ );
844 }
845 //*************************************************************************************************
846 
847 
848 //*************************************************************************************************
853 template< typename Type // Data type of the vector
854  , bool TF > // Transpose flag
856 {
857  return Iterator( end_ );
858 }
859 //*************************************************************************************************
860 
861 
862 //*************************************************************************************************
867 template< typename Type // Data type of the vector
868  , bool TF > // Transpose flag
871 {
872  return ConstIterator( end_ );
873 }
874 //*************************************************************************************************
875 
876 
877 //*************************************************************************************************
882 template< typename Type // Data type of the vector
883  , bool TF > // Transpose flag
886 {
887  return ConstIterator( end_ );
888 }
889 //*************************************************************************************************
890 
891 
892 
893 
894 //=================================================================================================
895 //
896 // ASSIGNMENT OPERATORS
897 //
898 //=================================================================================================
899 
900 //*************************************************************************************************
916 template< typename Type // Data type of the vector
917  , bool TF > // Transpose flag
920 {
921  using blaze::nonZeros;
922 
923  resize( list.size(), false );
924  reserve( nonZeros( list ) );
925 
926  size_t i( 0UL );
927 
928  for( const Type& element : list ) {
929  if( !isDefault<strict>( element ) )
930  append( i, element );
931  ++i;
932  }
933 
934  return *this;
935 }
936 //*************************************************************************************************
937 
938 
939 //*************************************************************************************************
948 template< typename Type // Data type of the vector
949  , bool TF > // Transpose flag
952 {
953  using std::swap;
954 
955  if( &rhs == this ) return *this;
956 
957  const size_t nonzeros( rhs.nonZeros() );
958 
959  if( nonzeros > capacity_ ) {
960  Iterator newBegin( allocate<Element>( nonzeros ) );
961  end_ = castDown( std::copy( rhs.begin_, rhs.end_, castUp( newBegin ) ) );
962  swap( begin_, newBegin );
963  deallocate( newBegin );
964 
965  size_ = rhs.size_;
966  capacity_ = nonzeros;
967  }
968  else {
969  end_ = castDown( std::copy( rhs.begin_, rhs.end_, castUp( begin_ ) ) );
970  size_ = rhs.size_;
971  }
972 
973  return *this;
974 }
975 //*************************************************************************************************
976 
977 
978 //*************************************************************************************************
984 template< typename Type // Data type of the vector
985  , bool TF > // Transpose flag
988 {
989  deallocate( begin_ );
990 
991  size_ = rhs.size_;
992  capacity_ = rhs.capacity_;
993  begin_ = rhs.begin_;
994  end_ = rhs.end_;
995 
996  rhs.size_ = 0UL;
997  rhs.capacity_ = 0UL;
998  rhs.begin_ = nullptr;
999  rhs.end_ = nullptr;
1000 
1001  return *this;
1002 }
1003 //*************************************************************************************************
1004 
1005 
1006 //*************************************************************************************************
1015 template< typename Type // Data type of the vector
1016  , bool TF > // Transpose flag
1017 template< typename VT > // Type of the right-hand side dense vector
1020 {
1021  using blaze::assign;
1022 
1023  if( (~rhs).canAlias( this ) ) {
1024  CompressedVector tmp( ~rhs );
1025  swap( tmp );
1026  }
1027  else {
1028  size_ = (~rhs).size();
1029  end_ = begin_;
1030  assign( *this, ~rhs );
1031  }
1032 
1033  return *this;
1034 }
1035 //*************************************************************************************************
1036 
1037 
1038 //*************************************************************************************************
1047 template< typename Type // Data type of the vector
1048  , bool TF > // Transpose flag
1049 template< typename VT > // Type of the right-hand side sparse vector
1052 {
1053  using blaze::assign;
1054 
1055  if( (~rhs).canAlias( this ) || (~rhs).nonZeros() > capacity_ ) {
1056  CompressedVector tmp( ~rhs );
1057  swap( tmp );
1058  }
1059  else {
1060  size_ = (~rhs).size();
1061  end_ = begin_;
1062 
1063  if( !IsZero_v<VT> ) {
1064  assign( *this, ~rhs );
1065  }
1066  }
1067 
1068  return *this;
1069 }
1070 //*************************************************************************************************
1071 
1072 
1073 //*************************************************************************************************
1083 template< typename Type // Data type of the vector
1084  , bool TF > // Transpose flag
1085 template< typename VT > // Type of the right-hand side vector
1087 {
1088  using blaze::addAssign;
1089 
1090  if( (~rhs).size() != size_ ) {
1091  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1092  }
1093 
1094  if( !IsZero_v<VT> ) {
1095  addAssign( *this, ~rhs );
1096  }
1097 
1098  return *this;
1099 }
1100 //*************************************************************************************************
1101 
1102 
1103 //*************************************************************************************************
1113 template< typename Type // Data type of the vector
1114  , bool TF > // Transpose flag
1115 template< typename VT > // Type of the right-hand side vector
1117 {
1118  using blaze::subAssign;
1119 
1120  if( (~rhs).size() != size_ ) {
1121  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1122  }
1123 
1124  if( !IsZero_v<VT> ) {
1125  subAssign( *this, ~rhs );
1126  }
1127 
1128  return *this;
1129 }
1130 //*************************************************************************************************
1131 
1132 
1133 //*************************************************************************************************
1144 template< typename Type // Data type of the vector
1145  , bool TF > // Transpose flag
1146 template< typename VT > // Type of the right-hand side vector
1149 {
1150  using blaze::multAssign;
1151 
1152  if( (~rhs).size() != size_ ) {
1153  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1154  }
1155 
1156  if( (~rhs).canAlias( this ) ) {
1157  CompressedVector tmp( *this * (~rhs) );
1158  swap( tmp );
1159  }
1160  else {
1161  CompositeType_t<VT> tmp( ~rhs );
1162  multAssign( *this, tmp );
1163  }
1164 
1165  return *this;
1166 }
1167 //*************************************************************************************************
1168 
1169 
1170 //*************************************************************************************************
1181 template< typename Type // Data type of the vector
1182  , bool TF > // Transpose flag
1183 template< typename VT > // Type of the right-hand side vector
1186 {
1187  if( (~rhs).size() != size_ ) {
1188  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1189  }
1190 
1191  if( !IsZero_v<VT> ) {
1192  CompressedVector tmp( *this * (~rhs) );
1193  swap( tmp );
1194  }
1195  else {
1196  reset();
1197  }
1198 
1199  return *this;
1200 }
1201 //*************************************************************************************************
1202 
1203 
1204 //*************************************************************************************************
1214 template< typename Type // Data type of the vector
1215  , bool TF > // Transpose flag
1216 template< typename VT > // Type of the right-hand side vector
1218 {
1219  using blaze::divAssign;
1220 
1221  if( (~rhs).size() != size_ ) {
1222  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1223  }
1224 
1225  if( (~rhs).canAlias( this ) ) {
1226  CompressedVector tmp( *this / (~rhs) );
1227  swap( tmp );
1228  }
1229  else {
1230  CompositeType_t<VT> tmp( ~rhs );
1231  divAssign( *this, tmp );
1232  }
1233 
1234  return *this;
1235 }
1236 //*************************************************************************************************
1237 
1238 
1239 //*************************************************************************************************
1250 template< typename Type // Data type of the vector
1251  , bool TF > // Transpose flag
1252 template< typename VT > // Type of the right-hand side vector
1254 {
1255  using blaze::assign;
1256 
1259 
1260  using CrossType = CrossTrait_t< This, ResultType_t<VT> >;
1261 
1265 
1266  if( size_ != 3UL || (~rhs).size() != 3UL ) {
1267  BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1268  }
1269 
1270  if( !IsZero_v<VT> ) {
1271  const CrossType tmp( *this % (~rhs) );
1272  reset();
1273  assign( *this, tmp );
1274  }
1275  else {
1276  reset();
1277  }
1278 
1279  return *this;
1280 }
1281 //*************************************************************************************************
1282 
1283 
1284 
1285 
1286 //=================================================================================================
1287 //
1288 // UTILITY FUNCTIONS
1289 //
1290 //=================================================================================================
1291 
1292 //*************************************************************************************************
1297 template< typename Type // Data type of the vector
1298  , bool TF > // Transpose flag
1299 inline size_t CompressedVector<Type,TF>::size() const noexcept
1300 {
1301  return size_;
1302 }
1303 //*************************************************************************************************
1304 
1305 
1306 //*************************************************************************************************
1311 template< typename Type // Data type of the vector
1312  , bool TF > // Transpose flag
1313 inline size_t CompressedVector<Type,TF>::capacity() const noexcept
1314 {
1315  return capacity_;
1316 }
1317 //*************************************************************************************************
1318 
1319 
1320 //*************************************************************************************************
1328 template< typename Type // Data type of the vector
1329  , bool TF > // Transpose flag
1331 {
1332  return end_ - begin_;
1333 }
1334 //*************************************************************************************************
1335 
1336 
1337 //*************************************************************************************************
1342 template< typename Type // Data type of the vector
1343  , bool TF > // Transpose flag
1345 {
1346  end_ = begin_;
1347 }
1348 //*************************************************************************************************
1349 
1350 
1351 //*************************************************************************************************
1358 template< typename Type // Data type of the vector
1359  , bool TF > // Transpose flag
1361 {
1362  size_ = 0UL;
1363  end_ = begin_;
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  using std::swap;
1412 
1413  if( n > capacity_ ) {
1414  const size_t newCapacity( n );
1415 
1416  // Allocating a new data and index array
1417  Iterator newBegin = allocate<Element>( newCapacity );
1418 
1419  // Replacing the old data and index array
1420  end_ = castDown( transfer( begin_, end_, castUp( newBegin ) ) );
1421  swap( newBegin, begin_ );
1422  capacity_ = newCapacity;
1423  deallocate( newBegin );
1424  }
1425 }
1426 //*************************************************************************************************
1427 
1428 
1429 //*************************************************************************************************
1438 template< typename Type // Data type of the vector
1439  , bool TF > // Transpose flag
1441 {
1442  if( nonZeros() < capacity_ ) {
1443  CompressedVector( *this ).swap( *this );
1444  }
1445 }
1446 //*************************************************************************************************
1447 
1448 
1449 //*************************************************************************************************
1455 template< typename Type // Data type of the vector
1456  , bool TF > // Transpose flag
1458 {
1459  using std::swap;
1460 
1461  swap( size_, sv.size_ );
1462  swap( capacity_, sv.capacity_ );
1463  swap( begin_, sv.begin_ );
1464  swap( end_, sv.end_ );
1465 }
1466 //*************************************************************************************************
1467 
1468 
1469 //*************************************************************************************************
1477 template< typename Type // Data type of the vector
1478  , bool TF > // Transpose flag
1479 inline size_t CompressedVector<Type,TF>::extendCapacity() const noexcept
1480 {
1481  using blaze::max;
1482  using blaze::min;
1483 
1484  size_t nonzeros( 2UL*capacity_+1UL );
1485  nonzeros = max( nonzeros, 7UL );
1486  nonzeros = min( nonzeros, size_ );
1487 
1488  BLAZE_INTERNAL_ASSERT( nonzeros > capacity_, "Invalid capacity value" );
1489 
1490  return nonzeros;
1491 }
1492 //*************************************************************************************************
1493 
1494 
1495 //*************************************************************************************************
1503 template< typename Type // Data type of the vector
1504  , bool TF > // Transpose flag
1507 {
1508  return static_cast<Iterator>( it );
1509 }
1510 //*************************************************************************************************
1511 
1512 
1513 //*************************************************************************************************
1521 template< typename Type // Data type of the vector
1522  , bool TF > // Transpose flag
1525 {
1526  return static_cast<IteratorBase>( it );
1527 }
1528 //*************************************************************************************************
1529 
1530 
1531 
1532 
1533 //=================================================================================================
1534 //
1535 // INSERTION FUNCTIONS
1536 //
1537 //=================================================================================================
1538 
1539 //*************************************************************************************************
1550 template< typename Type // Data type of the vector
1551  , bool TF > // Transpose flag
1553  CompressedVector<Type,TF>::set( size_t index, const Type& value )
1554 {
1555  BLAZE_USER_ASSERT( index < size_, "Invalid compressed vector access index" );
1556 
1557  const Iterator pos( lowerBound( index ) );
1558 
1559  if( pos != end_ && pos->index_ == index ) {
1560  pos->value() = value;
1561  return pos;
1562  }
1563  else return insert( pos, index, value );
1564 }
1565 //*************************************************************************************************
1566 
1567 
1568 //*************************************************************************************************
1580 template< typename Type // Data type of the vector
1581  , bool TF > // Transpose flag
1583  CompressedVector<Type,TF>::insert( size_t index, const Type& value )
1584 {
1585  BLAZE_USER_ASSERT( index < size_, "Invalid compressed vector access index" );
1586 
1587  const Iterator pos( lowerBound( index ) );
1588 
1589  if( pos != end_ && pos->index_ == index ) {
1590  BLAZE_THROW_INVALID_ARGUMENT( "Bad access index" );
1591  }
1592 
1593  return insert( pos, index, value );
1594 }
1595 //*************************************************************************************************
1596 
1597 
1598 //*************************************************************************************************
1607 template< typename Type // Data type of the vector
1608  , bool TF > // Transpose flag
1610  CompressedVector<Type,TF>::insert( Iterator pos, size_t index, const Type& value )
1611 {
1612  using std::swap;
1613 
1614  if( nonZeros() != capacity_ ) {
1615  std::move_backward( pos, end_, castUp( end_+1 ) );
1616  pos->value_ = value;
1617  pos->index_ = index;
1618  ++end_;
1619 
1620  return pos;
1621  }
1622  else {
1623  size_t newCapacity( extendCapacity() );
1624 
1625  Iterator newBegin = allocate<Element>( newCapacity );
1626  Iterator tmp = castDown( std::move( begin_, pos, castUp( newBegin ) ) );
1627  tmp->value_ = value;
1628  tmp->index_ = index;
1629  end_ = castDown( std::move( pos, end_, castUp( tmp+1 ) ) );
1630 
1631  swap( newBegin, begin_ );
1632  deallocate( newBegin );
1633  capacity_ = newCapacity;
1634 
1635  return tmp;
1636  }
1637 }
1638 //*************************************************************************************************
1639 
1640 
1641 //*************************************************************************************************
1665 template< typename Type // Data type of the vector
1666  , bool TF > // Transpose flag
1667 inline void CompressedVector<Type,TF>::append( size_t index, const Type& value, bool check )
1668 {
1669  BLAZE_USER_ASSERT( index < size_, "Invalid compressed vector access index" );
1670  BLAZE_USER_ASSERT( nonZeros() < capacity(), "Not enough reserved capacity" );
1671  BLAZE_USER_ASSERT( begin_ == end_ || (end_-1UL)->index_ < index, "Index is not strictly increasing" );
1672 
1673  end_->value_ = value;
1674 
1675  if( !check || !isDefault<strict>( end_->value_ ) ) {
1676  end_->index_ = index;
1677  ++end_;
1678  }
1679 }
1680 //*************************************************************************************************
1681 
1682 
1683 
1684 
1685 //=================================================================================================
1686 //
1687 // ERASE FUNCTIONS
1688 //
1689 //=================================================================================================
1690 
1691 //*************************************************************************************************
1699 template< typename Type // Data type of the vector
1700  , bool TF > // Transpose flag
1701 inline void CompressedVector<Type,TF>::erase( size_t index )
1702 {
1703  BLAZE_USER_ASSERT( index < size_, "Invalid compressed vector access index" );
1704 
1705  const Iterator pos( find( index ) );
1706  if( pos != end_ )
1707  end_ = castDown( std::move( pos+1, end_, castUp( pos ) ) );
1708 }
1709 //*************************************************************************************************
1710 
1711 
1712 //*************************************************************************************************
1720 template< typename Type // Data type of the vector
1721  , bool TF > // Transpose flag
1724 {
1725  BLAZE_USER_ASSERT( pos >= begin_ && pos <= end_, "Invalid compressed vector iterator" );
1726 
1727  if( pos != end_ )
1728  end_ = castDown( std::move( pos+1, end_, castUp( pos ) ) );
1729  return pos;
1730 }
1731 //*************************************************************************************************
1732 
1733 
1734 //*************************************************************************************************
1743 template< typename Type // Data type of the vector
1744  , bool TF > // Transpose flag
1747 {
1748  BLAZE_USER_ASSERT( first <= last, "Invalid iterator range" );
1749  BLAZE_USER_ASSERT( first >= begin_ && first <= end_, "Invalid compressed vector iterator" );
1750  BLAZE_USER_ASSERT( last >= begin_ && last <= end_, "Invalid compressed vector iterator" );
1751 
1752  if( first != last )
1753  end_ = castDown( std::move( last, end_, castUp( first ) ) );
1754  return first;
1755 }
1756 //*************************************************************************************************
1757 
1758 
1759 //*************************************************************************************************
1780 template< typename Type // Data type of the vector
1781  , bool TF > // Transpose flag
1782 template< typename Pred // Type of the unary predicate
1783  , typename > // Type restriction on the unary predicate
1784 inline void CompressedVector<Type,TF>::erase( Pred predicate )
1785 {
1786  end_ = castDown( std::remove_if( castUp( begin_ ), castUp( end_ ),
1787  [predicate=predicate]( const ElementBase& element ) {
1788  return predicate( element.value() );
1789  } ) );
1790 }
1791 //*************************************************************************************************
1792 
1793 
1794 //*************************************************************************************************
1817 template< typename Type // Data type of the vector
1818  , bool TF > // Transpose flag
1819 template< typename Pred > // Type of the unary predicate
1820 inline void CompressedVector<Type,TF>::erase( Iterator first, Iterator last, Pred predicate )
1821 {
1822  BLAZE_USER_ASSERT( first <= last, "Invalid iterator range" );
1823  BLAZE_USER_ASSERT( first >= begin_ && first <= end_, "Invalid compressed vector iterator" );
1824  BLAZE_USER_ASSERT( last >= begin_ && last <= end_, "Invalid compressed vector iterator" );
1825 
1826  const auto pos = std::remove_if( castUp( first ), castUp( last ),
1827  [predicate=predicate]( const ElementBase& element ) {
1828  return predicate( element.value() );
1829  } );
1830 
1831  end_ = castDown( std::move( last, end_, pos ) );
1832 }
1833 //*************************************************************************************************
1834 
1835 
1836 
1837 
1838 //=================================================================================================
1839 //
1840 // LOOKUP FUNCTIONS
1841 //
1842 //=================================================================================================
1843 
1844 //*************************************************************************************************
1857 template< typename Type // Data type of the vector
1858  , bool TF > // Transpose flag
1860 {
1861  return const_cast<Iterator>( const_cast<const This&>( *this ).find( index ) );
1862 }
1863 //*************************************************************************************************
1864 
1865 
1866 //*************************************************************************************************
1879 template< typename Type // Data type of the vector
1880  , bool TF > // Transpose flag
1882 {
1883  const ConstIterator pos( lowerBound( index ) );
1884  if( pos != end_ && pos->index_ == index )
1885  return pos;
1886  else return end_;
1887 }
1888 //*************************************************************************************************
1889 
1890 
1891 //*************************************************************************************************
1903 template< typename Type // Data type of the vector
1904  , bool TF > // Transpose flag
1907 {
1908  return const_cast<Iterator>( const_cast<const This&>( *this ).lowerBound( index ) );
1909 }
1910 //*************************************************************************************************
1911 
1912 
1913 //*************************************************************************************************
1925 template< typename Type // Data type of the vector
1926  , bool TF > // Transpose flag
1929 {
1930  return std::lower_bound( begin_, end_, index,
1931  []( const Element& element, size_t i )
1932  {
1933  return element.index() < i;
1934  } );
1935 }
1936 //*************************************************************************************************
1937 
1938 
1939 //*************************************************************************************************
1951 template< typename Type // Data type of the vector
1952  , bool TF > // Transpose flag
1955 {
1956  return const_cast<Iterator>( const_cast<const This&>( *this ).upperBound( index ) );
1957 }
1958 //*************************************************************************************************
1959 
1960 
1961 //*************************************************************************************************
1973 template< typename Type // Data type of the vector
1974  , bool TF > // Transpose flag
1977 {
1978  return std::upper_bound( begin_, end_, index,
1979  []( size_t i, const Element& element )
1980  {
1981  return i < element.index();
1982  } );
1983 }
1984 //*************************************************************************************************
1985 
1986 
1987 
1988 
1989 //=================================================================================================
1990 //
1991 // NUMERIC FUNCTIONS
1992 //
1993 //=================================================================================================
1994 
1995 //*************************************************************************************************
2012 template< typename Type // Data type of the vector
2013  , bool TF > // Transpose flag
2014 template< typename Other > // Data type of the scalar value
2016 {
2017  for( auto element=begin_; element!=end_; ++element )
2018  element->value_ *= scalar;
2019  return *this;
2020 }
2021 //*************************************************************************************************
2022 
2023 
2024 
2025 
2026 //=================================================================================================
2027 //
2028 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2029 //
2030 //=================================================================================================
2031 
2032 //*************************************************************************************************
2042 template< typename Type // Data type of the vector
2043  , bool TF > // Transpose flag
2044 template< typename Other > // Data type of the foreign expression
2045 inline bool CompressedVector<Type,TF>::canAlias( const Other* alias ) const noexcept
2046 {
2047  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2048 }
2049 //*************************************************************************************************
2050 
2051 
2052 //*************************************************************************************************
2062 template< typename Type // Data type of the vector
2063  , bool TF > // Transpose flag
2064 template< typename Other > // Data type of the foreign expression
2065 inline bool CompressedVector<Type,TF>::isAliased( const Other* alias ) const noexcept
2066 {
2067  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2068 }
2069 //*************************************************************************************************
2070 
2071 
2072 //*************************************************************************************************
2082 template< typename Type // Data type of the vector
2083  , bool TF > // Transpose flag
2084 inline bool CompressedVector<Type,TF>::canSMPAssign() const noexcept
2085 {
2086  return false;
2087 }
2088 //*************************************************************************************************
2089 
2090 
2091 //*************************************************************************************************
2102 template< typename Type // Data type of the vector
2103  , bool TF > // Transpose flag
2104 template< typename VT > // Type of the right-hand side dense vector
2106 {
2107  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2108  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
2109 
2110  size_t nonzeros( 0UL );
2111 
2112  for( size_t i=0UL; i<size_; ++i )
2113  {
2114  if( nonzeros == capacity_ )
2115  reserve( extendCapacity() );
2116 
2117  end_->value_ = (~rhs)[i];
2118 
2119  if( !isDefault<strict>( end_->value_ ) ) {
2120  end_->index_ = i;
2121  ++end_;
2122  ++nonzeros;
2123  }
2124  }
2125 }
2126 //*************************************************************************************************
2127 
2128 
2129 //*************************************************************************************************
2140 template< typename Type // Data type of the vector
2141  , bool TF > // Transpose flag
2142 template< typename VT > // Type of the right-hand side sparse vector
2144 {
2145  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2146  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
2147 
2148  // Using the following formulation instead of a std::copy function call of the form
2149  //
2150  // end_ = std::copy( (~rhs).begin(), (~rhs).end(), begin_ );
2151  //
2152  // results in much less requirements on the ConstIterator type provided from the right-hand
2153  // sparse vector type
2154  for( auto element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2155  append( element->index(), element->value() );
2156 }
2157 //*************************************************************************************************
2158 
2159 
2160 //*************************************************************************************************
2171 template< typename Type // Data type of the vector
2172  , bool TF > // Transpose flag
2173 template< typename VT > // Type of the right-hand side dense vector
2175 {
2176  using AddType = AddTrait_t< This, ResultType_t<VT> >;
2177 
2181 
2182  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2183 
2184  const AddType tmp( serial( *this + (~rhs) ) );
2185  reset();
2186  assign( tmp );
2187 }
2188 //*************************************************************************************************
2189 
2190 
2191 //*************************************************************************************************
2202 template< typename Type // Data type of the vector
2203  , bool TF > // Transpose flag
2204 template< typename VT > // Type of the right-hand side sparse vector
2206 {
2207  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2208 
2209  CompressedVector tmp( serial( *this + (~rhs) ) );
2210  swap( tmp );
2211 }
2212 //*************************************************************************************************
2213 
2214 
2215 //*************************************************************************************************
2226 template< typename Type // Data type of the vector
2227  , bool TF > // Transpose flag
2228 template< typename VT > // Type of the right-hand side dense vector
2230 {
2231  using SubType = SubTrait_t< This, ResultType_t<VT> >;
2232 
2236 
2237  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2238 
2239  const SubType tmp( serial( *this - (~rhs) ) );
2240  reset();
2241  assign( tmp );
2242 }
2243 //*************************************************************************************************
2244 
2245 
2246 //*************************************************************************************************
2257 template< typename Type // Data type of the vector
2258  , bool TF > // Transpose flag
2259 template< typename VT > // Type of the right-hand side sparse vector
2261 {
2262  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2263 
2264  CompressedVector tmp( serial( *this - (~rhs) ) );
2265  swap( tmp );
2266 }
2267 //*************************************************************************************************
2268 
2269 
2270 //*************************************************************************************************
2281 template< typename Type // Data type of the vector
2282  , bool TF > // Transpose flag
2283 template< typename VT > // Type of the right-hand side dense vector
2285 {
2286  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2287 
2289 
2290  for( auto element=begin_; element!=end_; ++element ) {
2291  element->value_ *= (~rhs)[element->index_];
2292  }
2293 }
2294 //*************************************************************************************************
2295 
2296 
2297 //*************************************************************************************************
2308 template< typename Type // Data type of the vector
2309  , bool TF > // Transpose flag
2310 template< typename VT > // Type of the right-hand side dense vector
2312 {
2313  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2314 
2316 
2317  for( auto element=begin_; element!=end_; ++element ) {
2318  element->value_ /= (~rhs)[element->index_];
2319  }
2320 }
2321 //*************************************************************************************************
2322 
2323 
2324 
2325 
2326 //=================================================================================================
2327 //
2328 // COMPRESSEDVECTOR OPERATORS
2329 //
2330 //=================================================================================================
2331 
2332 //*************************************************************************************************
2335 template< typename Type, bool TF >
2336 void reset( CompressedVector<Type,TF>& v );
2337 
2338 template< typename Type, bool TF >
2339 void clear( CompressedVector<Type,TF>& v );
2340 
2341 template< bool RF, typename Type, bool TF >
2342 bool isDefault( const CompressedVector<Type,TF>& v );
2343 
2344 template< typename Type, bool TF >
2345 bool isIntact( const CompressedVector<Type,TF>& v ) noexcept;
2346 
2347 template< typename Type, bool TF >
2350 //*************************************************************************************************
2351 
2352 
2353 //*************************************************************************************************
2360 template< typename Type // Data type of the vector
2361  , bool TF > // Transpose flag
2363 {
2364  v.reset();
2365 }
2366 //*************************************************************************************************
2367 
2368 
2369 //*************************************************************************************************
2376 template< typename Type // Data type of the vector
2377  , bool TF > // Transpose flag
2379 {
2380  v.clear();
2381 }
2382 //*************************************************************************************************
2383 
2384 
2385 //*************************************************************************************************
2409 template< bool RF // Relaxation flag
2410  , typename Type // Data type of the vector
2411  , bool TF > // Transpose flag
2412 inline bool isDefault( const CompressedVector<Type,TF>& v )
2413 {
2414  return ( v.size() == 0UL );
2415 }
2416 //*************************************************************************************************
2417 
2418 
2419 //*************************************************************************************************
2437 template< typename Type // Data type of the vector
2438  , bool TF > // Transpose flag
2439 inline bool isIntact( const CompressedVector<Type,TF>& v ) noexcept
2440 {
2441  return ( v.nonZeros() <= v.capacity() );
2442 }
2443 //*************************************************************************************************
2444 
2445 
2446 //*************************************************************************************************
2454 template< typename Type // Data type of the vector
2455  , bool TF > // Transpose flag
2457 {
2458  a.swap( b );
2459 }
2460 //*************************************************************************************************
2461 
2462 
2463 
2464 
2465 //=================================================================================================
2466 //
2467 // ISRESIZABLE SPECIALIZATIONS
2468 //
2469 //=================================================================================================
2470 
2471 //*************************************************************************************************
2473 template< typename T, bool TF >
2474 struct IsResizable< CompressedVector<T,TF> >
2475  : public TrueType
2476 {};
2478 //*************************************************************************************************
2479 
2480 
2481 
2482 
2483 //=================================================================================================
2484 //
2485 // ISSHRINKABLE SPECIALIZATIONS
2486 //
2487 //=================================================================================================
2488 
2489 //*************************************************************************************************
2491 template< typename T, bool TF >
2492 struct IsShrinkable< CompressedVector<T,TF> >
2493  : public TrueType
2494 {};
2496 //*************************************************************************************************
2497 
2498 
2499 
2500 
2501 //=================================================================================================
2502 //
2503 // ADDTRAIT SPECIALIZATIONS
2504 //
2505 //=================================================================================================
2506 
2507 //*************************************************************************************************
2509 template< typename T1, typename T2 >
2510 struct AddTraitEval2< T1, T2
2511  , EnableIf_t< IsSparseVector_v<T1> && IsSparseVector_v<T2> > >
2512 {
2513  using ET1 = ElementType_t<T1>;
2514  using ET2 = ElementType_t<T2>;
2515 
2516  using Type = CompressedVector< AddTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
2517 };
2519 //*************************************************************************************************
2520 
2521 
2522 
2523 
2524 //=================================================================================================
2525 //
2526 // SUBTRAIT SPECIALIZATIONS
2527 //
2528 //=================================================================================================
2529 
2530 //*************************************************************************************************
2532 template< typename T1, typename T2 >
2533 struct SubTraitEval2< T1, T2
2534  , EnableIf_t< IsSparseVector_v<T1> && IsSparseVector_v<T2> > >
2535 {
2536  using ET1 = ElementType_t<T1>;
2537  using ET2 = ElementType_t<T2>;
2538 
2539  using Type = CompressedVector< SubTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
2540 };
2542 //*************************************************************************************************
2543 
2544 
2545 
2546 
2547 //=================================================================================================
2548 //
2549 // MULTTRAIT SPECIALIZATIONS
2550 //
2551 //=================================================================================================
2552 
2553 //*************************************************************************************************
2555 template< typename T1, typename T2 >
2556 struct MultTraitEval2< T1, T2
2557  , EnableIf_t< IsSparseVector_v<T1> && IsNumeric_v<T2> > >
2558 {
2559  using ET1 = ElementType_t<T1>;
2560 
2561  using Type = CompressedVector< MultTrait_t<ET1,T2>, TransposeFlag_v<T1> >;
2562 };
2563 
2564 template< typename T1, typename T2 >
2565 struct MultTraitEval2< T1, T2
2566  , EnableIf_t< IsNumeric_v<T1> && IsSparseVector_v<T2> > >
2567 {
2568  using ET2 = ElementType_t<T2>;
2569 
2570  using Type = CompressedVector< MultTrait_t<T1,ET2>, TransposeFlag_v<T2> >;
2571 };
2572 
2573 template< typename T1, typename T2 >
2574 struct MultTraitEval2< T1, T2
2575  , EnableIf_t< ( ( IsRowVector_v<T1> && IsRowVector_v<T2> ) ||
2576  ( IsColumnVector_v<T1> && IsColumnVector_v<T2> ) ) &&
2577  ( IsSparseVector_v<T1> || IsSparseVector_v<T2> ) > >
2578 {
2579  using ET1 = ElementType_t<T1>;
2580  using ET2 = ElementType_t<T2>;
2581 
2582  using Type = CompressedVector< MultTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
2583 };
2584 
2585 template< typename T1, typename T2 >
2586 struct MultTraitEval2< T1, T2
2587  , EnableIf_t< IsSparseMatrix_v<T1> &&
2588  IsSparseVector_v<T2> &&
2589  IsColumnVector_v<T2> > >
2590 {
2591  using ET1 = ElementType_t<T1>;
2592  using ET2 = ElementType_t<T2>;
2593 
2594  using Type = CompressedVector< MultTrait_t<ET1,ET2>, false >;
2595 };
2596 
2597 template< typename T1, typename T2 >
2598 struct MultTraitEval2< T1, T2
2599  , EnableIf_t< IsSparseVector_v<T1> &&
2600  IsRowVector_v<T1> &&
2601  IsSparseMatrix_v<T2> > >
2602 {
2603  using ET1 = ElementType_t<T1>;
2604  using ET2 = ElementType_t<T2>;
2605 
2606  using Type = CompressedVector< MultTrait_t<ET1,ET2>, true >;
2607 };
2609 //*************************************************************************************************
2610 
2611 
2612 
2613 
2614 //=================================================================================================
2615 //
2616 // DIVTRAIT SPECIALIZATIONS
2617 //
2618 //=================================================================================================
2619 
2620 //*************************************************************************************************
2622 template< typename T1, typename T2 >
2623 struct DivTraitEval2< T1, T2
2624  , EnableIf_t< IsSparseVector_v<T1> && IsNumeric_v<T2> > >
2625 {
2626  using ET1 = ElementType_t<T1>;
2627 
2628  using Type = CompressedVector< DivTrait_t<ET1,T2>, TransposeFlag_v<T1> >;
2629 };
2630 
2631 template< typename T1, typename T2 >
2632 struct DivTraitEval2< T1, T2
2633  , EnableIf_t< IsSparseVector_v<T1> && IsDenseVector_v<T2> > >
2634 {
2635  using ET1 = ElementType_t<T1>;
2636  using ET2 = ElementType_t<T2>;
2637 
2638  using Type = CompressedVector< DivTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
2639 };
2641 //*************************************************************************************************
2642 
2643 
2644 
2645 
2646 //=================================================================================================
2647 //
2648 // KRONTRAIT SPECIALIZATIONS
2649 //
2650 //=================================================================================================
2651 
2652 //*************************************************************************************************
2654 template< typename T1 // Type of the left-hand side operand
2655  , typename T2 > // Type of the right-hand side operand
2656 struct KronTraitEval2< T1, T2
2657  , EnableIf_t< IsVector_v<T1> &&
2658  IsVector_v<T2> &&
2659  ( IsSparseVector_v<T1> || IsSparseVector_v<T2> ) > >
2660 {
2661  using ET1 = ElementType_t<T1>;
2662  using ET2 = ElementType_t<T2>;
2663 
2664  static constexpr bool TF = ( IsDenseVector_v<T2> ? TransposeFlag_v<T1> : TransposeFlag_v<T2> );
2665 
2666  using Type = CompressedVector< MultTrait_t<ET1,ET2>, TF >;
2667 };
2669 //*************************************************************************************************
2670 
2671 
2672 
2673 
2674 //=================================================================================================
2675 //
2676 // MAPTRAIT SPECIALIZATIONS
2677 //
2678 //=================================================================================================
2679 
2680 //*************************************************************************************************
2682 template< typename T, typename OP >
2683 struct UnaryMapTraitEval2< T, OP
2684  , EnableIf_t< IsSparseVector_v<T> > >
2685 {
2686  using ET = ElementType_t<T>;
2687 
2688  using Type = CompressedVector< MapTrait_t<ET,OP>, TransposeFlag_v<T> >;
2689 };
2691 //*************************************************************************************************
2692 
2693 
2694 
2695 
2696 //=================================================================================================
2697 //
2698 // HIGHTYPE SPECIALIZATIONS
2699 //
2700 //=================================================================================================
2701 
2702 //*************************************************************************************************
2704 template< typename T1, bool TF, typename T2 >
2705 struct HighType< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2706 {
2707  using Type = CompressedVector< typename HighType<T1,T2>::Type, TF >;
2708 };
2710 //*************************************************************************************************
2711 
2712 
2713 
2714 
2715 //=================================================================================================
2716 //
2717 // MATHTRAIT SPECIALIZATIONS
2718 //
2719 //=================================================================================================
2720 
2721 //*************************************************************************************************
2723 template< typename T1, bool TF, typename T2 >
2724 struct LowType< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2725 {
2726  using Type = CompressedVector< typename LowType<T1,T2>::Type, TF >;
2727 };
2729 //*************************************************************************************************
2730 
2731 
2732 
2733 
2734 //=================================================================================================
2735 //
2736 // SUBVECTORTRAIT SPECIALIZATIONS
2737 //
2738 //=================================================================================================
2739 
2740 //*************************************************************************************************
2742 template< typename VT, size_t I, size_t N >
2743 struct SubvectorTraitEval2< VT, I, N
2744  , EnableIf_t< IsSparseVector_v<VT> > >
2745 {
2746  using Type = CompressedVector< RemoveConst_t< ElementType_t<VT> >, TransposeFlag_v<VT> >;
2747 };
2749 //*************************************************************************************************
2750 
2751 
2752 
2753 
2754 //=================================================================================================
2755 //
2756 // ELEMENTSTRAIT SPECIALIZATIONS
2757 //
2758 //=================================================================================================
2759 
2760 //*************************************************************************************************
2762 template< typename VT, size_t N >
2763 struct ElementsTraitEval2< VT, N
2764  , EnableIf_t< IsSparseVector_v<VT> > >
2765 {
2766  using Type = CompressedVector< RemoveConst_t< ElementType_t<VT> >, TransposeFlag_v<VT> >;
2767 };
2769 //*************************************************************************************************
2770 
2771 
2772 
2773 
2774 //=================================================================================================
2775 //
2776 // ROWTRAIT SPECIALIZATIONS
2777 //
2778 //=================================================================================================
2779 
2780 //*************************************************************************************************
2782 template< typename MT, size_t I >
2783 struct RowTraitEval2< MT, I
2784  , EnableIf_t< IsSparseMatrix_v<MT> > >
2785 {
2786  using Type = CompressedVector< RemoveConst_t< ElementType_t<MT> >, true >;
2787 };
2789 //*************************************************************************************************
2790 
2791 
2792 
2793 
2794 //=================================================================================================
2795 //
2796 // COLUMNTRAIT SPECIALIZATIONS
2797 //
2798 //=================================================================================================
2799 
2800 //*************************************************************************************************
2802 template< typename MT, size_t I >
2803 struct ColumnTraitEval2< MT, I
2804  , EnableIf_t< IsSparseMatrix_v<MT> > >
2805 {
2806  using Type = CompressedVector< RemoveConst_t< ElementType_t<MT> >, false >;
2807 };
2809 //*************************************************************************************************
2810 
2811 
2812 
2813 
2814 //=================================================================================================
2815 //
2816 // BANDTRAIT SPECIALIZATIONS
2817 //
2818 //=================================================================================================
2819 
2820 //*************************************************************************************************
2822 template< typename MT, ptrdiff_t I >
2823 struct BandTraitEval2< MT, I
2824  , EnableIf_t< IsSparseMatrix_v<MT> > >
2825 {
2826  using Type = CompressedVector< RemoveConst_t< ElementType_t<MT> >, defaultTransposeFlag >;
2827 };
2829 //*************************************************************************************************
2830 
2831 } // namespace blaze
2832 
2833 #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,...
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.
Headerfile for the generic min algorithm.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
typename SubTrait< T1, T2 >::Type SubTrait_t
Auxiliary alias declaration for the SubTrait class template.The SubTrait_t alias declaration provides...
Definition: SubTrait.h:238
Header file for the subtraction trait.
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
Header file for the SparseVector base class.
Header file for the row trait.
void assign(const DenseVector< VT, TF > &rhs)
Default implementation of the assignment of a dense vector.
Definition: CompressedVector.h:2105
Iterator upperBound(size_t index)
Returns an iterator to the first index greater then the given index.
Definition: CompressedVector.h:1954
constexpr bool IsRowVector_v
Auxiliary variable template for the IsRowVector type trait.The IsRowVector_v variable template provid...
Definition: IsRowVector.h:142
void swap(CompressedVector< Type, TF > &a, CompressedVector< Type, TF > &b) noexcept
Swapping the contents of two compressed vectors.
Definition: CompressedVector.h:2456
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
Resize mechanism to obtain a CompressedVector with a different fixed number of elements.
Definition: CompressedVector.h:318
Header file for the IsSparseMatrix type trait.
Header file for the serial shim.
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
Access proxy for sparse, N-dimensional vectors.The VectorAccessProxy provides safe access to the elem...
Definition: VectorAccessProxy.h:101
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
Header file for the IsRowVector type trait.
Header file for the IsIntegral type trait.
IteratorBase castUp(Iterator it) const noexcept
Performs an up-cast of the given iterator.
Definition: CompressedVector.h:1524
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:2174
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
Definition: Volatile.h:79
void clear()
Clearing the compressed vector.
Definition: CompressedVector.h:1360
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: IntegralConstant.h:132
Header file for all forward declarations of the math module.
Header file for memory allocation and deallocation functionality.
Header file for the extended initializer_list functionality.
size_t size_
The current size/dimension of the compressed vector.
Definition: CompressedVector.h:485
Header file for the elements trait.
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the compressed vector elements.
Definition: CompressedVector.h:724
Header file for the band trait.
Constraint on the data type.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
Type ElementType
Type of the compressed vector elements.
Definition: CompressedVector.h:296
Headerfile for the generic max algorithm.
Header file for the ValueIndexPair class.
Rebind mechanism to obtain a CompressedVector with different data/element type.
Definition: CompressedVector.h:309
CompressedVector() noexcept
The default constructor for CompressedVector.
Definition: CompressedVector.h:533
Header file for the DisableIf class template.
Iterator set(size_t index, const Type &value)
Setting an element of the compressed vector.
Definition: CompressedVector.h:1553
Header file for the LowType type trait.
void subAssign(const DenseVector< VT, TF > &rhs)
Default implementation of the subtraction assignment of a dense vector.
Definition: CompressedVector.h:2229
void append(size_t index, const Type &value, bool check=false)
Appending an element to the compressed vector.
Definition: CompressedVector.h:1667
Header file for the multiplication trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the IsFloatingPoint type trait.
Header file for the IsShrinkable type trait.
Iterator insert(size_t index, const Type &value)
Inserting an element into the compressed vector.
Definition: CompressedVector.h:1583
#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.
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1162
Iterator begin_
Pointer to the first non-zero element of the compressed vector.
Definition: CompressedVector.h:487
#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
size_t size() const noexcept
Returns the current size/dimension of the compressed vector.
Definition: CompressedVector.h:1299
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedVector.h:297
#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
void shrinkToFit()
Requesting the removal of unused capacity.
Definition: CompressedVector.h:1440
Header file for the subvector trait.
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
size_t nonZeros() const
Returns the number of non-zero elements in the compressed vector.
Definition: CompressedVector.h:1330
Iterator castDown(IteratorBase it) const noexcept
Performs a down-cast of the given iterator.
Definition: CompressedVector.h:1506
Constraint on the data type.
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
typename AddTrait< T1, T2 >::Type AddTrait_t
Auxiliary alias declaration for the AddTrait class template.The AddTrait_t alias declaration provides...
Definition: AddTrait.h:238
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,...
Definition: Reference.h:60
Header file for the Kron product trait.
Header file for the TransposeFlag type trait.
Constraint on the data type.
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1198
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
Constraint on the data type.
Header file for the IsVector type trait.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
size_t capacity_
The maximum capacity of the compressed vector.
Definition: CompressedVector.h:486
void erase(size_t index)
Erasing an element from the compressed vector.
Definition: CompressedVector.h:1701
typename CrossTrait< T1, T2 >::Type CrossTrait_t
Auxiliary alias declaration for the CrossTrait class template.The CrossTrait_t alias declaration prov...
Definition: CrossTrait.h:164
Iterator lowerBound(size_t index)
Returns an iterator to the first index not less then the given index.
Definition: CompressedVector.h:1906
Iterator find(size_t index)
Searches for a specific vector element.
Definition: CompressedVector.h:1859
Header file for the IsNumeric type trait.
void reset()
Reset to the default initial values.
Definition: CompressedVector.h:1344
Header file for the RemoveConst type trait.
void resize(size_t n, bool preserve=true)
Changing the size of the compressed vector.
Definition: CompressedVector.h:1384
Header file for the IsSparseVector type trait.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedVector.h:302
Header file for run time assertion macros.
Header file for the relaxation flag types.
CompressedVector & operator=(initializer_list< Type > list)
List assignment to all vector elements.
Definition: CompressedVector.h:919
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
Constraint on the data type.
size_t extendCapacity() const noexcept
Calculating a new vector capacity.
Definition: CompressedVector.h:1479
Reference at(size_t index)
Checked access to the compressed vector elements.
Definition: CompressedVector.h:771
Headerfile for the generic transfer algorithm.
Header file for the IsZero type trait.
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.The IsVector_v variable template provides a c...
Definition: IsVector.h:139
#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,...
Definition: Reference.h:79
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedVector.h:328
Header file for the column trait.
Header file for the VectorAccessProxy class.
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:282
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
constexpr Reference value() noexcept
Access to the current value of the value-index-pair.
Definition: ValueIndexPair.h:370
Constraint on the data type.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedVector.h:301
#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:2284
void divAssign(const DenseVector< VT, TF > &rhs)
Default implementation of the division assignment of a dense vector.
Definition: CompressedVector.h:2311
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: CompressedVector.h:2065
Header file for the IsDenseVector type trait.
const Type & ConstReference
Reference to a constant vector value.
Definition: CompressedVector.h:300
void swap(CompressedVector &sv) noexcept
Swapping the contents of two compressed vectors.
Definition: CompressedVector.h:1457
ConstIterator cbegin() const noexcept
Returns an iterator to the first non-zero element of the compressed vector.
Definition: CompressedVector.h:841
#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:855
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
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:198
EnableIf_t< IsBuiltin_v< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:224
Header file for the default transpose flag for all vectors of the Blaze library.
Initializer list type of the Blaze library.
~CompressedVector()
The destructor for CompressedVector.
Definition: CompressedVector.h:695
size_t capacity() const noexcept
Returns the maximum capacity of the compressed vector.
Definition: CompressedVector.h:1313
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:146
Iterator end_
Pointer one past the last non-zero element of the compressed vector.
Definition: CompressedVector.h:488
CompressedVector< Type, TF > This
Type of this CompressedVector instance.
Definition: CompressedVector.h:292
Header file for the IntegralConstant class template.
Header file for the map trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
ConstIterator cend() const noexcept
Returns an iterator just past the last non-zero element of the compressed vector.
Definition: CompressedVector.h:885
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
constexpr bool IsIntegral_v
Auxiliary variable template for the IsIntegral type trait.The IsIntegral_v variable template provides...
Definition: IsIntegral.h:95
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
constexpr bool IsSparseVector_v
Auxiliary variable template for the IsSparseVector type trait.The IsSparseVector_v variable template ...
Definition: IsSparseVector.h:138
Header file for the IsColumnVector type trait.
OutputIterator transfer(InputIterator first, InputIterator last, OutputIterator dest)
Transfers the elements from the given source range to the destination range.
Definition: Transfer.h:70
Iterator begin() noexcept
Returns an iterator to the first non-zero element of the compressed vector.
Definition: CompressedVector.h:811
static const Type zero_
Neutral element for accesses to zero elements.
Definition: CompressedVector.h:490
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: CompressedVector.h:2045
Header file for the IsResizable type trait.
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: CompressedVector.h:2084
EnableIf_t< IsBuiltin_v< T >, T * > allocate(size_t size)
Aligned array allocation for built-in data types.
Definition: Memory.h:156
#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.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101
Efficient implementation of an arbitrary sized sparse vector.The CompressedVector class is the repres...
Definition: CompressedVector.h:210
void reserve(size_t n)
Setting the minimum capacity of the compressed vector.
Definition: CompressedVector.h:1409
constexpr bool IsSparseMatrix_v
Auxiliary variable template for the IsSparseMatrix type trait.The IsSparseMatrix_v variable template ...
Definition: IsSparseMatrix.h:138
Header file for the HighType type trait.