All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HybridVector.h
Go to the documentation of this file.
1 //=================================================================================================
24 //=================================================================================================
25 
26 #ifndef _BLAZE_MATH_DENSE_HYBRIDVECTOR_H_
27 #define _BLAZE_MATH_DENSE_HYBRIDVECTOR_H_
28 
29 
30 //*************************************************************************************************
31 // Includes
32 //*************************************************************************************************
33 
34 #include <algorithm>
35 #include <stdexcept>
39 #include <blaze/math/Forward.h>
40 #include <blaze/math/Functions.h>
41 #include <blaze/math/Intrinsics.h>
43 #include <blaze/math/shims/Reset.h>
54 #include <blaze/util/Assert.h>
61 #include <blaze/util/DisableIf.h>
62 #include <blaze/util/EnableIf.h>
64 #include <blaze/util/Template.h>
65 #include <blaze/util/Types.h>
69 #include <blaze/util/Unused.h>
70 
71 
72 namespace blaze {
73 
74 //=================================================================================================
75 //
76 // CLASS DEFINITION
77 //
78 //=================================================================================================
79 
80 //*************************************************************************************************
150 template< typename Type // Data type of the vector
151  , size_t N // Number of elements
152  , bool TF = defaultTransposeFlag > // Transpose flag
153 class HybridVector : public DenseVector< HybridVector<Type,N,TF>, TF >
154 {
155  private:
156  //**Type definitions****************************************************************************
158  //**********************************************************************************************
159 
160  //**********************************************************************************************
162  enum { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size };
163  //**********************************************************************************************
164 
165  public:
166  //**Type definitions****************************************************************************
168  typedef This ResultType;
170  typedef Type ElementType;
171  typedef typename IT::Type IntrinsicType;
172  typedef const Type& ReturnType;
173  typedef const HybridVector& CompositeType;
174  typedef Type& Reference;
175  typedef const Type& ConstReference;
178  //**********************************************************************************************
179 
180  //**Compilation flags***************************************************************************
182 
186  enum { vectorizable = IsVectorizable<Type>::value };
187 
189 
192  enum { smpAssignable = 0 };
193  //**********************************************************************************************
194 
195  //**Constructors********************************************************************************
198  explicit inline HybridVector();
199  explicit inline HybridVector( size_t n );
200  explicit inline HybridVector( size_t n, const Type& init );
201  template< typename Other > explicit inline HybridVector( size_t n, const Other* array );
202 
203  template< typename Other, size_t M >
204  explicit inline HybridVector( const Other (&array)[M] );
205 
206  inline HybridVector( const HybridVector& v );
207  template< typename VT > inline HybridVector( const Vector<VT,TF>& v );
209  //**********************************************************************************************
210 
211  //**Destructor**********************************************************************************
212  // No explicitly declared destructor.
213  //**********************************************************************************************
214 
215  //**Data access functions***********************************************************************
218  inline Reference operator[]( size_t index );
219  inline ConstReference operator[]( size_t index ) const;
220  inline Type* data ();
221  inline const Type* data () const;
222  inline Iterator begin ();
223  inline ConstIterator begin () const;
224  inline ConstIterator cbegin() const;
225  inline Iterator end ();
226  inline ConstIterator end () const;
227  inline ConstIterator cend () const;
229  //**********************************************************************************************
230 
231  //**Assignment operators************************************************************************
234  template< typename Other, size_t M >
235  inline HybridVector& operator=( const Other (&array)[M] );
236 
237  inline HybridVector& operator= ( const Type& rhs );
238  inline HybridVector& operator= ( const HybridVector& rhs );
239  template< typename VT > inline HybridVector& operator= ( const Vector<VT,TF>& rhs );
240  template< typename VT > inline HybridVector& operator+=( const Vector<VT,TF>& rhs );
241  template< typename VT > inline HybridVector& operator-=( const Vector<VT,TF>& rhs );
242  template< typename VT > inline HybridVector& operator*=( const Vector<VT,TF>& rhs );
243 
244  template< typename Other >
245  inline typename EnableIf< IsNumeric<Other>, HybridVector >::Type&
246  operator*=( Other rhs );
247 
248  template< typename Other >
249  inline typename EnableIf< IsNumeric<Other>, HybridVector >::Type&
250  operator/=( Other rhs );
252  //**********************************************************************************************
253 
254  //**Utility functions***************************************************************************
257  inline size_t size() const;
258  inline size_t capacity() const;
259  inline size_t nonZeros() const;
260  inline void reset();
261  inline void clear();
262  inline void resize( size_t n, bool preserve=true );
263  inline void extend( size_t n, bool preserve=true );
264  template< typename Other > inline HybridVector& scale( Other scalar );
265  inline void swap( HybridVector& v ) /* throw() */;
267  //**********************************************************************************************
268 
269  private:
270  //**********************************************************************************************
272  template< typename VT >
274  struct VectorizedAssign {
275  enum { value = vectorizable && VT::vectorizable &&
276  IsSame<Type,typename VT::ElementType>::value };
277  };
279  //**********************************************************************************************
280 
281  //**********************************************************************************************
283  template< typename VT >
285  struct VectorizedAddAssign {
286  enum { value = vectorizable && VT::vectorizable &&
287  IsSame<Type,typename VT::ElementType>::value &&
288  IntrinsicTrait<Type>::addition };
289  };
291  //**********************************************************************************************
292 
293  //**********************************************************************************************
295  template< typename VT >
297  struct VectorizedSubAssign {
298  enum { value = vectorizable && VT::vectorizable &&
299  IsSame<Type,typename VT::ElementType>::value &&
300  IntrinsicTrait<Type>::subtraction };
301  };
303  //**********************************************************************************************
304 
305  //**********************************************************************************************
307  template< typename VT >
309  struct VectorizedMultAssign {
310  enum { value = vectorizable && VT::vectorizable &&
311  IsSame<Type,typename VT::ElementType>::value &&
312  IntrinsicTrait<Type>::multiplication };
313  };
315  //**********************************************************************************************
316 
317  public:
318  //**Expression template evaluation functions****************************************************
321  template< typename Other > inline bool canAlias ( const Other* alias ) const;
322  template< typename Other > inline bool isAliased( const Other* alias ) const;
323 
324  inline IntrinsicType load ( size_t index ) const;
325  inline IntrinsicType loadu ( size_t index ) const;
326  inline void store ( size_t index, const IntrinsicType& value );
327  inline void storeu( size_t index, const IntrinsicType& value );
328  inline void stream( size_t index, const IntrinsicType& value );
329 
330  template< typename VT >
331  inline typename DisableIf< VectorizedAssign<VT> >::Type
332  assign( const DenseVector<VT,TF>& rhs );
333 
334  template< typename VT >
335  inline typename EnableIf< VectorizedAssign<VT> >::Type
336  assign( const DenseVector<VT,TF>& rhs );
337 
338  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
339 
340  template< typename VT >
341  inline typename DisableIf< VectorizedAddAssign<VT> >::Type
342  addAssign( const DenseVector<VT,TF>& rhs );
343 
344  template< typename VT >
345  inline typename EnableIf< VectorizedAddAssign<VT> >::Type
346  addAssign( const DenseVector<VT,TF>& rhs );
347 
348  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
349 
350  template< typename VT >
351  inline typename DisableIf< VectorizedSubAssign<VT> >::Type
352  subAssign( const DenseVector<VT,TF>& rhs );
353 
354  template< typename VT >
355  inline typename EnableIf< VectorizedSubAssign<VT> >::Type
356  subAssign( const DenseVector<VT,TF>& rhs );
357 
358  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
359 
360  template< typename VT >
361  inline typename DisableIf< VectorizedMultAssign<VT> >::Type
362  multAssign( const DenseVector<VT,TF>& rhs );
363 
364  template< typename VT >
365  inline typename EnableIf< VectorizedMultAssign<VT> >::Type
366  multAssign( const DenseVector<VT,TF>& rhs );
367 
368  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
370  //**********************************************************************************************
371 
372  private:
373  //**Member variables****************************************************************************
377 
382  size_t size_;
383 
384  //**********************************************************************************************
385 
386  //**Compile time checks*************************************************************************
392  BLAZE_STATIC_ASSERT( NN % IT::size == 0UL );
393  BLAZE_STATIC_ASSERT( NN >= N );
395  //**********************************************************************************************
396 };
397 //*************************************************************************************************
398 
399 
400 
401 
402 //=================================================================================================
403 //
404 // CONSTRUCTORS
405 //
406 //=================================================================================================
407 
408 //*************************************************************************************************
413 template< typename Type // Data type of the vector
414  , size_t N // Number of elements
415  , bool TF > // Transpose flag
417  : size_( 0UL ) // The current size/dimension of the vector
418 {
419  if( IsNumeric<Type>::value ) {
420  for( size_t i=0UL; i<NN; ++i )
421  v_[i] = Type();
422  }
423 }
424 //*************************************************************************************************
425 
426 
427 //*************************************************************************************************
437 template< typename Type // Data type of the vector
438  , size_t N // Number of elements
439  , bool TF > // Transpose flag
441  : size_( n ) // The current size/dimension of the vector
442 {
443  if( n > N )
444  throw std::invalid_argument( "Invalid size for hybrid vector" );
445 
446  if( IsNumeric<Type>::value ) {
447  for( size_t i=0UL; i<NN; ++i )
448  v_[i] = Type();
449  }
450 }
451 //*************************************************************************************************
452 
453 
454 //*************************************************************************************************
465 template< typename Type // Data type of the vector
466  , size_t N // Number of elements
467  , bool TF > // Transpose flag
468 inline HybridVector<Type,N,TF>::HybridVector( size_t n, const Type& init )
469  : size_( n ) // The current size/dimension of the vector
470 {
471  if( n > N )
472  throw std::invalid_argument( "Invalid size for hybrid vector" );
473 
474  for( size_t i=0UL; i<n; ++i )
475  v_[i] = init;
476 
477  if( IsNumeric<Type>::value ) {
478  for( size_t i=n; i<NN; ++i )
479  v_[i] = Type();
480  }
481 }
482 //*************************************************************************************************
483 
484 
485 //*************************************************************************************************
507 template< typename Type // Data type of the vector
508  , size_t N // Number of elements
509  , bool TF > // Transpose flag
510 template< typename Other > // Data type of the initialization array
511 inline HybridVector<Type,N,TF>::HybridVector( size_t n, const Other* array )
512  : size_( n ) // The current size/dimension of the vector
513 {
514  if( n > N )
515  throw std::invalid_argument( "Invalid setup of hybrid vector" );
516 
517  for( size_t i=0UL; i<n; ++i )
518  v_[i] = array[i];
519 
520  if( IsNumeric<Type>::value ) {
521  for( size_t i=n; i<NN; ++i )
522  v_[i] = Type();
523  }
524 }
525 //*************************************************************************************************
526 
527 
528 //*************************************************************************************************
546 template< typename Type // Data type of the vector
547  , size_t N // Number of elements
548  , bool TF > // Transpose flag
549 template< typename Other // Data type of the initialization array
550  , size_t M > // Number of elements of the initialization array
551 inline HybridVector<Type,N,TF>::HybridVector( const Other (&array)[M] )
552  : size_( M ) // The current size/dimension of the vector
553 {
554  BLAZE_STATIC_ASSERT( M <= N );
555 
556  for( size_t i=0UL; i<M; ++i )
557  v_[i] = array[i];
558 
559  if( IsNumeric<Type>::value ) {
560  for( size_t i=M; i<NN; ++i )
561  v_[i] = Type();
562  }
563 }
564 //*************************************************************************************************
565 
566 
567 //*************************************************************************************************
574 template< typename Type // Data type of the vector
575  , size_t N // Number of elements
576  , bool TF > // Transpose flag
578  : size_( v.size_ ) // The current size/dimension of the vector
579 {
580  for( size_t i=0UL; i<size_; ++i )
581  v_[i] = v.v_[i];
582 
583  if( IsNumeric<Type>::value ) {
584  for( size_t i=size_; i<NN; ++i )
585  v_[i] = Type();
586  }
587 }
588 //*************************************************************************************************
589 
590 
591 //*************************************************************************************************
601 template< typename Type // Data type of the vector
602  , size_t N // Number of elements
603  , bool TF > // Transpose flag
604 template< typename VT > // Type of the foreign vector
606  : size_( (~v).size() ) // The current size/dimension of the vector
607 {
608  using blaze::assign;
609 
610  if( (~v).size() > N )
611  throw std::invalid_argument( "Invalid setup of hybrid vector" );
612 
613  if( IsNumeric<Type>::value ) {
614  for( size_t i=( IsSparseVector<VT>::value )?( 0UL ):( size_ ); i<NN; ++i )
615  v_[i] = Type();
616  }
617 
618  assign( *this, ~v );
619 }
620 //*************************************************************************************************
621 
622 
623 
624 
625 //=================================================================================================
626 //
627 // DATA ACCESS FUNCTIONS
628 //
629 //=================================================================================================
630 
631 //*************************************************************************************************
639 template< typename Type // Data type of the vector
640  , size_t N // Number of elements
641  , bool TF > // Transpose flag
644 {
645  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
646  return v_[index];
647 }
648 //*************************************************************************************************
649 
650 
651 //*************************************************************************************************
659 template< typename Type // Data type of the vector
660  , size_t N // Number of elements
661  , bool TF > // Transpose flag
664 {
665  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
666  return v_[index];
667 }
668 //*************************************************************************************************
669 
670 
671 //*************************************************************************************************
678 template< typename Type // Data type of the vector
679  , size_t N // Number of elements
680  , bool TF > // Transpose flag
682 {
683  return v_;
684 }
685 //*************************************************************************************************
686 
687 
688 //*************************************************************************************************
695 template< typename Type // Data type of the vector
696  , size_t N // Number of elements
697  , bool TF > // Transpose flag
698 inline const Type* HybridVector<Type,N,TF>::data() const
699 {
700  return v_;
701 }
702 //*************************************************************************************************
703 
704 
705 //*************************************************************************************************
710 template< typename Type // Data type of the vector
711  , size_t N // Number of elements
712  , bool TF > // Transpose flag
714 {
715  return Iterator( v_ );
716 }
717 //*************************************************************************************************
718 
719 
720 //*************************************************************************************************
725 template< typename Type // Data type of the vector
726  , size_t N // Number of elements
727  , bool TF > // Transpose flag
729 {
730  return ConstIterator( v_ );
731 }
732 //*************************************************************************************************
733 
734 
735 //*************************************************************************************************
740 template< typename Type // Data type of the vector
741  , size_t N // Number of elements
742  , bool TF > // Transpose flag
744 {
745  return ConstIterator( v_ );
746 }
747 //*************************************************************************************************
748 
749 
750 //*************************************************************************************************
755 template< typename Type // Data type of the vector
756  , size_t N // Number of elements
757  , bool TF > // Transpose flag
759 {
760  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
761  return Iterator( v_ + size_ );
762 }
763 //*************************************************************************************************
764 
765 
766 //*************************************************************************************************
771 template< typename Type // Data type of the vector
772  , size_t N // Number of elements
773  , bool TF > // Transpose flag
775 {
776  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
777  return ConstIterator( v_ + size_ );
778 }
779 //*************************************************************************************************
780 
781 
782 //*************************************************************************************************
787 template< typename Type // Data type of the vector
788  , size_t N // Number of elements
789  , bool TF > // Transpose flag
791 {
792  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
793  return ConstIterator( v_ + size_ );
794 }
795 //*************************************************************************************************
796 
797 
798 
799 
800 //=================================================================================================
801 //
802 // ASSIGNMENT OPERATORS
803 //
804 //=================================================================================================
805 
806 //*************************************************************************************************
825 template< typename Type // Data type of the vector
826  , size_t N // Number of elements
827  , bool TF > // Transpose flag
828 template< typename Other // Data type of the initialization array
829  , size_t M > // Number of elements of the initialization array
831 {
832  BLAZE_STATIC_ASSERT( M <= N );
833 
834  resize( M );
835 
836  for( size_t i=0UL; i<M; ++i )
837  v_[i] = array[i];
838 
839  return *this;
840 }
841 //*************************************************************************************************
842 
843 
844 //*************************************************************************************************
850 template< typename Type // Data type of the vector
851  , size_t N // Number of elements
852  , bool TF > // Transpose flag
854 {
855  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
856 
857  for( size_t i=0UL; i<size_; ++i )
858  v_[i] = rhs;
859  return *this;
860 }
861 //*************************************************************************************************
862 
863 
864 //*************************************************************************************************
872 template< typename Type // Data type of the vector
873  , size_t N // Number of elements
874  , bool TF > // Transpose flag
876 {
877  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
878 
879  resize( rhs.size() );
880 
881  for( size_t i=0UL; i<size_; ++i )
882  v_[i] = rhs.v_[i];
883 
884  return *this;
885 }
886 //*************************************************************************************************
887 
888 
889 //*************************************************************************************************
899 template< typename Type // Data type of the vector
900  , size_t N // Number of elements
901  , bool TF > // Transpose flag
902 template< typename VT > // Type of the right-hand side vector
904 {
905  using blaze::assign;
906 
907  if( (~rhs).size() > N )
908  throw std::invalid_argument( "Invalid assignment to hybrid vector" );
909 
910  if( (~rhs).canAlias( this ) ) {
911  HybridVector tmp( ~rhs );
912  swap( tmp );
913  }
914  else {
915  resize( (~rhs).size() );
917  reset();
918  assign( *this, ~rhs );
919  }
920 
921  return *this;
922 }
923 //*************************************************************************************************
924 
925 
926 //*************************************************************************************************
936 template< typename Type // Data type of the vector
937  , size_t N // Number of elements
938  , bool TF > // Transpose flag
939 template< typename VT > // Type of the right-hand side vector
941 {
942  using blaze::addAssign;
943 
944  if( (~rhs).size() != size_ )
945  throw std::invalid_argument( "Vector sizes do not match" );
946 
947  if( (~rhs).canAlias( this ) ) {
948  typename VT::ResultType tmp( ~rhs );
949  addAssign( *this, tmp );
950  }
951  else {
952  addAssign( *this, ~rhs );
953  }
954 
955  return *this;
956 }
957 //*************************************************************************************************
958 
959 
960 //*************************************************************************************************
970 template< typename Type // Data type of the vector
971  , size_t N // Number of elements
972  , bool TF > // Transpose flag
973 template< typename VT > // Type of the right-hand side vector
975 {
976  using blaze::subAssign;
977 
978  if( (~rhs).size() != size_ )
979  throw std::invalid_argument( "Vector sizes do not match" );
980 
981  if( (~rhs).canAlias( this ) ) {
982  typename VT::ResultType tmp( ~rhs );
983  subAssign( *this, tmp );
984  }
985  else {
986  subAssign( *this, ~rhs );
987  }
988 
989  return *this;
990 }
991 //*************************************************************************************************
992 
993 
994 //*************************************************************************************************
1005 template< typename Type // Data type of the vector
1006  , size_t N // Number of elements
1007  , bool TF > // Transpose flag
1008 template< typename VT > // Type of the right-hand side vector
1010 {
1011  using blaze::assign;
1012 
1013  if( (~rhs).size() != size_ )
1014  throw std::invalid_argument( "Vector sizes do not match" );
1015 
1016  if( (~rhs).canAlias( this ) || IsSparseVector<VT>::value ) {
1017  HybridVector tmp( *this * (~rhs) );
1018  this->operator=( tmp );
1019  }
1020  else {
1021  assign( *this, *this * (~rhs) );
1022  }
1023 
1024  return *this;
1025 }
1026 //*************************************************************************************************
1027 
1028 
1029 //*************************************************************************************************
1036 template< typename Type // Data type of the vector
1037  , size_t N // Number of elements
1038  , bool TF > // Transpose flag
1039 template< typename Other > // Data type of the right-hand side scalar
1040 inline typename EnableIf< IsNumeric<Other>, HybridVector<Type,N,TF> >::Type&
1042 {
1043  using blaze::assign;
1044 
1045  assign( *this, (*this) * rhs );
1046  return *this;
1047 }
1048 //*************************************************************************************************
1049 
1050 
1051 //*************************************************************************************************
1060 template< typename Type // Data type of the vector
1061  , size_t N // Number of elements
1062  , bool TF > // Transpose flag
1063 template< typename Other > // Data type of the right-hand side scalar
1064 inline typename EnableIf< IsNumeric<Other>, HybridVector<Type,N,TF> >::Type&
1066 {
1067  using blaze::assign;
1068 
1069  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1070 
1071  assign( *this, (*this) / rhs );
1072  return *this;
1073 }
1074 //*************************************************************************************************
1075 
1076 
1077 
1078 
1079 //=================================================================================================
1080 //
1081 // UTILITY FUNCTIONS
1082 //
1083 //=================================================================================================
1084 
1085 //*************************************************************************************************
1090 template< typename Type // Data type of the vector
1091  , size_t N // Number of elements
1092  , bool TF > // Transpose flag
1093 inline size_t HybridVector<Type,N,TF>::size() const
1094 {
1095  return size_;
1096 }
1097 //*************************************************************************************************
1098 
1099 
1100 //*************************************************************************************************
1105 template< typename Type // Data type of the vector
1106  , size_t N // Number of elements
1107  , bool TF > // Transpose flag
1109 {
1110  return NN;
1111 }
1112 //*************************************************************************************************
1113 
1114 
1115 //*************************************************************************************************
1123 template< typename Type // Data type of the vector
1124  , size_t N // Number of elements
1125  , bool TF > // Transpose flag
1127 {
1128  size_t nonzeros( 0 );
1129 
1130  for( size_t i=0UL; i<size_; ++i ) {
1131  if( !isDefault( v_[i] ) )
1132  ++nonzeros;
1133  }
1134 
1135  return nonzeros;
1136 }
1137 //*************************************************************************************************
1138 
1139 
1140 //*************************************************************************************************
1145 template< typename Type // Data type of the vector
1146  , size_t N // Number of elements
1147  , bool TF > // Transpose flag
1149 {
1150  using blaze::reset;
1151  for( size_t i=0UL; i<size_; ++i )
1152  reset( v_[i] );
1153 }
1154 //*************************************************************************************************
1155 
1156 
1157 //*************************************************************************************************
1164 template< typename Type // Data type of the vector
1165  , size_t N // Number of elements
1166  , bool TF > // Transpose flag
1168 {
1169  resize( 0UL );
1170 }
1171 //*************************************************************************************************
1172 
1173 
1174 //*************************************************************************************************
1202 template< typename Type // Data type of the vector
1203  , size_t N // Number of elements
1204  , bool TF > // Transpose flag
1205 inline void HybridVector<Type,N,TF>::resize( size_t n, bool preserve )
1206 {
1207  UNUSED_PARAMETER( preserve );
1208 
1209  if( n > N )
1210  throw std::invalid_argument( "Invalid size for hybrid vector" );
1211 
1212  if( IsNumeric<Type>::value && n < size_ ) {
1213  for( size_t i=n; i<size_; ++i )
1214  v_[i] = Type();
1215  }
1216 
1217  size_ = n;
1218 }
1219 //*************************************************************************************************
1220 
1221 
1222 //*************************************************************************************************
1236 template< typename Type // Data type of the vector
1237  , size_t N // Number of elements
1238  , bool TF > // Transpose flag
1239 inline void HybridVector<Type,N,TF>::extend( size_t n, bool preserve )
1240 {
1241  UNUSED_PARAMETER( preserve );
1242  resize( size_+n );
1243 }
1244 //*************************************************************************************************
1245 
1246 
1247 //*************************************************************************************************
1253 template< typename Type // Data type of the vector
1254  , size_t N // Number of elements
1255  , bool TF > // Transpose flag
1256 template< typename Other > // Data type of the scalar value
1258 {
1259  for( size_t i=0; i<size_; ++i )
1260  v_[i] *= scalar;
1261  return *this;
1262 }
1263 //*************************************************************************************************
1264 
1265 
1266 //*************************************************************************************************
1273 template< typename Type // Data type of the vector
1274  , size_t N // Number of elements
1275  , bool TF > // Transpose flag
1276 inline void HybridVector<Type,N,TF>::swap( HybridVector& v ) /* throw() */
1277 {
1278  using std::swap;
1279 
1280  const size_t maxsize( max( size_, v.size_ ) );
1281  for( size_t i=0UL; i<maxsize; ++i )
1282  swap( v_[i], v.v_[i] );
1283  swap( size_, v.size_ );
1284 }
1285 //*************************************************************************************************
1286 
1287 
1288 
1289 
1290 //=================================================================================================
1291 //
1292 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1293 //
1294 //=================================================================================================
1295 
1296 //*************************************************************************************************
1306 template< typename Type // Data type of the vector
1307  , size_t N // Number of elements
1308  , bool TF > // Transpose flag
1309 template< typename Other > // Data type of the foreign expression
1310 inline bool HybridVector<Type,N,TF>::canAlias( const Other* alias ) const
1311 {
1312  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1313 }
1314 //*************************************************************************************************
1315 
1316 
1317 //*************************************************************************************************
1327 template< typename Type // Data type of the vector
1328  , size_t N // Number of elements
1329  , bool TF > // Transpose flag
1330 template< typename Other > // Data type of the foreign expression
1331 inline bool HybridVector<Type,N,TF>::isAliased( const Other* alias ) const
1332 {
1333  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1334 }
1335 //*************************************************************************************************
1336 
1337 
1338 //*************************************************************************************************
1351 template< typename Type // Data type of the vector
1352  , size_t N // Number of elements
1353  , bool TF > // Transpose flag
1355  HybridVector<Type,N,TF>::load( size_t index ) const
1356 {
1357  using blaze::load;
1358 
1360 
1361  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1362  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1363  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL , "Invalid vector access index" );
1364 
1365  return load( &v_[index] );
1366 }
1367 //*************************************************************************************************
1368 
1369 
1370 //*************************************************************************************************
1383 template< typename Type // Data type of the vector
1384  , size_t N // Number of elements
1385  , bool TF > // Transpose flag
1387  HybridVector<Type,N,TF>::loadu( size_t index ) const
1388 {
1389  using blaze::loadu;
1390 
1392 
1393  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1394  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1395 
1396  return loadu( &v_[index] );
1397 }
1398 //*************************************************************************************************
1399 
1400 
1401 //*************************************************************************************************
1415 template< typename Type // Data type of the vector
1416  , size_t N // Number of elements
1417  , bool TF > // Transpose flag
1418 inline void HybridVector<Type,N,TF>::store( size_t index, const IntrinsicType& value )
1419 {
1420  using blaze::store;
1421 
1423 
1424  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1425  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1426  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL , "Invalid vector access index" );
1427 
1428  store( &v_[index], value );
1429 }
1430 //*************************************************************************************************
1431 
1432 
1433 //*************************************************************************************************
1447 template< typename Type // Data type of the vector
1448  , size_t N // Number of elements
1449  , bool TF > // Transpose flag
1450 inline void HybridVector<Type,N,TF>::storeu( size_t index, const IntrinsicType& value )
1451 {
1452  using blaze::storeu;
1453 
1455 
1456  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1457  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1458 
1459  storeu( &v_[index], value );
1460 }
1461 //*************************************************************************************************
1462 
1463 
1464 //*************************************************************************************************
1478 template< typename Type // Data type of the vector
1479  , size_t N // Number of elements
1480  , bool TF > // Transpose flag
1481 inline void HybridVector<Type,N,TF>::stream( size_t index, const IntrinsicType& value )
1482 {
1483  using blaze::stream;
1484 
1486 
1487  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1488  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1489  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL , "Invalid vector access index" );
1490 
1491  stream( &v_[index], value );
1492 }
1493 //*************************************************************************************************
1494 
1495 
1496 //*************************************************************************************************
1507 template< typename Type // Data type of the vector
1508  , size_t N // Number of elements
1509  , bool TF > // Transpose flag
1510 template< typename VT > // Type of the right-hand side dense vector
1511 inline typename DisableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1513 {
1514  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1515 
1516  for( size_t i=0UL; i<size_; ++i )
1517  v_[i] = (~rhs)[i];
1518 }
1519 //*************************************************************************************************
1520 
1521 
1522 //*************************************************************************************************
1533 template< typename Type // Data type of the vector
1534  , size_t N // Number of elements
1535  , bool TF > // Transpose flag
1536 template< typename VT > // Type of the right-hand side dense vector
1537 inline typename EnableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1539 {
1540  using blaze::store;
1541 
1542  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1543 
1545 
1546  for( size_t i=0UL; i<size_; i+=IT::size ) {
1547  store( v_+i, (~rhs).load(i) );
1548  }
1549 }
1550 //*************************************************************************************************
1551 
1552 
1553 //*************************************************************************************************
1564 template< typename Type // Data type of the vector
1565  , size_t N // Number of elements
1566  , bool TF > // Transpose flag
1567 template< typename VT > // Type of the right-hand side sparse vector
1569 {
1570  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1571 
1572  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1573  v_[element->index()] = element->value();
1574 }
1575 //*************************************************************************************************
1576 
1577 
1578 //*************************************************************************************************
1589 template< typename Type // Data type of the vector
1590  , size_t N // Number of elements
1591  , bool TF > // Transpose flag
1592 template< typename VT > // Type of the right-hand side dense vector
1593 inline typename DisableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1595 {
1596  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1597 
1598  for( size_t i=0UL; i<size_; ++i )
1599  v_[i] += (~rhs)[i];
1600 }
1601 //*************************************************************************************************
1602 
1603 
1604 //*************************************************************************************************
1615 template< typename Type // Data type of the vector
1616  , size_t N // Number of elements
1617  , bool TF > // Transpose flag
1618 template< typename VT > // Type of the right-hand side dense vector
1619 inline typename EnableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1621 {
1622  using blaze::load;
1623  using blaze::store;
1624 
1625  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1626 
1628 
1629  for( size_t i=0UL; i<size_; i+=IT::size ) {
1630  store( v_+i, load( v_+i ) + (~rhs).load(i) );
1631  }
1632 }
1633 //*************************************************************************************************
1634 
1635 
1636 //*************************************************************************************************
1647 template< typename Type // Data type of the vector
1648  , size_t N // Number of elements
1649  , bool TF > // Transpose flag
1650 template< typename VT > // Type of the right-hand side sparse vector
1652 {
1653  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1654 
1655  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1656  v_[element->index()] += element->value();
1657 }
1658 //*************************************************************************************************
1659 
1660 
1661 //*************************************************************************************************
1672 template< typename Type // Data type of the vector
1673  , size_t N // Number of elements
1674  , bool TF > // Transpose flag
1675 template< typename VT > // Type of the right-hand side dense vector
1676 inline typename DisableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1678 {
1679  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1680 
1681  for( size_t i=0UL; i<size_; ++i )
1682  v_[i] -= (~rhs)[i];
1683 }
1684 //*************************************************************************************************
1685 
1686 
1687 //*************************************************************************************************
1698 template< typename Type // Data type of the vector
1699  , size_t N // Number of elements
1700  , bool TF > // Transpose flag
1701 template< typename VT > // Type of the right-hand side dense vector
1702 inline typename EnableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1704 {
1705  using blaze::load;
1706  using blaze::store;
1707 
1708  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1709 
1711 
1712  for( size_t i=0UL; i<size_; i+=IT::size ) {
1713  store( v_+i, load( v_+i ) - (~rhs).load(i) );
1714  }
1715 }
1716 //*************************************************************************************************
1717 
1718 
1719 //*************************************************************************************************
1730 template< typename Type // Data type of the vector
1731  , size_t N // Number of elements
1732  , bool TF > // Transpose flag
1733 template< typename VT > // Type of the right-hand side sparse vector
1735 {
1736  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1737 
1738  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1739  v_[element->index()] -= element->value();
1740 }
1741 //*************************************************************************************************
1742 
1743 
1744 //*************************************************************************************************
1755 template< typename Type // Data type of the vector
1756  , size_t N // Number of elements
1757  , bool TF > // Transpose flag
1758 template< typename VT > // Type of the right-hand side dense vector
1759 inline typename DisableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1761 {
1762  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1763 
1764  for( size_t i=0UL; i<size_; ++i )
1765  v_[i] *= (~rhs)[i];
1766 }
1767 //*************************************************************************************************
1768 
1769 
1770 //*************************************************************************************************
1781 template< typename Type // Data type of the vector
1782  , size_t N // Number of elements
1783  , bool TF > // Transpose flag
1784 template< typename VT > // Type of the right-hand side dense vector
1785 inline typename EnableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1787 {
1788  using blaze::load;
1789  using blaze::store;
1790 
1791  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1792 
1794 
1795  for( size_t i=0UL; i<size_; i+=IT::size ) {
1796  store( v_+i, load( v_+i ) * (~rhs).load(i) );
1797  }
1798 }
1799 //*************************************************************************************************
1800 
1801 
1802 //*************************************************************************************************
1813 template< typename Type // Data type of the vector
1814  , size_t N // Number of elements
1815  , bool TF > // Transpose flag
1816 template< typename VT > // Type of the right-hand side sparse vector
1818 {
1819  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1820 
1821  const HybridVector tmp( *this );
1822 
1823  reset();
1824 
1825  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1826  v_[element->index()] = tmp[element->index()] * element->value();
1827 }
1828 //*************************************************************************************************
1829 
1830 
1831 
1832 
1833 
1834 
1835 
1836 
1837 //=================================================================================================
1838 //
1839 // UNDEFINED CLASS TEMPLATE SPECIALIZATION
1840 //
1841 //=================================================================================================
1842 
1843 //*************************************************************************************************
1851 template< typename Type // Data type of the vector
1852  , bool TF > // Transpose flag
1853 class HybridVector<Type,0UL,TF>;
1855 //*************************************************************************************************
1856 
1857 
1858 
1859 
1860 
1861 
1862 
1863 
1864 //=================================================================================================
1865 //
1866 // HYBRIDVECTOR OPERATORS
1867 //
1868 //=================================================================================================
1869 
1870 //*************************************************************************************************
1873 template< typename Type, size_t N, bool TF >
1874 inline void reset( HybridVector<Type,N,TF>& v );
1875 
1876 template< typename Type, size_t N, bool TF >
1877 inline void clear( HybridVector<Type,N,TF>& v );
1878 
1879 template< typename Type, size_t N, bool TF >
1880 inline bool isDefault( const HybridVector<Type,N,TF>& v );
1881 
1882 template< typename Type, size_t N, bool TF >
1883 inline void swap( HybridVector<Type,N,TF>& a, HybridVector<Type,N,TF>& b ) /* throw() */;
1885 //*************************************************************************************************
1886 
1887 
1888 //*************************************************************************************************
1895 template< typename Type // Data type of the vector
1896  , size_t N // Number of elements
1897  , bool TF > // Transpose flag
1899 {
1900  v.reset();
1901 }
1902 //*************************************************************************************************
1903 
1904 
1905 //*************************************************************************************************
1914 template< typename Type // Data type of the vector
1915  , size_t N // Number of elements
1916  , bool TF > // Transpose flag
1918 {
1919  v.clear();
1920 }
1921 //*************************************************************************************************
1922 
1923 
1924 //*************************************************************************************************
1942 template< typename Type // Data type of the vector
1943  , size_t N // Number of elements
1944  , bool TF > // Transpose flag
1945 inline bool isDefault( const HybridVector<Type,N,TF>& v )
1946 {
1947  for( size_t i=0UL; i<v.size(); ++i )
1948  if( !isDefault( v[i] ) ) return false;
1949  return true;
1950 }
1951 //*************************************************************************************************
1952 
1953 
1954 //*************************************************************************************************
1963 template< typename Type // Data type of the vector
1964  , size_t N // Number of elements
1965  , bool TF > // Transpose flag
1966 inline void swap( HybridVector<Type,N,TF>& a, HybridVector<Type,N,TF>& b ) /* throw() */
1967 {
1968  a.swap( b );
1969 }
1970 //*************************************************************************************************
1971 
1972 
1973 
1974 
1975 //=================================================================================================
1976 //
1977 // ADDTRAIT SPECIALIZATIONS
1978 //
1979 //=================================================================================================
1980 
1981 //*************************************************************************************************
1983 template< typename T1, size_t M, bool TF, typename T2, size_t N >
1984 struct AddTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
1985 {
1986  typedef StaticVector< typename AddTrait<T1,T2>::Type, N, TF > Type;
1987 };
1988 
1989 template< typename T1, size_t M, bool TF, typename T2, size_t N >
1990 struct AddTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
1991 {
1992  typedef StaticVector< typename AddTrait<T1,T2>::Type, M, TF > Type;
1993 };
1994 
1995 template< typename T1, size_t M, bool TF, typename T2, size_t N >
1996 struct AddTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
1997 {
1998  typedef HybridVector< typename AddTrait<T1,T2>::Type, ( M < N )?( M ):( N ), TF > Type;
1999 };
2001 //*************************************************************************************************
2002 
2003 
2004 
2005 
2006 //=================================================================================================
2007 //
2008 // SUBTRAIT SPECIALIZATIONS
2009 //
2010 //=================================================================================================
2011 
2012 //*************************************************************************************************
2014 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2015 struct SubTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2016 {
2017  typedef StaticVector< typename SubTrait<T1,T2>::Type, N, TF > Type;
2018 };
2019 
2020 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2021 struct SubTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2022 {
2023  typedef StaticVector< typename SubTrait<T1,T2>::Type, M, TF > Type;
2024 };
2025 
2026 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2027 struct SubTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2028 {
2029  typedef HybridVector< typename SubTrait<T1,T2>::Type, ( M < N )?( M ):( N ), TF > Type;
2030 };
2032 //*************************************************************************************************
2033 
2034 
2035 
2036 
2037 //=================================================================================================
2038 //
2039 // MULTTRAIT SPECIALIZATIONS
2040 //
2041 //=================================================================================================
2042 
2043 //*************************************************************************************************
2045 template< typename T1, size_t N, bool TF, typename T2 >
2046 struct MultTrait< HybridVector<T1,N,TF>, T2 >
2047 {
2048  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2050 };
2051 
2052 template< typename T1, typename T2, size_t N, bool TF >
2053 struct MultTrait< T1, HybridVector<T2,N,TF> >
2054 {
2055  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2057 };
2058 
2059 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2060 struct MultTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2061 {
2062  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2063 };
2064 
2065 template< typename T1, size_t M, typename T2, size_t N >
2066 struct MultTrait< HybridVector<T1,M,false>, StaticVector<T2,N,true> >
2067 {
2068  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2069 };
2070 
2071 template< typename T1, size_t M, typename T2, size_t N >
2072 struct MultTrait< HybridVector<T1,M,true>, StaticVector<T2,N,false> >
2073 {
2074  typedef typename MultTrait<T1,T2>::Type Type;
2075 };
2076 
2077 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2078 struct MultTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2079 {
2080  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, TF > Type;
2081 };
2082 
2083 template< typename T1, size_t M, typename T2, size_t N >
2084 struct MultTrait< StaticVector<T1,M,false>, HybridVector<T2,N,true> >
2085 {
2086  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2087 };
2088 
2089 template< typename T1, size_t M, typename T2, size_t N >
2090 struct MultTrait< StaticVector<T1,M,true>, HybridVector<T2,N,false> >
2091 {
2092  typedef typename MultTrait<T1,T2>::Type Type;
2093 };
2094 
2095 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2096 struct MultTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2097 {
2098  typedef HybridVector< typename MultTrait<T1,T2>::Type, ( M < N )?( M ):( N ), TF > Type;
2099 };
2100 
2101 template< typename T1, size_t M, typename T2, size_t N >
2102 struct MultTrait< HybridVector<T1,M,false>, HybridVector<T2,N,true> >
2103 {
2104  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2105 };
2106 
2107 template< typename T1, size_t M, typename T2, size_t N >
2108 struct MultTrait< HybridVector<T1,M,true>, HybridVector<T2,N,false> >
2109 {
2110  typedef typename MultTrait<T1,T2>::Type Type;
2111 };
2113 //*************************************************************************************************
2114 
2115 
2116 
2117 
2118 //=================================================================================================
2119 //
2120 // CROSSTRAIT SPECIALIZATIONS
2121 //
2122 //=================================================================================================
2123 
2124 //*************************************************************************************************
2126 template< typename T1, size_t N, typename T2 >
2127 struct CrossTrait< HybridVector<T1,N,false>, StaticVector<T2,3UL,false> >
2128 {
2129  private:
2130  typedef typename MultTrait<T1,T2>::Type T;
2131 
2132  public:
2133  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2134 };
2135 
2136 template< typename T1, typename T2, size_t N >
2137 struct CrossTrait< StaticVector<T1,3UL,false>, HybridVector<T2,N,false> >
2138 {
2139  private:
2140  typedef typename MultTrait<T1,T2>::Type T;
2141 
2142  public:
2143  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2144 };
2145 
2146 template< typename T1, size_t M, typename T2, size_t N >
2147 struct CrossTrait< HybridVector<T1,M,false>, HybridVector<T2,N,false> >
2148 {
2149  private:
2150  typedef typename MultTrait<T1,T2>::Type T;
2151 
2152  public:
2153  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2154 };
2156 //*************************************************************************************************
2157 
2158 
2159 
2160 
2161 //=================================================================================================
2162 //
2163 // DIVTRAIT SPECIALIZATIONS
2164 //
2165 //=================================================================================================
2166 
2167 //*************************************************************************************************
2169 template< typename T1, size_t N, bool TF, typename T2 >
2170 struct DivTrait< HybridVector<T1,N,TF>, T2 >
2171 {
2172  typedef HybridVector< typename DivTrait<T1,T2>::Type, N, TF > Type;
2174 };
2176 //*************************************************************************************************
2177 
2178 
2179 
2180 
2181 //=================================================================================================
2182 //
2183 // MATHTRAIT SPECIALIZATIONS
2184 //
2185 //=================================================================================================
2186 
2187 //*************************************************************************************************
2189 template< typename T1, size_t N, bool TF, typename T2 >
2190 struct MathTrait< HybridVector<T1,N,TF>, HybridVector<T2,N,TF> >
2191 {
2192  typedef StaticVector< typename MathTrait<T1,T2>::HighType, N, TF > HighType;
2193  typedef StaticVector< typename MathTrait<T1,T2>::LowType , N, TF > LowType;
2194 };
2196 //*************************************************************************************************
2197 
2198 
2199 
2200 
2201 //=================================================================================================
2202 //
2203 // SUBVECTORTRAIT SPECIALIZATIONS
2204 //
2205 //=================================================================================================
2206 
2207 //*************************************************************************************************
2209 template< typename T1, size_t N, bool TF >
2210 struct SubvectorTrait< HybridVector<T1,N,TF> >
2211 {
2212  typedef HybridVector<T1,N,TF> Type;
2213 };
2215 //*************************************************************************************************
2216 
2217 } // namespace blaze
2218 
2219 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:107
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
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
Constraint on the data type.
Header file for mathematical functions.
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4512
#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
EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
void extend(size_t n, bool preserve=true)
Extending the size of the vector.
Definition: HybridVector.h:1239
Header file for the UNUSED_PARAMETER function template.
HybridVector()
The default constructor for HybridVector.
Definition: HybridVector.h:416
Header file for the subtraction trait.
Header file for the SparseVector base class.
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: HybridVector.h:376
size_t capacity() const
Returns the maximum capacity of the vector.
Definition: HybridVector.h:1108
HybridVector< Type, N,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: HybridVector.h:169
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4555
IntrinsicType load(size_t index) const
Aligned load of an intrinsic element of the vector.
Definition: HybridVector.h:1355
EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:219
Header file for the IsSame and IsStrictlySame type traits.
void storeu(size_t index, const IntrinsicType &value)
Unaligned store of an intrinsic element of the vector.
Definition: HybridVector.h:1450
void storeu(float *address, const sse_float_t &value)
Unaligned store of a vector of &#39;float&#39; values.
Definition: Storeu.h:234
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:84
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
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: HybridVector.h:1126
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4528
Constraint on the data type.
Iterator begin()
Returns an iterator to the first element of the hybrid vector.
Definition: HybridVector.h:713
IntrinsicType loadu(size_t index) const
Unaligned load of an intrinsic element of the vector.
Definition: HybridVector.h:1387
Efficient implementation of a dynamically sized vector with static memory.The HybridVector class temp...
Definition: Forward.h:49
void stream(float *address, const sse_float_t &value)
Aligned, non-temporal store of a vector of &#39;float&#39; values.
Definition: Stream.h:233
const HybridVector & CompositeType
Data type for composite expression templates.
Definition: HybridVector.h:173
ConstIterator cbegin() const
Returns an iterator to the first element of the hybrid vector.
Definition: HybridVector.h:743
Header file for the DisableIf class template.
Header file for the multiplication trait.
ConstIterator cend() const
Returns an iterator just past the last element of the hybrid vector.
Definition: HybridVector.h:790
Header file for nested template disabiguation.
Compile time assertion.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two sparse matrices.
Definition: CompressedMatrix.h:4541
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
#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
size_t size() const
Returns the current size/dimension of the vector.
Definition: HybridVector.h:1093
Header file for the DenseIterator class template.
Header file for the subvector trait.
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:179
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: HybridVector.h:177
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
const Type & ConstReference
Reference to a constant vector value.
Definition: HybridVector.h:175
Type ElementType
Type of the vector elements.
Definition: HybridVector.h:170
#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
Type * data()
Low-level data access to the vector elements.
Definition: HybridVector.h:681
Reference operator[](size_t index)
Subscript operator for the direct access to the vector elements.
Definition: HybridVector.h:643
This ResultType
Result type for expression template evaluations.
Definition: HybridVector.h:168
void clear()
Clearing the vector.
Definition: HybridVector.h:1167
Header file for the EnableIf class template.
void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the vector.
Definition: HybridVector.h:1481
Header file for the IsVectorizable type trait.
ColumnIterator< const MT > ConstIterator
Iterator over constant elements.
Definition: DenseColumn.h:1972
Header file for the IsNumeric type trait.
IT::Type IntrinsicType
Intrinsic type of the vector elements.
Definition: HybridVector.h:171
void resize(size_t n, bool preserve=true)
Changing the size of the vector.
Definition: HybridVector.h:1205
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: HybridVector.h:176
Header file for the IsSparseVector type trait.
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:648
Header file for run time assertion macros.
IntrinsicTrait< Type > IT
Intrinsic trait for the vector element type.
Definition: HybridVector.h:157
Header file for the addition trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: HybridVector.h:172
Header file for the cross product trait.
Header file for the division trait.
void swap(DynamicMatrix< Type, SO > &a, DynamicMatrix< Type, SO > &b)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:4584
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:209
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
#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
Header file for the reset shim.
Header file for the AlignedArray implementation.
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:239
#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:2378
Header file for the isDefault shim.
Constraint on the data type.
void swap(HybridVector &v)
Swapping the contents of two hybrid vectors.
Definition: HybridVector.h:1276
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
bool isAliased(const Other *alias) const
Returns whether the vector is aliased with the given address alias.
Definition: HybridVector.h:1331
Type & Reference
Reference to a non-constant vector value.
Definition: HybridVector.h:174
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
Header file for all intrinsic functionality.
Header file for the mathematical trait.
void reset()
Reset to the default initial values.
Definition: HybridVector.h:1148
size_t size_
The current size/dimension of the vector.
Definition: HybridVector.h:382
Iterator end()
Returns an iterator just past the last element of the hybrid vector.
Definition: HybridVector.h:758
bool canAlias(const Other *alias) const
Returns whether the vector can alias with the given address alias.
Definition: HybridVector.h:1310
Header file for the default transpose flag for all vectors of the Blaze library.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:105
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2370
Header file for basic type definitions.
SelectType< useConst, ConstIterator, ColumnIterator< MT > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseColumn.h:1980
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:143
#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
void store(size_t index, const IntrinsicType &value)
Aligned store of an intrinsic element of the vector.
Definition: HybridVector.h:1418
HybridVector< Type, N, TF > This
Type of this HybridVector instance.
Definition: HybridVector.h:167
void store(float *address, const sse_float_t &value)
Aligned store of a vector of &#39;float&#39; values.
Definition: Store.h:242