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 //*************************************************************************************************
172 template< typename Type // Data type of the vector
173  , size_t N // Number of elements
174  , bool TF = defaultTransposeFlag > // Transpose flag
175 class HybridVector : public DenseVector< HybridVector<Type,N,TF>, TF >
176 {
177  private:
178  //**Type definitions****************************************************************************
180  //**********************************************************************************************
181 
182  //**********************************************************************************************
184  enum { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size };
185  //**********************************************************************************************
186 
187  public:
188  //**Type definitions****************************************************************************
190  typedef This ResultType;
192  typedef Type ElementType;
193  typedef typename IT::Type IntrinsicType;
194  typedef const Type& ReturnType;
195  typedef const HybridVector& CompositeType;
196  typedef Type& Reference;
197  typedef const Type& ConstReference;
200  //**********************************************************************************************
201 
202  //**Compilation flags***************************************************************************
204 
208  enum { vectorizable = IsVectorizable<Type>::value };
209 
211 
214  enum { smpAssignable = 0 };
215  //**********************************************************************************************
216 
217  //**Constructors********************************************************************************
220  explicit inline HybridVector();
221  explicit inline HybridVector( size_t n );
222  explicit inline HybridVector( size_t n, const Type& init );
223  template< typename Other > explicit inline HybridVector( size_t n, const Other* array );
224 
225  template< typename Other, size_t M >
226  explicit inline HybridVector( const Other (&array)[M] );
227 
228  inline HybridVector( const HybridVector& v );
229  template< typename VT > inline HybridVector( const Vector<VT,TF>& v );
231  //**********************************************************************************************
232 
233  //**Destructor**********************************************************************************
234  // No explicitly declared destructor.
235  //**********************************************************************************************
236 
237  //**Data access functions***********************************************************************
240  inline Reference operator[]( size_t index );
241  inline ConstReference operator[]( size_t index ) const;
242  inline Type* data ();
243  inline const Type* data () const;
244  inline Iterator begin ();
245  inline ConstIterator begin () const;
246  inline ConstIterator cbegin() const;
247  inline Iterator end ();
248  inline ConstIterator end () const;
249  inline ConstIterator cend () const;
251  //**********************************************************************************************
252 
253  //**Assignment operators************************************************************************
256  template< typename Other, size_t M >
257  inline HybridVector& operator=( const Other (&array)[M] );
258 
259  inline HybridVector& operator= ( const Type& rhs );
260  inline HybridVector& operator= ( const HybridVector& rhs );
261  template< typename VT > inline HybridVector& operator= ( const Vector<VT,TF>& rhs );
262  template< typename VT > inline HybridVector& operator+=( const Vector<VT,TF>& rhs );
263  template< typename VT > inline HybridVector& operator-=( const Vector<VT,TF>& rhs );
264  template< typename VT > inline HybridVector& operator*=( const Vector<VT,TF>& rhs );
265 
266  template< typename Other >
267  inline typename EnableIf< IsNumeric<Other>, HybridVector >::Type&
268  operator*=( Other rhs );
269 
270  template< typename Other >
271  inline typename EnableIf< IsNumeric<Other>, HybridVector >::Type&
272  operator/=( Other rhs );
274  //**********************************************************************************************
275 
276  //**Utility functions***************************************************************************
279  inline size_t size() const;
280  inline size_t capacity() const;
281  inline size_t nonZeros() const;
282  inline void reset();
283  inline void clear();
284  inline void resize( size_t n, bool preserve=true );
285  inline void extend( size_t n, bool preserve=true );
286  template< typename Other > inline HybridVector& scale( Other scalar );
287  inline void swap( HybridVector& v ) /* throw() */;
289  //**********************************************************************************************
290 
291  private:
292  //**********************************************************************************************
294  template< typename VT >
296  struct VectorizedAssign {
297  enum { value = vectorizable && VT::vectorizable &&
298  IsSame<Type,typename VT::ElementType>::value };
299  };
301  //**********************************************************************************************
302 
303  //**********************************************************************************************
305  template< typename VT >
307  struct VectorizedAddAssign {
308  enum { value = vectorizable && VT::vectorizable &&
309  IsSame<Type,typename VT::ElementType>::value &&
310  IntrinsicTrait<Type>::addition };
311  };
313  //**********************************************************************************************
314 
315  //**********************************************************************************************
317  template< typename VT >
319  struct VectorizedSubAssign {
320  enum { value = vectorizable && VT::vectorizable &&
321  IsSame<Type,typename VT::ElementType>::value &&
322  IntrinsicTrait<Type>::subtraction };
323  };
325  //**********************************************************************************************
326 
327  //**********************************************************************************************
329  template< typename VT >
331  struct VectorizedMultAssign {
332  enum { value = vectorizable && VT::vectorizable &&
333  IsSame<Type,typename VT::ElementType>::value &&
334  IntrinsicTrait<Type>::multiplication };
335  };
337  //**********************************************************************************************
338 
339  public:
340  //**Expression template evaluation functions****************************************************
343  template< typename Other > inline bool canAlias ( const Other* alias ) const;
344  template< typename Other > inline bool isAliased( const Other* alias ) const;
345 
346  inline bool isAligned() const;
347 
348  inline IntrinsicType load ( size_t index ) const;
349  inline IntrinsicType loadu ( size_t index ) const;
350  inline void store ( size_t index, const IntrinsicType& value );
351  inline void storeu( size_t index, const IntrinsicType& value );
352  inline void stream( size_t index, const IntrinsicType& value );
353 
354  template< typename VT >
355  inline typename DisableIf< VectorizedAssign<VT> >::Type
356  assign( const DenseVector<VT,TF>& rhs );
357 
358  template< typename VT >
359  inline typename EnableIf< VectorizedAssign<VT> >::Type
360  assign( const DenseVector<VT,TF>& rhs );
361 
362  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
363 
364  template< typename VT >
365  inline typename DisableIf< VectorizedAddAssign<VT> >::Type
366  addAssign( const DenseVector<VT,TF>& rhs );
367 
368  template< typename VT >
369  inline typename EnableIf< VectorizedAddAssign<VT> >::Type
370  addAssign( const DenseVector<VT,TF>& rhs );
371 
372  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
373 
374  template< typename VT >
375  inline typename DisableIf< VectorizedSubAssign<VT> >::Type
376  subAssign( const DenseVector<VT,TF>& rhs );
377 
378  template< typename VT >
379  inline typename EnableIf< VectorizedSubAssign<VT> >::Type
380  subAssign( const DenseVector<VT,TF>& rhs );
381 
382  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
383 
384  template< typename VT >
385  inline typename DisableIf< VectorizedMultAssign<VT> >::Type
386  multAssign( const DenseVector<VT,TF>& rhs );
387 
388  template< typename VT >
389  inline typename EnableIf< VectorizedMultAssign<VT> >::Type
390  multAssign( const DenseVector<VT,TF>& rhs );
391 
392  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
394  //**********************************************************************************************
395 
396  private:
397  //**Member variables****************************************************************************
401 
406  size_t size_;
407 
408  //**********************************************************************************************
409 
410  //**Compile time checks*************************************************************************
416  BLAZE_STATIC_ASSERT( NN % IT::size == 0UL );
417  BLAZE_STATIC_ASSERT( NN >= N );
419  //**********************************************************************************************
420 };
421 //*************************************************************************************************
422 
423 
424 
425 
426 //=================================================================================================
427 //
428 // CONSTRUCTORS
429 //
430 //=================================================================================================
431 
432 //*************************************************************************************************
437 template< typename Type // Data type of the vector
438  , size_t N // Number of elements
439  , bool TF > // Transpose flag
441  : size_( 0UL ) // The current size/dimension of the vector
442 {
443  if( IsNumeric<Type>::value ) {
444  for( size_t i=0UL; i<NN; ++i )
445  v_[i] = Type();
446  }
447 }
448 //*************************************************************************************************
449 
450 
451 //*************************************************************************************************
461 template< typename Type // Data type of the vector
462  , size_t N // Number of elements
463  , bool TF > // Transpose flag
465  : size_( n ) // The current size/dimension of the vector
466 {
467  if( n > N )
468  throw std::invalid_argument( "Invalid size for hybrid vector" );
469 
470  if( IsNumeric<Type>::value ) {
471  for( size_t i=0UL; i<NN; ++i )
472  v_[i] = Type();
473  }
474 }
475 //*************************************************************************************************
476 
477 
478 //*************************************************************************************************
489 template< typename Type // Data type of the vector
490  , size_t N // Number of elements
491  , bool TF > // Transpose flag
492 inline HybridVector<Type,N,TF>::HybridVector( size_t n, const Type& init )
493  : size_( n ) // The current size/dimension of the vector
494 {
495  if( n > N )
496  throw std::invalid_argument( "Invalid size for hybrid vector" );
497 
498  for( size_t i=0UL; i<n; ++i )
499  v_[i] = init;
500 
501  if( IsNumeric<Type>::value ) {
502  for( size_t i=n; i<NN; ++i )
503  v_[i] = Type();
504  }
505 }
506 //*************************************************************************************************
507 
508 
509 //*************************************************************************************************
531 template< typename Type // Data type of the vector
532  , size_t N // Number of elements
533  , bool TF > // Transpose flag
534 template< typename Other > // Data type of the initialization array
535 inline HybridVector<Type,N,TF>::HybridVector( size_t n, const Other* array )
536  : size_( n ) // The current size/dimension of the vector
537 {
538  if( n > N )
539  throw std::invalid_argument( "Invalid setup of hybrid vector" );
540 
541  for( size_t i=0UL; i<n; ++i )
542  v_[i] = array[i];
543 
544  if( IsNumeric<Type>::value ) {
545  for( size_t i=n; i<NN; ++i )
546  v_[i] = Type();
547  }
548 }
549 //*************************************************************************************************
550 
551 
552 //*************************************************************************************************
570 template< typename Type // Data type of the vector
571  , size_t N // Number of elements
572  , bool TF > // Transpose flag
573 template< typename Other // Data type of the initialization array
574  , size_t M > // Number of elements of the initialization array
575 inline HybridVector<Type,N,TF>::HybridVector( const Other (&array)[M] )
576  : size_( M ) // The current size/dimension of the vector
577 {
578  BLAZE_STATIC_ASSERT( M <= N );
579 
580  for( size_t i=0UL; i<M; ++i )
581  v_[i] = array[i];
582 
583  if( IsNumeric<Type>::value ) {
584  for( size_t i=M; i<NN; ++i )
585  v_[i] = Type();
586  }
587 }
588 //*************************************************************************************************
589 
590 
591 //*************************************************************************************************
598 template< typename Type // Data type of the vector
599  , size_t N // Number of elements
600  , bool TF > // Transpose flag
602  : size_( v.size_ ) // The current size/dimension of the vector
603 {
604  for( size_t i=0UL; i<size_; ++i )
605  v_[i] = v.v_[i];
606 
607  if( IsNumeric<Type>::value ) {
608  for( size_t i=size_; i<NN; ++i )
609  v_[i] = Type();
610  }
611 }
612 //*************************************************************************************************
613 
614 
615 //*************************************************************************************************
625 template< typename Type // Data type of the vector
626  , size_t N // Number of elements
627  , bool TF > // Transpose flag
628 template< typename VT > // Type of the foreign vector
630  : size_( (~v).size() ) // The current size/dimension of the vector
631 {
632  using blaze::assign;
633 
634  if( (~v).size() > N )
635  throw std::invalid_argument( "Invalid setup of hybrid vector" );
636 
637  if( IsNumeric<Type>::value ) {
638  for( size_t i=( IsSparseVector<VT>::value )?( 0UL ):( size_ ); i<NN; ++i )
639  v_[i] = Type();
640  }
641 
642  assign( *this, ~v );
643 }
644 //*************************************************************************************************
645 
646 
647 
648 
649 //=================================================================================================
650 //
651 // DATA ACCESS FUNCTIONS
652 //
653 //=================================================================================================
654 
655 //*************************************************************************************************
663 template< typename Type // Data type of the vector
664  , size_t N // Number of elements
665  , bool TF > // Transpose flag
668 {
669  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
670  return v_[index];
671 }
672 //*************************************************************************************************
673 
674 
675 //*************************************************************************************************
683 template< typename Type // Data type of the vector
684  , size_t N // Number of elements
685  , bool TF > // Transpose flag
688 {
689  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
690  return v_[index];
691 }
692 //*************************************************************************************************
693 
694 
695 //*************************************************************************************************
702 template< typename Type // Data type of the vector
703  , size_t N // Number of elements
704  , bool TF > // Transpose flag
706 {
707  return v_;
708 }
709 //*************************************************************************************************
710 
711 
712 //*************************************************************************************************
719 template< typename Type // Data type of the vector
720  , size_t N // Number of elements
721  , bool TF > // Transpose flag
722 inline const Type* HybridVector<Type,N,TF>::data() const
723 {
724  return v_;
725 }
726 //*************************************************************************************************
727 
728 
729 //*************************************************************************************************
734 template< typename Type // Data type of the vector
735  , size_t N // Number of elements
736  , bool TF > // Transpose flag
738 {
739  return Iterator( v_ );
740 }
741 //*************************************************************************************************
742 
743 
744 //*************************************************************************************************
749 template< typename Type // Data type of the vector
750  , size_t N // Number of elements
751  , bool TF > // Transpose flag
753 {
754  return ConstIterator( v_ );
755 }
756 //*************************************************************************************************
757 
758 
759 //*************************************************************************************************
764 template< typename Type // Data type of the vector
765  , size_t N // Number of elements
766  , bool TF > // Transpose flag
768 {
769  return ConstIterator( v_ );
770 }
771 //*************************************************************************************************
772 
773 
774 //*************************************************************************************************
779 template< typename Type // Data type of the vector
780  , size_t N // Number of elements
781  , bool TF > // Transpose flag
783 {
784  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
785  return Iterator( v_ + size_ );
786 }
787 //*************************************************************************************************
788 
789 
790 //*************************************************************************************************
795 template< typename Type // Data type of the vector
796  , size_t N // Number of elements
797  , bool TF > // Transpose flag
799 {
800  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
801  return ConstIterator( v_ + size_ );
802 }
803 //*************************************************************************************************
804 
805 
806 //*************************************************************************************************
811 template< typename Type // Data type of the vector
812  , size_t N // Number of elements
813  , bool TF > // Transpose flag
815 {
816  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
817  return ConstIterator( v_ + size_ );
818 }
819 //*************************************************************************************************
820 
821 
822 
823 
824 //=================================================================================================
825 //
826 // ASSIGNMENT OPERATORS
827 //
828 //=================================================================================================
829 
830 //*************************************************************************************************
849 template< typename Type // Data type of the vector
850  , size_t N // Number of elements
851  , bool TF > // Transpose flag
852 template< typename Other // Data type of the initialization array
853  , size_t M > // Number of elements of the initialization array
855 {
856  BLAZE_STATIC_ASSERT( M <= N );
857 
858  resize( M );
859 
860  for( size_t i=0UL; i<M; ++i )
861  v_[i] = array[i];
862 
863  return *this;
864 }
865 //*************************************************************************************************
866 
867 
868 //*************************************************************************************************
874 template< typename Type // Data type of the vector
875  , size_t N // Number of elements
876  , bool TF > // Transpose flag
878 {
879  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
880 
881  for( size_t i=0UL; i<size_; ++i )
882  v_[i] = rhs;
883  return *this;
884 }
885 //*************************************************************************************************
886 
887 
888 //*************************************************************************************************
896 template< typename Type // Data type of the vector
897  , size_t N // Number of elements
898  , bool TF > // Transpose flag
900 {
901  using blaze::assign;
902 
903  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
904 
905  resize( rhs.size() );
906  assign( *this, ~rhs );
907 
908  return *this;
909 }
910 //*************************************************************************************************
911 
912 
913 //*************************************************************************************************
923 template< typename Type // Data type of the vector
924  , size_t N // Number of elements
925  , bool TF > // Transpose flag
926 template< typename VT > // Type of the right-hand side vector
928 {
929  using blaze::assign;
930 
931  if( (~rhs).size() > N )
932  throw std::invalid_argument( "Invalid assignment to hybrid vector" );
933 
934  if( (~rhs).canAlias( this ) ) {
935  HybridVector tmp( ~rhs );
936  swap( tmp );
937  }
938  else {
939  resize( (~rhs).size() );
941  reset();
942  assign( *this, ~rhs );
943  }
944 
945  return *this;
946 }
947 //*************************************************************************************************
948 
949 
950 //*************************************************************************************************
960 template< typename Type // Data type of the vector
961  , size_t N // Number of elements
962  , bool TF > // Transpose flag
963 template< typename VT > // Type of the right-hand side vector
965 {
966  using blaze::addAssign;
967 
968  if( (~rhs).size() != size_ )
969  throw std::invalid_argument( "Vector sizes do not match" );
970 
971  if( (~rhs).canAlias( this ) ) {
972  typename VT::ResultType tmp( ~rhs );
973  addAssign( *this, tmp );
974  }
975  else {
976  addAssign( *this, ~rhs );
977  }
978 
979  return *this;
980 }
981 //*************************************************************************************************
982 
983 
984 //*************************************************************************************************
994 template< typename Type // Data type of the vector
995  , size_t N // Number of elements
996  , bool TF > // Transpose flag
997 template< typename VT > // Type of the right-hand side vector
999 {
1000  using blaze::subAssign;
1001 
1002  if( (~rhs).size() != size_ )
1003  throw std::invalid_argument( "Vector sizes do not match" );
1004 
1005  if( (~rhs).canAlias( this ) ) {
1006  typename VT::ResultType tmp( ~rhs );
1007  subAssign( *this, tmp );
1008  }
1009  else {
1010  subAssign( *this, ~rhs );
1011  }
1012 
1013  return *this;
1014 }
1015 //*************************************************************************************************
1016 
1017 
1018 //*************************************************************************************************
1029 template< typename Type // Data type of the vector
1030  , size_t N // Number of elements
1031  , bool TF > // Transpose flag
1032 template< typename VT > // Type of the right-hand side vector
1034 {
1035  using blaze::assign;
1036 
1037  if( (~rhs).size() != size_ )
1038  throw std::invalid_argument( "Vector sizes do not match" );
1039 
1040  if( (~rhs).canAlias( this ) || IsSparseVector<VT>::value ) {
1041  HybridVector tmp( *this * (~rhs) );
1042  this->operator=( tmp );
1043  }
1044  else {
1045  assign( *this, *this * (~rhs) );
1046  }
1047 
1048  return *this;
1049 }
1050 //*************************************************************************************************
1051 
1052 
1053 //*************************************************************************************************
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  assign( *this, (*this) * rhs );
1070  return *this;
1071 }
1072 //*************************************************************************************************
1073 
1074 
1075 //*************************************************************************************************
1084 template< typename Type // Data type of the vector
1085  , size_t N // Number of elements
1086  , bool TF > // Transpose flag
1087 template< typename Other > // Data type of the right-hand side scalar
1088 inline typename EnableIf< IsNumeric<Other>, HybridVector<Type,N,TF> >::Type&
1090 {
1091  using blaze::assign;
1092 
1093  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1094 
1095  assign( *this, (*this) / rhs );
1096  return *this;
1097 }
1098 //*************************************************************************************************
1099 
1100 
1101 
1102 
1103 //=================================================================================================
1104 //
1105 // UTILITY FUNCTIONS
1106 //
1107 //=================================================================================================
1108 
1109 //*************************************************************************************************
1114 template< typename Type // Data type of the vector
1115  , size_t N // Number of elements
1116  , bool TF > // Transpose flag
1117 inline size_t HybridVector<Type,N,TF>::size() const
1118 {
1119  return size_;
1120 }
1121 //*************************************************************************************************
1122 
1123 
1124 //*************************************************************************************************
1129 template< typename Type // Data type of the vector
1130  , size_t N // Number of elements
1131  , bool TF > // Transpose flag
1133 {
1134  return NN;
1135 }
1136 //*************************************************************************************************
1137 
1138 
1139 //*************************************************************************************************
1147 template< typename Type // Data type of the vector
1148  , size_t N // Number of elements
1149  , bool TF > // Transpose flag
1151 {
1152  size_t nonzeros( 0 );
1153 
1154  for( size_t i=0UL; i<size_; ++i ) {
1155  if( !isDefault( v_[i] ) )
1156  ++nonzeros;
1157  }
1158 
1159  return nonzeros;
1160 }
1161 //*************************************************************************************************
1162 
1163 
1164 //*************************************************************************************************
1169 template< typename Type // Data type of the vector
1170  , size_t N // Number of elements
1171  , bool TF > // Transpose flag
1173 {
1174  using blaze::reset;
1175  for( size_t i=0UL; i<size_; ++i )
1176  reset( v_[i] );
1177 }
1178 //*************************************************************************************************
1179 
1180 
1181 //*************************************************************************************************
1188 template< typename Type // Data type of the vector
1189  , size_t N // Number of elements
1190  , bool TF > // Transpose flag
1192 {
1193  resize( 0UL );
1194 }
1195 //*************************************************************************************************
1196 
1197 
1198 //*************************************************************************************************
1226 template< typename Type // Data type of the vector
1227  , size_t N // Number of elements
1228  , bool TF > // Transpose flag
1229 inline void HybridVector<Type,N,TF>::resize( size_t n, bool preserve )
1230 {
1231  UNUSED_PARAMETER( preserve );
1232 
1233  if( n > N )
1234  throw std::invalid_argument( "Invalid size for hybrid vector" );
1235 
1236  if( IsNumeric<Type>::value && n < size_ ) {
1237  for( size_t i=n; i<size_; ++i )
1238  v_[i] = Type();
1239  }
1240 
1241  size_ = n;
1242 }
1243 //*************************************************************************************************
1244 
1245 
1246 //*************************************************************************************************
1260 template< typename Type // Data type of the vector
1261  , size_t N // Number of elements
1262  , bool TF > // Transpose flag
1263 inline void HybridVector<Type,N,TF>::extend( size_t n, bool preserve )
1264 {
1265  UNUSED_PARAMETER( preserve );
1266  resize( size_+n );
1267 }
1268 //*************************************************************************************************
1269 
1270 
1271 //*************************************************************************************************
1277 template< typename Type // Data type of the vector
1278  , size_t N // Number of elements
1279  , bool TF > // Transpose flag
1280 template< typename Other > // Data type of the scalar value
1282 {
1283  for( size_t i=0; i<size_; ++i )
1284  v_[i] *= scalar;
1285  return *this;
1286 }
1287 //*************************************************************************************************
1288 
1289 
1290 //*************************************************************************************************
1297 template< typename Type // Data type of the vector
1298  , size_t N // Number of elements
1299  , bool TF > // Transpose flag
1300 inline void HybridVector<Type,N,TF>::swap( HybridVector& v ) /* throw() */
1301 {
1302  using std::swap;
1303 
1304  const size_t maxsize( max( size_, v.size_ ) );
1305  for( size_t i=0UL; i<maxsize; ++i )
1306  swap( v_[i], v.v_[i] );
1307  swap( size_, v.size_ );
1308 }
1309 //*************************************************************************************************
1310 
1311 
1312 
1313 
1314 //=================================================================================================
1315 //
1316 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1317 //
1318 //=================================================================================================
1319 
1320 //*************************************************************************************************
1330 template< typename Type // Data type of the vector
1331  , size_t N // Number of elements
1332  , bool TF > // Transpose flag
1333 template< typename Other > // Data type of the foreign expression
1334 inline bool HybridVector<Type,N,TF>::canAlias( const Other* alias ) const
1335 {
1336  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1337 }
1338 //*************************************************************************************************
1339 
1340 
1341 //*************************************************************************************************
1351 template< typename Type // Data type of the vector
1352  , size_t N // Number of elements
1353  , bool TF > // Transpose flag
1354 template< typename Other > // Data type of the foreign expression
1355 inline bool HybridVector<Type,N,TF>::isAliased( const Other* alias ) const
1356 {
1357  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1358 }
1359 //*************************************************************************************************
1360 
1361 
1362 //*************************************************************************************************
1371 template< typename Type // Data type of the vector
1372  , size_t N // Number of elements
1373  , bool TF > // Transpose flag
1375 {
1376  return true;
1377 }
1378 //*************************************************************************************************
1379 
1380 
1381 //*************************************************************************************************
1394 template< typename Type // Data type of the vector
1395  , size_t N // Number of elements
1396  , bool TF > // Transpose flag
1398  HybridVector<Type,N,TF>::load( size_t index ) const
1399 {
1400  using blaze::load;
1401 
1403 
1404  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1405  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1406  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL , "Invalid vector access index" );
1407 
1408  return load( &v_[index] );
1409 }
1410 //*************************************************************************************************
1411 
1412 
1413 //*************************************************************************************************
1426 template< typename Type // Data type of the vector
1427  , size_t N // Number of elements
1428  , bool TF > // Transpose flag
1430  HybridVector<Type,N,TF>::loadu( size_t index ) const
1431 {
1432  using blaze::loadu;
1433 
1435 
1436  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1437  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1438 
1439  return loadu( &v_[index] );
1440 }
1441 //*************************************************************************************************
1442 
1443 
1444 //*************************************************************************************************
1458 template< typename Type // Data type of the vector
1459  , size_t N // Number of elements
1460  , bool TF > // Transpose flag
1461 inline void HybridVector<Type,N,TF>::store( size_t index, const IntrinsicType& value )
1462 {
1463  using blaze::store;
1464 
1466 
1467  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1468  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1469  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL , "Invalid vector access index" );
1470 
1471  store( &v_[index], value );
1472 }
1473 //*************************************************************************************************
1474 
1475 
1476 //*************************************************************************************************
1490 template< typename Type // Data type of the vector
1491  , size_t N // Number of elements
1492  , bool TF > // Transpose flag
1493 inline void HybridVector<Type,N,TF>::storeu( size_t index, const IntrinsicType& value )
1494 {
1495  using blaze::storeu;
1496 
1498 
1499  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1500  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1501 
1502  storeu( &v_[index], value );
1503 }
1504 //*************************************************************************************************
1505 
1506 
1507 //*************************************************************************************************
1521 template< typename Type // Data type of the vector
1522  , size_t N // Number of elements
1523  , bool TF > // Transpose flag
1524 inline void HybridVector<Type,N,TF>::stream( size_t index, const IntrinsicType& value )
1525 {
1526  using blaze::stream;
1527 
1529 
1530  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1531  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1532  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL , "Invalid vector access index" );
1533 
1534  stream( &v_[index], value );
1535 }
1536 //*************************************************************************************************
1537 
1538 
1539 //*************************************************************************************************
1550 template< typename Type // Data type of the vector
1551  , size_t N // Number of elements
1552  , bool TF > // Transpose flag
1553 template< typename VT > // Type of the right-hand side dense vector
1554 inline typename DisableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1556 {
1557  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1558 
1559  for( size_t i=0UL; i<size_; ++i )
1560  v_[i] = (~rhs)[i];
1561 }
1562 //*************************************************************************************************
1563 
1564 
1565 //*************************************************************************************************
1576 template< typename Type // Data type of the vector
1577  , size_t N // Number of elements
1578  , bool TF > // Transpose flag
1579 template< typename VT > // Type of the right-hand side dense vector
1580 inline typename EnableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1582 {
1583  using blaze::store;
1584 
1585  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1586 
1588 
1589  for( size_t i=0UL; i<size_; i+=IT::size ) {
1590  store( v_+i, (~rhs).load(i) );
1591  }
1592 }
1593 //*************************************************************************************************
1594 
1595 
1596 //*************************************************************************************************
1607 template< typename Type // Data type of the vector
1608  , size_t N // Number of elements
1609  , bool TF > // Transpose flag
1610 template< typename VT > // Type of the right-hand side sparse vector
1612 {
1613  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1614 
1615  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1616  v_[element->index()] = element->value();
1617 }
1618 //*************************************************************************************************
1619 
1620 
1621 //*************************************************************************************************
1632 template< typename Type // Data type of the vector
1633  , size_t N // Number of elements
1634  , bool TF > // Transpose flag
1635 template< typename VT > // Type of the right-hand side dense vector
1636 inline typename DisableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1638 {
1639  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1640 
1641  for( size_t i=0UL; i<size_; ++i )
1642  v_[i] += (~rhs)[i];
1643 }
1644 //*************************************************************************************************
1645 
1646 
1647 //*************************************************************************************************
1658 template< typename Type // Data type of the vector
1659  , size_t N // Number of elements
1660  , bool TF > // Transpose flag
1661 template< typename VT > // Type of the right-hand side dense vector
1662 inline typename EnableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1664 {
1665  using blaze::load;
1666  using blaze::store;
1667 
1668  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1669 
1671 
1672  for( size_t i=0UL; i<size_; i+=IT::size ) {
1673  store( v_+i, load( v_+i ) + (~rhs).load(i) );
1674  }
1675 }
1676 //*************************************************************************************************
1677 
1678 
1679 //*************************************************************************************************
1690 template< typename Type // Data type of the vector
1691  , size_t N // Number of elements
1692  , bool TF > // Transpose flag
1693 template< typename VT > // Type of the right-hand side sparse vector
1695 {
1696  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1697 
1698  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1699  v_[element->index()] += element->value();
1700 }
1701 //*************************************************************************************************
1702 
1703 
1704 //*************************************************************************************************
1715 template< typename Type // Data type of the vector
1716  , size_t N // Number of elements
1717  , bool TF > // Transpose flag
1718 template< typename VT > // Type of the right-hand side dense vector
1719 inline typename DisableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1721 {
1722  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1723 
1724  for( size_t i=0UL; i<size_; ++i )
1725  v_[i] -= (~rhs)[i];
1726 }
1727 //*************************************************************************************************
1728 
1729 
1730 //*************************************************************************************************
1741 template< typename Type // Data type of the vector
1742  , size_t N // Number of elements
1743  , bool TF > // Transpose flag
1744 template< typename VT > // Type of the right-hand side dense vector
1745 inline typename EnableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1747 {
1748  using blaze::load;
1749  using blaze::store;
1750 
1751  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1752 
1754 
1755  for( size_t i=0UL; i<size_; i+=IT::size ) {
1756  store( v_+i, load( v_+i ) - (~rhs).load(i) );
1757  }
1758 }
1759 //*************************************************************************************************
1760 
1761 
1762 //*************************************************************************************************
1773 template< typename Type // Data type of the vector
1774  , size_t N // Number of elements
1775  , bool TF > // Transpose flag
1776 template< typename VT > // Type of the right-hand side sparse vector
1778 {
1779  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1780 
1781  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1782  v_[element->index()] -= element->value();
1783 }
1784 //*************************************************************************************************
1785 
1786 
1787 //*************************************************************************************************
1798 template< typename Type // Data type of the vector
1799  , size_t N // Number of elements
1800  , bool TF > // Transpose flag
1801 template< typename VT > // Type of the right-hand side dense vector
1802 inline typename DisableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1804 {
1805  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1806 
1807  for( size_t i=0UL; i<size_; ++i )
1808  v_[i] *= (~rhs)[i];
1809 }
1810 //*************************************************************************************************
1811 
1812 
1813 //*************************************************************************************************
1824 template< typename Type // Data type of the vector
1825  , size_t N // Number of elements
1826  , bool TF > // Transpose flag
1827 template< typename VT > // Type of the right-hand side dense vector
1828 inline typename EnableIf< typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1830 {
1831  using blaze::load;
1832  using blaze::store;
1833 
1834  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1835 
1837 
1838  for( size_t i=0UL; i<size_; i+=IT::size ) {
1839  store( v_+i, load( v_+i ) * (~rhs).load(i) );
1840  }
1841 }
1842 //*************************************************************************************************
1843 
1844 
1845 //*************************************************************************************************
1856 template< typename Type // Data type of the vector
1857  , size_t N // Number of elements
1858  , bool TF > // Transpose flag
1859 template< typename VT > // Type of the right-hand side sparse vector
1861 {
1862  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
1863 
1864  const HybridVector tmp( *this );
1865 
1866  reset();
1867 
1868  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1869  v_[element->index()] = tmp[element->index()] * element->value();
1870 }
1871 //*************************************************************************************************
1872 
1873 
1874 
1875 
1876 
1877 
1878 
1879 
1880 //=================================================================================================
1881 //
1882 // UNDEFINED CLASS TEMPLATE SPECIALIZATION
1883 //
1884 //=================================================================================================
1885 
1886 //*************************************************************************************************
1894 template< typename Type // Data type of the vector
1895  , bool TF > // Transpose flag
1896 class HybridVector<Type,0UL,TF>;
1898 //*************************************************************************************************
1899 
1900 
1901 
1902 
1903 
1904 
1905 
1906 
1907 //=================================================================================================
1908 //
1909 // HYBRIDVECTOR OPERATORS
1910 //
1911 //=================================================================================================
1912 
1913 //*************************************************************************************************
1916 template< typename Type, size_t N, bool TF >
1917 inline void reset( HybridVector<Type,N,TF>& v );
1918 
1919 template< typename Type, size_t N, bool TF >
1920 inline void clear( HybridVector<Type,N,TF>& v );
1921 
1922 template< typename Type, size_t N, bool TF >
1923 inline bool isDefault( const HybridVector<Type,N,TF>& v );
1924 
1925 template< typename Type, size_t N, bool TF >
1926 inline void swap( HybridVector<Type,N,TF>& a, HybridVector<Type,N,TF>& b ) /* throw() */;
1928 //*************************************************************************************************
1929 
1930 
1931 //*************************************************************************************************
1938 template< typename Type // Data type of the vector
1939  , size_t N // Number of elements
1940  , bool TF > // Transpose flag
1942 {
1943  v.reset();
1944 }
1945 //*************************************************************************************************
1946 
1947 
1948 //*************************************************************************************************
1957 template< typename Type // Data type of the vector
1958  , size_t N // Number of elements
1959  , bool TF > // Transpose flag
1961 {
1962  v.clear();
1963 }
1964 //*************************************************************************************************
1965 
1966 
1967 //*************************************************************************************************
1985 template< typename Type // Data type of the vector
1986  , size_t N // Number of elements
1987  , bool TF > // Transpose flag
1988 inline bool isDefault( const HybridVector<Type,N,TF>& v )
1989 {
1990  for( size_t i=0UL; i<v.size(); ++i )
1991  if( !isDefault( v[i] ) ) return false;
1992  return true;
1993 }
1994 //*************************************************************************************************
1995 
1996 
1997 //*************************************************************************************************
2006 template< typename Type // Data type of the vector
2007  , size_t N // Number of elements
2008  , bool TF > // Transpose flag
2009 inline void swap( HybridVector<Type,N,TF>& a, HybridVector<Type,N,TF>& b ) /* throw() */
2010 {
2011  a.swap( b );
2012 }
2013 //*************************************************************************************************
2014 
2015 
2016 
2017 
2018 //=================================================================================================
2019 //
2020 // ADDTRAIT SPECIALIZATIONS
2021 //
2022 //=================================================================================================
2023 
2024 //*************************************************************************************************
2026 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2027 struct AddTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2028 {
2029  typedef StaticVector< typename AddTrait<T1,T2>::Type, N, TF > Type;
2030 };
2031 
2032 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2033 struct AddTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2034 {
2035  typedef StaticVector< typename AddTrait<T1,T2>::Type, M, TF > Type;
2036 };
2037 
2038 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2039 struct AddTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2040 {
2041  typedef HybridVector< typename AddTrait<T1,T2>::Type, ( M < N )?( M ):( N ), TF > Type;
2042 };
2044 //*************************************************************************************************
2045 
2046 
2047 
2048 
2049 //=================================================================================================
2050 //
2051 // SUBTRAIT SPECIALIZATIONS
2052 //
2053 //=================================================================================================
2054 
2055 //*************************************************************************************************
2057 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2058 struct SubTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2059 {
2060  typedef StaticVector< typename SubTrait<T1,T2>::Type, N, TF > Type;
2061 };
2062 
2063 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2064 struct SubTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2065 {
2066  typedef StaticVector< typename SubTrait<T1,T2>::Type, M, TF > Type;
2067 };
2068 
2069 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2070 struct SubTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2071 {
2072  typedef HybridVector< typename SubTrait<T1,T2>::Type, ( M < N )?( M ):( N ), TF > Type;
2073 };
2075 //*************************************************************************************************
2076 
2077 
2078 
2079 
2080 //=================================================================================================
2081 //
2082 // MULTTRAIT SPECIALIZATIONS
2083 //
2084 //=================================================================================================
2085 
2086 //*************************************************************************************************
2088 template< typename T1, size_t N, bool TF, typename T2 >
2089 struct MultTrait< HybridVector<T1,N,TF>, T2 >
2090 {
2091  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2093 };
2094 
2095 template< typename T1, typename T2, size_t N, bool TF >
2096 struct MultTrait< T1, HybridVector<T2,N,TF> >
2097 {
2098  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2100 };
2101 
2102 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2103 struct MultTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2104 {
2105  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2106 };
2107 
2108 template< typename T1, size_t M, typename T2, size_t N >
2109 struct MultTrait< HybridVector<T1,M,false>, StaticVector<T2,N,true> >
2110 {
2111  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2112 };
2113 
2114 template< typename T1, size_t M, typename T2, size_t N >
2115 struct MultTrait< HybridVector<T1,M,true>, StaticVector<T2,N,false> >
2116 {
2117  typedef typename MultTrait<T1,T2>::Type Type;
2118 };
2119 
2120 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2121 struct MultTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2122 {
2123  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, TF > Type;
2124 };
2125 
2126 template< typename T1, size_t M, typename T2, size_t N >
2127 struct MultTrait< StaticVector<T1,M,false>, HybridVector<T2,N,true> >
2128 {
2129  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2130 };
2131 
2132 template< typename T1, size_t M, typename T2, size_t N >
2133 struct MultTrait< StaticVector<T1,M,true>, HybridVector<T2,N,false> >
2134 {
2135  typedef typename MultTrait<T1,T2>::Type Type;
2136 };
2137 
2138 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2139 struct MultTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2140 {
2141  typedef HybridVector< typename MultTrait<T1,T2>::Type, ( M < N )?( M ):( N ), TF > Type;
2142 };
2143 
2144 template< typename T1, size_t M, typename T2, size_t N >
2145 struct MultTrait< HybridVector<T1,M,false>, HybridVector<T2,N,true> >
2146 {
2147  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, false > Type;
2148 };
2149 
2150 template< typename T1, size_t M, typename T2, size_t N >
2151 struct MultTrait< HybridVector<T1,M,true>, HybridVector<T2,N,false> >
2152 {
2153  typedef typename MultTrait<T1,T2>::Type Type;
2154 };
2156 //*************************************************************************************************
2157 
2158 
2159 
2160 
2161 //=================================================================================================
2162 //
2163 // CROSSTRAIT SPECIALIZATIONS
2164 //
2165 //=================================================================================================
2166 
2167 //*************************************************************************************************
2169 template< typename T1, size_t N, typename T2 >
2170 struct CrossTrait< HybridVector<T1,N,false>, StaticVector<T2,3UL,false> >
2171 {
2172  private:
2173  typedef typename MultTrait<T1,T2>::Type T;
2174 
2175  public:
2176  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2177 };
2178 
2179 template< typename T1, typename T2, size_t N >
2180 struct CrossTrait< StaticVector<T1,3UL,false>, HybridVector<T2,N,false> >
2181 {
2182  private:
2183  typedef typename MultTrait<T1,T2>::Type T;
2184 
2185  public:
2186  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2187 };
2188 
2189 template< typename T1, size_t M, typename T2, size_t N >
2190 struct CrossTrait< HybridVector<T1,M,false>, HybridVector<T2,N,false> >
2191 {
2192  private:
2193  typedef typename MultTrait<T1,T2>::Type T;
2194 
2195  public:
2196  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2197 };
2199 //*************************************************************************************************
2200 
2201 
2202 
2203 
2204 //=================================================================================================
2205 //
2206 // DIVTRAIT SPECIALIZATIONS
2207 //
2208 //=================================================================================================
2209 
2210 //*************************************************************************************************
2212 template< typename T1, size_t N, bool TF, typename T2 >
2213 struct DivTrait< HybridVector<T1,N,TF>, T2 >
2214 {
2215  typedef HybridVector< typename DivTrait<T1,T2>::Type, N, TF > Type;
2217 };
2219 //*************************************************************************************************
2220 
2221 
2222 
2223 
2224 //=================================================================================================
2225 //
2226 // MATHTRAIT SPECIALIZATIONS
2227 //
2228 //=================================================================================================
2229 
2230 //*************************************************************************************************
2232 template< typename T1, size_t N, bool TF, typename T2 >
2233 struct MathTrait< HybridVector<T1,N,TF>, HybridVector<T2,N,TF> >
2234 {
2235  typedef StaticVector< typename MathTrait<T1,T2>::HighType, N, TF > HighType;
2236  typedef StaticVector< typename MathTrait<T1,T2>::LowType , N, TF > LowType;
2237 };
2239 //*************************************************************************************************
2240 
2241 
2242 
2243 
2244 //=================================================================================================
2245 //
2246 // SUBVECTORTRAIT SPECIALIZATIONS
2247 //
2248 //=================================================================================================
2249 
2250 //*************************************************************************************************
2252 template< typename T1, size_t N, bool TF >
2253 struct SubvectorTrait< HybridVector<T1,N,TF> >
2254 {
2255  typedef HybridVector<T1,N,TF> Type;
2256 };
2258 //*************************************************************************************************
2259 
2260 } // namespace blaze
2261 
2262 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:108
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:116
const bool defaultTransposeFlag
The default transpose flag for all vectors of the Blaze library.This value specifies the default tran...
Definition: TransposeFlag.h:56
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:4579
#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:1263
Header file for the UNUSED_PARAMETER function template.
HybridVector()
The default constructor for HybridVector.
Definition: HybridVector.h:440
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:400
size_t capacity() const
Returns the maximum capacity of the vector.
Definition: HybridVector.h:1132
HybridVector< Type, N,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: HybridVector.h:191
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4622
IntrinsicType load(size_t index) const
Aligned load of an intrinsic element of the vector.
Definition: HybridVector.h:1398
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:1493
void storeu(float *address, const sse_float_t &value)
Unaligned store of a vector of &#39;float&#39; values.
Definition: Storeu.h:234
bool isAligned() const
Returns whether the vector is properly aligned in memory.
Definition: HybridVector.h:1374
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:1150
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4595
Constraint on the data type.
Iterator begin()
Returns an iterator to the first element of the hybrid vector.
Definition: HybridVector.h:737
IntrinsicType loadu(size_t index) const
Unaligned load of an intrinsic element of the vector.
Definition: HybridVector.h:1430
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:195
ConstIterator cbegin() const
Returns an iterator to the first element of the hybrid vector.
Definition: HybridVector.h:767
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:814
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:4558
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2388
#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:1117
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:199
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:197
Type ElementType
Type of the vector elements.
Definition: HybridVector.h:192
#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:705
Reference operator[](size_t index)
Subscript operator for the direct access to the vector elements.
Definition: HybridVector.h:667
This ResultType
Result type for expression template evaluations.
Definition: HybridVector.h:190
void clear()
Clearing the vector.
Definition: HybridVector.h:1191
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:1524
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
IT::Type IntrinsicType
Intrinsic type of the vector elements.
Definition: HybridVector.h:193
void resize(size_t n, bool preserve=true)
Changing the size of the vector.
Definition: HybridVector.h:1229
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: HybridVector.h:198
Header file for the IsSparseVector type trait.
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:748
Header file for run time assertion macros.
IntrinsicTrait< Type > IT
Intrinsic trait for the vector element type.
Definition: HybridVector.h:179
Header file for the addition trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: HybridVector.h:194
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:4651
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:2387
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:1300
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:1355
Type & Reference
Reference to a non-constant vector value.
Definition: HybridVector.h:196
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:1172
size_t size_
The current size/dimension of the vector.
Definition: HybridVector.h:406
Iterator end()
Returns an iterator just past the last element of the hybrid vector.
Definition: HybridVector.h:782
bool canAlias(const Other *alias) const
Returns whether the vector can alias with the given address alias.
Definition: HybridVector.h:1334
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:2379
Header file for basic type definitions.
#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:1461
HybridVector< Type, N, TF > This
Type of this HybridVector instance.
Definition: HybridVector.h:189
void store(float *address, const sse_float_t &value)
Aligned store of a vector of &#39;float&#39; values.
Definition: Store.h:242