DynamicVector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_DENSE_DYNAMICVECTOR_H_
36 #define _BLAZE_MATH_DENSE_DYNAMICVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <utility>
45 #include <blaze/math/Aliases.h>
48 #include <blaze/math/Exception.h>
51 #include <blaze/math/Forward.h>
52 #include <blaze/math/Functions.h>
54 #include <blaze/math/shims/Clear.h>
57 #include <blaze/math/SIMD.h>
78 #include <blaze/system/CacheSize.h>
79 #include <blaze/system/Inline.h>
81 #include <blaze/system/Restrict.h>
84 #include <blaze/util/Algorithm.h>
86 #include <blaze/util/Assert.h>
92 #include <blaze/util/DisableIf.h>
93 #include <blaze/util/EnableIf.h>
95 #include <blaze/util/Memory.h>
96 #include <blaze/util/Template.h>
97 #include <blaze/util/TrueType.h>
98 #include <blaze/util/Types.h>
101 
102 
103 namespace blaze {
104 
105 //=================================================================================================
106 //
107 // CLASS DEFINITION
108 //
109 //=================================================================================================
110 
111 //*************************************************************************************************
175 template< typename Type // Data type of the vector
176  , bool TF = defaultTransposeFlag > // Transpose flag
177 class DynamicVector : public DenseVector< DynamicVector<Type,TF>, TF >
178 {
179  public:
180  //**Type definitions****************************************************************************
183  typedef This ResultType;
185  typedef Type ElementType;
187  typedef const Type& ReturnType;
188  typedef const DynamicVector& CompositeType;
189 
190  typedef Type& Reference;
191  typedef const Type& ConstReference;
192  typedef Type* Pointer;
193  typedef const Type* ConstPointer;
194 
197  //**********************************************************************************************
198 
199  //**Rebind struct definition********************************************************************
202  template< typename NewType > // Data type of the other vector
203  struct Rebind {
205  };
206  //**********************************************************************************************
207 
208  //**Resize struct definition********************************************************************
211  template< size_t NewN > // Number of elements of the other vector
212  struct Resize {
214  };
215  //**********************************************************************************************
216 
217  //**Compilation flags***************************************************************************
219 
223  enum : bool { simdEnabled = IsVectorizable<Type>::value };
224 
226 
229  enum : bool { smpAssignable = !IsSMPAssignable<Type>::value };
230  //**********************************************************************************************
231 
232  //**Constructors********************************************************************************
235  explicit inline DynamicVector() noexcept;
236  explicit inline DynamicVector( size_t n );
237  explicit inline DynamicVector( size_t n, const Type& init );
238  explicit inline DynamicVector( initializer_list<Type> list );
239 
240  template< typename Other >
241  explicit inline DynamicVector( size_t n, const Other* array );
242 
243  template< typename Other, size_t N >
244  explicit inline DynamicVector( const Other (&array)[N] );
245 
246  inline DynamicVector( const DynamicVector& v );
247  inline DynamicVector( DynamicVector&& v ) noexcept;
248  template< typename VT > inline DynamicVector( const Vector<VT,TF>& v );
250  //**********************************************************************************************
251 
252  //**Destructor**********************************************************************************
255  inline ~DynamicVector();
257  //**********************************************************************************************
258 
259  //**Data access functions***********************************************************************
262  inline Reference operator[]( size_t index ) noexcept;
263  inline ConstReference operator[]( size_t index ) const noexcept;
264  inline Reference at( size_t index );
265  inline ConstReference at( size_t index ) const;
266  inline Pointer data () noexcept;
267  inline ConstPointer data () const noexcept;
268  inline Iterator begin () noexcept;
269  inline ConstIterator begin () const noexcept;
270  inline ConstIterator cbegin() const noexcept;
271  inline Iterator end () noexcept;
272  inline ConstIterator end () const noexcept;
273  inline ConstIterator cend () const noexcept;
275  //**********************************************************************************************
276 
277  //**Assignment operators************************************************************************
280  inline DynamicVector& operator=( const Type& rhs );
281  inline DynamicVector& operator=( initializer_list<Type> list );
282 
283  template< typename Other, size_t N >
284  inline DynamicVector& operator=( const Other (&array)[N] );
285 
286  inline DynamicVector& operator=( const DynamicVector& rhs );
287  inline DynamicVector& operator=( DynamicVector&& rhs ) noexcept;
288 
289  template< typename VT > inline DynamicVector& operator= ( const Vector<VT,TF>& rhs );
290  template< typename VT > inline DynamicVector& operator+=( const Vector<VT,TF>& rhs );
291  template< typename VT > inline DynamicVector& operator-=( const Vector<VT,TF>& rhs );
292  template< typename VT > inline DynamicVector& operator*=( const Vector<VT,TF>& rhs );
293  template< typename VT > inline DynamicVector& operator/=( const DenseVector<VT,TF>& rhs );
294 
295  template< typename Other >
296  inline EnableIf_<IsNumeric<Other>, DynamicVector >& operator*=( Other rhs );
297 
298  template< typename Other >
299  inline EnableIf_<IsNumeric<Other>, DynamicVector >& operator/=( Other rhs );
301  //**********************************************************************************************
302 
303  //**Utility functions***************************************************************************
306  inline size_t size() const noexcept;
307  inline size_t capacity() const noexcept;
308  inline size_t nonZeros() const;
309  inline void reset();
310  inline void clear();
311  inline void resize( size_t n, bool preserve=true );
312  inline void extend( size_t n, bool preserve=true );
313  inline void reserve( size_t n );
314  inline void swap( DynamicVector& v ) noexcept;
316  //**********************************************************************************************
317 
318  //**Numeric functions***************************************************************************
321  template< typename Other > inline DynamicVector& scale( const Other& scalar );
323  //**********************************************************************************************
324 
325  private:
326  //**********************************************************************************************
328  template< typename VT >
330  struct VectorizedAssign {
331  enum : bool { value = useOptimizedKernels &&
332  simdEnabled && VT::simdEnabled &&
334  };
336  //**********************************************************************************************
337 
338  //**********************************************************************************************
340  template< typename VT >
342  struct VectorizedAddAssign {
343  enum : bool { value = useOptimizedKernels &&
344  simdEnabled && VT::simdEnabled &&
347  };
349  //**********************************************************************************************
350 
351  //**********************************************************************************************
353  template< typename VT >
355  struct VectorizedSubAssign {
356  enum : bool { value = useOptimizedKernels &&
357  simdEnabled && VT::simdEnabled &&
360  };
362  //**********************************************************************************************
363 
364  //**********************************************************************************************
366  template< typename VT >
368  struct VectorizedMultAssign {
369  enum : bool { value = useOptimizedKernels &&
370  simdEnabled && VT::simdEnabled &&
373  };
375  //**********************************************************************************************
376 
377  //**********************************************************************************************
379  template< typename VT >
381  struct VectorizedDivAssign {
382  enum : bool { value = useOptimizedKernels &&
383  simdEnabled && VT::simdEnabled &&
386  };
388  //**********************************************************************************************
389 
390  //**********************************************************************************************
392  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
393  //**********************************************************************************************
394 
395  public:
396  //**Debugging functions*************************************************************************
399  inline bool isIntact() const noexcept;
401  //**********************************************************************************************
402 
403  //**Expression template evaluation functions****************************************************
406  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
407  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
408 
409  inline bool isAligned () const noexcept;
410  inline bool canSMPAssign() const noexcept;
411 
412  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
413  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
414  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
415 
416  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
417  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
418  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
419  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
420 
421  template< typename VT >
422  inline DisableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
423 
424  template< typename VT >
425  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
426 
427  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
428 
429  template< typename VT >
430  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
431 
432  template< typename VT >
433  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
434 
435  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
436 
437  template< typename VT >
438  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
439 
440  template< typename VT >
441  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
442 
443  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
444 
445  template< typename VT >
446  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
447 
448  template< typename VT >
449  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
450 
451  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
452 
453  template< typename VT >
454  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
455 
456  template< typename VT >
457  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
459  //**********************************************************************************************
460 
461  private:
462  //**Utility functions***************************************************************************
465  inline size_t adjustCapacity( size_t minCapacity ) const noexcept;
467  //**********************************************************************************************
468 
469  //**Member variables****************************************************************************
472  size_t size_;
473  size_t capacity_;
475 
481  //**********************************************************************************************
482 
483  //**Compile time checks*************************************************************************
490  //**********************************************************************************************
491 };
492 //*************************************************************************************************
493 
494 
495 
496 
497 //=================================================================================================
498 //
499 // CONSTRUCTORS
500 //
501 //=================================================================================================
502 
503 //*************************************************************************************************
506 template< typename Type // Data type of the vector
507  , bool TF > // Transpose flag
509  : size_ ( 0UL ) // The current size/dimension of the vector
510  , capacity_( 0UL ) // The maximum capacity of the vector
511  , v_ ( nullptr ) // The vector elements
512 {}
513 //*************************************************************************************************
514 
515 
516 //*************************************************************************************************
524 template< typename Type // Data type of the vector
525  , bool TF > // Transpose flag
527  : size_ ( n ) // The current size/dimension of the vector
528  , capacity_( adjustCapacity( n ) ) // The maximum capacity of the vector
529  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
530 {
532  for( size_t i=size_; i<capacity_; ++i )
533  v_[i] = Type();
534  }
535 
536  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
537 }
538 //*************************************************************************************************
539 
540 
541 //*************************************************************************************************
549 template< typename Type // Data type of the vector
550  , bool TF > // Transpose flag
551 inline DynamicVector<Type,TF>::DynamicVector( size_t n, const Type& init )
552  : size_ ( n ) // The current size/dimension of the vector
553  , capacity_( adjustCapacity( n ) ) // The maximum capacity of the vector
554  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
555 {
556  for( size_t i=0UL; i<size_; ++i )
557  v_[i] = init;
558 
560  for( size_t i=size_; i<capacity_; ++i )
561  v_[i] = Type();
562  }
563 
564  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
565 }
566 //*************************************************************************************************
567 
568 
569 //*************************************************************************************************
584 template< typename Type // Data type of the vector
585  , bool TF > // Transpose flag
587  : size_ ( list.size() ) // The current size/dimension of the vector
588  , capacity_( adjustCapacity( size_ ) ) // The maximum capacity of the vector
589  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
590 {
591  std::fill( std::copy( list.begin(), list.end(), v_ ), v_+capacity_, Type() );
592 
593  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
594 }
595 //*************************************************************************************************
596 
597 
598 //*************************************************************************************************
618 template< typename Type // Data type of the vector
619  , bool TF > // Transpose flag
620 template< typename Other > // Data type of the initialization array
621 inline DynamicVector<Type,TF>::DynamicVector( size_t n, const Other* array )
622  : size_ ( n ) // The current size/dimension of the vector
623  , capacity_( adjustCapacity( n ) ) // The maximum capacity of the vector
624  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
625 {
626  for( size_t i=0UL; i<n; ++i )
627  v_[i] = array[i];
628 
630  for( size_t i=n; i<capacity_; ++i )
631  v_[i] = Type();
632  }
633 
634  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
635 }
636 //*************************************************************************************************
637 
638 
639 //*************************************************************************************************
656 template< typename Type // Data type of the vector
657  , bool TF > // Transpose flag
658 template< typename Other // Data type of the initialization array
659  , size_t N > // Dimension of the initialization array
660 inline DynamicVector<Type,TF>::DynamicVector( const Other (&array)[N] )
661  : size_ ( N ) // The current size/dimension of the vector
662  , capacity_( adjustCapacity( N ) ) // The maximum capacity of the vector
663  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
664 {
665  for( size_t i=0UL; i<N; ++i )
666  v_[i] = array[i];
667 
669  for( size_t i=N; i<capacity_; ++i )
670  v_[i] = Type();
671  }
672 
673  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
674 }
675 //*************************************************************************************************
676 
677 
678 //*************************************************************************************************
686 template< typename Type // Data type of the vector
687  , bool TF > // Transpose flag
689  : size_ ( v.size_ ) // The current size/dimension of the vector
690  , capacity_( adjustCapacity( v.size_ ) ) // The maximum capacity of the vector
691  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
692 {
693  BLAZE_INTERNAL_ASSERT( capacity_ <= v.capacity_, "Invalid capacity estimation" );
694 
695  for( size_t i=0UL; i<capacity_; ++i )
696  v_[i] = v.v_[i];
697 
698  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
699 }
700 //*************************************************************************************************
701 
702 
703 //*************************************************************************************************
708 template< typename Type // Data type of the vector
709  , bool TF > // Transpose flag
711  : size_ ( v.size_ ) // The current size/dimension of the vector
712  , capacity_( v.capacity_ ) // The maximum capacity of the vector
713  , v_ ( v.v_ ) // The vector elements
714 {
715  v.size_ = 0UL;
716  v.capacity_ = 0UL;
717  v.v_ = nullptr;
718 }
719 //*************************************************************************************************
720 
721 
722 //*************************************************************************************************
727 template< typename Type // Data type of the vector
728  , bool TF > // Transpose flag
729 template< typename VT > // Type of the foreign vector
731  : size_ ( (~v).size() ) // The current size/dimension of the vector
732  , capacity_( adjustCapacity( size_ ) ) // The maximum capacity of the vector
733  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
734 {
735  for( size_t i=( IsSparseVector<VT>::value ? 0UL : size_ );
736  i<( IsVectorizable<Type>::value ? capacity_ : size_ ); ++i ) {
737  v_[i] = Type();
738  }
739 
740  smpAssign( *this, ~v );
741 
742  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
743 }
744 //*************************************************************************************************
745 
746 
747 
748 
749 //=================================================================================================
750 //
751 // DESTRUCTOR
752 //
753 //=================================================================================================
754 
755 //*************************************************************************************************
758 template< typename Type // Data type of the vector
759  , bool TF > // Transpose flag
761 {
762  deallocate( v_ );
763 }
764 //*************************************************************************************************
765 
766 
767 
768 
769 //=================================================================================================
770 //
771 // DATA ACCESS FUNCTIONS
772 //
773 //=================================================================================================
774 
775 //*************************************************************************************************
784 template< typename Type // Data type of the vector
785  , bool TF > // Transpose flag
786 inline typename DynamicVector<Type,TF>::Reference
787  DynamicVector<Type,TF>::operator[]( size_t index ) noexcept
788 {
789  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
790  return v_[index];
791 }
792 //*************************************************************************************************
793 
794 
795 //*************************************************************************************************
804 template< typename Type // Data type of the vector
805  , bool TF > // Transpose flag
807  DynamicVector<Type,TF>::operator[]( size_t index ) const noexcept
808 {
809  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
810  return v_[index];
811 }
812 //*************************************************************************************************
813 
814 
815 //*************************************************************************************************
825 template< typename Type // Data type of the vector
826  , bool TF > // Transpose flag
827 inline typename DynamicVector<Type,TF>::Reference
829 {
830  if( index >= size_ ) {
831  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
832  }
833  return (*this)[index];
834 }
835 //*************************************************************************************************
836 
837 
838 //*************************************************************************************************
848 template< typename Type // Data type of the vector
849  , bool TF > // Transpose flag
851  DynamicVector<Type,TF>::at( size_t index ) const
852 {
853  if( index >= size_ ) {
854  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
855  }
856  return (*this)[index];
857 }
858 //*************************************************************************************************
859 
860 
861 //*************************************************************************************************
868 template< typename Type // Data type of the vector
869  , bool TF > // Transpose flag
871 {
872  return v_;
873 }
874 //*************************************************************************************************
875 
876 
877 //*************************************************************************************************
884 template< typename Type // Data type of the vector
885  , bool TF > // Transpose flag
887 {
888  return v_;
889 }
890 //*************************************************************************************************
891 
892 
893 //*************************************************************************************************
898 template< typename Type // Data type of the vector
899  , bool TF > // Transpose flag
901 {
902  return Iterator( v_ );
903 }
904 //*************************************************************************************************
905 
906 
907 //*************************************************************************************************
912 template< typename Type // Data type of the vector
913  , bool TF > // Transpose flag
915 {
916  return ConstIterator( v_ );
917 }
918 //*************************************************************************************************
919 
920 
921 //*************************************************************************************************
926 template< typename Type // Data type of the vector
927  , bool TF > // Transpose flag
929 {
930  return ConstIterator( v_ );
931 }
932 //*************************************************************************************************
933 
934 
935 //*************************************************************************************************
940 template< typename Type // Data type of the vector
941  , bool TF > // Transpose flag
943 {
944  return Iterator( v_ + size_ );
945 }
946 //*************************************************************************************************
947 
948 
949 //*************************************************************************************************
954 template< typename Type // Data type of the vector
955  , bool TF > // Transpose flag
957 {
958  return ConstIterator( v_ + size_ );
959 }
960 //*************************************************************************************************
961 
962 
963 //*************************************************************************************************
968 template< typename Type // Data type of the vector
969  , bool TF > // Transpose flag
971 {
972  return ConstIterator( v_ + size_ );
973 }
974 //*************************************************************************************************
975 
976 
977 
978 
979 //=================================================================================================
980 //
981 // ASSIGNMENT OPERATORS
982 //
983 //=================================================================================================
984 
985 //*************************************************************************************************
991 template< typename Type // Data type of the vector
992  , bool TF > // Transpose flag
994 {
995  for( size_t i=0UL; i<size_; ++i )
996  v_[i] = rhs;
997  return *this;
998 }
999 //*************************************************************************************************
1000 
1001 
1002 //*************************************************************************************************
1018 template< typename Type // Data type of the vector
1019  , bool TF > // Transpose flag
1021 {
1022  resize( list.size(), false );
1023  std::copy( list.begin(), list.end(), v_ );
1024 
1025  return *this;
1026 }
1027 //*************************************************************************************************
1028 
1029 
1030 //*************************************************************************************************
1048 template< typename Type // Data type of the vector
1049  , bool TF > // Transpose flag
1050 template< typename Other // Data type of the initialization array
1051  , size_t N > // Dimension of the initialization array
1053 {
1054  resize( N, false );
1055 
1056  for( size_t i=0UL; i<N; ++i )
1057  v_[i] = array[i];
1058 
1059  return *this;
1060 }
1061 //*************************************************************************************************
1062 
1063 
1064 //*************************************************************************************************
1073 template< typename Type // Data type of the vector
1074  , bool TF > // Transpose flag
1076 {
1077  if( &rhs == this ) return *this;
1078 
1079  resize( rhs.size_, false );
1080  smpAssign( *this, ~rhs );
1081 
1082  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1083 
1084  return *this;
1085 }
1086 //*************************************************************************************************
1087 
1088 
1089 //*************************************************************************************************
1095 template< typename Type // Data type of the vector
1096  , bool TF > // Transpose flag
1098 {
1099  deallocate( v_ );
1100 
1101  size_ = rhs.size_;
1102  capacity_ = rhs.capacity_;
1103  v_ = rhs.v_;
1104 
1105  rhs.size_ = 0UL;
1106  rhs.capacity_ = 0UL;
1107  rhs.v_ = nullptr;
1108 
1109  return *this;
1110 }
1111 //*************************************************************************************************
1112 
1113 
1114 //*************************************************************************************************
1122 template< typename Type // Data type of the vector
1123  , bool TF > // Transpose flag
1124 template< typename VT > // Type of the right-hand side vector
1126 {
1127  if( (~rhs).canAlias( this ) ) {
1128  DynamicVector tmp( ~rhs );
1129  swap( tmp );
1130  }
1131  else {
1132  resize( (~rhs).size(), false );
1134  reset();
1135  smpAssign( *this, ~rhs );
1136  }
1137 
1138  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1139 
1140  return *this;
1141 }
1142 //*************************************************************************************************
1143 
1144 
1145 //*************************************************************************************************
1155 template< typename Type // Data type of the vector
1156  , bool TF > // Transpose flag
1157 template< typename VT > // Type of the right-hand side vector
1159 {
1160  if( (~rhs).size() != size_ ) {
1161  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1162  }
1163 
1164  if( (~rhs).canAlias( this ) ) {
1165  const ResultType_<VT> tmp( ~rhs );
1166  smpAddAssign( *this, tmp );
1167  }
1168  else {
1169  smpAddAssign( *this, ~rhs );
1170  }
1171 
1172  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1173 
1174  return *this;
1175 }
1176 //*************************************************************************************************
1177 
1178 
1179 //*************************************************************************************************
1190 template< typename Type // Data type of the vector
1191  , bool TF > // Transpose flag
1192 template< typename VT > // Type of the right-hand side vector
1194 {
1195  if( (~rhs).size() != size_ ) {
1196  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1197  }
1198 
1199  if( (~rhs).canAlias( this ) ) {
1200  const ResultType_<VT> tmp( ~rhs );
1201  smpSubAssign( *this, tmp );
1202  }
1203  else {
1204  smpSubAssign( *this, ~rhs );
1205  }
1206 
1207  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1208 
1209  return *this;
1210 }
1211 //*************************************************************************************************
1212 
1213 
1214 //*************************************************************************************************
1225 template< typename Type // Data type of the vector
1226  , bool TF > // Transpose flag
1227 template< typename VT > // Type of the right-hand side vector
1229 {
1230  if( (~rhs).size() != size_ ) {
1231  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1232  }
1233 
1234  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1235  DynamicVector<Type,TF> tmp( *this * (~rhs) );
1236  swap( tmp );
1237  }
1238  else {
1239  smpMultAssign( *this, ~rhs );
1240  }
1241 
1242  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1243 
1244  return *this;
1245 }
1246 //*************************************************************************************************
1247 
1248 
1249 //*************************************************************************************************
1259 template< typename Type // Data type of the vector
1260  , bool TF > // Transpose flag
1261 template< typename VT > // Type of the right-hand side vector
1263 {
1264  if( (~rhs).size() != size_ ) {
1265  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1266  }
1267 
1268  if( (~rhs).canAlias( this ) ) {
1269  DynamicVector<Type,TF> tmp( *this / (~rhs) );
1270  swap( tmp );
1271  }
1272  else {
1273  smpDivAssign( *this, ~rhs );
1274  }
1275 
1276  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1277 
1278  return *this;
1279 }
1280 //*************************************************************************************************
1281 
1282 
1283 //*************************************************************************************************
1290 template< typename Type // Data type of the vector
1291  , bool TF > // Transpose flag
1292 template< typename Other > // Data type of the right-hand side scalar
1295 {
1296  smpAssign( *this, (*this) * rhs );
1297 
1298  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1299 
1300  return *this;
1301 }
1302 //*************************************************************************************************
1303 
1304 
1305 //*************************************************************************************************
1314 template< typename Type // Data type of the vector
1315  , bool TF > // Transpose flag
1316 template< typename Other > // Data type of the right-hand side scalar
1317 inline EnableIf_<IsNumeric<Other>, DynamicVector<Type,TF> >&
1319 {
1320  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1321 
1322  smpAssign( *this, (*this) / rhs );
1323 
1324  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1325 
1326  return *this;
1327 }
1328 //*************************************************************************************************
1329 
1330 
1331 
1332 
1333 //=================================================================================================
1334 //
1335 // UTILITY FUNCTIONS
1336 //
1337 //=================================================================================================
1338 
1339 //*************************************************************************************************
1344 template< typename Type // Data type of the vector
1345  , bool TF > // Transpose flag
1346 inline size_t DynamicVector<Type,TF>::size() const noexcept
1347 {
1348  return size_;
1349 }
1350 //*************************************************************************************************
1351 
1352 
1353 //*************************************************************************************************
1358 template< typename Type // Data type of the vector
1359  , bool TF > // Transpose flag
1360 inline size_t DynamicVector<Type,TF>::capacity() const noexcept
1361 {
1362  return capacity_;
1363 }
1364 //*************************************************************************************************
1365 
1366 
1367 //*************************************************************************************************
1375 template< typename Type // Data type of the vector
1376  , bool TF > // Transpose flag
1378 {
1379  size_t nonzeros( 0 );
1380 
1381  for( size_t i=0UL; i<size_; ++i ) {
1382  if( !isDefault( v_[i] ) )
1383  ++nonzeros;
1384  }
1385 
1386  return nonzeros;
1387 }
1388 //*************************************************************************************************
1389 
1390 
1391 //*************************************************************************************************
1396 template< typename Type // Data type of the vector
1397  , bool TF > // Transpose flag
1399 {
1400  using blaze::clear;
1401  for( size_t i=0UL; i<size_; ++i )
1402  clear( v_[i] );
1403 }
1404 //*************************************************************************************************
1405 
1406 
1407 //*************************************************************************************************
1414 template< typename Type // Data type of the vector
1415  , bool TF > // Transpose flag
1417 {
1418  resize( 0UL, false );
1419 }
1420 //*************************************************************************************************
1421 
1422 
1423 //*************************************************************************************************
1452 template< typename Type // Data type of the vector
1453  , bool TF > // Transpose flag
1454 inline void DynamicVector<Type,TF>::resize( size_t n, bool preserve )
1455 {
1456  if( n > capacity_ )
1457  {
1458  // Allocating a new array
1459  const size_t newCapacity( adjustCapacity( n ) );
1460  Type* BLAZE_RESTRICT tmp = allocate<Type>( newCapacity );
1461 
1462  // Initializing the new array
1463  if( preserve ) {
1464  transfer( v_, v_+size_, tmp );
1465  }
1466 
1468  for( size_t i=size_; i<newCapacity; ++i )
1469  tmp[i] = Type();
1470  }
1471 
1472  // Replacing the old array
1473  std::swap( v_, tmp );
1474  deallocate( tmp );
1475  capacity_ = newCapacity;
1476  }
1477  else if( IsVectorizable<Type>::value && n < size_ )
1478  {
1479  for( size_t i=n; i<size_; ++i )
1480  v_[i] = Type();
1481  }
1482 
1483  size_ = n;
1484 }
1485 //*************************************************************************************************
1486 
1487 
1488 //*************************************************************************************************
1500 template< typename Type // Data type of the vector
1501  , bool TF > // Transpose flag
1502 inline void DynamicVector<Type,TF>::extend( size_t n, bool preserve )
1503 {
1504  resize( size_+n, preserve );
1505 }
1506 //*************************************************************************************************
1507 
1508 
1509 //*************************************************************************************************
1518 template< typename Type // Data type of the vector
1519  , bool TF > // Transpose flag
1520 inline void DynamicVector<Type,TF>::reserve( size_t n )
1521 {
1522  if( n > capacity_ )
1523  {
1524  // Allocating a new array
1525  const size_t newCapacity( adjustCapacity( n ) );
1526  Type* BLAZE_RESTRICT tmp = allocate<Type>( newCapacity );
1527 
1528  // Initializing the new array
1529  transfer( v_, v_+size_, tmp );
1530 
1532  for( size_t i=size_; i<newCapacity; ++i )
1533  tmp[i] = Type();
1534  }
1535 
1536  // Replacing the old array
1537  std::swap( tmp, v_ );
1538  deallocate( tmp );
1539  capacity_ = newCapacity;
1540  }
1541 }
1542 //*************************************************************************************************
1543 
1544 
1545 //*************************************************************************************************
1551 template< typename Type // Data type of the vector
1552  , bool TF > // Transpose flag
1554 {
1555  std::swap( size_, v.size_ );
1556  std::swap( capacity_, v.capacity_ );
1557  std::swap( v_, v.v_ );
1558 }
1559 //*************************************************************************************************
1560 
1561 
1562 //*************************************************************************************************
1568 template< typename Type // Data type of the vector
1569  , bool TF > // Transpose flag
1570 inline size_t DynamicVector<Type,TF>::adjustCapacity( size_t minCapacity ) const noexcept
1571 {
1573  return nextMultiple<size_t>( minCapacity, SIMDSIZE );
1574  else return minCapacity;
1575 }
1576 //*************************************************************************************************
1577 
1578 
1579 
1580 
1581 //=================================================================================================
1582 //
1583 // NUMERIC FUNCTIONS
1584 //
1585 //=================================================================================================
1586 
1587 //*************************************************************************************************
1593 template< typename Type // Data type of the vector
1594  , bool TF > // Transpose flag
1595 template< typename Other > // Data type of the scalar value
1597 {
1598  for( size_t i=0UL; i<size_; ++i )
1599  v_[i] *= scalar;
1600  return *this;
1601 }
1602 //*************************************************************************************************
1603 
1604 
1605 
1606 
1607 //=================================================================================================
1608 //
1609 // DEBUGGING FUNCTIONS
1610 //
1611 //=================================================================================================
1612 
1613 //*************************************************************************************************
1622 template< typename Type // Data type of the vector
1623  , bool TF > // Transpose flag
1624 inline bool DynamicVector<Type,TF>::isIntact() const noexcept
1625 {
1626  if( size_ > capacity_ )
1627  return false;
1628 
1629  if( IsNumeric<Type>::value ) {
1630  for( size_t i=size_; i<capacity_; ++i ) {
1631  if( v_[i] != Type() )
1632  return false;
1633  }
1634  }
1635 
1636  return true;
1637 }
1638 //*************************************************************************************************
1639 
1640 
1641 
1642 
1643 //=================================================================================================
1644 //
1645 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1646 //
1647 //=================================================================================================
1648 
1649 //*************************************************************************************************
1659 template< typename Type // Data type of the vector
1660  , bool TF > // Transpose flag
1661 template< typename Other > // Data type of the foreign expression
1662 inline bool DynamicVector<Type,TF>::canAlias( const Other* alias ) const noexcept
1663 {
1664  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1665 }
1666 //*************************************************************************************************
1667 
1668 
1669 //*************************************************************************************************
1679 template< typename Type // Data type of the vector
1680  , bool TF > // Transpose flag
1681 template< typename Other > // Data type of the foreign expression
1682 inline bool DynamicVector<Type,TF>::isAliased( const Other* alias ) const noexcept
1683 {
1684  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1685 }
1686 //*************************************************************************************************
1687 
1688 
1689 //*************************************************************************************************
1698 template< typename Type // Data type of the vector
1699  , bool TF > // Transpose flag
1700 inline bool DynamicVector<Type,TF>::isAligned() const noexcept
1701 {
1702  return true;
1703 }
1704 //*************************************************************************************************
1705 
1706 
1707 //*************************************************************************************************
1717 template< typename Type // Data type of the vector
1718  , bool TF > // Transpose flag
1719 inline bool DynamicVector<Type,TF>::canSMPAssign() const noexcept
1720 {
1721  return ( size() > SMP_DVECASSIGN_THRESHOLD );
1722 }
1723 //*************************************************************************************************
1724 
1725 
1726 //*************************************************************************************************
1738 template< typename Type // Data type of the vector
1739  , bool TF > // Transpose flag
1741  DynamicVector<Type,TF>::load( size_t index ) const noexcept
1742 {
1743  return loada( index );
1744 }
1745 //*************************************************************************************************
1746 
1747 
1748 //*************************************************************************************************
1761 template< typename Type // Data type of the vector
1762  , bool TF > // Transpose flag
1764  DynamicVector<Type,TF>::loada( size_t index ) const noexcept
1765 {
1766  using blaze::loada;
1767 
1769 
1770  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1771  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
1772  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1773  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+index ), "Invalid alignment detected" );
1774 
1775  return loada( v_+index );
1776 }
1777 //*************************************************************************************************
1778 
1779 
1780 //*************************************************************************************************
1793 template< typename Type // Data type of the vector
1794  , bool TF > // Transpose flag
1796  DynamicVector<Type,TF>::loadu( size_t index ) const noexcept
1797 {
1798  using blaze::loadu;
1799 
1801 
1802  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1803  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
1804 
1805  return loadu( v_+index );
1806 }
1807 //*************************************************************************************************
1808 
1809 
1810 //*************************************************************************************************
1823 template< typename Type // Data type of the vector
1824  , bool TF > // Transpose flag
1826  DynamicVector<Type,TF>::store( size_t index, const SIMDType& value ) noexcept
1827 {
1828  storea( index, value );
1829 }
1830 //*************************************************************************************************
1831 
1832 
1833 //*************************************************************************************************
1846 template< typename Type // Data type of the vector
1847  , bool TF > // Transpose flag
1849  DynamicVector<Type,TF>::storea( size_t index, const SIMDType& value ) noexcept
1850 {
1851  using blaze::storea;
1852 
1854 
1855  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1856  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
1857  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1858  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+index ), "Invalid alignment detected" );
1859 
1860  storea( v_+index, value );
1861 }
1862 //*************************************************************************************************
1863 
1864 
1865 //*************************************************************************************************
1878 template< typename Type // Data type of the vector
1879  , bool TF > // Transpose flag
1881  DynamicVector<Type,TF>::storeu( size_t index, const SIMDType& value ) noexcept
1882 {
1883  using blaze::storeu;
1884 
1886 
1887  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1888  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
1889 
1890  storeu( v_+index, value );
1891 }
1892 //*************************************************************************************************
1893 
1894 
1895 //*************************************************************************************************
1909 template< typename Type // Data type of the vector
1910  , bool TF > // Transpose flag
1912  DynamicVector<Type,TF>::stream( size_t index, const SIMDType& value ) noexcept
1913 {
1914  using blaze::stream;
1915 
1917 
1918  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1919  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
1920  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1921  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+index ), "Invalid alignment detected" );
1922 
1923  stream( v_+index, value );
1924 }
1925 //*************************************************************************************************
1926 
1927 
1928 //*************************************************************************************************
1939 template< typename Type // Data type of the vector
1940  , bool TF > // Transpose flag
1941 template< typename VT > // Type of the right-hand side dense vector
1944 {
1945  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1946 
1947  const size_t ipos( size_ & size_t(-2) );
1948  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
1949 
1950  for( size_t i=0UL; i<ipos; i+=2UL ) {
1951  v_[i ] = (~rhs)[i ];
1952  v_[i+1UL] = (~rhs)[i+1UL];
1953  }
1954  if( ipos < (~rhs).size() )
1955  v_[ipos] = (~rhs)[ipos];
1956 }
1957 //*************************************************************************************************
1958 
1959 
1960 //*************************************************************************************************
1971 template< typename Type // Data type of the vector
1972  , bool TF > // Transpose flag
1973 template< typename VT > // Type of the right-hand side dense vector
1976 {
1978 
1979  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1980 
1981  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
1982 
1983  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
1984  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
1985 
1986  size_t i=0UL;
1987  Iterator left( begin() );
1988  ConstIterator_<VT> right( (~rhs).begin() );
1989 
1990  if( useStreaming && size_ > ( cacheSize/( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
1991  {
1992  for( ; i<ipos; i+=SIMDSIZE ) {
1993  left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1994  }
1995  for( ; remainder && i<size_; ++i ) {
1996  *left = *right; ++left; ++right;
1997  }
1998  }
1999  else
2000  {
2001  for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
2002  left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2003  left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2004  left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2005  left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2006  }
2007  for( ; i<ipos; i+=SIMDSIZE ) {
2008  left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2009  }
2010  for( ; remainder && i<size_; ++i ) {
2011  *left = *right; ++left; ++right;
2012  }
2013  }
2014 }
2015 //*************************************************************************************************
2016 
2017 
2018 //*************************************************************************************************
2029 template< typename Type // Data type of the vector
2030  , bool TF > // Transpose flag
2031 template< typename VT > // Type of the right-hand side sparse vector
2033 {
2034  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2035 
2036  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2037  v_[element->index()] = element->value();
2038 }
2039 //*************************************************************************************************
2040 
2041 
2042 //*************************************************************************************************
2053 template< typename Type // Data type of the vector
2054  , bool TF > // Transpose flag
2055 template< typename VT > // Type of the right-hand side dense vector
2056 inline DisableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2058 {
2059  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2060 
2061  const size_t ipos( size_ & size_t(-2) );
2062  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2063 
2064  for( size_t i=0UL; i<ipos; i+=2UL ) {
2065  v_[i ] += (~rhs)[i ];
2066  v_[i+1UL] += (~rhs)[i+1UL];
2067  }
2068  if( ipos < (~rhs).size() )
2069  v_[ipos] += (~rhs)[ipos];
2070 }
2071 //*************************************************************************************************
2072 
2073 
2074 //*************************************************************************************************
2085 template< typename Type // Data type of the vector
2086  , bool TF > // Transpose flag
2087 template< typename VT > // Type of the right-hand side dense vector
2088 inline EnableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2090 {
2092 
2093  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2094 
2095  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2096 
2097  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2098  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2099 
2100  size_t i( 0UL );
2101  Iterator left( begin() );
2102  ConstIterator_<VT> right( (~rhs).begin() );
2103 
2104  for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
2105  left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2106  left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2107  left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2108  left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2109  }
2110  for( ; i<ipos; i+=SIMDSIZE ) {
2111  left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2112  }
2113  for( ; remainder && i<size_; ++i ) {
2114  *left += *right; ++left; ++right;
2115  }
2116 }
2117 //*************************************************************************************************
2118 
2119 
2120 //*************************************************************************************************
2131 template< typename Type // Data type of the vector
2132  , bool TF > // Transpose flag
2133 template< typename VT > // Type of the right-hand side sparse vector
2135 {
2136  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2137 
2138  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2139  v_[element->index()] += element->value();
2140 }
2141 //*************************************************************************************************
2142 
2143 
2144 //*************************************************************************************************
2155 template< typename Type // Data type of the vector
2156  , bool TF > // Transpose flag
2157 template< typename VT > // Type of the right-hand side dense vector
2158 inline DisableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2160 {
2161  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2162 
2163  const size_t ipos( size_ & size_t(-2) );
2164  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2165 
2166  for( size_t i=0UL; i<ipos; i+=2UL ) {
2167  v_[i ] -= (~rhs)[i ];
2168  v_[i+1UL] -= (~rhs)[i+1UL];
2169  }
2170  if( ipos < (~rhs).size() )
2171  v_[ipos] -= (~rhs)[ipos];
2172 }
2173 //*************************************************************************************************
2174 
2175 
2176 //*************************************************************************************************
2187 template< typename Type // Data type of the vector
2188  , bool TF > // Transpose flag
2189 template< typename VT > // Type of the right-hand side dense vector
2190 inline EnableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2192 {
2194 
2195  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2196 
2197  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2198 
2199  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2200  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2201 
2202  size_t i( 0UL );
2203  Iterator left( begin() );
2204  ConstIterator_<VT> right( (~rhs).begin() );
2205 
2206  for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
2207  left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2208  left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2209  left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2210  left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2211  }
2212  for( ; i<ipos; i+=SIMDSIZE ) {
2213  left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2214  }
2215  for( ; remainder && i<size_; ++i ) {
2216  *left -= *right; ++left; ++right;
2217  }
2218 }
2219 //*************************************************************************************************
2220 
2221 
2222 //*************************************************************************************************
2233 template< typename Type // Data type of the vector
2234  , bool TF > // Transpose flag
2235 template< typename VT > // Type of the right-hand side sparse vector
2237 {
2238  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2239 
2240  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2241  v_[element->index()] -= element->value();
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 dense vector
2260 inline DisableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2262 {
2263  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2264 
2265  const size_t ipos( size_ & size_t(-2) );
2266  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2267 
2268  for( size_t i=0UL; i<ipos; i+=2UL ) {
2269  v_[i ] *= (~rhs)[i ];
2270  v_[i+1UL] *= (~rhs)[i+1UL];
2271  }
2272  if( ipos < (~rhs).size() )
2273  v_[ipos] *= (~rhs)[ipos];
2274 }
2275 //*************************************************************************************************
2276 
2277 
2278 //*************************************************************************************************
2289 template< typename Type // Data type of the vector
2290  , bool TF > // Transpose flag
2291 template< typename VT > // Type of the right-hand side dense vector
2292 inline EnableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2294 {
2296 
2297  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2298 
2299  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2300 
2301  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2302  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2303 
2304  size_t i( 0UL );
2305  Iterator left( begin() );
2306  ConstIterator_<VT> right( (~rhs).begin() );
2307 
2308  for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
2309  left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2310  left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2311  left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2312  left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2313  }
2314  for( ; i<ipos; i+=SIMDSIZE ) {
2315  left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2316  }
2317  for( ; remainder && i<size_; ++i ) {
2318  *left *= *right; ++left; ++right;
2319  }
2320 }
2321 //*************************************************************************************************
2322 
2323 
2324 //*************************************************************************************************
2335 template< typename Type // Data type of the vector
2336  , bool TF > // Transpose flag
2337 template< typename VT > // Type of the right-hand side sparse vector
2339 {
2340  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2341 
2342  const DynamicVector tmp( serial( *this ) );
2343 
2344  reset();
2345 
2346  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2347  v_[element->index()] = tmp[element->index()] * element->value();
2348 }
2349 //*************************************************************************************************
2350 
2351 
2352 //*************************************************************************************************
2363 template< typename Type // Data type of the vector
2364  , bool TF > // Transpose flag
2365 template< typename VT > // Type of the right-hand side dense vector
2366 inline DisableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2368 {
2369  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2370 
2371  const size_t ipos( size_ & size_t(-2) );
2372  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2373 
2374  for( size_t i=0UL; i<ipos; i+=2UL ) {
2375  v_[i ] /= (~rhs)[i ];
2376  v_[i+1UL] /= (~rhs)[i+1UL];
2377  }
2378  if( ipos < (~rhs).size() )
2379  v_[ipos] /= (~rhs)[ipos];
2380 }
2381 //*************************************************************************************************
2382 
2383 
2384 //*************************************************************************************************
2395 template< typename Type // Data type of the vector
2396  , bool TF > // Transpose flag
2397 template< typename VT > // Type of the right-hand side dense vector
2398 inline EnableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2400 {
2402 
2403  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2404 
2405  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2406  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2407 
2408  size_t i( 0UL );
2409  Iterator left( begin() );
2410  ConstIterator_<VT> right( (~rhs).begin() );
2411 
2412  for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
2413  left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2414  left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2415  left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2416  left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2417  }
2418  for( ; i<ipos; i+=SIMDSIZE ) {
2419  left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2420  }
2421  for( ; i<size_; ++i ) {
2422  *left /= *right; ++left; ++right;
2423  }
2424 }
2425 //*************************************************************************************************
2426 
2427 
2428 
2429 
2430 //=================================================================================================
2431 //
2432 // DYNAMICVECTOR OPERATORS
2433 //
2434 //=================================================================================================
2435 
2436 //*************************************************************************************************
2439 template< typename Type, bool TF >
2440 inline void reset( DynamicVector<Type,TF>& v );
2441 
2442 template< typename Type, bool TF >
2443 inline void clear( DynamicVector<Type,TF>& v );
2444 
2445 template< bool RF, typename Type, bool TF >
2446 inline bool isDefault( const DynamicVector<Type,TF>& v );
2447 
2448 template< typename Type, bool TF >
2449 inline bool isIntact( const DynamicVector<Type,TF>& v ) noexcept;
2450 
2451 template< typename Type, bool TF >
2452 inline void swap( DynamicVector<Type,TF>& a, DynamicVector<Type,TF>& b ) noexcept;
2454 //*************************************************************************************************
2455 
2456 
2457 //*************************************************************************************************
2464 template< typename Type // Data type of the vector
2465  , bool TF > // Transpose flag
2467 {
2468  v.reset();
2469 }
2470 //*************************************************************************************************
2471 
2472 
2473 //*************************************************************************************************
2480 template< typename Type // Data type of the vector
2481  , bool TF > // Transpose flag
2483 {
2484  v.clear();
2485 }
2486 //*************************************************************************************************
2487 
2488 
2489 //*************************************************************************************************
2513 template< bool RF // Relaxation flag
2514  , typename Type // Data type of the vector
2515  , bool TF > // Transpose flag
2516 inline bool isDefault( const DynamicVector<Type,TF>& v )
2517 {
2518  return ( v.size() == 0UL );
2519 }
2520 //*************************************************************************************************
2521 
2522 
2523 //*************************************************************************************************
2541 template< typename Type // Data type of the vector
2542  , bool TF > // Transpose flag
2543 inline bool isIntact( const DynamicVector<Type,TF>& v ) noexcept
2544 {
2545  return v.isIntact();
2546 }
2547 //*************************************************************************************************
2548 
2549 
2550 //*************************************************************************************************
2558 template< typename Type // Data type of the vector
2559  , bool TF > // Transpose flag
2561 {
2562  a.swap( b );
2563 }
2564 //*************************************************************************************************
2565 
2566 
2567 
2568 
2569 //=================================================================================================
2570 //
2571 // HASCONSTDATAACCESS SPECIALIZATIONS
2572 //
2573 //=================================================================================================
2574 
2575 //*************************************************************************************************
2577 template< typename T, bool TF >
2578 struct HasConstDataAccess< DynamicVector<T,TF> > : public TrueType
2579 {};
2581 //*************************************************************************************************
2582 
2583 
2584 
2585 
2586 //=================================================================================================
2587 //
2588 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2589 //
2590 //=================================================================================================
2591 
2592 //*************************************************************************************************
2594 template< typename T, bool TF >
2595 struct HasMutableDataAccess< DynamicVector<T,TF> > : public TrueType
2596 {};
2598 //*************************************************************************************************
2599 
2600 
2601 
2602 
2603 //=================================================================================================
2604 //
2605 // ISALIGNED SPECIALIZATIONS
2606 //
2607 //=================================================================================================
2608 
2609 //*************************************************************************************************
2611 template< typename T, bool TF >
2612 struct IsAligned< DynamicVector<T,TF> > : public TrueType
2613 {};
2615 //*************************************************************************************************
2616 
2617 
2618 
2619 
2620 //=================================================================================================
2621 //
2622 // ISPADDED SPECIALIZATIONS
2623 //
2624 //=================================================================================================
2625 
2626 //*************************************************************************************************
2628 template< typename T, bool TF >
2629 struct IsPadded< DynamicVector<T,TF> > : public BoolConstant<usePadding>
2630 {};
2632 //*************************************************************************************************
2633 
2634 
2635 
2636 
2637 //=================================================================================================
2638 //
2639 // ISRESIZABLE SPECIALIZATIONS
2640 //
2641 //=================================================================================================
2642 
2643 //*************************************************************************************************
2645 template< typename T, bool TF >
2646 struct IsResizable< DynamicVector<T,TF> > : public TrueType
2647 {};
2649 //*************************************************************************************************
2650 
2651 
2652 
2653 
2654 //=================================================================================================
2655 //
2656 // ADDTRAIT SPECIALIZATIONS
2657 //
2658 //=================================================================================================
2659 
2660 //*************************************************************************************************
2662 template< typename T1, bool TF, typename T2, size_t N >
2663 struct AddTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2664 {
2665  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2666 };
2667 
2668 template< typename T1, size_t N, bool TF, typename T2 >
2669 struct AddTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2670 {
2671  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2672 };
2673 
2674 template< typename T1, bool TF, typename T2, size_t N >
2675 struct AddTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
2676 {
2677  using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
2678 };
2679 
2680 template< typename T1, size_t N, bool TF, typename T2 >
2681 struct AddTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
2682 {
2683  using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
2684 };
2685 
2686 template< typename T1, bool TF, typename T2 >
2687 struct AddTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2688 {
2689  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
2690 };
2692 //*************************************************************************************************
2693 
2694 
2695 
2696 
2697 //=================================================================================================
2698 //
2699 // SUBTRAIT SPECIALIZATIONS
2700 //
2701 //=================================================================================================
2702 
2703 //*************************************************************************************************
2705 template< typename T1, bool TF, typename T2, size_t N >
2706 struct SubTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2707 {
2708  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2709 };
2710 
2711 template< typename T1, size_t N, bool TF, typename T2 >
2712 struct SubTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2713 {
2714  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2715 };
2716 
2717 template< typename T1, bool TF, typename T2, size_t N >
2718 struct SubTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
2719 {
2720  using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
2721 };
2722 
2723 template< typename T1, size_t N, bool TF, typename T2 >
2724 struct SubTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
2725 {
2726  using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
2727 };
2728 
2729 template< typename T1, bool TF, typename T2 >
2730 struct SubTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2731 {
2732  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
2733 };
2735 //*************************************************************************************************
2736 
2737 
2738 
2739 
2740 //=================================================================================================
2741 //
2742 // MULTTRAIT SPECIALIZATIONS
2743 //
2744 //=================================================================================================
2745 
2746 //*************************************************************************************************
2748 template< typename T1, bool TF, typename T2 >
2749 struct MultTrait< DynamicVector<T1,TF>, T2, EnableIf_<IsNumeric<T2> > >
2750 {
2751  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
2752 };
2753 
2754 template< typename T1, typename T2, bool TF >
2755 struct MultTrait< T1, DynamicVector<T2,TF>, EnableIf_<IsNumeric<T1> > >
2756 {
2757  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
2758 };
2759 
2760 template< typename T1, bool TF, typename T2, size_t N >
2761 struct MultTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2762 {
2763  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2764 };
2765 
2766 template< typename T1, typename T2, size_t N >
2767 struct MultTrait< DynamicVector<T1,false>, StaticVector<T2,N,true> >
2768 {
2769  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2770 };
2771 
2772 template< typename T1, typename T2, size_t N >
2773 struct MultTrait< DynamicVector<T1,true>, StaticVector<T2,N,false> >
2774 {
2775  using Type = MultTrait_<T1,T2>;
2776 };
2777 
2778 template< typename T1, size_t N, bool TF, typename T2 >
2779 struct MultTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2780 {
2781  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2782 };
2783 
2784 template< typename T1, size_t N, typename T2 >
2785 struct MultTrait< StaticVector<T1,N,false>, DynamicVector<T2,true> >
2786 {
2787  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2788 };
2789 
2790 template< typename T1, size_t N, typename T2 >
2791 struct MultTrait< StaticVector<T1,N,true>, DynamicVector<T2,false> >
2792 {
2793  using Type = MultTrait_<T1,T2>;
2794 };
2795 
2796 template< typename T1, bool TF, typename T2, size_t N >
2797 struct MultTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
2798 {
2799  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
2800 };
2801 
2802 template< typename T1, typename T2, size_t N >
2803 struct MultTrait< DynamicVector<T1,false>, HybridVector<T2,N,true> >
2804 {
2805  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2806 };
2807 
2808 template< typename T1, typename T2, size_t N >
2809 struct MultTrait< DynamicVector<T1,true>, HybridVector<T2,N,false> >
2810 {
2811  using Type = MultTrait_<T1,T2>;
2812 };
2813 
2814 template< typename T1, size_t N, bool TF, typename T2 >
2815 struct MultTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
2816 {
2817  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
2818 };
2819 
2820 template< typename T1, size_t N, typename T2 >
2821 struct MultTrait< HybridVector<T1,N,false>, DynamicVector<T2,true> >
2822 {
2823  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2824 };
2825 
2826 template< typename T1, size_t N, typename T2 >
2827 struct MultTrait< HybridVector<T1,N,true>, DynamicVector<T2,false> >
2828 {
2829  using Type = MultTrait_<T1,T2>;
2830 };
2831 
2832 template< typename T1, bool TF, typename T2 >
2833 struct MultTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2834 {
2835  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
2836 };
2837 
2838 template< typename T1, typename T2 >
2839 struct MultTrait< DynamicVector<T1,false>, DynamicVector<T2,true> >
2840 {
2841  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2842 };
2843 
2844 template< typename T1, typename T2 >
2845 struct MultTrait< DynamicVector<T1,true>, DynamicVector<T2,false> >
2846 {
2847  using Type = MultTrait_<T1,T2>;
2848 };
2850 //*************************************************************************************************
2851 
2852 
2853 
2854 
2855 //=================================================================================================
2856 //
2857 // CROSSTRAIT SPECIALIZATIONS
2858 //
2859 //=================================================================================================
2860 
2861 //*************************************************************************************************
2863 template< typename T1, bool TF, typename T2 >
2864 struct CrossTrait< DynamicVector<T1,TF>, StaticVector<T2,3UL,TF> >
2865 {
2866  private:
2867  using T = MultTrait_<T1,T2>;
2868 
2869  public:
2870  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2871 };
2872 
2873 template< typename T1, bool TF, typename T2 >
2874 struct CrossTrait< StaticVector<T1,3UL,TF>, DynamicVector<T2,TF> >
2875 {
2876  private:
2877  using T = MultTrait_<T1,T2>;
2878 
2879  public:
2880  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2881 };
2882 
2883 template< typename T1, bool TF, typename T2, size_t N >
2884 struct CrossTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
2885 {
2886  private:
2887  using T = MultTrait_<T1,T2>;
2888 
2889  public:
2890  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2891 };
2892 
2893 template< typename T1, size_t N, bool TF, typename T2 >
2894 struct CrossTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
2895 {
2896  private:
2897  using T = MultTrait_<T1,T2>;
2898 
2899  public:
2900  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2901 };
2902 
2903 template< typename T1, bool TF, typename T2 >
2904 struct CrossTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2905 {
2906  private:
2907  using T = MultTrait_<T1,T2>;
2908 
2909  public:
2910  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2911 };
2913 //*************************************************************************************************
2914 
2915 
2916 
2917 
2918 //=================================================================================================
2919 //
2920 // DIVTRAIT SPECIALIZATIONS
2921 //
2922 //=================================================================================================
2923 
2924 //*************************************************************************************************
2926 template< typename T1, bool TF, typename T2 >
2927 struct DivTrait< DynamicVector<T1,TF>, T2, EnableIf_<IsNumeric<T2> > >
2928 {
2929  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
2930 };
2931 
2932 template< typename T1, bool TF, typename T2, size_t N >
2933 struct DivTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2934 {
2935  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2936 };
2937 
2938 template< typename T1, size_t N, bool TF, typename T2 >
2939 struct DivTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2940 {
2941  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2942 };
2943 
2944 template< typename T1, bool TF, typename T2, size_t N >
2945 struct DivTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
2946 {
2947  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
2948 };
2949 
2950 template< typename T1, size_t N, bool TF, typename T2 >
2951 struct DivTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
2952 {
2953  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
2954 };
2955 
2956 template< typename T1, bool TF, typename T2 >
2957 struct DivTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2958 {
2959  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
2960 };
2962 //*************************************************************************************************
2963 
2964 
2965 
2966 
2967 //=================================================================================================
2968 //
2969 // HIGHTYPE SPECIALIZATIONS
2970 //
2971 //=================================================================================================
2972 
2973 //*************************************************************************************************
2975 template< typename T1, bool TF, typename T2 >
2976 struct HighType< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2977 {
2979 };
2981 //*************************************************************************************************
2982 
2983 
2984 
2985 
2986 //=================================================================================================
2987 //
2988 // LOWTYPE SPECIALIZATIONS
2989 //
2990 //=================================================================================================
2991 
2992 //*************************************************************************************************
2994 template< typename T1, bool TF, typename T2 >
2995 struct LowType< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2996 {
2998 };
3000 //*************************************************************************************************
3001 
3002 
3003 
3004 
3005 //=================================================================================================
3006 //
3007 // SUBVECTORTRAIT SPECIALIZATIONS
3008 //
3009 //=================================================================================================
3010 
3011 //*************************************************************************************************
3013 template< typename T1, bool TF >
3014 struct SubvectorTrait< DynamicVector<T1,TF> >
3015 {
3016  using Type = DynamicVector<T1,TF>;
3017 };
3019 //*************************************************************************************************
3020 
3021 } // namespace blaze
3022 
3023 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:133
Constraint on the data type.
#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
BLAZE_ALWAYS_INLINE void stream(size_t index, const SIMDType &value) noexcept
Aligned, non-temporal store of a SIMD element of the vector.
Definition: DynamicVector.h:1912
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: DynamicVector.h:1826
Header file for auxiliary alias declarations.
DenseIterator< Type, aligned > Iterator
Iterator over non-constant elements.
Definition: DynamicVector.h:195
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:79
Type *BLAZE_RESTRICT v_
The dynamically allocated vector elements.
Definition: DynamicVector.h:474
Availability of a SIMD subtraction for the given data types.Depending on the available instruction se...
Definition: HasSIMDSub.h:163
Header file for mathematical functions.
constexpr bool useOptimizedKernels
Configuration switch for optimized kernels.This configuration switch enables/disables all optimized c...
Definition: Optimizations.h:84
Compile time check for low-level access to constant data.This type trait tests whether the given data...
Definition: HasConstDataAccess.h:75
#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 alignment flag values.
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: DynamicVector.h:1849
Header file for the subtraction trait.
Header file for basic type definitions.
Header file for the SparseVector base class.
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DynamicVector.h:1346
const SIMDType load() const noexcept
Load of the SIMD element at the current iterator position.
Definition: DenseIterator.h:403
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:79
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
void clear()
Clearing the vector.
Definition: DynamicVector.h:1416
Header file for the serial shim.
constexpr size_t cacheSize
Cache size of the target architecture.This setting specifies the available cache size in Byte of the ...
Definition: CacheSize.h:48
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
SIMDTrait_< ElementType > SIMDType
SIMD type of the vector elements.
Definition: DynamicVector.h:186
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
bool isIntact() const noexcept
Returns whether the invariants of the dynamic vector are intact.
Definition: DynamicVector.h:1624
Availability of a SIMD multiplication for the given data types.Depending on the available instruction...
Definition: HasSIMDMult.h:162
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: DynamicVector.h:1719
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:315
const Type * ConstPointer
Pointer to a constant vector value.
Definition: DynamicVector.h:193
EnableIf_< IsDenseVector< VT1 > > smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:193
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
OutputIterator transfer(InputIterator first, InputIterator last, OutputIterator dest)
Transfers the elements from the given source range to the destination range.
Definition: Algorithm.h:71
Header file for the DenseVector base class.
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: DynamicVector.h:1881
Availability of a SIMD addition for the given data types.Depending on the available instruction set (...
Definition: HasSIMDAdd.h:163
#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
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the dynamic vector.
Definition: DynamicVector.h:928
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
Efficient implementation of an arbitrary sized vector.The DynamicVector class template is the represe...
Definition: DynamicVector.h:177
Header file for memory allocation and deallocation functionality.
System settings for performance optimizations.
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:204
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Compile time check for data types.This type trait tests whether or not the given types can be combine...
Definition: IsSIMDCombinable.h:120
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:77
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
DenseVector< This, TF > BaseType
Base type of this DynamicVector instance.
Definition: DynamicVector.h:182
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: DynamicVector.h:1764
Constraint on the data type.
Base template for the CrossTrait class.
Definition: CrossTrait.h:110
size_t adjustCapacity(size_t minCapacity) const noexcept
Adjusting the new capacity of the vector according to its data type Type.
Definition: DynamicVector.h:1570
Efficient implementation of a fixed-sized vector.The StaticVector class template is the representatio...
Definition: Forward.h:61
Header file for the std::initializer_list aliases.
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:120
Efficient implementation of a dynamically sized vector with static memory.The HybridVector class temp...
Definition: Forward.h:59
~DynamicVector()
The destructor for DynamicVector.
Definition: DynamicVector.h:760
Compile time check for low-level access to mutable data.This type trait tests whether the given data ...
Definition: HasMutableDataAccess.h:75
Iterator begin() noexcept
Returns an iterator to the first element of the dynamic vector.
Definition: DynamicVector.h:900
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
EnableIf_< IsBuiltin< T >, T *> allocate(size_t size)
Aligned array allocation for built-in data types.
Definition: Memory.h:150
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: DynamicVector.h:1796
DenseIterator< const Type, aligned > ConstIterator
Iterator over constant elements.
Definition: DynamicVector.h:196
Header file for the DisableIf class template.
Header file for the LowType type trait.
Base template for the HighType type trait.
Definition: HighType.h:133
This ResultType
Result type for expression template evaluations.
Definition: DynamicVector.h:183
void resize(size_t n, bool preserve=true)
Changing the size of the vector.
Definition: DynamicVector.h:1454
Header file for the multiplication trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5635
constexpr bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Optimizations.h:68
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 Type & ReturnType
Return type for expression template evaluations.
Definition: DynamicVector.h:187
#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.
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:76
EnableIf_< IsDenseMatrix< MT1 > > smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
DynamicVector() noexcept
The default constructor for DynamicVector.
Definition: DynamicVector.h:508
#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 capacity() const noexcept
Returns the maximum capacity of the vector.
Definition: DynamicVector.h:1360
Header file for the HasSIMDAdd type trait.
Header file for the DenseIterator class template.
void stream(const SIMDType &value) const noexcept
Aligned, non-temporal store of the SIMD element at the current iterator position. ...
Definition: DenseIterator.h:531
Header file for the subvector trait.
Header file for all SIMD functionality.
Constraint on the data type.
void store(const SIMDType &value) const noexcept
Store of the SIMD element at the current iterator position.
Definition: DenseIterator.h:468
Availability of a SIMD division for the given data types.Depending on the available instruction set (...
Definition: HasSIMDDiv.h:144
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:78
void reset()
Reset to the default initial values.
Definition: DynamicVector.h:1398
Resize mechanism to obtain a DynamicVector with a different fixed number of elements.
Definition: DynamicVector.h:212
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: DynamicVector.h:1700
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: DynamicVector.h:787
Header file for the IsAligned type trait.
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the dynamic vector.
Definition: DynamicVector.h:970
size_t size_
The current size/dimension of the vector.
Definition: DynamicVector.h:472
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:80
#define BLAZE_RESTRICT
Platform dependent setup of the restrict keyword.
Definition: Restrict.h:81
Type & Reference
Reference to a non-constant vector value.
Definition: DynamicVector.h:190
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a vectorizable data type...
Definition: Vectorizable.h:61
const Type & ConstReference
Reference to a constant vector value.
Definition: DynamicVector.h:191
Header file for the exception macros of the math module.
Compile time check for data types.This type trait tests whether or not the given template parameter i...
Definition: IsSMPAssignable.h:119
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
Header file for the IsPadded type trait.
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: DynamicVector.h:1741
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
Base template for the LowType type trait.
Definition: LowType.h:133
Header file for the HasConstDataAccess type trait.
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
size_t capacity_
The maximum capacity of the vector.
Definition: DynamicVector.h:473
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > stream(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned, non-temporal store of a vector of 1-byte integral values.
Definition: Stream.h:75
Header file for the IsSIMDCombinable type trait.
Header file for the IsSparseVector type trait.
Header file for the HasSIMDMult type trait.
DynamicVector< Type, TF > Other
The type of the other DynamicVector.
Definition: DynamicVector.h:213
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:143
Base template for the MultTrait class.
Definition: MultTrait.h:143
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
Constraint on the data type.
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: DynamicVector.h:870
EnableIf_< IsDenseVector< VT1 > > smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:222
const DynamicVector & CompositeType
Data type for composite expression templates.
Definition: DynamicVector.h:188
void extend(size_t n, bool preserve=true)
Extending the size of the vector.
Definition: DynamicVector.h:1502
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:296
Header file for the cache size of the target architecture.
#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
Rebind mechanism to obtain a DynamicVector with different data/element type.
Definition: DynamicVector.h:203
Header file for the isDefault shim.
System settings for the restrict keyword.
Type ElementType
Type of the vector elements.
Definition: DynamicVector.h:185
Type * Pointer
Pointer to a non-constant vector value.
Definition: DynamicVector.h:192
Constraint on the data type.
Header file for the HasSIMDSub type trait.
Header file for the HasMutableDataAccess type trait.
void reserve(size_t n)
Setting the minimum capacity of the vector.
Definition: DynamicVector.h:1520
void swap(DynamicVector &v) noexcept
Swapping the contents of two vectors.
Definition: DynamicVector.h:1553
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: DynamicVector.h:1377
EnableIf_< IsBuiltin< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:225
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Base template for the DivTrait class.
Definition: DivTrait.h:143
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition: Storeu.h:76
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: DynamicVector.h:1682
constexpr bool usePadding
Configuration of the padding of dense vectors and matrices.This configuration switch enables/disables...
Definition: Optimizations.h:52
Iterator end() noexcept
Returns an iterator just past the last element of the dynamic vector.
Definition: DynamicVector.h:942
Header file for the HasSIMDDiv type trait.
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:164
Header file for the default transpose flag for all vectors of the Blaze library.
Initializer list type of the Blaze library.
Header file for the alignment check function.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:120
DynamicVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: DynamicVector.h:993
Header file for the IntegralConstant class template.
DynamicVector< NewType, TF > Other
The type of the other DynamicVector.
Definition: DynamicVector.h:204
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Base template for the SubTrait class.
Definition: SubTrait.h:143
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
Reference at(size_t index)
Checked access to the vector elements.
Definition: DynamicVector.h:828
Header file for the IsResizable type trait.
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: DynamicVector.h:1662
#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
Header file for the HighType type trait.
Header file for the TrueType type/value trait base class.
DynamicVector< Type,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: DynamicVector.h:184
DynamicVector< Type, TF > This
Type of this DynamicVector instance.
Definition: DynamicVector.h:181