All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DynamicVector.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_MATH_DENSE_DYNAMICVECTOR_H_
23 #define _BLAZE_MATH_DENSE_DYNAMICVECTOR_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
30 #include <algorithm>
31 #include <fstream>
32 #include <ostream>
33 #include <stdexcept>
35 #include <blaze/math/Forward.h>
36 #include <blaze/math/Functions.h>
37 #include <blaze/math/Intrinsics.h>
39 #include <blaze/math/shims/IsNaN.h>
40 #include <blaze/math/shims/Reset.h>
49 #include <blaze/system/CacheSize.h>
50 #include <blaze/system/Restrict.h>
52 #include <blaze/util/Assert.h>
59 #include <blaze/util/DisableIf.h>
60 #include <blaze/util/EnableIf.h>
61 #include <blaze/util/Memory.h>
62 #include <blaze/util/mpl/If.h>
63 #include <blaze/util/Null.h>
64 #include <blaze/util/Template.h>
65 #include <blaze/util/Types.h>
70 
71 
72 namespace blaze {
73 
74 //=================================================================================================
75 //
76 // CLASS DEFINITION
77 //
78 //=================================================================================================
79 
80 //*************************************************************************************************
144 template< typename Type // Data type of the vector
145  , bool TF = defaultTransposeFlag > // Transpose flag
146 class DynamicVector : public DenseVector< DynamicVector<Type,TF>, TF >
147 {
148  private:
149  //**Type definitions****************************************************************************
151  //**********************************************************************************************
152 
153  public:
154  //**Type definitions****************************************************************************
156  typedef This ResultType;
158  typedef Type ElementType;
159  typedef typename IT::Type IntrinsicType;
160  typedef const Type& ReturnType;
161  typedef const DynamicVector& CompositeType;
162  typedef Type& Reference;
163  typedef const Type& ConstReference;
164  typedef Type* Iterator;
165  typedef const Type* ConstIterator;
166  //**********************************************************************************************
167 
168  //**Compilation flags***************************************************************************
170 
174  enum { vectorizable = IsVectorizable<Type>::value };
175  //**********************************************************************************************
176 
177  //**Constructors********************************************************************************
180  explicit inline DynamicVector();
181  explicit inline DynamicVector( size_t n );
182  explicit inline DynamicVector( size_t n, Type init );
183  inline DynamicVector( const DynamicVector& v );
184  template< typename VT > inline DynamicVector( const Vector<VT,TF>& v );
185 
186  template< typename Other, size_t N >
187  explicit inline DynamicVector( const Other (&rhs)[N] );
189  //**********************************************************************************************
190 
191  //**Destructor**********************************************************************************
194  inline ~DynamicVector();
196  //**********************************************************************************************
197 
198  //**Data access functions***********************************************************************
201  inline Reference operator[]( size_t index );
202  inline ConstReference operator[]( size_t index ) const;
203  inline Type* data ();
204  inline const Type* data () const;
205  inline Iterator begin ();
206  inline ConstIterator begin () const;
207  inline ConstIterator cbegin() const;
208  inline Iterator end ();
209  inline ConstIterator end () const;
210  inline ConstIterator cend () const;
212  //**********************************************************************************************
213 
214  //**Assignment operators************************************************************************
217  template< typename Other, size_t N >
218  inline DynamicVector& operator=( const Other (&rhs)[N] );
219 
220  inline DynamicVector& operator= ( Type rhs );
221  inline DynamicVector& operator= ( const DynamicVector& rhs );
222  template< typename VT > inline DynamicVector& operator= ( const Vector<VT,TF>& rhs );
223  template< typename VT > inline DynamicVector& operator+=( const Vector<VT,TF>& rhs );
224  template< typename VT > inline DynamicVector& operator-=( const Vector<VT,TF>& rhs );
225  template< typename VT > inline DynamicVector& operator*=( const Vector<VT,TF>& rhs );
226 
227  template< typename Other >
228  inline typename EnableIf< IsNumeric<Other>, DynamicVector >::Type&
229  operator*=( Other rhs );
230 
231  template< typename Other >
232  inline typename EnableIf< IsNumeric<Other>, DynamicVector >::Type&
233  operator/=( Other rhs );
235  //**********************************************************************************************
236 
237  //**Utility functions***************************************************************************
240  inline size_t size() const;
241  inline size_t capacity() const;
242  inline size_t nonZeros() const;
243  inline void reset();
244  inline void clear();
245  inline void resize( size_t n, bool preserve=true );
246  inline void extend( size_t n, bool preserve=true );
247  inline void reserve( size_t n );
248  template< typename Other > inline DynamicVector& scale( Other scalar );
249  inline void swap( DynamicVector& v ) /* throw() */;
251  //**********************************************************************************************
252 
253  //**Read/Write functions************************************************************************
256  void read ( const char* file );
257  void write( const char* file, std::streamsize prec=6 ) const;
259  //**********************************************************************************************
260 
261  private:
262  //**********************************************************************************************
264 
265  template< typename VT >
266  struct VectorizedAssign {
267  enum { value = vectorizable && VT::vectorizable &&
269  };
271  //**********************************************************************************************
272 
273  //**********************************************************************************************
275 
276  template< typename VT >
277  struct VectorizedAddAssign {
278  enum { value = vectorizable && VT::vectorizable &&
279  IsSame<Type,typename VT::ElementType>::value &&
280  IntrinsicTrait<Type>::addition };
281  };
283  //**********************************************************************************************
284 
285  //**********************************************************************************************
287 
288  template< typename VT >
289  struct VectorizedSubAssign {
290  enum { value = vectorizable && VT::vectorizable &&
291  IsSame<Type,typename VT::ElementType>::value &&
292  IntrinsicTrait<Type>::subtraction };
293  };
295  //**********************************************************************************************
296 
297  //**********************************************************************************************
299 
300  template< typename VT >
301  struct VectorizedMultAssign {
302  enum { value = vectorizable && VT::vectorizable &&
303  IsSame<Type,typename VT::ElementType>::value &&
304  IntrinsicTrait<Type>::multiplication };
305  };
307  //**********************************************************************************************
308 
309  public:
310  //**Expression template evaluation functions****************************************************
313  template< typename Other > inline bool canAlias ( const Other* alias ) const;
314  template< typename Other > inline bool isAliased( const Other* alias ) const;
315  inline IntrinsicType get ( size_t index ) const;
316 
317  template< typename VT >
318  inline typename DisableIf< VectorizedAssign<VT> >::Type
319  assign( const DenseVector<VT,TF>& rhs );
320 
321  template< typename VT >
322  inline typename EnableIf< VectorizedAssign<VT> >::Type
323  assign( const DenseVector<VT,TF>& rhs );
324 
325  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
326 
327  template< typename VT >
328  inline typename DisableIf< VectorizedAddAssign<VT> >::Type
329  addAssign( const DenseVector<VT,TF>& rhs );
330 
331  template< typename VT >
332  inline typename EnableIf< VectorizedAddAssign<VT> >::Type
333  addAssign( const DenseVector<VT,TF>& rhs );
334 
335  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
336 
337  template< typename VT >
338  inline typename DisableIf< VectorizedSubAssign<VT> >::Type
339  subAssign( const DenseVector<VT,TF>& rhs );
340 
341  template< typename VT >
342  inline typename EnableIf< VectorizedSubAssign<VT> >::Type
343  subAssign( const DenseVector<VT,TF>& rhs );
344 
345  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
346 
347  template< typename VT >
348  inline typename DisableIf< VectorizedMultAssign<VT> >::Type
349  multAssign( const DenseVector<VT,TF>& rhs );
350 
351  template< typename VT >
352  inline typename EnableIf< VectorizedMultAssign<VT> >::Type
353  multAssign( const DenseVector<VT,TF>& rhs );
354 
355  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
357  //**********************************************************************************************
358 
359  private:
360  //**Utility functions***************************************************************************
363  inline size_t adjustCapacity( size_t minCapacity ) const;
365  //**********************************************************************************************
366 
367  //**Member variables****************************************************************************
370  size_t size_;
371  size_t capacity_;
373 
379  //**********************************************************************************************
380 
381  //**Compile time checks*************************************************************************
388  //**********************************************************************************************
389 };
390 //*************************************************************************************************
391 
392 
393 
394 
395 //=================================================================================================
396 //
397 // CONSTRUCTORS
398 //
399 //=================================================================================================
400 
401 //*************************************************************************************************
404 template< typename Type // Data type of the vector
405  , bool TF > // Transpose flag
407  : size_ ( 0UL ) // The current size/dimension of the vector
408  , capacity_( 0UL ) // The maximum capacity of the vector
409  , v_ ( NULL ) // The vector elements
410 {}
411 //*************************************************************************************************
412 
413 
414 //*************************************************************************************************
422 template< typename Type // Data type of the vector
423  , bool TF > // Transpose flag
425  : size_ ( n ) // The current size/dimension of the vector
426  , capacity_( adjustCapacity( n ) ) // The maximum capacity of the vector
427  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
428 {
429  if( IsNumeric<Type>::value ) {
430  for( size_t i=size_; i<capacity_; ++i )
431  v_[i] = Type();
432  }
433 }
434 //*************************************************************************************************
435 
436 
437 //*************************************************************************************************
445 template< typename Type // Data type of the vector
446  , bool TF > // Transpose flag
447 inline DynamicVector<Type,TF>::DynamicVector( size_t n, Type init )
448  : size_ ( n ) // The current size/dimension of the vector
449  , capacity_( adjustCapacity( n ) ) // The maximum capacity of the vector
450  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
451 {
452  for( size_t i=0UL; i<size_; ++i )
453  v_[i] = init;
454 
455  if( IsNumeric<Type>::value ) {
456  for( size_t i=size_; i<capacity_; ++i )
457  v_[i] = Type();
458  }
459 }
460 //*************************************************************************************************
461 
462 
463 //*************************************************************************************************
471 template< typename Type // Data type of the vector
472  , bool TF > // Transpose flag
474  : size_ ( v.size_ ) // The current size/dimension of the vector
475  , capacity_( adjustCapacity( v.size_ ) ) // The maximum capacity of the vector
476  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
477 {
478  BLAZE_INTERNAL_ASSERT( capacity_ <= v.capacity_, "Invalid capacity estimation" );
479 
480  for( size_t i=0UL; i<capacity_; ++i )
481  v_[i] = v.v_[i];
482 }
483 //*************************************************************************************************
484 
485 
486 //*************************************************************************************************
491 template< typename Type // Data type of the vector
492  , bool TF > // Transpose flag
493 template< typename VT > // Type of the foreign vector
495  : size_ ( (~v).size() ) // The current size/dimension of the vector
496  , capacity_( adjustCapacity( size_ ) ) // The maximum capacity of the vector
497  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
498 {
499  using blaze::assign;
500 
501  if( IsNumeric<Type>::value ) {
503  reset();
504  for( size_t i=size_; i<capacity_; ++i )
505  v_[i] = Type();
506  }
507 
508  assign( *this, ~v );
509 }
510 //*************************************************************************************************
511 
512 
513 //*************************************************************************************************
528 template< typename Type // Data type of the vector
529  , bool TF > // Transpose flag
530 template< typename Other // Data type of the initialization array
531  , size_t N > // Dimension of the initialization array
532 inline DynamicVector<Type,TF>::DynamicVector( const Other (&rhs)[N] )
533  : size_ ( N ) // The current size/dimension of the vector
534  , capacity_( adjustCapacity( N ) ) // The maximum capacity of the vector
535  , v_ ( allocate<Type>( capacity_ ) ) // The vector elements
536 {
537  for( size_t i=0UL; i<N; ++i )
538  v_[i] = rhs[i];
539 
540  if( IsNumeric<Type>::value ) {
541  for( size_t i=size_; i<capacity_; ++i )
542  v_[i] = Type();
543  }
544 }
545 //*************************************************************************************************
546 
547 
548 
549 
550 //=================================================================================================
551 //
552 // DESTRUCTOR
553 //
554 //=================================================================================================
555 
556 //*************************************************************************************************
559 template< typename Type // Data type of the vector
560  , bool TF > // Transpose flag
562 {
563  deallocate( v_ );
564 }
565 //*************************************************************************************************
566 
567 
568 
569 
570 //=================================================================================================
571 //
572 // DATA ACCESS FUNCTIONS
573 //
574 //=================================================================================================
575 
576 //*************************************************************************************************
582 template< typename Type // Data type of the vector
583  , bool TF > // Transpose flag
584 inline typename DynamicVector<Type,TF>::Reference
586 {
587  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
588  return v_[index];
589 }
590 //*************************************************************************************************
591 
592 
593 //*************************************************************************************************
599 template< typename Type // Data type of the vector
600  , bool TF > // Transpose flag
603 {
604  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
605  return v_[index];
606 }
607 //*************************************************************************************************
608 
609 
610 //*************************************************************************************************
615 template< typename Type // Data type of the vector
616  , bool TF > // Transpose flag
618 {
619  return v_;
620 }
621 //*************************************************************************************************
622 
623 
624 //*************************************************************************************************
629 template< typename Type // Data type of the vector
630  , bool TF > // Transpose flag
631 inline const Type* DynamicVector<Type,TF>::data() const
632 {
633  return v_;
634 }
635 //*************************************************************************************************
636 
637 
638 //*************************************************************************************************
643 template< typename Type // Data type of the vector
644  , bool TF > // Transpose flag
646 {
647  return v_;
648 }
649 //*************************************************************************************************
650 
651 
652 //*************************************************************************************************
657 template< typename Type // Data type of the vector
658  , bool TF > // Transpose flag
660 {
661  return v_;
662 }
663 //*************************************************************************************************
664 
665 
666 //*************************************************************************************************
671 template< typename Type // Data type of the vector
672  , bool TF > // Transpose flag
674 {
675  return v_;
676 }
677 //*************************************************************************************************
678 
679 
680 //*************************************************************************************************
685 template< typename Type // Data type of the vector
686  , bool TF > // Transpose flag
688 {
689  return v_ + size_;
690 }
691 //*************************************************************************************************
692 
693 
694 //*************************************************************************************************
699 template< typename Type // Data type of the vector
700  , bool TF > // Transpose flag
702 {
703  return v_ + size_;
704 }
705 //*************************************************************************************************
706 
707 
708 //*************************************************************************************************
713 template< typename Type // Data type of the vector
714  , bool TF > // Transpose flag
716 {
717  return v_ + size_;
718 }
719 //*************************************************************************************************
720 
721 
722 
723 
724 //=================================================================================================
725 //
726 // ASSIGNMENT OPERATORS
727 //
728 //=================================================================================================
729 
730 //*************************************************************************************************
747 template< typename Type // Data type of the vector
748  , bool TF > // Transpose flag
749 template< typename Other // Data type of the initialization array
750  , size_t N > // Dimension of the initialization array
752 {
753  resize( N, false );
754 
755  for( size_t i=0UL; i<N; ++i )
756  v_[i] = rhs[i];
757 
758  return *this;
759 }
760 //*************************************************************************************************
761 
762 
763 //*************************************************************************************************
769 template< typename Type // Data type of the vector
770  , bool TF > // Transpose flag
772 {
773  for( size_t i=0UL; i<size_; ++i )
774  v_[i] = rhs;
775  return *this;
776 }
777 //*************************************************************************************************
778 
779 
780 //*************************************************************************************************
789 template< typename Type // Data type of the vector
790  , bool TF > // Transpose flag
792 {
793  if( &rhs == this ) return *this;
794 
795  resize( rhs.size_, false );
796 
797  for( size_t i=0UL; i<size_; ++i )
798  v_[i] = rhs.v_[i];
799 
800  return *this;
801 }
802 //*************************************************************************************************
803 
804 
805 //*************************************************************************************************
813 template< typename Type // Data type of the vector
814  , bool TF > // Transpose flag
815 template< typename VT > // Type of the right-hand side vector
817 {
818  using blaze::assign;
819 
820  if( (~rhs).canAlias( this ) ) {
821  DynamicVector tmp( ~rhs );
822  swap( tmp );
823  }
824  else {
825  resize( (~rhs).size(), false );
827  reset();
828  assign( *this, ~rhs );
829  }
830 
831  return *this;
832 }
833 //*************************************************************************************************
834 
835 
836 //*************************************************************************************************
846 template< typename Type // Data type of the vector
847  , bool TF > // Transpose flag
848 template< typename VT > // Type of the right-hand side vector
850 {
851  using blaze::addAssign;
852 
853  if( (~rhs).size() != size_ )
854  throw std::invalid_argument( "Vector sizes do not match" );
855 
856  if( (~rhs).canAlias( this ) ) {
857  typename VT::ResultType tmp( ~rhs );
858  addAssign( *this, tmp );
859  }
860  else {
861  addAssign( *this, ~rhs );
862  }
863 
864  return *this;
865 }
866 //*************************************************************************************************
867 
868 
869 //*************************************************************************************************
880 template< typename Type // Data type of the vector
881  , bool TF > // Transpose flag
882 template< typename VT > // Type of the right-hand side vector
884 {
885  using blaze::subAssign;
886 
887  if( (~rhs).size() != size_ )
888  throw std::invalid_argument( "Vector sizes do not match" );
889 
890  if( (~rhs).canAlias( this ) ) {
891  typename VT::ResultType tmp( ~rhs );
892  subAssign( *this, tmp );
893  }
894  else {
895  subAssign( *this, ~rhs );
896  }
897 
898  return *this;
899 }
900 //*************************************************************************************************
901 
902 
903 //*************************************************************************************************
914 template< typename Type // Data type of the vector
915  , bool TF > // Transpose flag
916 template< typename VT > // Type of the right-hand side vector
918 {
919  using blaze::assign;
920 
921  if( (~rhs).size() != size_ )
922  throw std::invalid_argument( "Vector sizes do not match" );
923 
924  if( (~rhs).canAlias( this ) || IsSparseVector<VT>::value ) {
925  DynamicVector<Type,TF> tmp( *this * (~rhs) );
926  swap( tmp );
927  }
928  else {
929  assign( *this, *this * (~rhs) );
930  }
931 
932  return *this;
933 }
934 //*************************************************************************************************
935 
936 
937 //*************************************************************************************************
944 template< typename Type // Data type of the vector
945  , bool TF > // Transpose flag
946 template< typename Other > // Data type of the right-hand side scalar
947 inline typename EnableIf< IsNumeric<Other>, DynamicVector<Type,TF> >::Type&
949 {
950  return operator=( (*this) * rhs );
951 }
952 //*************************************************************************************************
953 
954 
955 //*************************************************************************************************
964 template< typename Type // Data type of the vector
965  , bool TF > // Transpose flag
966 template< typename Other > // Data type of the right-hand side scalar
967 inline typename EnableIf< IsNumeric<Other>, DynamicVector<Type,TF> >::Type&
969 {
970  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
971 
972  return operator=( (*this) / rhs );
973 }
974 //*************************************************************************************************
975 
976 
977 
978 
979 //=================================================================================================
980 //
981 // UTILITY FUNCTIONS
982 //
983 //=================================================================================================
984 
985 //*************************************************************************************************
990 template< typename Type // Data type of the vector
991  , bool TF > // Transpose flag
992 inline size_t DynamicVector<Type,TF>::size() const
993 {
994  return size_;
995 }
996 //*************************************************************************************************
997 
998 
999 //*************************************************************************************************
1004 template< typename Type // Data type of the vector
1005  , bool TF > // Transpose flag
1007 {
1008  return capacity_;
1009 }
1010 //*************************************************************************************************
1011 
1012 
1013 //*************************************************************************************************
1021 template< typename Type // Data type of the vector
1022  , bool TF > // Transpose flag
1024 {
1025  size_t nonzeros( 0 );
1026 
1027  for( size_t i=0UL; i<size_; ++i ) {
1028  if( !isDefault( v_[i] ) )
1029  ++nonzeros;
1030  }
1031 
1032  return nonzeros;
1033 }
1034 //*************************************************************************************************
1035 
1036 
1037 //*************************************************************************************************
1042 template< typename Type // Data type of the vector
1043  , bool TF > // Transpose flag
1045 {
1046  using blaze::reset;
1047  for( size_t i=0UL; i<size_; ++i )
1048  reset( v_[i] );
1049 }
1050 //*************************************************************************************************
1051 
1052 
1053 //*************************************************************************************************
1060 template< typename Type // Data type of the vector
1061  , bool TF > // Transpose flag
1063 {
1064  size_ = 0UL;
1065 }
1066 //*************************************************************************************************
1067 
1068 
1069 //*************************************************************************************************
1096 template< typename Type // Data type of the vector
1097  , bool TF > // Transpose flag
1098 inline void DynamicVector<Type,TF>::resize( size_t n, bool preserve )
1099 {
1100  if( n > capacity_ )
1101  {
1102  // Allocating a new array
1103  const size_t newCapacity( adjustCapacity( n ) );
1104  Type* BLAZE_RESTRICT tmp = allocate<Type>( newCapacity );
1105 
1106  // Initializing the new array
1107  if( preserve ) {
1108  std::copy( v_, v_+size_, tmp );
1109  }
1110 
1111  if( IsNumeric<Type>::value ) {
1112  for( size_t i=size_; i<newCapacity; ++i )
1113  tmp[i] = Type();
1114  }
1115 
1116  // Replacing the old array
1117  std::swap( v_, tmp );
1118  deallocate( tmp );
1119  capacity_ = newCapacity;
1120  }
1121  else if( IsNumeric<Type>::value && n < size_ )
1122  {
1123  for( size_t i=n; i<size_; ++i )
1124  v_[i] = Type();
1125  }
1126 
1127  size_ = n;
1128 }
1129 //*************************************************************************************************
1130 
1131 
1132 //*************************************************************************************************
1144 template< typename Type // Data type of the vector
1145  , bool TF > // Transpose flag
1146 inline void DynamicVector<Type,TF>::extend( size_t n, bool preserve )
1147 {
1148  resize( size_+n, preserve );
1149 }
1150 //*************************************************************************************************
1151 
1152 
1153 //*************************************************************************************************
1162 template< typename Type // Data type of the vector
1163  , bool TF > // Transpose flag
1164 inline void DynamicVector<Type,TF>::reserve( size_t n )
1165 {
1166  if( n > capacity_ )
1167  {
1168  // Allocating a new array
1169  const size_t newCapacity( adjustCapacity( n ) );
1170  Type* BLAZE_RESTRICT tmp = allocate<Type>( newCapacity );
1171 
1172  // Initializing the new array
1173  std::copy( v_, v_+size_, tmp );
1174 
1175  if( IsNumeric<Type>::value ) {
1176  for( size_t i=size_; i<newCapacity; ++i )
1177  tmp[i] = Type();
1178  }
1179 
1180  // Replacing the old array
1181  std::swap( tmp, v_ );
1182  deallocate( tmp );
1183  capacity_ = newCapacity;
1184  }
1185 }
1186 //*************************************************************************************************
1187 
1188 
1189 //*************************************************************************************************
1195 template< typename Type // Data type of the vector
1196  , bool TF > // Transpose flag
1197 template< typename Other > // Data type of the scalar value
1199 {
1200  for( size_t i=0UL; i<size_; ++i )
1201  v_[i] *= scalar;
1202  return *this;
1203 }
1204 //*************************************************************************************************
1205 
1206 
1207 //*************************************************************************************************
1214 template< typename Type // Data type of the vector
1215  , bool TF > // Transpose flag
1216 inline void DynamicVector<Type,TF>::swap( DynamicVector& v ) /* throw() */
1217 {
1218  std::swap( size_, v.size_ );
1219  std::swap( capacity_, v.capacity_ );
1220  std::swap( v_, v.v_ );
1221 }
1222 //*************************************************************************************************
1223 
1224 
1225 //*************************************************************************************************
1231 template< typename Type // Data type of the vector
1232  , bool TF > // Transpose flag
1233 inline size_t DynamicVector<Type,TF>::adjustCapacity( size_t minCapacity ) const
1234 {
1236  return minCapacity + ( IT::size - ( minCapacity % IT::size ) ) % IT::size;
1237  else return minCapacity;
1238 }
1239 //*************************************************************************************************
1240 
1241 
1242 
1243 
1244 //=================================================================================================
1245 //
1246 // READ/WRITE FUNCTIONS
1247 //
1248 //=================================================================================================
1249 
1250 //*************************************************************************************************
1271 template< typename Type // Data type of the vector
1272  , bool TF > // Transpose flag
1273 void DynamicVector<Type,TF>::read( const char* file )
1274 {
1275  std::ifstream in( file, std::ifstream::in );
1276  if( !in.is_open() ) {
1277  throw std::runtime_error( "File could not be opened!" );
1278  }
1279 
1280  size_t vsize(0UL);
1281  if( !(in >> vsize) || vsize == 0UL ) {
1282  throw std::runtime_error( "Vector size could not be extracted!" );
1283  }
1284 
1285  DynamicVector tmp( vsize );
1286 
1287  for( size_t i=0UL; i<vsize; ++i ) {
1288  if( !(in >> tmp.v_[i]) ) {
1289  throw std::runtime_error( "Error during vector extraction!" );
1290  }
1291  }
1292 
1293  swap( tmp );
1294 
1295  in.close();
1296 }
1297 //*************************************************************************************************
1298 
1299 
1300 //*************************************************************************************************
1323 template< typename Type // Data type of the vector
1324  , bool TF > // Transpose flag
1325 void DynamicVector<Type,TF>::write( const char* file, std::streamsize prec ) const
1326 {
1327  std::ofstream out( file, std::ofstream::out | std::ostream::trunc );
1328  if( !out.is_open() ) {
1329  throw std::runtime_error( "File could not be opened!" );
1330  }
1331 
1332  out << size_ << "\n";
1333 
1334  out.precision( prec );
1335  for( size_t i=0UL; i<size_; ++i )
1336  out << v_[i] << "\n";
1337 
1338  out.close();
1339 }
1340 //*************************************************************************************************
1341 
1342 
1343 
1344 
1345 //=================================================================================================
1346 //
1347 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1348 //
1349 //=================================================================================================
1350 
1351 //*************************************************************************************************
1361 template< typename Type // Data type of the vector
1362  , bool TF > // Transpose flag
1363 template< typename Other > // Data type of the foreign expression
1364 inline bool DynamicVector<Type,TF>::canAlias( const Other* alias ) const
1365 {
1366  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1367 }
1368 //*************************************************************************************************
1369 
1370 
1371 //*************************************************************************************************
1381 template< typename Type // Data type of the vector
1382  , bool TF > // Transpose flag
1383 template< typename Other > // Data type of the foreign expression
1384 inline bool DynamicVector<Type,TF>::isAliased( const Other* alias ) const
1385 {
1386  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1387 }
1388 //*************************************************************************************************
1389 
1390 
1391 //*************************************************************************************************
1402 template< typename Type // Data type of the vector
1403  , bool TF > // Transpose flag
1405  DynamicVector<Type,TF>::get( size_t index ) const
1406 {
1408 
1409  BLAZE_INTERNAL_ASSERT( index < size_ , "Invalid vector access index" );
1410  BLAZE_INTERNAL_ASSERT( index + IT::size <= capacity_, "Invalid vector access index" );
1411  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL , "Invalid vector access index" );
1412 
1413  return load( &v_[index] );
1414 }
1415 //*************************************************************************************************
1416 
1417 
1418 //*************************************************************************************************
1429 template< typename Type // Data type of the vector
1430  , bool TF > // Transpose flag
1431 template< typename VT > // Type of the right-hand side dense vector
1432 inline typename DisableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1434 {
1435  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1436 
1437  const size_t iend( (~rhs).size() & size_t(-2) );
1438  for( size_t i=0UL; i<iend; i+=2UL ) {
1439  v_[i ] = (~rhs)[i ];
1440  v_[i+1UL] = (~rhs)[i+1UL];
1441  }
1442  if( iend < (~rhs).size() )
1443  v_[iend] = (~rhs)[iend];
1444 }
1445 //*************************************************************************************************
1446 
1447 
1448 //*************************************************************************************************
1459 template< typename Type // Data type of the vector
1460  , bool TF > // Transpose flag
1461 template< typename VT > // Type of the right-hand side dense vector
1462 inline typename EnableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1464 {
1465  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1466 
1468 
1469  if( size_ > ( cacheSize/( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
1470  {
1471  for( size_t i=0UL; i<size_; i+=IT::size ) {
1472  stream( v_+i, (~rhs).get(i) );
1473  }
1474  }
1475  else
1476  {
1477  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == ( size_ & size_t(-IT::size*4) ), "Invalid end calculation" );
1478  const size_t iend( size_ & size_t(-IT::size*4) );
1479 
1480  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1481  store( v_+i , (~rhs).get(i ) );
1482  store( v_+i+IT::size , (~rhs).get(i+IT::size ) );
1483  store( v_+i+IT::size*2UL, (~rhs).get(i+IT::size*2UL) );
1484  store( v_+i+IT::size*3UL, (~rhs).get(i+IT::size*3UL) );
1485  }
1486  for( size_t i=iend; i<size_; i+=IT::size ) {
1487  store( v_+i, (~rhs).get(i) );
1488  }
1489  }
1490 }
1491 //*************************************************************************************************
1492 
1493 
1494 //*************************************************************************************************
1505 template< typename Type // Data type of the vector
1506  , bool TF > // Transpose flag
1507 template< typename VT > // Type of the right-hand side sparse vector
1509 {
1510  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1511 
1512  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1513  v_[element->index()] = element->value();
1514 }
1515 //*************************************************************************************************
1516 
1517 
1518 //*************************************************************************************************
1529 template< typename Type // Data type of the vector
1530  , bool TF > // Transpose flag
1531 template< typename VT > // Type of the right-hand side dense vector
1532 inline typename DisableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1534 {
1535  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1536 
1537  const size_t iend( (~rhs).size() & size_t(-2) );
1538  for( size_t i=0UL; i<iend; i+=2UL ) {
1539  v_[i ] += (~rhs)[i ];
1540  v_[i+1UL] += (~rhs)[i+1UL];
1541  }
1542  if( iend < (~rhs).size() )
1543  v_[iend] += (~rhs)[iend];
1544 }
1545 //*************************************************************************************************
1546 
1547 
1548 //*************************************************************************************************
1559 template< typename Type // Data type of the vector
1560  , bool TF > // Transpose flag
1561 template< typename VT > // Type of the right-hand side dense vector
1562 inline typename EnableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1564 {
1565  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1566 
1568 
1569  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == ( size_ & size_t(-IT::size*4) ), "Invalid end calculation" );
1570  const size_t iend( size_ & size_t(-IT::size*4) );
1571 
1572  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1573  store( v_+i , load(v_+i ) + (~rhs).get(i ) );
1574  store( v_+i+IT::size , load(v_+i+IT::size ) + (~rhs).get(i+IT::size ) );
1575  store( v_+i+IT::size*2UL, load(v_+i+IT::size*2UL) + (~rhs).get(i+IT::size*2UL) );
1576  store( v_+i+IT::size*3UL, load(v_+i+IT::size*3UL) + (~rhs).get(i+IT::size*3UL) );
1577  }
1578  for( size_t i=iend; i<size_; i+=IT::size ) {
1579  store( v_+i, load(v_+i) + (~rhs).get(i) );
1580  }
1581 }
1582 //*************************************************************************************************
1583 
1584 
1585 //*************************************************************************************************
1596 template< typename Type // Data type of the vector
1597  , bool TF > // Transpose flag
1598 template< typename VT > // Type of the right-hand side sparse vector
1600 {
1601  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1602 
1603  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1604  v_[element->index()] += element->value();
1605 }
1606 //*************************************************************************************************
1607 
1608 
1609 //*************************************************************************************************
1620 template< typename Type // Data type of the vector
1621  , bool TF > // Transpose flag
1622 template< typename VT > // Type of the right-hand side dense vector
1623 inline typename DisableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1625 {
1626  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1627 
1628  const size_t iend( (~rhs).size() & size_t(-2) );
1629  for( size_t i=0UL; i<iend; i+=2UL ) {
1630  v_[i ] -= (~rhs)[i ];
1631  v_[i+1UL] -= (~rhs)[i+1UL];
1632  }
1633  if( iend < (~rhs).size() )
1634  v_[iend] -= (~rhs)[iend];
1635 }
1636 //*************************************************************************************************
1637 
1638 
1639 //*************************************************************************************************
1650 template< typename Type // Data type of the vector
1651  , bool TF > // Transpose flag
1652 template< typename VT > // Type of the right-hand side dense vector
1653 inline typename EnableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1655 {
1656  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1657 
1659 
1660  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == ( size_ & size_t(-IT::size*4) ), "Invalid end calculation" );
1661  const size_t iend( size_ & size_t(-IT::size*4) );
1662 
1663  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1664  store( v_+i , load(v_+i ) - (~rhs).get(i ) );
1665  store( v_+i+IT::size , load(v_+i+IT::size ) - (~rhs).get(i+IT::size ) );
1666  store( v_+i+IT::size*2UL, load(v_+i+IT::size*2UL) - (~rhs).get(i+IT::size*2UL) );
1667  store( v_+i+IT::size*3UL, load(v_+i+IT::size*3UL) - (~rhs).get(i+IT::size*3UL) );
1668  }
1669  for( size_t i=iend; i<size_; i+=IT::size ) {
1670  store( v_+i, load(v_+i) - (~rhs).get(i) );
1671  }
1672 }
1673 //*************************************************************************************************
1674 
1675 
1676 //*************************************************************************************************
1687 template< typename Type // Data type of the vector
1688  , bool TF > // Transpose flag
1689 template< typename VT > // Type of the right-hand side sparse vector
1691 {
1692  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1693 
1694  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1695  v_[element->index()] -= element->value();
1696 }
1697 //*************************************************************************************************
1698 
1699 
1700 //*************************************************************************************************
1711 template< typename Type // Data type of the vector
1712  , bool TF > // Transpose flag
1713 template< typename VT > // Type of the right-hand side dense vector
1714 inline typename DisableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1716 {
1717  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1718 
1719  const size_t iend( (~rhs).size() & size_t(-2) );
1720  for( size_t i=0UL; i<iend; i+=2UL ) {
1721  v_[i ] *= (~rhs)[i ];
1722  v_[i+1UL] *= (~rhs)[i+1UL];
1723  }
1724  if( iend < (~rhs).size() )
1725  v_[iend] *= (~rhs)[iend];
1726 }
1727 //*************************************************************************************************
1728 
1729 
1730 //*************************************************************************************************
1741 template< typename Type // Data type of the vector
1742  , bool TF > // Transpose flag
1743 template< typename VT > // Type of the right-hand side dense vector
1744 inline typename EnableIf< typename DynamicVector<Type,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1746 {
1747  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1748 
1750 
1751  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == ( size_ & size_t(-IT::size*4) ), "Invalid end calculation" );
1752  const size_t iend( size_ & size_t(-IT::size*4) );
1753 
1754  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1755  store( v_+i , load(v_+i ) * (~rhs).get(i ) );
1756  store( v_+i+IT::size , load(v_+i+IT::size ) * (~rhs).get(i+IT::size ) );
1757  store( v_+i+IT::size*2UL, load(v_+i+IT::size*2UL) * (~rhs).get(i+IT::size*2UL) );
1758  store( v_+i+IT::size*3UL, load(v_+i+IT::size*3UL) * (~rhs).get(i+IT::size*3UL) );
1759  }
1760  for( size_t i=iend; i<size_; i+=IT::size ) {
1761  store( v_+i, load(v_+i) * (~rhs).get(i) );
1762  }
1763 }
1764 //*************************************************************************************************
1765 
1766 
1767 //*************************************************************************************************
1778 template< typename Type // Data type of the vector
1779  , bool TF > // Transpose flag
1780 template< typename VT > // Type of the right-hand side sparse vector
1782 {
1783  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
1784 
1785  const DynamicVector tmp( *this );
1786 
1787  reset();
1788 
1789  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1790  v_[element->index()] = tmp[element->index()] * element->value();
1791 }
1792 //*************************************************************************************************
1793 
1794 
1795 
1796 
1797 //=================================================================================================
1798 //
1799 // DYNAMICVECTOR OPERATORS
1800 //
1801 //=================================================================================================
1802 
1803 //*************************************************************************************************
1806 template< typename Type, bool TF >
1807 inline void reset( DynamicVector<Type,TF>& v );
1808 
1809 template< typename Type, bool TF >
1810 inline void clear( DynamicVector<Type,TF>& v );
1811 
1812 template< typename Type, bool TF >
1813 inline bool isnan( const DynamicVector<Type,TF>& v );
1814 
1815 template< typename Type, bool TF >
1816 inline bool isDefault( const DynamicVector<Type,TF>& v );
1817 
1818 template< typename Type, bool TF >
1819 inline void swap( DynamicVector<Type,TF>& a, DynamicVector<Type,TF>& b ) /* throw() */;
1821 //*************************************************************************************************
1822 
1823 
1824 //*************************************************************************************************
1831 template< typename Type // Data type of the vector
1832  , bool TF > // Transpose flag
1834 {
1835  v.reset();
1836 }
1837 //*************************************************************************************************
1838 
1839 
1840 //*************************************************************************************************
1847 template< typename Type // Data type of the vector
1848  , bool TF > // Transpose flag
1850 {
1851  v.clear();
1852 }
1853 //*************************************************************************************************
1854 
1855 
1856 //*************************************************************************************************
1873 template< typename Type // Data type of the vector
1874  , bool TF > // Transpose flag
1875 inline bool isnan( const DynamicVector<Type,TF>& v )
1876 {
1877  for( size_t i=0UL; i<v.size(); ++i ) {
1878  if( isnan( v[i] ) ) return true;
1879  }
1880  return false;
1881 }
1882 //*************************************************************************************************
1883 
1884 
1885 //*************************************************************************************************
1904 template< typename Type // Data type of the vector
1905  , bool TF > // Transpose flag
1906 inline bool isDefault( const DynamicVector<Type,TF>& v )
1907 {
1908  for( size_t i=0UL; i<v.size(); ++i )
1909  if( !isDefault( v[i] ) ) return false;
1910  return true;
1911 }
1912 //*************************************************************************************************
1913 
1914 
1915 //*************************************************************************************************
1924 template< typename Type // Data type of the vector
1925  , bool TF > // Transpose flag
1926 inline void swap( DynamicVector<Type,TF>& a, DynamicVector<Type,TF>& b ) /* throw() */
1927 {
1928  a.swap( b );
1929 }
1930 //*************************************************************************************************
1931 
1932 
1933 
1934 
1935 //=================================================================================================
1936 //
1937 // ISRESIZABLE SPECIALIZATIONS
1938 //
1939 //=================================================================================================
1940 
1941 //*************************************************************************************************
1943 template< typename T, bool TF >
1944 struct IsResizable< DynamicVector<T,TF> > : public TrueType
1945 {
1946  enum { value = 1 };
1947  typedef TrueType Type;
1948 };
1949 
1950 template< typename T, bool TF >
1951 struct IsResizable< const DynamicVector<T,TF> > : public TrueType
1952 {
1953  enum { value = 1 };
1954  typedef TrueType Type;
1955 };
1956 
1957 template< typename T, bool TF >
1958 struct IsResizable< volatile DynamicVector<T,TF> > : public TrueType
1959 {
1960  enum { value = 1 };
1961  typedef TrueType Type;
1962 };
1963 
1964 template< typename T, bool TF >
1965 struct IsResizable< const volatile DynamicVector<T,TF> > : public TrueType
1966 {
1967  enum { value = 1 };
1968  typedef TrueType Type;
1969 };
1971 //*************************************************************************************************
1972 
1973 
1974 
1975 
1976 //=================================================================================================
1977 //
1978 // ADDTRAIT SPECIALIZATIONS
1979 //
1980 //=================================================================================================
1981 
1982 //*************************************************************************************************
1984 template< typename T1, bool TF, typename T2, size_t N >
1985 struct AddTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
1986 {
1987  typedef StaticVector< typename AddTrait<T1,T2>::Type, N, TF > Type;
1988 };
1989 
1990 template< typename T1, size_t N, bool TF, typename T2 >
1991 struct AddTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
1992 {
1993  typedef StaticVector< typename AddTrait<T1,T2>::Type, N, TF > Type;
1994 };
1995 
1996 template< typename T1, bool TF, typename T2 >
1997 struct AddTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
1998 {
1999  typedef DynamicVector< typename AddTrait<T1,T2>::Type, TF > Type;
2000 };
2002 //*************************************************************************************************
2003 
2004 
2005 
2006 
2007 //=================================================================================================
2008 //
2009 // SUBTRAIT SPECIALIZATIONS
2010 //
2011 //=================================================================================================
2012 
2013 //*************************************************************************************************
2015 template< typename T1, bool TF, typename T2, size_t N >
2016 struct SubTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2017 {
2018  typedef StaticVector< typename SubTrait<T1,T2>::Type, N, TF > Type;
2019 };
2020 
2021 template< typename T1, size_t N, bool TF, typename T2 >
2022 struct SubTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2023 {
2024  typedef StaticVector< typename SubTrait<T1,T2>::Type, N, TF > Type;
2025 };
2026 
2027 template< typename T1, bool TF, typename T2 >
2028 struct SubTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2029 {
2030  typedef DynamicVector< typename SubTrait<T1,T2>::Type, TF > Type;
2031 };
2033 //*************************************************************************************************
2034 
2035 
2036 
2037 
2038 //=================================================================================================
2039 //
2040 // MULTTRAIT SPECIALIZATIONS
2041 //
2042 //=================================================================================================
2043 
2044 //*************************************************************************************************
2046 template< typename T1, bool TF, typename T2 >
2047 struct MultTrait< DynamicVector<T1,TF>, T2 >
2048 {
2049  typedef DynamicVector< typename MultTrait<T1,T2>::Type, TF > Type;
2051 };
2052 
2053 template< typename T1, typename T2, bool TF >
2054 struct MultTrait< T1, DynamicVector<T2,TF> >
2055 {
2056  typedef DynamicVector< typename MultTrait<T1,T2>::Type, TF > Type;
2058 };
2059 
2060 template< typename T1, bool TF, typename T2, size_t N >
2061 struct MultTrait< DynamicVector<T1,TF>, StaticVector<T2,N,TF> >
2062 {
2063  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2064 };
2065 
2066 template< typename T1, typename T2, size_t N >
2067 struct MultTrait< DynamicVector<T1,false>, StaticVector<T2,N,true> >
2068 {
2069  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2070 };
2071 
2072 template< typename T1, typename T2, size_t N >
2073 struct MultTrait< DynamicVector<T1,true>, StaticVector<T2,N,false> >
2074 {
2075  typedef typename MultTrait<T1,T2>::Type Type;
2076 };
2077 
2078 template< typename T1, size_t N, bool TF, typename T2 >
2079 struct MultTrait< StaticVector<T1,N,TF>, DynamicVector<T2,TF> >
2080 {
2081  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2082 };
2083 
2084 template< typename T1, size_t N, typename T2 >
2085 struct MultTrait< StaticVector<T1,N,false>, DynamicVector<T2,true> >
2086 {
2087  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2088 };
2089 
2090 template< typename T1, size_t N, typename T2 >
2091 struct MultTrait< StaticVector<T1,N,true>, DynamicVector<T2,false> >
2092 {
2093  typedef typename MultTrait<T1,T2>::Type Type;
2094 };
2095 
2096 template< typename T1, bool TF, typename T2 >
2097 struct MultTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2098 {
2099  typedef DynamicVector< typename MultTrait<T1,T2>::Type, TF > Type;
2100 };
2101 
2102 template< typename T1, typename T2 >
2103 struct MultTrait< DynamicVector<T1,false>, DynamicVector<T2,true> >
2104 {
2105  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2106 };
2107 
2108 template< typename T1, typename T2 >
2109 struct MultTrait< DynamicVector<T1,true>, DynamicVector<T2,false> >
2110 {
2111  typedef typename MultTrait<T1,T2>::Type Type;
2112 };
2114 //*************************************************************************************************
2115 
2116 
2117 
2118 
2119 //=================================================================================================
2120 //
2121 // CROSSTRAIT SPECIALIZATIONS
2122 //
2123 //=================================================================================================
2124 
2125 //*************************************************************************************************
2127 template< typename T1, typename T2 >
2128 struct CrossTrait< DynamicVector<T1,false>, StaticVector<T2,3UL,false> >
2129 {
2130  private:
2131  typedef typename MultTrait<T1,T2>::Type T;
2132 
2133  public:
2134  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2135 };
2136 
2137 template< typename T1, typename T2 >
2138 struct CrossTrait< StaticVector<T1,3UL,false>, DynamicVector<T2,false> >
2139 {
2140  private:
2141  typedef typename MultTrait<T1,T2>::Type T;
2142 
2143  public:
2144  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2145 };
2146 
2147 template< typename T1, typename T2 >
2148 struct CrossTrait< DynamicVector<T1,false>, DynamicVector<T2,false> >
2149 {
2150  private:
2151  typedef typename MultTrait<T1,T2>::Type T;
2152 
2153  public:
2154  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2155 };
2157 //*************************************************************************************************
2158 
2159 
2160 
2161 
2162 //=================================================================================================
2163 //
2164 // DIVTRAIT SPECIALIZATIONS
2165 //
2166 //=================================================================================================
2167 
2168 //*************************************************************************************************
2170 template< typename T1, bool TF, typename T2 >
2171 struct DivTrait< DynamicVector<T1,TF>, T2 >
2172 {
2173  typedef DynamicVector< typename DivTrait<T1,T2>::Type, TF > Type;
2175 };
2177 //*************************************************************************************************
2178 
2179 
2180 
2181 
2182 //=================================================================================================
2183 //
2184 // MATHTRAIT SPECIALIZATIONS
2185 //
2186 //=================================================================================================
2187 
2188 //*************************************************************************************************
2190 template< typename T1, bool TF, typename T2 >
2191 struct MathTrait< DynamicVector<T1,TF>, DynamicVector<T2,TF> >
2192 {
2193  typedef DynamicVector< typename MathTrait<T1,T2>::HighType, TF > HighType;
2194  typedef DynamicVector< typename MathTrait<T1,T2>::LowType , TF > LowType;
2195 };
2197 //*************************************************************************************************
2198 
2199 } // namespace blaze
2200 
2201 #endif