All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <stdexcept>
48 #include <blaze/math/Forward.h>
49 #include <blaze/math/Intrinsics.h>
50 #include <blaze/math/shims/Clear.h>
63 #include <blaze/system/CacheSize.h>
64 #include <blaze/system/Restrict.h>
65 #include <blaze/system/Streaming.h>
68 #include <blaze/util/Assert.h>
75 #include <blaze/util/DisableIf.h>
76 #include <blaze/util/EnableIf.h>
77 #include <blaze/util/Memory.h>
78 #include <blaze/util/Null.h>
79 #include <blaze/util/Template.h>
80 #include <blaze/util/Types.h>
84 
85 
86 namespace blaze {
87 
88 //=================================================================================================
89 //
90 // CLASS DEFINITION
91 //
92 //=================================================================================================
93 
94 //*************************************************************************************************
158 template< typename Type // Data type of the vector
159  , bool TF = defaultTransposeFlag > // Transpose flag
160 class DynamicVector : public DenseVector< DynamicVector<Type,TF>, TF >
161 {
162  private:
163  //**Type definitions****************************************************************************
165  //**********************************************************************************************
166 
167  public:
168  //**Type definitions****************************************************************************
170  typedef This ResultType;
172  typedef Type ElementType;
173  typedef typename IT::Type IntrinsicType;
174  typedef const Type& ReturnType;
175  typedef const DynamicVector& CompositeType;
176  typedef Type& Reference;
177  typedef const Type& ConstReference;
178  typedef Type* Pointer;
179  typedef const Type* ConstPointer;
182  //**********************************************************************************************
183 
184  //**Rebind struct definition********************************************************************
187  template< typename ET > // Data type of the other vector
188  struct Rebind {
190  };
191  //**********************************************************************************************
192 
193  //**Compilation flags***************************************************************************
195 
199  enum { vectorizable = IsVectorizable<Type>::value };
200 
202 
205  enum { smpAssignable = !IsSMPAssignable<Type>::value };
206  //**********************************************************************************************
207 
208  //**Constructors********************************************************************************
211  explicit inline DynamicVector();
212  explicit inline DynamicVector( size_t n );
213  explicit inline DynamicVector( size_t n, const Type& init );
214  template< typename Other > explicit inline DynamicVector( size_t n, const Other* array );
215 
216  template< typename Other, size_t N >
217  explicit inline DynamicVector( const Other (&array)[N] );
218 
219  inline DynamicVector( const DynamicVector& v );
220  template< typename VT > inline DynamicVector( const Vector<VT,TF>& v );
222  //**********************************************************************************************
223 
224  //**Destructor**********************************************************************************
227  inline ~DynamicVector();
229  //**********************************************************************************************
230 
231  //**Data access functions***********************************************************************
234  inline Reference operator[]( size_t index );
235  inline ConstReference operator[]( size_t index ) const;
236  inline Pointer data ();
237  inline ConstPointer data () const;
238  inline Iterator begin ();
239  inline ConstIterator begin () const;
240  inline ConstIterator cbegin() const;
241  inline Iterator end ();
242  inline ConstIterator end () const;
243  inline ConstIterator cend () const;
245  //**********************************************************************************************
246 
247  //**Assignment operators************************************************************************
250  template< typename Other, size_t N >
251  inline DynamicVector& operator=( const Other (&array)[N] );
252 
253  inline DynamicVector& operator= ( const Type& rhs );
254  inline DynamicVector& operator= ( const DynamicVector& rhs );
255  template< typename VT > inline DynamicVector& operator= ( const Vector<VT,TF>& rhs );
256  template< typename VT > inline DynamicVector& operator+=( const Vector<VT,TF>& rhs );
257  template< typename VT > inline DynamicVector& operator-=( const Vector<VT,TF>& rhs );
258  template< typename VT > inline DynamicVector& operator*=( const Vector<VT,TF>& rhs );
259 
260  template< typename Other >
261  inline typename EnableIf< IsNumeric<Other>, DynamicVector >::Type&
262  operator*=( Other rhs );
263 
264  template< typename Other >
265  inline typename EnableIf< IsNumeric<Other>, DynamicVector >::Type&
266  operator/=( Other rhs );
268  //**********************************************************************************************
269 
270  //**Utility functions***************************************************************************
273  inline size_t size() const;
274  inline size_t capacity() const;
275  inline size_t nonZeros() const;
276  inline void reset();
277  inline void clear();
278  inline void resize( size_t n, bool preserve=true );
279  inline void extend( size_t n, bool preserve=true );
280  inline void reserve( size_t n );
281  template< typename Other > inline DynamicVector& scale( const Other& scalar );
282  inline void swap( DynamicVector& v ) /* throw() */;
284  //**********************************************************************************************
285 
286  private:
287  //**********************************************************************************************
289  template< typename VT >
291  struct VectorizedAssign {
292  enum { value = vectorizable && VT::vectorizable &&
293  IsSame<Type,typename VT::ElementType>::value };
294  };
296  //**********************************************************************************************
297 
298  //**********************************************************************************************
300  template< typename VT >
302  struct VectorizedAddAssign {
303  enum { value = vectorizable && VT::vectorizable &&
304  IsSame<Type,typename VT::ElementType>::value &&
305  IntrinsicTrait<Type>::addition };
306  };
308  //**********************************************************************************************
309 
310  //**********************************************************************************************
312  template< typename VT >
314  struct VectorizedSubAssign {
315  enum { value = vectorizable && VT::vectorizable &&
316  IsSame<Type,typename VT::ElementType>::value &&
317  IntrinsicTrait<Type>::subtraction };
318  };
320  //**********************************************************************************************
321 
322  //**********************************************************************************************
324  template< typename VT >
326  struct VectorizedMultAssign {
327  enum { value = vectorizable && VT::vectorizable &&
328  IsSame<Type,typename VT::ElementType>::value &&
329  IntrinsicTrait<Type>::multiplication };
330  };
332  //**********************************************************************************************
333 
334  public:
335  //**Expression template evaluation functions****************************************************
338  template< typename Other > inline bool canAlias ( const Other* alias ) const;
339  template< typename Other > inline bool isAliased( const Other* alias ) const;
340 
341  inline bool isAligned () const;
342  inline bool canSMPAssign() const;
343 
344  inline IntrinsicType load ( size_t index ) const;
345  inline IntrinsicType loadu ( size_t index ) const;
346  inline void store ( size_t index, const IntrinsicType& value );
347  inline void storeu( size_t index, const IntrinsicType& value );
348  inline void stream( size_t index, const IntrinsicType& value );
349 
350  template< typename VT >
351  inline typename DisableIf< VectorizedAssign<VT> >::Type
352  assign( const DenseVector<VT,TF>& rhs );
353 
354  template< typename VT >
355  inline typename EnableIf< VectorizedAssign<VT> >::Type
356  assign( const DenseVector<VT,TF>& rhs );
357 
358  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
359 
360  template< typename VT >
361  inline typename DisableIf< VectorizedAddAssign<VT> >::Type
362  addAssign( const DenseVector<VT,TF>& rhs );
363 
364  template< typename VT >
365  inline typename EnableIf< VectorizedAddAssign<VT> >::Type
366  addAssign( const DenseVector<VT,TF>& rhs );
367 
368  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
369 
370  template< typename VT >
371  inline typename DisableIf< VectorizedSubAssign<VT> >::Type
372  subAssign( const DenseVector<VT,TF>& rhs );
373 
374  template< typename VT >
375  inline typename EnableIf< VectorizedSubAssign<VT> >::Type
376  subAssign( const DenseVector<VT,TF>& rhs );
377 
378  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
379 
380  template< typename VT >
381  inline typename DisableIf< VectorizedMultAssign<VT> >::Type
382  multAssign( const DenseVector<VT,TF>& rhs );
383 
384  template< typename VT >
385  inline typename EnableIf< VectorizedMultAssign<VT> >::Type
386  multAssign( const DenseVector<VT,TF>& rhs );
387 
388  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
390  //**********************************************************************************************
391 
392  private:
393  //**Utility functions***************************************************************************
396  inline size_t adjustCapacity( size_t minCapacity ) const;
398  //**********************************************************************************************
399 
400  //**Member variables****************************************************************************
403  size_t size_;
404  size_t capacity_;
406 
412  //**********************************************************************************************
413 
414  //**Compile time checks*************************************************************************
421  //**********************************************************************************************
422 };
423 //*************************************************************************************************
424 
425 
426 
427 
428 //=================================================================================================
429 //
430 // CONSTRUCTORS
431 //
432 //=================================================================================================
433 
434 //*************************************************************************************************
437 template< typename Type // Data type of the vector
438  , bool TF > // Transpose flag
440  : size_ ( 0UL ) // The current size/dimension of the vector
441  , capacity_( 0UL ) // The maximum capacity of the vector
442  , v_ ( NULL ) // The vector elements
443 {}
444 //*************************************************************************************************
445 
446 
447 //*************************************************************************************************
455 template< typename Type // Data type of the vector
456  , bool TF > // Transpose flag
458  : size_ ( n ) // The current size/dimension of the vector
459  , capacity_( adjustCapacity( n ) ) // The maximum capacity of the vector
460  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
461 {
463  for( size_t i=size_; i<capacity_; ++i )
464  v_[i] = Type();
465  }
466 }
467 //*************************************************************************************************
468 
469 
470 //*************************************************************************************************
478 template< typename Type // Data type of the vector
479  , bool TF > // Transpose flag
480 inline DynamicVector<Type,TF>::DynamicVector( size_t n, const Type& init )
481  : size_ ( n ) // The current size/dimension of the vector
482  , capacity_( adjustCapacity( n ) ) // The maximum capacity of the vector
483  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
484 {
485  for( size_t i=0UL; i<size_; ++i )
486  v_[i] = init;
487 
489  for( size_t i=size_; i<capacity_; ++i )
490  v_[i] = Type();
491  }
492 }
493 //*************************************************************************************************
494 
495 
496 //*************************************************************************************************
516 template< typename Type // Data type of the vector
517  , bool TF > // Transpose flag
518 template< typename Other > // Data type of the initialization array
519 inline DynamicVector<Type,TF>::DynamicVector( size_t n, const Other* array )
520  : size_ ( n ) // The current size/dimension of the vector
521  , capacity_( adjustCapacity( n ) ) // The maximum capacity of the vector
522  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
523 {
524  for( size_t i=0UL; i<n; ++i )
525  v_[i] = array[i];
526 
528  for( size_t i=n; i<capacity_; ++i )
529  v_[i] = Type();
530  }
531 }
532 //*************************************************************************************************
533 
534 
535 //*************************************************************************************************
552 template< typename Type // Data type of the vector
553  , bool TF > // Transpose flag
554 template< typename Other // Data type of the initialization array
555  , size_t N > // Dimension of the initialization array
556 inline DynamicVector<Type,TF>::DynamicVector( const Other (&array)[N] )
557  : size_ ( N ) // The current size/dimension of the vector
558  , capacity_( adjustCapacity( N ) ) // The maximum capacity of the vector
559  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
560 {
561  for( size_t i=0UL; i<N; ++i )
562  v_[i] = array[i];
563 
565  for( size_t i=N; i<capacity_; ++i )
566  v_[i] = Type();
567  }
568 }
569 //*************************************************************************************************
570 
571 
572 //*************************************************************************************************
580 template< typename Type // Data type of the vector
581  , bool TF > // Transpose flag
583  : size_ ( v.size_ ) // The current size/dimension of the vector
584  , capacity_( adjustCapacity( v.size_ ) ) // The maximum capacity of the vector
585  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
586 {
587  BLAZE_INTERNAL_ASSERT( capacity_ <= v.capacity_, "Invalid capacity estimation" );
588 
589  for( size_t i=0UL; i<capacity_; ++i )
590  v_[i] = v.v_[i];
591 }
592 //*************************************************************************************************
593 
594 
595 //*************************************************************************************************
600 template< typename Type // Data type of the vector
601  , bool TF > // Transpose flag
602 template< typename VT > // Type of the foreign vector
604  : size_ ( (~v).size() ) // The current size/dimension of the vector
605  , capacity_( adjustCapacity( size_ ) ) // The maximum capacity of the vector
606  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
607 {
608  for( size_t i=( IsSparseVector<VT>::value ? 0UL : size_ );
609  i<( IsVectorizable<Type>::value ? capacity_ : size_ ); ++i ) {
610  v_[i] = Type();
611  }
612 
613  smpAssign( *this, ~v );
614 }
615 //*************************************************************************************************
616 
617 
618 
619 
620 //=================================================================================================
621 //
622 // DESTRUCTOR
623 //
624 //=================================================================================================
625 
626 //*************************************************************************************************
629 template< typename Type // Data type of the vector
630  , bool TF > // Transpose flag
632 {
633  deallocate( v_ );
634 }
635 //*************************************************************************************************
636 
637 
638 
639 
640 //=================================================================================================
641 //
642 // DATA ACCESS FUNCTIONS
643 //
644 //=================================================================================================
645 
646 //*************************************************************************************************
652 template< typename Type // Data type of the vector
653  , bool TF > // Transpose flag
654 inline typename DynamicVector<Type,TF>::Reference
656 {
657  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
658  return v_[index];
659 }
660 //*************************************************************************************************
661 
662 
663 //*************************************************************************************************
669 template< typename Type // Data type of the vector
670  , bool TF > // Transpose flag
673 {
674  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
675  return v_[index];
676 }
677 //*************************************************************************************************
678 
679 
680 //*************************************************************************************************
687 template< typename Type // Data type of the vector
688  , bool TF > // Transpose flag
690 {
691  return v_;
692 }
693 //*************************************************************************************************
694 
695 
696 //*************************************************************************************************
703 template< typename Type // Data type of the vector
704  , bool TF > // Transpose flag
706 {
707  return v_;
708 }
709 //*************************************************************************************************
710 
711 
712 //*************************************************************************************************
717 template< typename Type // Data type of the vector
718  , bool TF > // Transpose flag
720 {
721  return Iterator( v_ );
722 }
723 //*************************************************************************************************
724 
725 
726 //*************************************************************************************************
731 template< typename Type // Data type of the vector
732  , bool TF > // Transpose flag
734 {
735  return ConstIterator( v_ );
736 }
737 //*************************************************************************************************
738 
739 
740 //*************************************************************************************************
745 template< typename Type // Data type of the vector
746  , bool TF > // Transpose flag
748 {
749  return ConstIterator( v_ );
750 }
751 //*************************************************************************************************
752 
753 
754 //*************************************************************************************************
759 template< typename Type // Data type of the vector
760  , bool TF > // Transpose flag
762 {
763  return Iterator( v_ + size_ );
764 }
765 //*************************************************************************************************
766 
767 
768 //*************************************************************************************************
773 template< typename Type // Data type of the vector
774  , bool TF > // Transpose flag
776 {
777  return ConstIterator( v_ + size_ );
778 }
779 //*************************************************************************************************
780 
781 
782 //*************************************************************************************************
787 template< typename Type // Data type of the vector
788  , bool TF > // Transpose flag
790 {
791  return ConstIterator( v_ + size_ );
792 }
793 //*************************************************************************************************
794 
795 
796 
797 
798 //=================================================================================================
799 //
800 // ASSIGNMENT OPERATORS
801 //
802 //=================================================================================================
803 
804 //*************************************************************************************************
822 template< typename Type // Data type of the vector
823  , bool TF > // Transpose flag
824 template< typename Other // Data type of the initialization array
825  , size_t N > // Dimension of the initialization array
827 {
828  resize( N, false );
829 
830  for( size_t i=0UL; i<N; ++i )
831  v_[i] = array[i];
832 
833  return *this;
834 }
835 //*************************************************************************************************
836 
837 
838 //*************************************************************************************************
844 template< typename Type // Data type of the vector
845  , bool TF > // Transpose flag
847 {
848  for( size_t i=0UL; i<size_; ++i )
849  v_[i] = rhs;
850  return *this;
851 }
852 //*************************************************************************************************
853 
854 
855 //*************************************************************************************************
864 template< typename Type // Data type of the vector
865  , bool TF > // Transpose flag
867 {
868  if( &rhs == this ) return *this;
869 
870  resize( rhs.size_, false );
871  smpAssign( *this, ~rhs );
872 
873  return *this;
874 }
875 //*************************************************************************************************
876 
877 
878 //*************************************************************************************************
886 template< typename Type // Data type of the vector
887  , bool TF > // Transpose flag
888 template< typename VT > // Type of the right-hand side vector
890 {
891  if( (~rhs).canAlias( this ) ) {
892  DynamicVector tmp( ~rhs );
893  swap( tmp );
894  }
895  else {
896  resize( (~rhs).size(), false );
898  reset();
899  smpAssign( *this, ~rhs );
900  }
901 
902  return *this;
903 }
904 //*************************************************************************************************
905 
906 
907 //*************************************************************************************************
917 template< typename Type // Data type of the vector
918  , bool TF > // Transpose flag
919 template< typename VT > // Type of the right-hand side vector
921 {
922  if( (~rhs).size() != size_ )
923  throw std::invalid_argument( "Vector sizes do not match" );
924 
925  if( (~rhs).canAlias( this ) ) {
926  typename VT::ResultType tmp( ~rhs );
927  smpAddAssign( *this, tmp );
928  }
929  else {
930  smpAddAssign( *this, ~rhs );
931  }
932 
933  return *this;
934 }
935 //*************************************************************************************************
936 
937 
938 //*************************************************************************************************
949 template< typename Type // Data type of the vector
950  , bool TF > // Transpose flag
951 template< typename VT > // Type of the right-hand side vector
953 {
954  if( (~rhs).size() != size_ )
955  throw std::invalid_argument( "Vector sizes do not match" );
956 
957  if( (~rhs).canAlias( this ) ) {
958  typename VT::ResultType tmp( ~rhs );
959  smpSubAssign( *this, tmp );
960  }
961  else {
962  smpSubAssign( *this, ~rhs );
963  }
964 
965  return *this;
966 }
967 //*************************************************************************************************
968 
969 
970 //*************************************************************************************************
981 template< typename Type // Data type of the vector
982  , bool TF > // Transpose flag
983 template< typename VT > // Type of the right-hand side vector
985 {
986  if( (~rhs).size() != size_ )
987  throw std::invalid_argument( "Vector sizes do not match" );
988 
989  if( (~rhs).canAlias( this ) || IsSparseVector<VT>::value ) {
990  DynamicVector<Type,TF> tmp( *this * (~rhs) );
991  swap( tmp );
992  }
993  else {
994  smpMultAssign( *this, ~rhs );
995  }
996 
997  return *this;
998 }
999 //*************************************************************************************************
1000 
1001 
1002 //*************************************************************************************************
1009 template< typename Type // Data type of the vector
1010  , bool TF > // Transpose flag
1011 template< typename Other > // Data type of the right-hand side scalar
1012 inline typename EnableIf< IsNumeric<Other>, DynamicVector<Type,TF> >::Type&
1014 {
1015  smpAssign( *this, (*this) * rhs );
1016  return *this;
1017 }
1018 //*************************************************************************************************
1019 
1020 
1021 //*************************************************************************************************
1030 template< typename Type // Data type of the vector
1031  , bool TF > // Transpose flag
1032 template< typename Other > // Data type of the right-hand side scalar
1033 inline typename EnableIf< IsNumeric<Other>, DynamicVector<Type,TF> >::Type&
1035 {
1036  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1037 
1038  smpAssign( *this, (*this) / rhs );
1039  return *this;
1040 }
1041 //*************************************************************************************************
1042 
1043 
1044 
1045 
1046 //=================================================================================================
1047 //
1048 // UTILITY FUNCTIONS
1049 //
1050 //=================================================================================================
1051 
1052 //*************************************************************************************************
1057 template< typename Type // Data type of the vector
1058  , bool TF > // Transpose flag
1059 inline size_t DynamicVector<Type,TF>::size() const
1060 {
1061  return size_;
1062 }
1063 //*************************************************************************************************
1064 
1065 
1066 //*************************************************************************************************
1071 template< typename Type // Data type of the vector
1072  , bool TF > // Transpose flag
1074 {
1075  return capacity_;
1076 }
1077 //*************************************************************************************************
1078 
1079 
1080 //*************************************************************************************************
1088 template< typename Type // Data type of the vector
1089  , bool TF > // Transpose flag
1091 {
1092  size_t nonzeros( 0 );
1093 
1094  for( size_t i=0UL; i<size_; ++i ) {
1095  if( !isDefault( v_[i] ) )
1096  ++nonzeros;
1097  }
1098 
1099  return nonzeros;
1100 }
1101 //*************************************************************************************************
1102 
1103 
1104 //*************************************************************************************************
1109 template< typename Type // Data type of the vector
1110  , bool TF > // Transpose flag
1112 {
1113  using blaze::clear;
1114  for( size_t i=0UL; i<size_; ++i )
1115  clear( v_[i] );
1116 }
1117 //*************************************************************************************************
1118 
1119 
1120 //*************************************************************************************************
1127 template< typename Type // Data type of the vector
1128  , bool TF > // Transpose flag
1130 {
1131  resize( 0UL, false );
1132 }
1133 //*************************************************************************************************
1134 
1135 
1136 //*************************************************************************************************
1165 template< typename Type // Data type of the vector
1166  , bool TF > // Transpose flag
1167 inline void DynamicVector<Type,TF>::resize( size_t n, bool preserve )
1168 {
1169  if( n > capacity_ )
1170  {
1171  // Allocating a new array
1172  const size_t newCapacity( adjustCapacity( n ) );
1173  Type* BLAZE_RESTRICT tmp = allocate<Type>( newCapacity );
1174 
1175  // Initializing the new array
1176  if( preserve ) {
1177  std::copy( v_, v_+size_, tmp );
1178  }
1179 
1181  for( size_t i=size_; i<newCapacity; ++i )
1182  tmp[i] = Type();
1183  }
1184 
1185  // Replacing the old array
1186  std::swap( v_, tmp );
1187  deallocate( tmp );
1188  capacity_ = newCapacity;
1189  }
1190  else if( IsVectorizable<Type>::value && n < size_ )
1191  {
1192  for( size_t i=n; i<size_; ++i )
1193  v_[i] = Type();
1194  }
1195 
1196  size_ = n;
1197 }
1198 //*************************************************************************************************
1199 
1200 
1201 //*************************************************************************************************
1213 template< typename Type // Data type of the vector
1214  , bool TF > // Transpose flag
1215 inline void DynamicVector<Type,TF>::extend( size_t n, bool preserve )
1216 {
1217  resize( size_+n, preserve );
1218 }
1219 //*************************************************************************************************
1220 
1221 
1222 //*************************************************************************************************
1231 template< typename Type // Data type of the vector
1232  , bool TF > // Transpose flag
1233 inline void DynamicVector<Type,TF>::reserve( size_t n )
1234 {
1235  if( n > capacity_ )
1236  {
1237  // Allocating a new array
1238  const size_t newCapacity( adjustCapacity( n ) );
1239  Type* BLAZE_RESTRICT tmp = allocate<Type>( newCapacity );
1240 
1241  // Initializing the new array
1242  std::copy( v_, v_+size_, tmp );
1243 
1245  for( size_t i=size_; i<newCapacity; ++i )
1246  tmp[i] = Type();
1247  }
1248 
1249  // Replacing the old array
1250  std::swap( tmp, v_ );
1251  deallocate( tmp );
1252  capacity_ = newCapacity;
1253  }
1254 }
1255 //*************************************************************************************************
1256 
1257 
1258 //*************************************************************************************************
1264 template< typename Type // Data type of the vector
1265  , bool TF > // Transpose flag
1266 template< typename Other > // Data type of the scalar value
1268 {
1269  for( size_t i=0UL; i<size_; ++i )
1270  v_[i] *= scalar;
1271  return *this;
1272 }
1273 //*************************************************************************************************
1274 
1275 
1276 //*************************************************************************************************
1283 template< typename Type // Data type of the vector
1284  , bool TF > // Transpose flag
1285 inline void DynamicVector<Type,TF>::swap( DynamicVector& v ) /* throw() */
1286 {
1287  std::swap( size_, v.size_ );
1289  std::swap( v_, v.v_ );
1290 }
1291 //*************************************************************************************************
1292 
1293 
1294 //*************************************************************************************************
1300 template< typename Type // Data type of the vector
1301  , bool TF > // Transpose flag
1302 inline size_t DynamicVector<Type,TF>::adjustCapacity( size_t minCapacity ) const
1303 {
1305  return minCapacity + ( IT::size - ( minCapacity % IT::size ) ) % IT::size;
1306  else return minCapacity;
1307 }
1308 //*************************************************************************************************
1309 
1310 
1311 
1312 
1313 //=================================================================================================
1314 //
1315 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1316 //
1317 //=================================================================================================
1318 
1319 //*************************************************************************************************
1329 template< typename Type // Data type of the vector
1330  , bool TF > // Transpose flag
1331 template< typename Other > // Data type of the foreign expression
1332 inline bool DynamicVector<Type,TF>::canAlias( const Other* alias ) const
1333 {
1334  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1335 }
1336 //*************************************************************************************************
1337 
1338 
1339 //*************************************************************************************************
1349 template< typename Type // Data type of the vector
1350  , bool TF > // Transpose flag
1351 template< typename Other > // Data type of the foreign expression
1352 inline bool DynamicVector<Type,TF>::isAliased( const Other* alias ) const
1353 {
1354  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1355 }
1356 //*************************************************************************************************
1357 
1358 
1359 //*************************************************************************************************
1368 template< typename Type // Data type of the vector
1369  , bool TF > // Transpose flag
1371 {
1372  return true;
1373 }
1374 //*************************************************************************************************
1375 
1376 
1377 //*************************************************************************************************
1387 template< typename Type // Data type of the vector
1388  , bool TF > // Transpose flag
1390 {
1391  return ( size() > SMP_DVECASSIGN_THRESHOLD );
1392 }
1393 //*************************************************************************************************
1394 
1395 
1396 //*************************************************************************************************
1409 template< typename Type // Data type of the vector
1410  , bool TF > // Transpose flag
1412  DynamicVector<Type,TF>::load( size_t index ) const
1413 {
1414  using blaze::load;
1415 
1417 
1418  BLAZE_INTERNAL_ASSERT( index < size_ , "Invalid vector access index" );
1419  BLAZE_INTERNAL_ASSERT( index + IT::size <= capacity_, "Invalid vector access index" );
1420  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL , "Invalid vector access index" );
1421 
1422  return load( v_+index );
1423 }
1424 //*************************************************************************************************
1425 
1426 
1427 //*************************************************************************************************
1440 template< typename Type // Data type of the vector
1441  , bool TF > // Transpose flag
1443  DynamicVector<Type,TF>::loadu( size_t index ) const
1444 {
1445  using blaze::loadu;
1446 
1448 
1449  BLAZE_INTERNAL_ASSERT( index < size_ , "Invalid vector access index" );
1450  BLAZE_INTERNAL_ASSERT( index + IT::size <= capacity_, "Invalid vector access index" );
1451 
1452  return loadu( v_+index );
1453 }
1454 //*************************************************************************************************
1455 
1456 
1457 //*************************************************************************************************
1471 template< typename Type // Data type of the vector
1472  , bool TF > // Transpose flag
1473 inline void DynamicVector<Type,TF>::store( size_t index, const IntrinsicType& value )
1474 {
1475  using blaze::store;
1476 
1478 
1479  BLAZE_INTERNAL_ASSERT( index < size_ , "Invalid vector access index" );
1480  BLAZE_INTERNAL_ASSERT( index + IT::size <= capacity_, "Invalid vector access index" );
1481  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL , "Invalid vector access index" );
1482 
1483  store( v_+index, value );
1484 }
1485 //*************************************************************************************************
1486 
1487 
1488 //*************************************************************************************************
1502 template< typename Type // Data type of the vector
1503  , bool TF > // Transpose flag
1504 inline void DynamicVector<Type,TF>::storeu( size_t index, const IntrinsicType& value )
1505 {
1506  using blaze::storeu;
1507 
1509 
1510  BLAZE_INTERNAL_ASSERT( index < size_ , "Invalid vector access index" );
1511  BLAZE_INTERNAL_ASSERT( index + IT::size <= capacity_, "Invalid vector access index" );
1512 
1513  storeu( v_+index, value );
1514 }
1515 //*************************************************************************************************
1516 
1517 
1518 //*************************************************************************************************
1532 template< typename Type // Data type of the vector
1533  , bool TF > // Transpose flag
1534 inline void DynamicVector<Type,TF>::stream( size_t index, const IntrinsicType& value )
1535 {
1536  using blaze::stream;
1537 
1539 
1540  BLAZE_INTERNAL_ASSERT( index < size_ , "Invalid vector access index" );
1541  BLAZE_INTERNAL_ASSERT( index + IT::size <= capacity_, "Invalid vector access index" );
1542  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL , "Invalid vector access index" );
1543 
1544  stream( v_+index, value );
1545 }
1546 //*************************************************************************************************
1547 
1548 
1549 //*************************************************************************************************
1560 template< typename Type // Data type of the vector
1561  , bool TF > // Transpose flag
1562 template< typename VT > // Type of the right-hand side dense vector
1563 inline typename DisableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1565 {
1566  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1567 
1568  const size_t iend( (~rhs).size() & size_t(-2) );
1569  for( size_t i=0UL; i<iend; i+=2UL ) {
1570  v_[i ] = (~rhs)[i ];
1571  v_[i+1UL] = (~rhs)[i+1UL];
1572  }
1573  if( iend < (~rhs).size() )
1574  v_[iend] = (~rhs)[iend];
1575 }
1576 //*************************************************************************************************
1577 
1578 
1579 //*************************************************************************************************
1590 template< typename Type // Data type of the vector
1591  , bool TF > // Transpose flag
1592 template< typename VT > // Type of the right-hand side dense vector
1593 inline typename EnableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1595 {
1596  using blaze::store;
1597  using blaze::stream;
1598 
1599  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1600 
1602 
1603  if( useStreaming && size_ > ( cacheSize/( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
1604  {
1605  for( size_t i=0UL; i<size_; i+=IT::size ) {
1606  stream( v_+i, (~rhs).load(i) );
1607  }
1608  }
1609  else
1610  {
1611  const size_t iend( size_ & size_t(-IT::size*4) );
1612  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
1613 
1614  typename VT::ConstIterator it( (~rhs).begin() );
1615  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1616  store( v_+i , it.load() ); it += IT::size;
1617  store( v_+i+IT::size , it.load() ); it += IT::size;
1618  store( v_+i+IT::size*2UL, it.load() ); it += IT::size;
1619  store( v_+i+IT::size*3UL, it.load() ); it += IT::size;
1620  }
1621  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
1622  store( v_+i, it.load() );
1623  }
1624  }
1625 }
1626 //*************************************************************************************************
1627 
1628 
1629 //*************************************************************************************************
1640 template< typename Type // Data type of the vector
1641  , bool TF > // Transpose flag
1642 template< typename VT > // Type of the right-hand side sparse vector
1644 {
1645  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1646 
1647  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1648  v_[element->index()] = element->value();
1649 }
1650 //*************************************************************************************************
1651 
1652 
1653 //*************************************************************************************************
1664 template< typename Type // Data type of the vector
1665  , bool TF > // Transpose flag
1666 template< typename VT > // Type of the right-hand side dense vector
1667 inline typename DisableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1669 {
1670  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1671 
1672  const size_t iend( (~rhs).size() & size_t(-2) );
1673  for( size_t i=0UL; i<iend; i+=2UL ) {
1674  v_[i ] += (~rhs)[i ];
1675  v_[i+1UL] += (~rhs)[i+1UL];
1676  }
1677  if( iend < (~rhs).size() )
1678  v_[iend] += (~rhs)[iend];
1679 }
1680 //*************************************************************************************************
1681 
1682 
1683 //*************************************************************************************************
1694 template< typename Type // Data type of the vector
1695  , bool TF > // Transpose flag
1696 template< typename VT > // Type of the right-hand side dense vector
1697 inline typename EnableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1699 {
1700  using blaze::load;
1701  using blaze::store;
1702 
1703  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1704 
1706 
1707  const size_t iend( size_ & size_t(-IT::size*4) );
1708  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
1709 
1710  typename VT::ConstIterator it( (~rhs).begin() );
1711  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1712  store( v_+i , load(v_+i ) + it.load() ); it += IT::size;
1713  store( v_+i+IT::size , load(v_+i+IT::size ) + it.load() ); it += IT::size;
1714  store( v_+i+IT::size*2UL, load(v_+i+IT::size*2UL) + it.load() ); it += IT::size;
1715  store( v_+i+IT::size*3UL, load(v_+i+IT::size*3UL) + it.load() ); it += IT::size;
1716  }
1717  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
1718  store( v_+i, load(v_+i) + it.load() );
1719  }
1720 }
1721 //*************************************************************************************************
1722 
1723 
1724 //*************************************************************************************************
1735 template< typename Type // Data type of the vector
1736  , bool TF > // Transpose flag
1737 template< typename VT > // Type of the right-hand side sparse vector
1739 {
1740  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1741 
1742  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1743  v_[element->index()] += element->value();
1744 }
1745 //*************************************************************************************************
1746 
1747 
1748 //*************************************************************************************************
1759 template< typename Type // Data type of the vector
1760  , bool TF > // Transpose flag
1761 template< typename VT > // Type of the right-hand side dense vector
1762 inline typename DisableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1764 {
1765  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1766 
1767  const size_t iend( (~rhs).size() & size_t(-2) );
1768  for( size_t i=0UL; i<iend; i+=2UL ) {
1769  v_[i ] -= (~rhs)[i ];
1770  v_[i+1UL] -= (~rhs)[i+1UL];
1771  }
1772  if( iend < (~rhs).size() )
1773  v_[iend] -= (~rhs)[iend];
1774 }
1775 //*************************************************************************************************
1776 
1777 
1778 //*************************************************************************************************
1789 template< typename Type // Data type of the vector
1790  , bool TF > // Transpose flag
1791 template< typename VT > // Type of the right-hand side dense vector
1792 inline typename EnableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1794 {
1795  using blaze::load;
1796  using blaze::store;
1797 
1798  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1799 
1801 
1802  const size_t iend( size_ & size_t(-IT::size*4) );
1803  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
1804 
1805  typename VT::ConstIterator it( (~rhs).begin() );
1806  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1807  store( v_+i , load(v_+i ) - it.load() ); it += IT::size;
1808  store( v_+i+IT::size , load(v_+i+IT::size ) - it.load() ); it += IT::size;
1809  store( v_+i+IT::size*2UL, load(v_+i+IT::size*2UL) - it.load() ); it += IT::size;
1810  store( v_+i+IT::size*3UL, load(v_+i+IT::size*3UL) - it.load() ); it += IT::size;
1811  }
1812  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
1813  store( v_+i, load(v_+i) - it.load() );
1814  }
1815 }
1816 //*************************************************************************************************
1817 
1818 
1819 //*************************************************************************************************
1830 template< typename Type // Data type of the vector
1831  , bool TF > // Transpose flag
1832 template< typename VT > // Type of the right-hand side sparse vector
1834 {
1835  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1836 
1837  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1838  v_[element->index()] -= element->value();
1839 }
1840 //*************************************************************************************************
1841 
1842 
1843 //*************************************************************************************************
1854 template< typename Type // Data type of the vector
1855  , bool TF > // Transpose flag
1856 template< typename VT > // Type of the right-hand side dense vector
1857 inline typename DisableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1859 {
1860  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1861 
1862  const size_t iend( (~rhs).size() & size_t(-2) );
1863  for( size_t i=0UL; i<iend; i+=2UL ) {
1864  v_[i ] *= (~rhs)[i ];
1865  v_[i+1UL] *= (~rhs)[i+1UL];
1866  }
1867  if( iend < (~rhs).size() )
1868  v_[iend] *= (~rhs)[iend];
1869 }
1870 //*************************************************************************************************
1871 
1872 
1873 //*************************************************************************************************
1884 template< typename Type // Data type of the vector
1885  , bool TF > // Transpose flag
1886 template< typename VT > // Type of the right-hand side dense vector
1887 inline typename EnableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1889 {
1890  using blaze::load;
1891  using blaze::store;
1892 
1893  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1894 
1896 
1897  const size_t iend( size_ & size_t(-IT::size*4) );
1898  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
1899 
1900  typename VT::ConstIterator it( (~rhs).begin() );
1901  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1902  store( v_+i , load(v_+i ) * it.load() ); it += IT::size;
1903  store( v_+i+IT::size , load(v_+i+IT::size ) * it.load() ); it += IT::size;
1904  store( v_+i+IT::size*2UL, load(v_+i+IT::size*2UL) * it.load() ); it += IT::size;
1905  store( v_+i+IT::size*3UL, load(v_+i+IT::size*3UL) * it.load() ); it += IT::size;
1906  }
1907  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
1908  store( v_+i, load(v_+i) * it.load() );
1909  }
1910 }
1911 //*************************************************************************************************
1912 
1913 
1914 //*************************************************************************************************
1925 template< typename Type // Data type of the vector
1926  , bool TF > // Transpose flag
1927 template< typename VT > // Type of the right-hand side sparse vector
1929 {
1930  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1931 
1932  const DynamicVector tmp( serial( *this ) );
1933 
1934  reset();
1935 
1936  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1937  v_[element->index()] = tmp[element->index()] * element->value();
1938 }
1939 //*************************************************************************************************
1940 
1941 
1942 
1943 
1944 //=================================================================================================
1945 //
1946 // DYNAMICVECTOR OPERATORS
1947 //
1948 //=================================================================================================
1949 
1950 //*************************************************************************************************
1953 template< typename Type, bool TF >
1954 inline void reset( DynamicVector<Type,TF>& v );
1955 
1956 template< typename Type, bool TF >
1957 inline void clear( DynamicVector<Type,TF>& v );
1958 
1959 template< typename Type, bool TF >
1960 inline bool isDefault( const DynamicVector<Type,TF>& v );
1961 
1962 template< typename Type, bool TF >
1963 inline void swap( DynamicVector<Type,TF>& a, DynamicVector<Type,TF>& b ) /* throw() */;
1964 
1965 template< typename Type, bool TF >
1966 inline void move( DynamicVector<Type,TF>& dst, DynamicVector<Type,TF>& src ) /* throw() */;
1968 //*************************************************************************************************
1969 
1970 
1971 //*************************************************************************************************
1978 template< typename Type // Data type of the vector
1979  , bool TF > // Transpose flag
1981 {
1982  v.reset();
1983 }
1984 //*************************************************************************************************
1985 
1986 
1987 //*************************************************************************************************
1994 template< typename Type // Data type of the vector
1995  , bool TF > // Transpose flag
1997 {
1998  v.clear();
1999 }
2000 //*************************************************************************************************
2001 
2002 
2003 //*************************************************************************************************
2020 template< typename Type // Data type of the vector
2021  , bool TF > // Transpose flag
2022 inline bool isDefault( const DynamicVector<Type,TF>& v )
2023 {
2024  return ( v.size() == 0UL );
2025 }
2026 //*************************************************************************************************
2027 
2028 
2029 //*************************************************************************************************
2038 template< typename Type // Data type of the vector
2039  , bool TF > // Transpose flag
2040 inline void swap( DynamicVector<Type,TF>& a, DynamicVector<Type,TF>& b ) /* throw() */
2041 {
2042  a.swap( b );
2043 }
2044 //*************************************************************************************************
2045 
2046 
2047 //*************************************************************************************************
2056 template< typename Type // Data type of the vector
2057  , bool TF > // Transpose flag
2058 inline void move( DynamicVector<Type,TF>& dst, DynamicVector<Type,TF>& src ) /* throw() */
2059 {
2060  dst.swap( src );
2061 }
2062 //*************************************************************************************************
2063 
2064 
2065 
2066 
2067 //=================================================================================================
2068 //
2069 // ISRESIZABLE SPECIALIZATIONS
2070 //
2071 //=================================================================================================
2072 
2073 //*************************************************************************************************
2075 template< typename T, bool TF >
2076 struct IsResizable< DynamicVector<T,TF> > : public TrueType
2077 {
2078  enum { value = 1 };
2079  typedef TrueType Type;
2080 };
2082 //*************************************************************************************************
2083 
2084 
2085 
2086 
2087 //=================================================================================================
2088 //
2089 // ADDTRAIT SPECIALIZATIONS
2090 //
2091 //=================================================================================================
2092 
2093 //*************************************************************************************************
2095 template< typename T1, bool TF, typename T2, size_t N >
2096 struct AddTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2097 {
2098  typedef StaticVector< typename AddTrait<T1,T2>::Type, N, TF > Type;
2099 };
2100 
2101 template< typename T1, size_t N, bool TF, typename T2 >
2102 struct AddTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2103 {
2104  typedef StaticVector< typename AddTrait<T1,T2>::Type, N, TF > Type;
2105 };
2106 
2107 template< typename T1, bool TF, typename T2, size_t N >
2108 struct AddTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
2109 {
2110  typedef HybridVector< typename AddTrait<T1,T2>::Type, N, TF > Type;
2111 };
2112 
2113 template< typename T1, size_t N, bool TF, typename T2 >
2114 struct AddTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
2115 {
2116  typedef HybridVector< typename AddTrait<T1,T2>::Type, N, TF > Type;
2117 };
2118 
2119 template< typename T1, bool TF, typename T2 >
2120 struct AddTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2121 {
2122  typedef DynamicVector< typename AddTrait<T1,T2>::Type, TF > Type;
2123 };
2125 //*************************************************************************************************
2126 
2127 
2128 
2129 
2130 //=================================================================================================
2131 //
2132 // SUBTRAIT SPECIALIZATIONS
2133 //
2134 //=================================================================================================
2135 
2136 //*************************************************************************************************
2138 template< typename T1, bool TF, typename T2, size_t N >
2139 struct SubTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2140 {
2141  typedef StaticVector< typename SubTrait<T1,T2>::Type, N, TF > Type;
2142 };
2143 
2144 template< typename T1, size_t N, bool TF, typename T2 >
2145 struct SubTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2146 {
2147  typedef StaticVector< typename SubTrait<T1,T2>::Type, N, TF > Type;
2148 };
2149 
2150 template< typename T1, bool TF, typename T2, size_t N >
2151 struct SubTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
2152 {
2153  typedef HybridVector< typename SubTrait<T1,T2>::Type, N, TF > Type;
2154 };
2155 
2156 template< typename T1, size_t N, bool TF, typename T2 >
2157 struct SubTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
2158 {
2159  typedef HybridVector< typename SubTrait<T1,T2>::Type, N, TF > Type;
2160 };
2161 
2162 template< typename T1, bool TF, typename T2 >
2163 struct SubTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2164 {
2165  typedef DynamicVector< typename SubTrait<T1,T2>::Type, TF > Type;
2166 };
2168 //*************************************************************************************************
2169 
2170 
2171 
2172 
2173 //=================================================================================================
2174 //
2175 // MULTTRAIT SPECIALIZATIONS
2176 //
2177 //=================================================================================================
2178 
2179 //*************************************************************************************************
2181 template< typename T1, bool TF, typename T2 >
2182 struct MultTrait< DynamicVector<T1,TF>, T2 >
2183 {
2184  typedef DynamicVector< typename MultTrait<T1,T2>::Type, TF > Type;
2186 };
2187 
2188 template< typename T1, typename T2, bool TF >
2189 struct MultTrait< T1, DynamicVector<T2,TF> >
2190 {
2191  typedef DynamicVector< typename MultTrait<T1,T2>::Type, TF > Type;
2193 };
2194 
2195 template< typename T1, bool TF, typename T2, size_t N >
2196 struct MultTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2197 {
2198  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2199 };
2200 
2201 template< typename T1, typename T2, size_t N >
2202 struct MultTrait< DynamicVector<T1,false>, StaticVector<T2,N,true> >
2203 {
2204  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2205 };
2206 
2207 template< typename T1, typename T2, size_t N >
2208 struct MultTrait< DynamicVector<T1,true>, StaticVector<T2,N,false> >
2209 {
2210  typedef typename MultTrait<T1,T2>::Type Type;
2211 };
2212 
2213 template< typename T1, size_t N, bool TF, typename T2 >
2214 struct MultTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2215 {
2216  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2217 };
2218 
2219 template< typename T1, size_t N, typename T2 >
2220 struct MultTrait< StaticVector<T1,N,false>, DynamicVector<T2,true> >
2221 {
2222  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2223 };
2224 
2225 template< typename T1, size_t N, typename T2 >
2226 struct MultTrait< StaticVector<T1,N,true>, DynamicVector<T2,false> >
2227 {
2228  typedef typename MultTrait<T1,T2>::Type Type;
2229 };
2230 
2231 template< typename T1, bool TF, typename T2, size_t N >
2232 struct MultTrait< DynamicVector<T1,TF>, HybridVector<T2,N,TF> >
2233 {
2234  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2235 };
2236 
2237 template< typename T1, typename T2, size_t N >
2238 struct MultTrait< DynamicVector<T1,false>, HybridVector<T2,N,true> >
2239 {
2240  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2241 };
2242 
2243 template< typename T1, typename T2, size_t N >
2244 struct MultTrait< DynamicVector<T1,true>, HybridVector<T2,N,false> >
2245 {
2246  typedef typename MultTrait<T1,T2>::Type Type;
2247 };
2248 
2249 template< typename T1, size_t N, bool TF, typename T2 >
2250 struct MultTrait< HybridVector<T1,N,TF>, DynamicVector<T2,TF> >
2251 {
2252  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2253 };
2254 
2255 template< typename T1, size_t N, typename T2 >
2256 struct MultTrait< HybridVector<T1,N,false>, DynamicVector<T2,true> >
2257 {
2258  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2259 };
2260 
2261 template< typename T1, size_t N, typename T2 >
2262 struct MultTrait< HybridVector<T1,N,true>, DynamicVector<T2,false> >
2263 {
2264  typedef typename MultTrait<T1,T2>::Type Type;
2265 };
2266 
2267 template< typename T1, bool TF, typename T2 >
2268 struct MultTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2269 {
2270  typedef DynamicVector< typename MultTrait<T1,T2>::Type, TF > Type;
2271 };
2272 
2273 template< typename T1, typename T2 >
2274 struct MultTrait< DynamicVector<T1,false>, DynamicVector<T2,true> >
2275 {
2276  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2277 };
2278 
2279 template< typename T1, typename T2 >
2280 struct MultTrait< DynamicVector<T1,true>, DynamicVector<T2,false> >
2281 {
2282  typedef typename MultTrait<T1,T2>::Type Type;
2283 };
2285 //*************************************************************************************************
2286 
2287 
2288 
2289 
2290 //=================================================================================================
2291 //
2292 // CROSSTRAIT SPECIALIZATIONS
2293 //
2294 //=================================================================================================
2295 
2296 //*************************************************************************************************
2298 template< typename T1, typename T2 >
2299 struct CrossTrait< DynamicVector<T1,false>, StaticVector<T2,3UL,false> >
2300 {
2301  private:
2302  typedef typename MultTrait<T1,T2>::Type T;
2303 
2304  public:
2305  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2306 };
2307 
2308 template< typename T1, typename T2 >
2309 struct CrossTrait< StaticVector<T1,3UL,false>, DynamicVector<T2,false> >
2310 {
2311  private:
2312  typedef typename MultTrait<T1,T2>::Type T;
2313 
2314  public:
2315  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2316 };
2317 
2318 template< typename T1, typename T2, size_t N >
2319 struct CrossTrait< DynamicVector<T1,false>, HybridVector<T2,N,false> >
2320 {
2321  private:
2322  typedef typename MultTrait<T1,T2>::Type T;
2323 
2324  public:
2325  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2326 };
2327 
2328 template< typename T1, size_t N, typename T2 >
2329 struct CrossTrait< HybridVector<T1,N,false>, DynamicVector<T2,false> >
2330 {
2331  private:
2332  typedef typename MultTrait<T1,T2>::Type T;
2333 
2334  public:
2335  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2336 };
2337 
2338 template< typename T1, typename T2 >
2339 struct CrossTrait< DynamicVector<T1,false>, DynamicVector<T2,false> >
2340 {
2341  private:
2342  typedef typename MultTrait<T1,T2>::Type T;
2343 
2344  public:
2345  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2346 };
2348 //*************************************************************************************************
2349 
2350 
2351 
2352 
2353 //=================================================================================================
2354 //
2355 // DIVTRAIT SPECIALIZATIONS
2356 //
2357 //=================================================================================================
2358 
2359 //*************************************************************************************************
2361 template< typename T1, bool TF, typename T2 >
2362 struct DivTrait< DynamicVector<T1,TF>, T2 >
2363 {
2364  typedef DynamicVector< typename DivTrait<T1,T2>::Type, TF > Type;
2366 };
2368 //*************************************************************************************************
2369 
2370 
2371 
2372 
2373 //=================================================================================================
2374 //
2375 // MATHTRAIT SPECIALIZATIONS
2376 //
2377 //=================================================================================================
2378 
2379 //*************************************************************************************************
2381 template< typename T1, bool TF, typename T2 >
2382 struct MathTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2383 {
2384  typedef DynamicVector< typename MathTrait<T1,T2>::HighType, TF > HighType;
2385  typedef DynamicVector< typename MathTrait<T1,T2>::LowType , TF > LowType;
2386 };
2388 //*************************************************************************************************
2389 
2390 
2391 
2392 
2393 //=================================================================================================
2394 //
2395 // SUBVECTORTRAIT SPECIALIZATIONS
2396 //
2397 //=================================================================================================
2398 
2399 //*************************************************************************************************
2401 template< typename T1, bool TF >
2402 struct SubvectorTrait< DynamicVector<T1,TF> >
2403 {
2404  typedef DynamicVector<T1,TF> Type;
2405 };
2407 //*************************************************************************************************
2408 
2409 } // namespace blaze
2410 
2411 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:108
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:116
const bool defaultTransposeFlag
The default transpose flag for all vectors of the Blaze library.This value specifies the default tran...
Definition: TransposeFlag.h:56
Type *BLAZE_RESTRICT v_
The dynamically allocated vector elements.
Definition: DynamicVector.h:405
Constraint on the data type.
void swap(SymmetricMatrix< MT, SO, DF, NF > &a, SymmetricMatrix< MT, SO, DF, NF > &b)
Swapping the contents of two matrices.
Definition: SymmetricMatrix.h:195
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the subtraction trait.
Pointer data()
Low-level data access to the vector elements.
Definition: DynamicVector.h:689
Header file for the SparseVector base class.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:258
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: DynamicVector.h:1090
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:258
void swap(DynamicVector &v)
Swapping the contents of two vectors.
Definition: DynamicVector.h:1285
Iterator begin()
Returns an iterator to the first element of the dynamic vector.
Definition: DynamicVector.h:719
void clear()
Clearing the vector.
Definition: DynamicVector.h:1129
IT::Type IntrinsicType
Intrinsic type of the vector elements.
Definition: DynamicVector.h:173
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type stream(T *address, const typename Stream< T, sizeof(T)>::Type &value)
Aligned, non-temporal store of a vector of integral values.
Definition: Stream.h:220
Header file for the IsSame and IsStrictlySame type traits.
const bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Streaming.h:50
const Type * ConstPointer
Pointer to a constant vector value.
Definition: DynamicVector.h:179
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:224
Header file for the DenseVector base class.
#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:116
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:695
Efficient implementation of an arbitrary sized vector.The DynamicVector class template is the represe...
Definition: DynamicVector.h:160
Header file for memory allocation and deallocation functionality.
void store(size_t index, const IntrinsicType &value)
Aligned store of an intrinsic element of the vector.
Definition: DynamicVector.h:1473
EnableIf< IsBuiltin< T >, T * >::Type allocate(size_t size)
Aligned array allocation for built-in data types.
Definition: Memory.h:151
Constraint on the data type.
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2638
~DynamicVector()
The destructor for DynamicVector.
Definition: DynamicVector.h:631
ConstIterator cbegin() const
Returns an iterator to the first element of the dynamic vector.
Definition: DynamicVector.h:747
DynamicVector< ET, TF > Other
The type of the other DynamicVector.
Definition: DynamicVector.h:189
Header file for the DisableIf class template.
This ResultType
Result type for expression template evaluations.
Definition: DynamicVector.h:170
void resize(size_t n, bool preserve=true)
Changing the size of the vector.
Definition: DynamicVector.h:1167
Header file for the multiplication trait.
Header file for the clear shim.
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4754
bool isAligned() const
Returns whether the vector is properly aligned in memory.
Definition: DynamicVector.h:1370
void storeu(size_t index, const IntrinsicType &value)
Unaligned store of an intrinsic element of the dense vector.
Definition: DynamicVector.h:1504
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
const Type & ReturnType
Return type for expression template evaluations.
Definition: DynamicVector.h:174
#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:116
Header file for the IsSMPAssignable type trait.
EnableIf< IsBuiltin< T > >::Type deallocate(T *address)
Deallocation of memory for built-in data types.
Definition: Memory.h:226
Header file for the DenseIterator class template.
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
Header file for the subvector trait.
Constraint on the data type.
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
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:1111
size_t size() const
Returns the current size/dimension of the vector.
Definition: DynamicVector.h:1059
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: DynamicVector.h:180
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:221
size_t size_
The current size/dimension of the vector.
Definition: DynamicVector.h:403
#define BLAZE_RESTRICT
Platform dependent setup of the restrict keyword.
Definition: Restrict.h:81
Type & Reference
Reference to a non-constant vector value.
Definition: DynamicVector.h:176
#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:79
const Type & ConstReference
Reference to a constant vector value.
Definition: DynamicVector.h:177
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:195
Compile time check for data types.This type trait tests whether or not the given template parameter i...
Definition: IsSMPAssignable.h:120
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:535
size_t adjustCapacity(size_t minCapacity) const
Adjusting the new capacity of the vector according to its data type Type.
Definition: DynamicVector.h:1302
IntrinsicType load(size_t index) const
Aligned load of an intrinsic element of the vector.
Definition: DynamicVector.h:1412
System settings for streaming (non-temporal stores)
DynamicVector()
The default constructor for DynamicVector.
Definition: DynamicVector.h:439
Header file for the EnableIf class template.
Header file for the serial shim.
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
size_t capacity_
The maximum capacity of the vector.
Definition: DynamicVector.h:404
bool isAliased(const Other *alias) const
Returns whether the vector is aliased with the given address alias.
Definition: DynamicVector.h:1352
EnableIf< IsDenseMatrix< MT1 > >::Type smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
Header file for the IsSparseVector type trait.
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:749
ConstIterator cend() const
Returns an iterator just past the last element of the dynamic vector.
Definition: DynamicVector.h:789
Header file for run time assertion macros.
EnableIf< IsDenseMatrix< MT1 > >::Type smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
IntrinsicTrait< Type > IT
Intrinsic trait for the vector element type.
Definition: DynamicVector.h:164
Constraint on the data type.
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
const DynamicVector & CompositeType
Data type for composite expression templates.
Definition: DynamicVector.h:175
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
void extend(size_t n, bool preserve=true)
Extending the size of the vector.
Definition: DynamicVector.h:1215
void move(DynamicMatrix< Type, SO > &dst, DynamicMatrix< Type, SO > &src)
Moving the contents of one dynamic matrix to another.
Definition: DynamicMatrix.h:4769
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:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2481
Rebind mechanism to obtain a DynamicVector with different data/element type.
Definition: DynamicVector.h:188
Header file for the isDefault shim.
System settings for the restrict keyword.
Type ElementType
Type of the vector elements.
Definition: DynamicVector.h:172
Type * Pointer
Pointer to a non-constant vector value.
Definition: DynamicVector.h:178
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
size_t capacity() const
Returns the maximum capacity of the vector.
Definition: DynamicVector.h:1073
Constraint on the data type.
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
void reserve(size_t n)
Setting the minimum capacity of the vector.
Definition: DynamicVector.h:1233
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the dense vector.
Definition: DynamicVector.h:1534
Header file for all intrinsic functionality.
Header file for the mathematical trait.
bool canAlias(const Other *alias) const
Returns whether the vector can alias with the given address alias.
Definition: DynamicVector.h:1332
Header file for the default transpose flag for all vectors of the Blaze library.
EnableIf< IsDenseMatrix< MT1 > >::Type smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2473
bool canSMPAssign() const
Returns whether the vector can be used in SMP assignments.
Definition: DynamicVector.h:1389
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:218
IntrinsicType loadu(size_t index) const
Unaligned load of an intrinsic element of the vector.
Definition: DynamicVector.h:1443
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
Iterator end()
Returns an iterator just past the last element of the dynamic vector.
Definition: DynamicVector.h:761
const size_t SMP_DVECASSIGN_THRESHOLD
SMP dense vector assignment threshold.This threshold specifies when an assignment of a simple dense v...
Definition: Thresholds.h:207
const size_t cacheSize
Cache size of the target architecture.This setting specifies the available cache size in Byte of the ...
Definition: CacheSize.h:48
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:225
Header file for the IsResizable type trait.
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: DynamicVector.h:181
EnableIf< IsDenseVector< VT1 > >::Type 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:189
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, 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
Reference operator[](size_t index)
Subscript operator for the direct access to the vector elements.
Definition: DynamicVector.h:655
DynamicVector< Type,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: DynamicVector.h:171
Header file for a safe C++ NULL pointer implementation.
DynamicVector< Type, TF > This
Type of this DynamicVector instance.
Definition: DynamicVector.h:169