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>
51 #include <blaze/math/Exception.h>
54 #include <blaze/math/Forward.h>
55 #include <blaze/math/Functions.h>
57 #include <blaze/math/shims/Clear.h>
60 #include <blaze/math/SIMD.h>
86 #include <blaze/system/CacheSize.h>
87 #include <blaze/system/Inline.h>
89 #include <blaze/system/Restrict.h>
94 #include <blaze/util/Assert.h>
100 #include <blaze/util/DisableIf.h>
101 #include <blaze/util/EnableIf.h>
103 #include <blaze/util/Memory.h>
104 #include <blaze/util/Template.h>
105 #include <blaze/util/TrueType.h>
106 #include <blaze/util/Types.h>
109 
110 
111 namespace blaze {
112 
113 //=================================================================================================
114 //
115 // CLASS DEFINITION
116 //
117 //=================================================================================================
118 
119 //*************************************************************************************************
183 template< typename Type // Data type of the vector
184  , bool TF = defaultTransposeFlag > // Transpose flag
186  : public DenseVector< DynamicVector<Type,TF>, TF >
187 {
188  public:
189  //**Type definitions****************************************************************************
192  using ResultType = This;
194  using ElementType = Type;
196  using ReturnType = const Type&;
197  using CompositeType = const DynamicVector&;
198 
199  using Reference = Type&;
200  using ConstReference = const Type&;
201  using Pointer = Type*;
202  using ConstPointer = const Type*;
203 
206  //**********************************************************************************************
207 
208  //**Rebind struct definition********************************************************************
211  template< typename NewType > // Data type of the other vector
212  struct Rebind {
214  };
215  //**********************************************************************************************
216 
217  //**Resize struct definition********************************************************************
220  template< size_t NewN > // Number of elements of the other vector
221  struct Resize {
223  };
224  //**********************************************************************************************
225 
226  //**Compilation flags***************************************************************************
228 
232  enum : bool { simdEnabled = IsVectorizable<Type>::value };
233 
235 
238  enum : bool { smpAssignable = !IsSMPAssignable<Type>::value };
239  //**********************************************************************************************
240 
241  //**Constructors********************************************************************************
244  explicit inline DynamicVector() noexcept;
245  explicit inline DynamicVector( size_t n );
246  explicit inline DynamicVector( size_t n, const Type& init );
247  explicit inline DynamicVector( initializer_list<Type> list );
248 
249  template< typename Other >
250  explicit inline DynamicVector( size_t n, const Other* array );
251 
252  template< typename Other, size_t Dim >
253  explicit inline DynamicVector( const Other (&array)[Dim] );
254 
255  inline DynamicVector( const DynamicVector& v );
256  inline DynamicVector( DynamicVector&& v ) noexcept;
257  template< typename VT > inline DynamicVector( const Vector<VT,TF>& v );
259  //**********************************************************************************************
260 
261  //**Destructor**********************************************************************************
264  inline ~DynamicVector();
266  //**********************************************************************************************
267 
268  //**Data access functions***********************************************************************
271  inline Reference operator[]( size_t index ) noexcept;
272  inline ConstReference operator[]( size_t index ) const noexcept;
273  inline Reference at( size_t index );
274  inline ConstReference at( size_t index ) const;
275  inline Pointer data () noexcept;
276  inline ConstPointer data () const noexcept;
277  inline Iterator begin () noexcept;
278  inline ConstIterator begin () const noexcept;
279  inline ConstIterator cbegin() const noexcept;
280  inline Iterator end () noexcept;
281  inline ConstIterator end () const noexcept;
282  inline ConstIterator cend () const noexcept;
284  //**********************************************************************************************
285 
286  //**Assignment operators************************************************************************
289  inline DynamicVector& operator=( const Type& rhs );
290  inline DynamicVector& operator=( initializer_list<Type> list );
291 
292  template< typename Other, size_t Dim >
293  inline DynamicVector& operator=( const Other (&array)[Dim] );
294 
295  inline DynamicVector& operator=( const DynamicVector& rhs );
296  inline DynamicVector& operator=( DynamicVector&& rhs ) noexcept;
297 
298  template< typename VT > inline DynamicVector& operator= ( const Vector<VT,TF>& rhs );
299  template< typename VT > inline DynamicVector& operator+=( const Vector<VT,TF>& rhs );
300  template< typename VT > inline DynamicVector& operator-=( const Vector<VT,TF>& rhs );
301  template< typename VT > inline DynamicVector& operator*=( const Vector<VT,TF>& rhs );
302  template< typename VT > inline DynamicVector& operator/=( const DenseVector<VT,TF>& rhs );
303  template< typename VT > inline DynamicVector& operator%=( const Vector<VT,TF>& rhs );
305  //**********************************************************************************************
306 
307  //**Utility functions***************************************************************************
310  inline size_t size() const noexcept;
311  inline size_t spacing() const noexcept;
312  inline size_t capacity() const noexcept;
313  inline size_t nonZeros() const;
314  inline void reset();
315  inline void clear();
316  inline void resize( size_t n, bool preserve=true );
317  inline void extend( size_t n, bool preserve=true );
318  inline void reserve( size_t n );
319  inline void shrinkToFit();
320  inline void swap( DynamicVector& v ) noexcept;
322  //**********************************************************************************************
323 
324  //**Numeric functions***************************************************************************
327  template< typename Other > inline DynamicVector& scale( const Other& scalar );
329  //**********************************************************************************************
330 
331  private:
332  //**********************************************************************************************
334  template< typename VT >
336  struct VectorizedAssign {
337  enum : bool { value = useOptimizedKernels &&
338  simdEnabled && VT::simdEnabled &&
340  };
342  //**********************************************************************************************
343 
344  //**********************************************************************************************
346  template< typename VT >
348  struct VectorizedAddAssign {
349  enum : bool { value = useOptimizedKernels &&
350  simdEnabled && VT::simdEnabled &&
353  };
355  //**********************************************************************************************
356 
357  //**********************************************************************************************
359  template< typename VT >
361  struct VectorizedSubAssign {
362  enum : bool { value = useOptimizedKernels &&
363  simdEnabled && VT::simdEnabled &&
366  };
368  //**********************************************************************************************
369 
370  //**********************************************************************************************
372  template< typename VT >
374  struct VectorizedMultAssign {
375  enum : bool { value = useOptimizedKernels &&
376  simdEnabled && VT::simdEnabled &&
379  };
381  //**********************************************************************************************
382 
383  //**********************************************************************************************
385  template< typename VT >
387  struct VectorizedDivAssign {
388  enum : bool { value = useOptimizedKernels &&
389  simdEnabled && VT::simdEnabled &&
392  };
394  //**********************************************************************************************
395 
396  //**********************************************************************************************
398  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
399  //**********************************************************************************************
400 
401  public:
402  //**Debugging functions*************************************************************************
405  inline bool isIntact() const noexcept;
407  //**********************************************************************************************
408 
409  //**Expression template evaluation functions****************************************************
412  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
413  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
414 
415  inline bool isAligned () const noexcept;
416  inline bool canSMPAssign() const noexcept;
417 
418  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
419  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
420  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
421 
422  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
423  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
424  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
425  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
426 
427  template< typename VT >
428  inline DisableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
429 
430  template< typename VT >
431  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
432 
433  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
434 
435  template< typename VT >
436  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
437 
438  template< typename VT >
439  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
440 
441  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
442 
443  template< typename VT >
444  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
445 
446  template< typename VT >
447  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
448 
449  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
450 
451  template< typename VT >
452  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
453 
454  template< typename VT >
455  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
456 
457  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
458 
459  template< typename VT >
460  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
461 
462  template< typename VT >
463  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
465  //**********************************************************************************************
466 
467  private:
468  //**Utility functions***************************************************************************
471  inline size_t addPadding( size_t value ) const noexcept;
473  //**********************************************************************************************
474 
475  //**Member variables****************************************************************************
478  size_t size_;
479  size_t capacity_;
481 
487  //**********************************************************************************************
488 
489  //**Compile time checks*************************************************************************
496  //**********************************************************************************************
497 };
498 //*************************************************************************************************
499 
500 
501 
502 
503 //=================================================================================================
504 //
505 // CONSTRUCTORS
506 //
507 //=================================================================================================
508 
509 //*************************************************************************************************
512 template< typename Type // Data type of the vector
513  , bool TF > // Transpose flag
515  : size_ ( 0UL ) // The current size/dimension of the vector
516  , capacity_( 0UL ) // The maximum capacity of the vector
517  , v_ ( nullptr ) // The vector elements
518 {}
519 //*************************************************************************************************
520 
521 
522 //*************************************************************************************************
530 template< typename Type // Data type of the vector
531  , bool TF > // Transpose flag
533  : size_ ( n ) // The current size/dimension of the vector
534  , capacity_( addPadding( n ) ) // The maximum capacity of the vector
535  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
536 {
538  for( size_t i=size_; i<capacity_; ++i )
539  v_[i] = Type();
540  }
541 
542  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
543 }
544 //*************************************************************************************************
545 
546 
547 //*************************************************************************************************
555 template< typename Type // Data type of the vector
556  , bool TF > // Transpose flag
557 inline DynamicVector<Type,TF>::DynamicVector( size_t n, const Type& init )
558  : DynamicVector( n )
559 {
560  for( size_t i=0UL; i<size_; ++i )
561  v_[i] = init;
562 
563  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
564 }
565 //*************************************************************************************************
566 
567 
568 //*************************************************************************************************
583 template< typename Type // Data type of the vector
584  , bool TF > // Transpose flag
586  : DynamicVector( list.size() )
587 {
588  std::fill( std::copy( list.begin(), list.end(), begin() ), end(), Type() );
589 
590  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
591 }
592 //*************************************************************************************************
593 
594 
595 //*************************************************************************************************
615 template< typename Type // Data type of the vector
616  , bool TF > // Transpose flag
617 template< typename Other > // Data type of the initialization array
618 inline DynamicVector<Type,TF>::DynamicVector( size_t n, const Other* array )
619  : DynamicVector( n )
620 {
621  for( size_t i=0UL; i<n; ++i )
622  v_[i] = array[i];
623 
624  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
625 }
626 //*************************************************************************************************
627 
628 
629 //*************************************************************************************************
646 template< typename Type // Data type of the vector
647  , bool TF > // Transpose flag
648 template< typename Other // Data type of the initialization array
649  , size_t Dim > // Dimension of the initialization array
650 inline DynamicVector<Type,TF>::DynamicVector( const Other (&array)[Dim] )
651  : DynamicVector( Dim )
652 {
653  for( size_t i=0UL; i<Dim; ++i )
654  v_[i] = array[i];
655 
656  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
657 }
658 //*************************************************************************************************
659 
660 
661 //*************************************************************************************************
669 template< typename Type // Data type of the vector
670  , bool TF > // Transpose flag
672  : DynamicVector( v.size_ )
673 {
674  BLAZE_INTERNAL_ASSERT( capacity_ <= v.capacity_, "Invalid capacity estimation" );
675 
676  smpAssign( *this, ~v );
677 
678  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
679 }
680 //*************************************************************************************************
681 
682 
683 //*************************************************************************************************
688 template< typename Type // Data type of the vector
689  , bool TF > // Transpose flag
691  : size_ ( v.size_ ) // The current size/dimension of the vector
692  , capacity_( v.capacity_ ) // The maximum capacity of the vector
693  , v_ ( v.v_ ) // The vector elements
694 {
695  v.size_ = 0UL;
696  v.capacity_ = 0UL;
697  v.v_ = nullptr;
698 }
699 //*************************************************************************************************
700 
701 
702 //*************************************************************************************************
707 template< typename Type // Data type of the vector
708  , bool TF > // Transpose flag
709 template< typename VT > // Type of the foreign vector
711  : DynamicVector( (~v).size() )
712 {
714  for( size_t i=0UL; i<size_; ++i ) {
715  v_[i] = Type();
716  }
717  }
718 
719  smpAssign( *this, ~v );
720 
721  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
722 }
723 //*************************************************************************************************
724 
725 
726 
727 
728 //=================================================================================================
729 //
730 // DESTRUCTOR
731 //
732 //=================================================================================================
733 
734 //*************************************************************************************************
737 template< typename Type // Data type of the vector
738  , bool TF > // Transpose flag
740 {
741  deallocate( v_ );
742 }
743 //*************************************************************************************************
744 
745 
746 
747 
748 //=================================================================================================
749 //
750 // DATA ACCESS FUNCTIONS
751 //
752 //=================================================================================================
753 
754 //*************************************************************************************************
763 template< typename Type // Data type of the vector
764  , bool TF > // Transpose flag
765 inline typename DynamicVector<Type,TF>::Reference
766  DynamicVector<Type,TF>::operator[]( size_t index ) noexcept
767 {
768  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
769  return v_[index];
770 }
771 //*************************************************************************************************
772 
773 
774 //*************************************************************************************************
783 template< typename Type // Data type of the vector
784  , bool TF > // Transpose flag
786  DynamicVector<Type,TF>::operator[]( size_t index ) const noexcept
787 {
788  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
789  return v_[index];
790 }
791 //*************************************************************************************************
792 
793 
794 //*************************************************************************************************
804 template< typename Type // Data type of the vector
805  , bool TF > // Transpose flag
806 inline typename DynamicVector<Type,TF>::Reference
808 {
809  if( index >= size_ ) {
810  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
811  }
812  return (*this)[index];
813 }
814 //*************************************************************************************************
815 
816 
817 //*************************************************************************************************
827 template< typename Type // Data type of the vector
828  , bool TF > // Transpose flag
830  DynamicVector<Type,TF>::at( size_t index ) const
831 {
832  if( index >= size_ ) {
833  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
834  }
835  return (*this)[index];
836 }
837 //*************************************************************************************************
838 
839 
840 //*************************************************************************************************
847 template< typename Type // Data type of the vector
848  , bool TF > // Transpose flag
850 {
851  return v_;
852 }
853 //*************************************************************************************************
854 
855 
856 //*************************************************************************************************
863 template< typename Type // Data type of the vector
864  , bool TF > // Transpose flag
866 {
867  return v_;
868 }
869 //*************************************************************************************************
870 
871 
872 //*************************************************************************************************
877 template< typename Type // Data type of the vector
878  , bool TF > // Transpose flag
880 {
881  return Iterator( v_ );
882 }
883 //*************************************************************************************************
884 
885 
886 //*************************************************************************************************
891 template< typename Type // Data type of the vector
892  , bool TF > // Transpose flag
894 {
895  return ConstIterator( v_ );
896 }
897 //*************************************************************************************************
898 
899 
900 //*************************************************************************************************
905 template< typename Type // Data type of the vector
906  , bool TF > // Transpose flag
908 {
909  return ConstIterator( v_ );
910 }
911 //*************************************************************************************************
912 
913 
914 //*************************************************************************************************
919 template< typename Type // Data type of the vector
920  , bool TF > // Transpose flag
922 {
923  return Iterator( v_ + size_ );
924 }
925 //*************************************************************************************************
926 
927 
928 //*************************************************************************************************
933 template< typename Type // Data type of the vector
934  , bool TF > // Transpose flag
936 {
937  return ConstIterator( v_ + size_ );
938 }
939 //*************************************************************************************************
940 
941 
942 //*************************************************************************************************
947 template< typename Type // Data type of the vector
948  , bool TF > // Transpose flag
950 {
951  return ConstIterator( v_ + size_ );
952 }
953 //*************************************************************************************************
954 
955 
956 
957 
958 //=================================================================================================
959 //
960 // ASSIGNMENT OPERATORS
961 //
962 //=================================================================================================
963 
964 //*************************************************************************************************
970 template< typename Type // Data type of the vector
971  , bool TF > // Transpose flag
973 {
974  for( size_t i=0UL; i<size_; ++i )
975  v_[i] = rhs;
976  return *this;
977 }
978 //*************************************************************************************************
979 
980 
981 //*************************************************************************************************
997 template< typename Type // Data type of the vector
998  , bool TF > // Transpose flag
1000 {
1001  resize( list.size(), false );
1002  std::copy( list.begin(), list.end(), v_ );
1003 
1004  return *this;
1005 }
1006 //*************************************************************************************************
1007 
1008 
1009 //*************************************************************************************************
1027 template< typename Type // Data type of the vector
1028  , bool TF > // Transpose flag
1029 template< typename Other // Data type of the initialization array
1030  , size_t Dim > // Dimension of the initialization array
1031 inline DynamicVector<Type,TF>& DynamicVector<Type,TF>::operator=( const Other (&array)[Dim] )
1032 {
1033  resize( Dim, false );
1034 
1035  for( size_t i=0UL; i<Dim; ++i )
1036  v_[i] = array[i];
1037 
1038  return *this;
1039 }
1040 //*************************************************************************************************
1041 
1042 
1043 //*************************************************************************************************
1052 template< typename Type // Data type of the vector
1053  , bool TF > // Transpose flag
1055 {
1056  if( &rhs == this ) return *this;
1057 
1058  resize( rhs.size_, false );
1059  smpAssign( *this, ~rhs );
1060 
1061  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1062 
1063  return *this;
1064 }
1065 //*************************************************************************************************
1066 
1067 
1068 //*************************************************************************************************
1074 template< typename Type // Data type of the vector
1075  , bool TF > // Transpose flag
1077 {
1078  deallocate( v_ );
1079 
1080  size_ = rhs.size_;
1081  capacity_ = rhs.capacity_;
1082  v_ = rhs.v_;
1083 
1084  rhs.size_ = 0UL;
1085  rhs.capacity_ = 0UL;
1086  rhs.v_ = nullptr;
1087 
1088  return *this;
1089 }
1090 //*************************************************************************************************
1091 
1092 
1093 //*************************************************************************************************
1101 template< typename Type // Data type of the vector
1102  , bool TF > // Transpose flag
1103 template< typename VT > // Type of the right-hand side vector
1105 {
1106  if( (~rhs).canAlias( this ) ) {
1107  DynamicVector tmp( ~rhs );
1108  swap( tmp );
1109  }
1110  else {
1111  resize( (~rhs).size(), false );
1113  reset();
1114  smpAssign( *this, ~rhs );
1115  }
1116 
1117  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1118 
1119  return *this;
1120 }
1121 //*************************************************************************************************
1122 
1123 
1124 //*************************************************************************************************
1134 template< typename Type // Data type of the vector
1135  , bool TF > // Transpose flag
1136 template< typename VT > // Type of the right-hand side vector
1138 {
1139  if( (~rhs).size() != size_ ) {
1140  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1141  }
1142 
1143  if( (~rhs).canAlias( this ) ) {
1144  const ResultType_<VT> tmp( ~rhs );
1145  smpAddAssign( *this, tmp );
1146  }
1147  else {
1148  smpAddAssign( *this, ~rhs );
1149  }
1150 
1151  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1152 
1153  return *this;
1154 }
1155 //*************************************************************************************************
1156 
1157 
1158 //*************************************************************************************************
1169 template< typename Type // Data type of the vector
1170  , bool TF > // Transpose flag
1171 template< typename VT > // Type of the right-hand side vector
1173 {
1174  if( (~rhs).size() != size_ ) {
1175  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1176  }
1177 
1178  if( (~rhs).canAlias( this ) ) {
1179  const ResultType_<VT> tmp( ~rhs );
1180  smpSubAssign( *this, tmp );
1181  }
1182  else {
1183  smpSubAssign( *this, ~rhs );
1184  }
1185 
1186  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1187 
1188  return *this;
1189 }
1190 //*************************************************************************************************
1191 
1192 
1193 //*************************************************************************************************
1204 template< typename Type // Data type of the vector
1205  , bool TF > // Transpose flag
1206 template< typename VT > // Type of the right-hand side vector
1208 {
1209  if( (~rhs).size() != size_ ) {
1210  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1211  }
1212 
1213  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1214  DynamicVector<Type,TF> tmp( *this * (~rhs) );
1215  swap( tmp );
1216  }
1217  else {
1218  smpMultAssign( *this, ~rhs );
1219  }
1220 
1221  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1222 
1223  return *this;
1224 }
1225 //*************************************************************************************************
1226 
1227 
1228 //*************************************************************************************************
1238 template< typename Type // Data type of the vector
1239  , bool TF > // Transpose flag
1240 template< typename VT > // Type of the right-hand side vector
1242 {
1243  if( (~rhs).size() != size_ ) {
1244  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1245  }
1246 
1247  if( (~rhs).canAlias( this ) ) {
1248  DynamicVector<Type,TF> tmp( *this / (~rhs) );
1249  swap( tmp );
1250  }
1251  else {
1252  smpDivAssign( *this, ~rhs );
1253  }
1254 
1255  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1256 
1257  return *this;
1258 }
1259 //*************************************************************************************************
1260 
1261 
1262 //*************************************************************************************************
1273 template< typename Type // Data type of the vector
1274  , bool TF > // Transpose flag
1275 template< typename VT > // Type of the right-hand side vector
1277 {
1278  using blaze::assign;
1279 
1282 
1283  using CrossType = CrossTrait_< This, ResultType_<VT> >;
1284 
1288 
1289  if( size_ != 3UL || (~rhs).size() != 3UL ) {
1290  BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1291  }
1292 
1293  const CrossType tmp( *this % (~rhs) );
1294  assign( *this, tmp );
1295 
1296  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1297 
1298  return *this;
1299 }
1300 //*************************************************************************************************
1301 
1302 
1303 
1304 
1305 //=================================================================================================
1306 //
1307 // UTILITY FUNCTIONS
1308 //
1309 //=================================================================================================
1310 
1311 //*************************************************************************************************
1316 template< typename Type // Data type of the vector
1317  , bool TF > // Transpose flag
1318 inline size_t DynamicVector<Type,TF>::size() const noexcept
1319 {
1320  return size_;
1321 }
1322 //*************************************************************************************************
1323 
1324 
1325 //*************************************************************************************************
1333 template< typename Type // Data type of the vector
1334  , bool TF > // Transpose flag
1335 inline size_t DynamicVector<Type,TF>::spacing() const noexcept
1336 {
1337  return addPadding( size_ );
1338 }
1339 //*************************************************************************************************
1340 
1341 
1342 //*************************************************************************************************
1347 template< typename Type // Data type of the vector
1348  , bool TF > // Transpose flag
1349 inline size_t DynamicVector<Type,TF>::capacity() const noexcept
1350 {
1351  return capacity_;
1352 }
1353 //*************************************************************************************************
1354 
1355 
1356 //*************************************************************************************************
1364 template< typename Type // Data type of the vector
1365  , bool TF > // Transpose flag
1367 {
1368  size_t nonzeros( 0 );
1369 
1370  for( size_t i=0UL; i<size_; ++i ) {
1371  if( !isDefault( v_[i] ) )
1372  ++nonzeros;
1373  }
1374 
1375  return nonzeros;
1376 }
1377 //*************************************************************************************************
1378 
1379 
1380 //*************************************************************************************************
1385 template< typename Type // Data type of the vector
1386  , bool TF > // Transpose flag
1388 {
1389  using blaze::clear;
1390  for( size_t i=0UL; i<size_; ++i )
1391  clear( v_[i] );
1392 }
1393 //*************************************************************************************************
1394 
1395 
1396 //*************************************************************************************************
1403 template< typename Type // Data type of the vector
1404  , bool TF > // Transpose flag
1406 {
1407  resize( 0UL, false );
1408 }
1409 //*************************************************************************************************
1410 
1411 
1412 //*************************************************************************************************
1441 template< typename Type // Data type of the vector
1442  , bool TF > // Transpose flag
1443 inline void DynamicVector<Type,TF>::resize( size_t n, bool preserve )
1444 {
1445  using std::swap;
1446 
1447  if( n > capacity_ )
1448  {
1449  // Allocating a new array
1450  const size_t newCapacity( addPadding( n ) );
1451  Type* BLAZE_RESTRICT tmp = allocate<Type>( newCapacity );
1452 
1453  // Initializing the new array
1454  if( preserve ) {
1455  transfer( v_, v_+size_, tmp );
1456  }
1457 
1459  for( size_t i=size_; i<newCapacity; ++i )
1460  tmp[i] = Type();
1461  }
1462 
1463  // Replacing the old array
1464  swap( v_, tmp );
1465  deallocate( tmp );
1466  capacity_ = newCapacity;
1467  }
1468  else if( IsVectorizable<Type>::value && n < size_ )
1469  {
1470  for( size_t i=n; i<size_; ++i )
1471  v_[i] = Type();
1472  }
1473 
1474  size_ = n;
1475 }
1476 //*************************************************************************************************
1477 
1478 
1479 //*************************************************************************************************
1491 template< typename Type // Data type of the vector
1492  , bool TF > // Transpose flag
1493 inline void DynamicVector<Type,TF>::extend( size_t n, bool preserve )
1494 {
1495  resize( size_+n, preserve );
1496 }
1497 //*************************************************************************************************
1498 
1499 
1500 //*************************************************************************************************
1509 template< typename Type // Data type of the vector
1510  , bool TF > // Transpose flag
1511 inline void DynamicVector<Type,TF>::reserve( size_t n )
1512 {
1513  using std::swap;
1514 
1515  if( n > capacity_ )
1516  {
1517  // Allocating a new array
1518  const size_t newCapacity( addPadding( n ) );
1519  Type* BLAZE_RESTRICT tmp = allocate<Type>( newCapacity );
1520 
1521  // Initializing the new array
1522  transfer( v_, v_+size_, tmp );
1523 
1525  for( size_t i=size_; i<newCapacity; ++i )
1526  tmp[i] = Type();
1527  }
1528 
1529  // Replacing the old array
1530  swap( tmp, v_ );
1531  deallocate( tmp );
1532  capacity_ = newCapacity;
1533  }
1534 }
1535 //*************************************************************************************************
1536 
1537 
1538 //*************************************************************************************************
1548 template< typename Type // Data type of the vector
1549  , bool TF > // Transpose flag
1551 {
1552  if( spacing() < capacity_ ) {
1553  DynamicVector( *this ).swap( *this );
1554  }
1555 }
1556 //*************************************************************************************************
1557 
1558 
1559 //*************************************************************************************************
1565 template< typename Type // Data type of the vector
1566  , bool TF > // Transpose flag
1568 {
1569  using std::swap;
1570 
1571  swap( size_, v.size_ );
1572  swap( capacity_, v.capacity_ );
1573  swap( v_, v.v_ );
1574 }
1575 //*************************************************************************************************
1576 
1577 
1578 //*************************************************************************************************
1587 template< typename Type // Data type of the vector
1588  , bool TF > // Transpose flag
1589 inline size_t DynamicVector<Type,TF>::addPadding( size_t value ) const noexcept
1590 {
1591  if( usePadding && IsVectorizable<Type>::value )
1592  return nextMultiple<size_t>( value, SIMDSIZE );
1593  else return value;
1594 }
1595 //*************************************************************************************************
1596 
1597 
1598 
1599 
1600 //=================================================================================================
1601 //
1602 // NUMERIC FUNCTIONS
1603 //
1604 //=================================================================================================
1605 
1606 //*************************************************************************************************
1623 template< typename Type // Data type of the vector
1624  , bool TF > // Transpose flag
1625 template< typename Other > // Data type of the scalar value
1627 {
1628  for( size_t i=0UL; i<size_; ++i )
1629  v_[i] *= scalar;
1630  return *this;
1631 }
1632 //*************************************************************************************************
1633 
1634 
1635 
1636 
1637 //=================================================================================================
1638 //
1639 // DEBUGGING FUNCTIONS
1640 //
1641 //=================================================================================================
1642 
1643 //*************************************************************************************************
1652 template< typename Type // Data type of the vector
1653  , bool TF > // Transpose flag
1654 inline bool DynamicVector<Type,TF>::isIntact() const noexcept
1655 {
1656  if( size_ > capacity_ )
1657  return false;
1658 
1660  for( size_t i=size_; i<capacity_; ++i ) {
1661  if( v_[i] != Type() )
1662  return false;
1663  }
1664  }
1665 
1666  return true;
1667 }
1668 //*************************************************************************************************
1669 
1670 
1671 
1672 
1673 //=================================================================================================
1674 //
1675 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1676 //
1677 //=================================================================================================
1678 
1679 //*************************************************************************************************
1689 template< typename Type // Data type of the vector
1690  , bool TF > // Transpose flag
1691 template< typename Other > // Data type of the foreign expression
1692 inline bool DynamicVector<Type,TF>::canAlias( const Other* alias ) const noexcept
1693 {
1694  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1695 }
1696 //*************************************************************************************************
1697 
1698 
1699 //*************************************************************************************************
1709 template< typename Type // Data type of the vector
1710  , bool TF > // Transpose flag
1711 template< typename Other > // Data type of the foreign expression
1712 inline bool DynamicVector<Type,TF>::isAliased( const Other* alias ) const noexcept
1713 {
1714  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1715 }
1716 //*************************************************************************************************
1717 
1718 
1719 //*************************************************************************************************
1728 template< typename Type // Data type of the vector
1729  , bool TF > // Transpose flag
1730 inline bool DynamicVector<Type,TF>::isAligned() const noexcept
1731 {
1732  return true;
1733 }
1734 //*************************************************************************************************
1735 
1736 
1737 //*************************************************************************************************
1747 template< typename Type // Data type of the vector
1748  , bool TF > // Transpose flag
1749 inline bool DynamicVector<Type,TF>::canSMPAssign() const noexcept
1750 {
1751  return ( size() > SMP_DVECASSIGN_THRESHOLD );
1752 }
1753 //*************************************************************************************************
1754 
1755 
1756 //*************************************************************************************************
1768 template< typename Type // Data type of the vector
1769  , bool TF > // Transpose flag
1771  DynamicVector<Type,TF>::load( size_t index ) const noexcept
1772 {
1773  return loada( index );
1774 }
1775 //*************************************************************************************************
1776 
1777 
1778 //*************************************************************************************************
1791 template< typename Type // Data type of the vector
1792  , bool TF > // Transpose flag
1794  DynamicVector<Type,TF>::loada( size_t index ) const noexcept
1795 {
1796  using blaze::loada;
1797 
1799 
1800  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1801  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
1802  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1803  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+index ), "Invalid alignment detected" );
1804 
1805  return loada( 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>::loadu( size_t index ) const noexcept
1827 {
1828  using blaze::loadu;
1829 
1831 
1832  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1833  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
1834 
1835  return loadu( v_+index );
1836 }
1837 //*************************************************************************************************
1838 
1839 
1840 //*************************************************************************************************
1853 template< typename Type // Data type of the vector
1854  , bool TF > // Transpose flag
1856  DynamicVector<Type,TF>::store( size_t index, const SIMDType& value ) noexcept
1857 {
1858  storea( index, value );
1859 }
1860 //*************************************************************************************************
1861 
1862 
1863 //*************************************************************************************************
1876 template< typename Type // Data type of the vector
1877  , bool TF > // Transpose flag
1879  DynamicVector<Type,TF>::storea( size_t index, const SIMDType& value ) noexcept
1880 {
1881  using blaze::storea;
1882 
1884 
1885  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1886  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
1887  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1888  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+index ), "Invalid alignment detected" );
1889 
1890  storea( v_+index, value );
1891 }
1892 //*************************************************************************************************
1893 
1894 
1895 //*************************************************************************************************
1908 template< typename Type // Data type of the vector
1909  , bool TF > // Transpose flag
1911  DynamicVector<Type,TF>::storeu( size_t index, const SIMDType& value ) noexcept
1912 {
1913  using blaze::storeu;
1914 
1916 
1917  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1918  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
1919 
1920  storeu( v_+index, value );
1921 }
1922 //*************************************************************************************************
1923 
1924 
1925 //*************************************************************************************************
1939 template< typename Type // Data type of the vector
1940  , bool TF > // Transpose flag
1942  DynamicVector<Type,TF>::stream( size_t index, const SIMDType& value ) noexcept
1943 {
1944  using blaze::stream;
1945 
1947 
1948  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1949  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
1950  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1951  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+index ), "Invalid alignment detected" );
1952 
1953  stream( v_+index, value );
1954 }
1955 //*************************************************************************************************
1956 
1957 
1958 //*************************************************************************************************
1969 template< typename Type // Data type of the vector
1970  , bool TF > // Transpose flag
1971 template< typename VT > // Type of the right-hand side dense vector
1974 {
1975  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1976 
1977  const size_t ipos( size_ & size_t(-2) );
1978  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
1979 
1980  for( size_t i=0UL; i<ipos; i+=2UL ) {
1981  v_[i ] = (~rhs)[i ];
1982  v_[i+1UL] = (~rhs)[i+1UL];
1983  }
1984  if( ipos < (~rhs).size() )
1985  v_[ipos] = (~rhs)[ipos];
1986 }
1987 //*************************************************************************************************
1988 
1989 
1990 //*************************************************************************************************
2001 template< typename Type // Data type of the vector
2002  , bool TF > // Transpose flag
2003 template< typename VT > // Type of the right-hand side dense vector
2006 {
2008 
2009  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2010 
2011  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2012 
2013  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2014  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2015 
2016  size_t i=0UL;
2017  Iterator left( begin() );
2018  ConstIterator_<VT> right( (~rhs).begin() );
2019 
2020  if( useStreaming && size_ > ( cacheSize/( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
2021  {
2022  for( ; i<ipos; i+=SIMDSIZE ) {
2023  left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2024  }
2025  for( ; remainder && i<size_; ++i ) {
2026  *left = *right; ++left; ++right;
2027  }
2028  }
2029  else
2030  {
2031  for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
2032  left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2033  left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2034  left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2035  left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2036  }
2037  for( ; i<ipos; i+=SIMDSIZE ) {
2038  left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2039  }
2040  for( ; remainder && i<size_; ++i ) {
2041  *left = *right; ++left; ++right;
2042  }
2043  }
2044 }
2045 //*************************************************************************************************
2046 
2047 
2048 //*************************************************************************************************
2059 template< typename Type // Data type of the vector
2060  , bool TF > // Transpose flag
2061 template< typename VT > // Type of the right-hand side sparse vector
2063 {
2064  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2065 
2066  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2067  v_[element->index()] = element->value();
2068 }
2069 //*************************************************************************************************
2070 
2071 
2072 //*************************************************************************************************
2083 template< typename Type // Data type of the vector
2084  , bool TF > // Transpose flag
2085 template< typename VT > // Type of the right-hand side dense vector
2086 inline DisableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2088 {
2089  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2090 
2091  const size_t ipos( size_ & size_t(-2) );
2092  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2093 
2094  for( size_t i=0UL; i<ipos; i+=2UL ) {
2095  v_[i ] += (~rhs)[i ];
2096  v_[i+1UL] += (~rhs)[i+1UL];
2097  }
2098  if( ipos < (~rhs).size() )
2099  v_[ipos] += (~rhs)[ipos];
2100 }
2101 //*************************************************************************************************
2102 
2103 
2104 //*************************************************************************************************
2115 template< typename Type // Data type of the vector
2116  , bool TF > // Transpose flag
2117 template< typename VT > // Type of the right-hand side dense vector
2118 inline EnableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2120 {
2122 
2123  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2124 
2125  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2126 
2127  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2128  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2129 
2130  size_t i( 0UL );
2131  Iterator left( begin() );
2132  ConstIterator_<VT> right( (~rhs).begin() );
2133 
2134  for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
2135  left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2136  left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2137  left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2138  left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2139  }
2140  for( ; i<ipos; i+=SIMDSIZE ) {
2141  left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2142  }
2143  for( ; remainder && i<size_; ++i ) {
2144  *left += *right; ++left; ++right;
2145  }
2146 }
2147 //*************************************************************************************************
2148 
2149 
2150 //*************************************************************************************************
2161 template< typename Type // Data type of the vector
2162  , bool TF > // Transpose flag
2163 template< typename VT > // Type of the right-hand side sparse vector
2165 {
2166  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2167 
2168  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2169  v_[element->index()] += element->value();
2170 }
2171 //*************************************************************************************************
2172 
2173 
2174 //*************************************************************************************************
2185 template< typename Type // Data type of the vector
2186  , bool TF > // Transpose flag
2187 template< typename VT > // Type of the right-hand side dense vector
2188 inline DisableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2190 {
2191  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2192 
2193  const size_t ipos( size_ & size_t(-2) );
2194  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2195 
2196  for( size_t i=0UL; i<ipos; i+=2UL ) {
2197  v_[i ] -= (~rhs)[i ];
2198  v_[i+1UL] -= (~rhs)[i+1UL];
2199  }
2200  if( ipos < (~rhs).size() )
2201  v_[ipos] -= (~rhs)[ipos];
2202 }
2203 //*************************************************************************************************
2204 
2205 
2206 //*************************************************************************************************
2217 template< typename Type // Data type of the vector
2218  , bool TF > // Transpose flag
2219 template< typename VT > // Type of the right-hand side dense vector
2220 inline EnableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2222 {
2224 
2225  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2226 
2227  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2228 
2229  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2230  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2231 
2232  size_t i( 0UL );
2233  Iterator left( begin() );
2234  ConstIterator_<VT> right( (~rhs).begin() );
2235 
2236  for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
2237  left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2238  left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2239  left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2240  left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2241  }
2242  for( ; i<ipos; i+=SIMDSIZE ) {
2243  left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2244  }
2245  for( ; remainder && i<size_; ++i ) {
2246  *left -= *right; ++left; ++right;
2247  }
2248 }
2249 //*************************************************************************************************
2250 
2251 
2252 //*************************************************************************************************
2263 template< typename Type // Data type of the vector
2264  , bool TF > // Transpose flag
2265 template< typename VT > // Type of the right-hand side sparse vector
2267 {
2268  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2269 
2270  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2271  v_[element->index()] -= element->value();
2272 }
2273 //*************************************************************************************************
2274 
2275 
2276 //*************************************************************************************************
2287 template< typename Type // Data type of the vector
2288  , bool TF > // Transpose flag
2289 template< typename VT > // Type of the right-hand side dense vector
2290 inline DisableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2292 {
2293  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2294 
2295  const size_t ipos( size_ & size_t(-2) );
2296  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2297 
2298  for( size_t i=0UL; i<ipos; i+=2UL ) {
2299  v_[i ] *= (~rhs)[i ];
2300  v_[i+1UL] *= (~rhs)[i+1UL];
2301  }
2302  if( ipos < (~rhs).size() )
2303  v_[ipos] *= (~rhs)[ipos];
2304 }
2305 //*************************************************************************************************
2306 
2307 
2308 //*************************************************************************************************
2319 template< typename Type // Data type of the vector
2320  , bool TF > // Transpose flag
2321 template< typename VT > // Type of the right-hand side dense vector
2322 inline EnableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2324 {
2326 
2327  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2328 
2329  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2330 
2331  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2332  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2333 
2334  size_t i( 0UL );
2335  Iterator left( begin() );
2336  ConstIterator_<VT> right( (~rhs).begin() );
2337 
2338  for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
2339  left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2340  left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2341  left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2342  left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2343  }
2344  for( ; i<ipos; i+=SIMDSIZE ) {
2345  left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2346  }
2347  for( ; remainder && i<size_; ++i ) {
2348  *left *= *right; ++left; ++right;
2349  }
2350 }
2351 //*************************************************************************************************
2352 
2353 
2354 //*************************************************************************************************
2365 template< typename Type // Data type of the vector
2366  , bool TF > // Transpose flag
2367 template< typename VT > // Type of the right-hand side sparse vector
2369 {
2370  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2371 
2372  const DynamicVector tmp( serial( *this ) );
2373 
2374  reset();
2375 
2376  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2377  v_[element->index()] = tmp[element->index()] * element->value();
2378 }
2379 //*************************************************************************************************
2380 
2381 
2382 //*************************************************************************************************
2393 template< typename Type // Data type of the vector
2394  , bool TF > // Transpose flag
2395 template< typename VT > // Type of the right-hand side dense vector
2396 inline DisableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2398 {
2399  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2400 
2401  const size_t ipos( size_ & size_t(-2) );
2402  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2403 
2404  for( size_t i=0UL; i<ipos; i+=2UL ) {
2405  v_[i ] /= (~rhs)[i ];
2406  v_[i+1UL] /= (~rhs)[i+1UL];
2407  }
2408  if( ipos < (~rhs).size() )
2409  v_[ipos] /= (~rhs)[ipos];
2410 }
2411 //*************************************************************************************************
2412 
2413 
2414 //*************************************************************************************************
2425 template< typename Type // Data type of the vector
2426  , bool TF > // Transpose flag
2427 template< typename VT > // Type of the right-hand side dense vector
2428 inline EnableIf_<typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2430 {
2432 
2433  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2434 
2435  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2436  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2437 
2438  size_t i( 0UL );
2439  Iterator left( begin() );
2440  ConstIterator_<VT> right( (~rhs).begin() );
2441 
2442  for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
2443  left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2444  left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2445  left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2446  left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2447  }
2448  for( ; i<ipos; i+=SIMDSIZE ) {
2449  left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2450  }
2451  for( ; i<size_; ++i ) {
2452  *left /= *right; ++left; ++right;
2453  }
2454 }
2455 //*************************************************************************************************
2456 
2457 
2458 
2459 
2460 //=================================================================================================
2461 //
2462 // DYNAMICVECTOR OPERATORS
2463 //
2464 //=================================================================================================
2465 
2466 //*************************************************************************************************
2469 template< typename Type, bool TF >
2470 inline void reset( DynamicVector<Type,TF>& v );
2471 
2472 template< typename Type, bool TF >
2473 inline void clear( DynamicVector<Type,TF>& v );
2474 
2475 template< bool RF, typename Type, bool TF >
2476 inline bool isDefault( const DynamicVector<Type,TF>& v );
2477 
2478 template< typename Type, bool TF >
2479 inline bool isIntact( const DynamicVector<Type,TF>& v ) noexcept;
2480 
2481 template< typename Type, bool TF >
2482 inline void swap( DynamicVector<Type,TF>& a, DynamicVector<Type,TF>& b ) noexcept;
2484 //*************************************************************************************************
2485 
2486 
2487 //*************************************************************************************************
2494 template< typename Type // Data type of the vector
2495  , bool TF > // Transpose flag
2497 {
2498  v.reset();
2499 }
2500 //*************************************************************************************************
2501 
2502 
2503 //*************************************************************************************************
2510 template< typename Type // Data type of the vector
2511  , bool TF > // Transpose flag
2513 {
2514  v.clear();
2515 }
2516 //*************************************************************************************************
2517 
2518 
2519 //*************************************************************************************************
2543 template< bool RF // Relaxation flag
2544  , typename Type // Data type of the vector
2545  , bool TF > // Transpose flag
2546 inline bool isDefault( const DynamicVector<Type,TF>& v )
2547 {
2548  return ( v.size() == 0UL );
2549 }
2550 //*************************************************************************************************
2551 
2552 
2553 //*************************************************************************************************
2571 template< typename Type // Data type of the vector
2572  , bool TF > // Transpose flag
2573 inline bool isIntact( const DynamicVector<Type,TF>& v ) noexcept
2574 {
2575  return v.isIntact();
2576 }
2577 //*************************************************************************************************
2578 
2579 
2580 //*************************************************************************************************
2588 template< typename Type // Data type of the vector
2589  , bool TF > // Transpose flag
2591 {
2592  a.swap( b );
2593 }
2594 //*************************************************************************************************
2595 
2596 
2597 
2598 
2599 //=================================================================================================
2600 //
2601 // HASCONSTDATAACCESS SPECIALIZATIONS
2602 //
2603 //=================================================================================================
2604 
2605 //*************************************************************************************************
2607 template< typename T, bool TF >
2608 struct HasConstDataAccess< DynamicVector<T,TF> >
2609  : public TrueType
2610 {};
2612 //*************************************************************************************************
2613 
2614 
2615 
2616 
2617 //=================================================================================================
2618 //
2619 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2620 //
2621 //=================================================================================================
2622 
2623 //*************************************************************************************************
2625 template< typename T, bool TF >
2626 struct HasMutableDataAccess< DynamicVector<T,TF> >
2627  : public TrueType
2628 {};
2630 //*************************************************************************************************
2631 
2632 
2633 
2634 
2635 //=================================================================================================
2636 //
2637 // ISALIGNED SPECIALIZATIONS
2638 //
2639 //=================================================================================================
2640 
2641 //*************************************************************************************************
2643 template< typename T, bool TF >
2644 struct IsAligned< DynamicVector<T,TF> >
2645  : public TrueType
2646 {};
2648 //*************************************************************************************************
2649 
2650 
2651 
2652 
2653 //=================================================================================================
2654 //
2655 // ISCONTIGUOUS SPECIALIZATIONS
2656 //
2657 //=================================================================================================
2658 
2659 //*************************************************************************************************
2661 template< typename T, bool TF >
2662 struct IsContiguous< DynamicVector<T,TF> >
2663  : public TrueType
2664 {};
2666 //*************************************************************************************************
2667 
2668 
2669 
2670 
2671 //=================================================================================================
2672 //
2673 // ISPADDED SPECIALIZATIONS
2674 //
2675 //=================================================================================================
2676 
2677 //*************************************************************************************************
2679 template< typename T, bool TF >
2680 struct IsPadded< DynamicVector<T,TF> >
2681  : public BoolConstant<usePadding>
2682 {};
2684 //*************************************************************************************************
2685 
2686 
2687 
2688 
2689 //=================================================================================================
2690 //
2691 // ISRESIZABLE SPECIALIZATIONS
2692 //
2693 //=================================================================================================
2694 
2695 //*************************************************************************************************
2697 template< typename T, bool TF >
2698 struct IsResizable< DynamicVector<T,TF> >
2699  : public TrueType
2700 {};
2702 //*************************************************************************************************
2703 
2704 
2705 
2706 
2707 //=================================================================================================
2708 //
2709 // ISSHRINKABLE SPECIALIZATIONS
2710 //
2711 //=================================================================================================
2712 
2713 //*************************************************************************************************
2715 template< typename T, bool TF >
2716 struct IsShrinkable< DynamicVector<T,TF> >
2717  : public TrueType
2718 {};
2720 //*************************************************************************************************
2721 
2722 
2723 
2724 
2725 //=================================================================================================
2726 //
2727 // ADDTRAIT SPECIALIZATIONS
2728 //
2729 //=================================================================================================
2730 
2731 //*************************************************************************************************
2733 template< typename T1, bool TF, typename T2, size_t N >
2734 struct AddTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2735 {
2736  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2737 };
2738 
2739 template< typename T1, size_t N, bool TF, typename T2 >
2740 struct AddTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2741 {
2742  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2743 };
2744 
2745 template< typename T1, bool TF, typename T2, size_t N >
2746 struct AddTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
2747 {
2748  using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
2749 };
2750 
2751 template< typename T1, size_t N, bool TF, typename T2 >
2752 struct AddTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
2753 {
2754  using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
2755 };
2756 
2757 template< typename T1, bool TF, typename T2 >
2758 struct AddTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2759 {
2760  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
2761 };
2763 //*************************************************************************************************
2764 
2765 
2766 
2767 
2768 //=================================================================================================
2769 //
2770 // SUBTRAIT SPECIALIZATIONS
2771 //
2772 //=================================================================================================
2773 
2774 //*************************************************************************************************
2776 template< typename T1, bool TF, typename T2, size_t N >
2777 struct SubTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2778 {
2779  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2780 };
2781 
2782 template< typename T1, size_t N, bool TF, typename T2 >
2783 struct SubTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2784 {
2785  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2786 };
2787 
2788 template< typename T1, bool TF, typename T2, size_t N >
2789 struct SubTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
2790 {
2791  using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
2792 };
2793 
2794 template< typename T1, size_t N, bool TF, typename T2 >
2795 struct SubTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
2796 {
2797  using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
2798 };
2799 
2800 template< typename T1, bool TF, typename T2 >
2801 struct SubTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2802 {
2803  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
2804 };
2806 //*************************************************************************************************
2807 
2808 
2809 
2810 
2811 //=================================================================================================
2812 //
2813 // MULTTRAIT SPECIALIZATIONS
2814 //
2815 //=================================================================================================
2816 
2817 //*************************************************************************************************
2819 template< typename T1, bool TF, typename T2 >
2820 struct MultTrait< DynamicVector<T1,TF>, T2, EnableIf_<IsNumeric<T2> > >
2821 {
2822  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
2823 };
2824 
2825 template< typename T1, typename T2, bool TF >
2826 struct MultTrait< T1, DynamicVector<T2,TF>, EnableIf_<IsNumeric<T1> > >
2827 {
2828  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
2829 };
2830 
2831 template< typename T1, bool TF, typename T2, size_t N >
2832 struct MultTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2833 {
2834  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2835 };
2836 
2837 template< typename T1, typename T2, size_t N >
2838 struct MultTrait< DynamicVector<T1,false>, StaticVector<T2,N,true> >
2839 {
2840  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2841 };
2842 
2843 template< typename T1, typename T2, size_t N >
2844 struct MultTrait< DynamicVector<T1,true>, StaticVector<T2,N,false> >
2845 {
2846  using Type = MultTrait_<T1,T2>;
2847 };
2848 
2849 template< typename T1, size_t N, bool TF, typename T2 >
2850 struct MultTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2851 {
2852  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2853 };
2854 
2855 template< typename T1, size_t N, typename T2 >
2856 struct MultTrait< StaticVector<T1,N,false>, DynamicVector<T2,true> >
2857 {
2858  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2859 };
2860 
2861 template< typename T1, size_t N, typename T2 >
2862 struct MultTrait< StaticVector<T1,N,true>, DynamicVector<T2,false> >
2863 {
2864  using Type = MultTrait_<T1,T2>;
2865 };
2866 
2867 template< typename T1, bool TF, typename T2, size_t N >
2868 struct MultTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
2869 {
2870  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
2871 };
2872 
2873 template< typename T1, typename T2, size_t N >
2874 struct MultTrait< DynamicVector<T1,false>, HybridVector<T2,N,true> >
2875 {
2876  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2877 };
2878 
2879 template< typename T1, typename T2, size_t N >
2880 struct MultTrait< DynamicVector<T1,true>, HybridVector<T2,N,false> >
2881 {
2882  using Type = MultTrait_<T1,T2>;
2883 };
2884 
2885 template< typename T1, size_t N, bool TF, typename T2 >
2886 struct MultTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
2887 {
2888  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
2889 };
2890 
2891 template< typename T1, size_t N, typename T2 >
2892 struct MultTrait< HybridVector<T1,N,false>, DynamicVector<T2,true> >
2893 {
2894  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2895 };
2896 
2897 template< typename T1, size_t N, typename T2 >
2898 struct MultTrait< HybridVector<T1,N,true>, DynamicVector<T2,false> >
2899 {
2900  using Type = MultTrait_<T1,T2>;
2901 };
2902 
2903 template< typename T1, bool TF, typename T2 >
2904 struct MultTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2905 {
2906  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
2907 };
2908 
2909 template< typename T1, typename T2 >
2910 struct MultTrait< DynamicVector<T1,false>, DynamicVector<T2,true> >
2911 {
2912  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2913 };
2914 
2915 template< typename T1, typename T2 >
2916 struct MultTrait< DynamicVector<T1,true>, DynamicVector<T2,false> >
2917 {
2918  using Type = MultTrait_<T1,T2>;
2919 };
2921 //*************************************************************************************************
2922 
2923 
2924 
2925 
2926 //=================================================================================================
2927 //
2928 // DIVTRAIT SPECIALIZATIONS
2929 //
2930 //=================================================================================================
2931 
2932 //*************************************************************************************************
2934 template< typename T1, bool TF, typename T2 >
2935 struct DivTrait< DynamicVector<T1,TF>, T2, EnableIf_<IsNumeric<T2> > >
2936 {
2937  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
2938 };
2939 
2940 template< typename T1, bool TF, typename T2, size_t N >
2941 struct DivTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2942 {
2943  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2944 };
2945 
2946 template< typename T1, size_t N, bool TF, typename T2 >
2947 struct DivTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2948 {
2949  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2950 };
2951 
2952 template< typename T1, bool TF, typename T2, size_t N >
2953 struct DivTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
2954 {
2955  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
2956 };
2957 
2958 template< typename T1, size_t N, bool TF, typename T2 >
2959 struct DivTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
2960 {
2961  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
2962 };
2963 
2964 template< typename T1, bool TF, typename T2 >
2965 struct DivTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2966 {
2967  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
2968 };
2970 //*************************************************************************************************
2971 
2972 
2973 
2974 
2975 //=================================================================================================
2976 //
2977 // CROSSTRAIT SPECIALIZATIONS
2978 //
2979 //=================================================================================================
2980 
2981 //*************************************************************************************************
2983 template< typename T1, bool TF, typename T2 >
2984 struct CrossTrait< DynamicVector<T1,TF>, StaticVector<T2,3UL,TF> >
2985 {
2986  private:
2987  using T = MultTrait_<T1,T2>;
2988 
2989  public:
2990  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2991 };
2992 
2993 template< typename T1, bool TF, typename T2 >
2994 struct CrossTrait< StaticVector<T1,3UL,TF>, DynamicVector<T2,TF> >
2995 {
2996  private:
2997  using T = MultTrait_<T1,T2>;
2998 
2999  public:
3000  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
3001 };
3002 
3003 template< typename T1, bool TF, typename T2, size_t N >
3004 struct CrossTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
3005 {
3006  private:
3007  using T = MultTrait_<T1,T2>;
3008 
3009  public:
3010  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
3011 };
3012 
3013 template< typename T1, size_t N, bool TF, typename T2 >
3014 struct CrossTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
3015 {
3016  private:
3017  using T = MultTrait_<T1,T2>;
3018 
3019  public:
3020  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
3021 };
3022 
3023 template< typename T1, bool TF, typename T2 >
3024 struct CrossTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
3025 {
3026  private:
3027  using T = MultTrait_<T1,T2>;
3028 
3029  public:
3030  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
3031 };
3033 //*************************************************************************************************
3034 
3035 
3036 
3037 
3038 //=================================================================================================
3039 //
3040 // UNARYMAPTRAIT SPECIALIZATIONS
3041 //
3042 //=================================================================================================
3043 
3044 //*************************************************************************************************
3046 template< typename T, bool TF, typename OP >
3047 struct UnaryMapTrait< DynamicVector<T,TF>, OP >
3048 {
3049  using Type = DynamicVector< UnaryMapTrait_<T,OP>, TF >;
3050 };
3052 //*************************************************************************************************
3053 
3054 
3055 
3056 
3057 //=================================================================================================
3058 //
3059 // BINARYMAPTRAIT SPECIALIZATIONS
3060 //
3061 //=================================================================================================
3062 
3063 //*************************************************************************************************
3065 template< typename T1, bool TF, typename T2, size_t N, typename OP >
3066 struct BinaryMapTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF>, OP >
3067 {
3068  using Type = StaticVector< BinaryMapTrait_<T1,T2,OP>, N, TF >;
3069 };
3070 
3071 template< typename T1, size_t N, bool TF, typename T2, typename OP >
3072 struct BinaryMapTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF>, OP >
3073 {
3074  using Type = StaticVector< BinaryMapTrait_<T1,T2,OP>, N, TF >;
3075 };
3076 
3077 template< typename T1, bool TF, typename T2, size_t N, typename OP >
3078 struct BinaryMapTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF>, OP >
3079 {
3080  using Type = HybridVector< BinaryMapTrait_<T1,T2,OP>, N, TF >;
3081 };
3082 
3083 template< typename T1, size_t N, bool TF, typename T2, typename OP >
3084 struct BinaryMapTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF>, OP >
3085 {
3086  using Type = HybridVector< BinaryMapTrait_<T1,T2,OP>, N, TF >;
3087 };
3088 
3089 template< typename T1, bool TF, typename T2, typename OP >
3090 struct BinaryMapTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF>, OP >
3091 {
3092  using Type = DynamicVector< BinaryMapTrait_<T1,T2,OP>, TF >;
3093 };
3095 //*************************************************************************************************
3096 
3097 
3098 
3099 
3100 //=================================================================================================
3101 //
3102 // HIGHTYPE SPECIALIZATIONS
3103 //
3104 //=================================================================================================
3105 
3106 //*************************************************************************************************
3108 template< typename T1, bool TF, typename T2 >
3109 struct HighType< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
3110 {
3112 };
3114 //*************************************************************************************************
3115 
3116 
3117 
3118 
3119 //=================================================================================================
3120 //
3121 // LOWTYPE SPECIALIZATIONS
3122 //
3123 //=================================================================================================
3124 
3125 //*************************************************************************************************
3127 template< typename T1, bool TF, typename T2 >
3128 struct LowType< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
3129 {
3131 };
3133 //*************************************************************************************************
3134 
3135 
3136 
3137 
3138 //=================================================================================================
3139 //
3140 // SUBVECTORTRAIT SPECIALIZATIONS
3141 //
3142 //=================================================================================================
3143 
3144 //*************************************************************************************************
3146 template< typename T, bool TF, size_t I, size_t N >
3147 struct SubvectorTrait< DynamicVector<T,TF>, I, N >
3148 {
3149  using Type = StaticVector<T,N,TF>;
3150 };
3151 
3152 template< typename T, bool TF >
3153 struct SubvectorTrait< DynamicVector<T,TF> >
3154 {
3155  using Type = DynamicVector<T,TF>;
3156 };
3158 //*************************************************************************************************
3159 
3160 
3161 
3162 
3163 //=================================================================================================
3164 //
3165 // ELEMENTSTRAIT SPECIALIZATIONS
3166 //
3167 //=================================================================================================
3168 
3169 //*************************************************************************************************
3171 template< typename T, bool TF, size_t... CEAs >
3172 struct ElementsTrait< DynamicVector<T,TF>, CEAs... >
3173 {
3174  using Type = StaticVector<T,sizeof...(CEAs),TF>;
3175 };
3176 
3177 template< typename T, bool TF >
3178 struct ElementsTrait< DynamicVector<T,TF> >
3179 {
3180  using Type = DynamicVector<T,TF>;
3181 };
3183 //*************************************************************************************************
3184 
3185 } // namespace blaze
3186 
3187 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:135
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:1942
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: DynamicVector.h:1856
Header file for auxiliary alias declarations.
Type *BLAZE_RESTRICT v_
The dynamically allocated vector elements.
Definition: DynamicVector.h:480
Availability of a SIMD subtraction for the given data types.Depending on the available instruction se...
Definition: HasSIMDSub.h:171
Header file for mathematical functions.
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.
Type * Pointer
Pointer to a non-constant vector value.
Definition: DynamicVector.h:201
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: DynamicVector.h:1879
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:1318
const SIMDType load() const noexcept
Load of the SIMD element at the current iterator position.
Definition: DenseIterator.h:405
size_t spacing() const noexcept
Returns the minimum capacity of the vector.
Definition: DynamicVector.h:1335
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:164
void clear()
Clearing the vector.
Definition: DynamicVector.h:1405
Header file for the serial shim.
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
bool isIntact() const noexcept
Returns whether the invariants of the dynamic vector are intact.
Definition: DynamicVector.h:1654
Availability of a SIMD multiplication for the given data types.Depending on the available instruction...
Definition: HasSIMDMult.h:172
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: DynamicVector.h:1749
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:316
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:224
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:1911
Availability of a SIMD addition for the given data types.Depending on the available instruction set (...
Definition: HasSIMDAdd.h:171
#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
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the dynamic vector.
Definition: DynamicVector.h:907
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:291
Efficient implementation of an arbitrary sized vector.The DynamicVector class template is the represe...
Definition: DynamicVector.h:185
Header file for memory allocation and deallocation functionality.
Header file for the extended initializer_list functionality.
System settings for performance optimizations.
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:217
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:343
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:133
Header file for the elements trait.
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: DynamicVector.h:1794
Constraint on the data type.
Base template for the CrossTrait class.
Definition: CrossTrait.h:113
Efficient implementation of a fixed-sized vector.The StaticVector class template is the representatio...
Definition: Forward.h:61
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:109
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:739
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:879
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:155
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: DynamicVector.h:1826
Compile time check for the memory layout of data types.This type trait tests whether the given data t...
Definition: IsContiguous.h:86
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
void resize(size_t n, bool preserve=true)
Changing the size of the vector.
Definition: DynamicVector.h:1443
Header file for the multiplication trait.
Header file for the unary map trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#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:5908
Header file for the IsShrinkable type trait.
Header file for all forward declarations of the math module.
#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:102
DynamicVector() noexcept
The default constructor for DynamicVector.
Definition: DynamicVector.h:514
#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:1349
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:533
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:470
Availability of a SIMD division for the given data types.Depending on the available instruction set (...
Definition: HasSIMDDiv.h:150
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:103
void reset()
Reset to the default initial values.
Definition: DynamicVector.h:1387
Resize mechanism to obtain a DynamicVector with a different fixed number of elements.
Definition: DynamicVector.h:221
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: DynamicVector.h:1730
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: DynamicVector.h:766
Header file for the IsAligned type trait.
Constraint on the data type.
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the dynamic vector.
Definition: DynamicVector.h:949
size_t size_
The current size/dimension of the vector.
Definition: DynamicVector.h:478
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
#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
Constraint on the data type.
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:123
Base template for the ElementsTrait class.
Definition: ElementsTrait.h:108
typename CrossTrait< T1, T2 >::Type CrossTrait_
Auxiliary alias declaration for the CrossTrait class template.The CrossTrait_ alias declaration provi...
Definition: CrossTrait.h:209
Constraint on the data type.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:608
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:1771
Header file for the IsVectorizable type trait.
Compile time check for shrinkable data types.This type trait tests whether the given data type is a s...
Definition: IsShrinkable.h:75
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:479
const Type & ReturnType
Return type for expression template evaluations.
Definition: DynamicVector.h:196
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
SIMDTrait_< ElementType > SIMDType
SIMD type of the vector elements.
Definition: DynamicVector.h:195
Header file for the IsSIMDCombinable type trait.
Header file for the IsSparseVector type trait.
Header file for the HasSIMDMult type trait.
Header file for the binary map trait.
DynamicVector< Type, TF > This
Type of this DynamicVector instance.
Definition: DynamicVector.h:190
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:1357
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:119
const Type & ConstReference
Reference to a constant vector value.
Definition: DynamicVector.h:200
Base template for the MultTrait class.
Definition: MultTrait.h:119
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
Constraint on the data type.
Header file for the IsContiguous type trait.
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: DynamicVector.h:849
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
Headerfile for the generic transfer algorithm.
Type & Reference
Reference to a non-constant vector value.
Definition: DynamicVector.h:199
void extend(size_t n, bool preserve=true)
Extending the size of the vector.
Definition: DynamicVector.h:1493
size_t addPadding(size_t value) const noexcept
Add the necessary amount of padding to the given value.
Definition: DynamicVector.h:1589
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:212
Header file for the isDefault shim.
System settings for the restrict keyword.
Constraint on the data type.
Header file for the HasSIMDSub type trait.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:816
Header file for the HasMutableDataAccess type trait.
void reserve(size_t n)
Setting the minimum capacity of the vector.
Definition: DynamicVector.h:1511
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
DenseIterator< const Type, aligned > ConstIterator
Iterator over constant elements.
Definition: DynamicVector.h:205
void swap(DynamicVector &v) noexcept
Swapping the contents of two vectors.
Definition: DynamicVector.h:1567
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: DynamicVector.h:1366
EnableIf_< IsBuiltin< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:230
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
Base template for the DivTrait class.
Definition: DivTrait.h:120
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
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: DynamicVector.h:1712
Type ElementType
Type of the vector elements.
Definition: DynamicVector.h:194
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
void shrinkToFit()
Requesting the removal of unused capacity.
Definition: DynamicVector.h:1550
Iterator end() noexcept
Returns an iterator just past the last element of the dynamic vector.
Definition: DynamicVector.h:921
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:177
Header file for the default transpose flag for all vectors 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:130
const Type * ConstPointer
Pointer to a constant vector value.
Definition: DynamicVector.h:202
DynamicVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: DynamicVector.h:972
Header file for the IntegralConstant class template.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
Base template for the SubTrait class.
Definition: SubTrait.h:119
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:1375
OutputIterator transfer(InputIterator first, InputIterator last, OutputIterator dest)
Transfers the elements from the given source range to the destination range.
Definition: Transfer.h:70
Reference at(size_t index)
Checked access to the vector elements.
Definition: DynamicVector.h:807
DenseIterator< Type, aligned > Iterator
Iterator over non-constant elements.
Definition: DynamicVector.h:204
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
Base template for the BinaryMapTrait class.
Definition: BinaryMapTrait.h:97
Header file for the IsResizable type trait.
Base template for the UnaryMapTrait class.
Definition: UnaryMapTrait.h:95
System settings for the inline keywords.
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.In case the given data type T is not a dense or sparse vector type and in...
Definition: TransposeFlag.h:63
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: DynamicVector.h:1692
#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.