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 <utility>
36 #include <blaze/math/Aliases.h>
39 #include <blaze/math/Exception.h>
42 #include <blaze/math/Forward.h>
43 #include <blaze/math/Functions.h>
45 #include <blaze/math/shims/Clear.h>
48 #include <blaze/math/SIMD.h>
67 #include <blaze/system/Inline.h>
72 #include <blaze/util/Assert.h>
78 #include <blaze/util/DisableIf.h>
79 #include <blaze/util/EnableIf.h>
81 #include <blaze/util/Memory.h>
83 #include <blaze/util/mpl/SizeT.h>
85 #include <blaze/util/Template.h>
86 #include <blaze/util/TrueType.h>
87 #include <blaze/util/Types.h>
90 #include <blaze/util/Unused.h>
91 
92 
93 namespace blaze {
94 
95 //=================================================================================================
96 //
97 // CLASS DEFINITION
98 //
99 //=================================================================================================
100 
101 //*************************************************************************************************
171 template< typename Type // Data type of the vector
172  , size_t N // Number of elements
173  , bool TF = defaultTransposeFlag > // Transpose flag
174 class HybridVector : public DenseVector< HybridVector<Type,N,TF>, TF >
175 {
176  public:
177  //**Type definitions****************************************************************************
180  typedef This ResultType;
182  typedef Type ElementType;
184  typedef const Type& ReturnType;
185  typedef const HybridVector& CompositeType;
186 
187  typedef Type& Reference;
188  typedef const Type& ConstReference;
189  typedef Type* Pointer;
190  typedef const Type* ConstPointer;
191 
194  //**********************************************************************************************
195 
196  //**Rebind struct definition********************************************************************
199  template< typename ET > // Data type of the other vector
200  struct Rebind {
202  };
203  //**********************************************************************************************
204 
205  //**Compilation flags***************************************************************************
207 
211  enum : bool { simdEnabled = IsVectorizable<Type>::value };
212 
214 
217  enum : bool { smpAssignable = false };
218  //**********************************************************************************************
219 
220  //**Constructors********************************************************************************
223  explicit inline HybridVector();
224  explicit inline HybridVector( size_t n );
225  explicit inline HybridVector( size_t n, const Type& init );
226  explicit inline HybridVector( initializer_list<Type> list );
227 
228  template< typename Other >
229  explicit inline HybridVector( size_t n, const Other* array );
230 
231  template< typename Other, size_t M >
232  explicit inline HybridVector( const Other (&array)[M] );
233 
234  inline HybridVector( const HybridVector& v );
235  template< typename VT > inline HybridVector( const Vector<VT,TF>& v );
237  //**********************************************************************************************
238 
239  //**Destructor**********************************************************************************
240  // No explicitly declared destructor.
241  //**********************************************************************************************
242 
243  //**Data access functions***********************************************************************
246  inline Reference operator[]( size_t index ) noexcept;
247  inline ConstReference operator[]( size_t index ) const noexcept;
248  inline Reference at( size_t index );
249  inline ConstReference at( size_t index ) const;
250  inline Pointer data () noexcept;
251  inline ConstPointer data () const noexcept;
252  inline Iterator begin () noexcept;
253  inline ConstIterator begin () const noexcept;
254  inline ConstIterator cbegin() const noexcept;
255  inline Iterator end () noexcept;
256  inline ConstIterator end () const noexcept;
257  inline ConstIterator cend () const noexcept;
259  //**********************************************************************************************
260 
261  //**Assignment operators************************************************************************
264  inline HybridVector& operator=( const Type& rhs );
265  inline HybridVector& operator=( initializer_list<Type> list );
266 
267  template< typename Other, size_t M >
268  inline HybridVector& operator=( const Other (&array)[M] );
269 
270  inline HybridVector& operator= ( const HybridVector& rhs );
271  template< typename VT > inline HybridVector& operator= ( const Vector<VT,TF>& rhs );
272  template< typename VT > inline HybridVector& operator+=( const Vector<VT,TF>& rhs );
273  template< typename VT > inline HybridVector& operator-=( const Vector<VT,TF>& rhs );
274  template< typename VT > inline HybridVector& operator*=( const Vector<VT,TF>& rhs );
275  template< typename VT > inline HybridVector& operator/=( const DenseVector<VT,TF>& rhs );
276 
277  template< typename Other >
278  inline EnableIf_<IsNumeric<Other>, HybridVector >& operator*=( Other rhs );
279 
280  template< typename Other >
281  inline EnableIf_<IsNumeric<Other>, HybridVector >& operator/=( Other rhs );
283  //**********************************************************************************************
284 
285  //**Utility functions***************************************************************************
288  inline size_t size() const noexcept;
289  inline size_t capacity() const noexcept;
290  inline size_t nonZeros() const;
291  inline void reset();
292  inline void clear();
293  inline void resize( size_t n, bool preserve=true );
294  inline void extend( size_t n, bool preserve=true );
295  template< typename Other > inline HybridVector& scale( const Other& scalar );
296  inline void swap( HybridVector& v ) noexcept;
298  //**********************************************************************************************
299 
300  //**Memory functions****************************************************************************
303  static inline void* operator new ( std::size_t size );
304  static inline void* operator new[]( std::size_t size );
305  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
306  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
307 
308  static inline void operator delete ( void* ptr );
309  static inline void operator delete[]( void* ptr );
310  static inline void operator delete ( void* ptr, const std::nothrow_t& );
311  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
313  //**********************************************************************************************
314 
315  private:
316  //**********************************************************************************************
318  template< typename VT >
320  struct VectorizedAssign {
321  enum : bool { value = useOptimizedKernels &&
322  simdEnabled && VT::simdEnabled &&
323  AreSIMDCombinable< Type, ElementType_<VT> >::value };
324  };
326  //**********************************************************************************************
327 
328  //**********************************************************************************************
330  template< typename VT >
332  struct VectorizedAddAssign {
333  enum : bool { value = useOptimizedKernels &&
334  simdEnabled && VT::simdEnabled &&
335  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
336  HasSIMDAdd< Type, ElementType_<VT> >::value };
337  };
339  //**********************************************************************************************
340 
341  //**********************************************************************************************
343  template< typename VT >
345  struct VectorizedSubAssign {
346  enum : bool { value = useOptimizedKernels &&
347  simdEnabled && VT::simdEnabled &&
348  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
349  HasSIMDSub< Type, ElementType_<VT> >::value };
350  };
352  //**********************************************************************************************
353 
354  //**********************************************************************************************
356  template< typename VT >
358  struct VectorizedMultAssign {
359  enum : bool { value = useOptimizedKernels &&
360  simdEnabled && VT::simdEnabled &&
361  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
362  HasSIMDMult< Type, ElementType_<VT> >::value };
363  };
365  //**********************************************************************************************
366 
367  //**********************************************************************************************
369  template< typename VT >
371  struct VectorizedDivAssign {
372  enum : bool { value = useOptimizedKernels &&
373  simdEnabled && VT::simdEnabled &&
374  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
375  HasSIMDDiv< Type, ElementType_<VT> >::value };
376  };
378  //**********************************************************************************************
379 
380  //**********************************************************************************************
382  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
383  //**********************************************************************************************
384 
385  public:
386  //**Debugging functions*************************************************************************
389  inline bool isIntact() const noexcept;
391  //**********************************************************************************************
392 
393  //**Expression template evaluation functions****************************************************
396  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
397  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
398 
399  inline bool isAligned() const noexcept;
400 
401  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
402  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
403  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
404 
405  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
406  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
407  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
408  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
409 
410  template< typename VT >
411  inline DisableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
412 
413  template< typename VT >
414  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
415 
416  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
417 
418  template< typename VT >
419  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
420 
421  template< typename VT >
422  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
423 
424  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
425 
426  template< typename VT >
427  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
428 
429  template< typename VT >
430  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
431 
432  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
433 
434  template< typename VT >
435  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
436 
437  template< typename VT >
438  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
439 
440  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
441 
442  template< typename VT >
443  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
444 
445  template< typename VT >
446  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
448  //**********************************************************************************************
449 
450  private:
451  //**********************************************************************************************
453  enum : size_t { NN = ( usePadding )?( NextMultiple< SizeT<N>, SizeT<SIMDSIZE> >::value ):( N ) };
454  //**********************************************************************************************
455 
456  //**Member variables****************************************************************************
460 
465  size_t size_;
466 
467  //**********************************************************************************************
468 
469  //**Compile time checks*************************************************************************
475  BLAZE_STATIC_ASSERT( !usePadding || NN % SIMDSIZE == 0UL );
476  BLAZE_STATIC_ASSERT( NN >= N );
478  //**********************************************************************************************
479 };
480 //*************************************************************************************************
481 
482 
483 
484 
485 //=================================================================================================
486 //
487 // CONSTRUCTORS
488 //
489 //=================================================================================================
490 
491 //*************************************************************************************************
496 template< typename Type // Data type of the vector
497  , size_t N // Number of elements
498  , bool TF > // Transpose flag
500  : v_ () // The statically allocated vector elements
501  , size_( 0UL ) // The current size/dimension of the vector
502 {
504 
505  if( IsNumeric<Type>::value ) {
506  for( size_t i=0UL; i<NN; ++i )
507  v_[i] = Type();
508  }
509 
510  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
511 }
512 //*************************************************************************************************
513 
514 
515 //*************************************************************************************************
525 template< typename Type // Data type of the vector
526  , size_t N // Number of elements
527  , bool TF > // Transpose flag
529  : v_ () // The statically allocated vector elements
530  , size_( n ) // The current size/dimension of the vector
531 {
533 
534  if( n > N ) {
535  BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
536  }
537 
538  if( IsNumeric<Type>::value ) {
539  for( size_t i=0UL; i<NN; ++i )
540  v_[i] = Type();
541  }
542 
543  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
544 }
545 //*************************************************************************************************
546 
547 
548 //*************************************************************************************************
559 template< typename Type // Data type of the vector
560  , size_t N // Number of elements
561  , bool TF > // Transpose flag
562 inline HybridVector<Type,N,TF>::HybridVector( size_t n, const Type& init )
563  : v_ () // The statically allocated vector elements
564  , size_( n ) // The current size/dimension of the vector
565 {
567 
568  if( n > N ) {
569  BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
570  }
571 
572  for( size_t i=0UL; i<n; ++i )
573  v_[i] = init;
574 
575  if( IsNumeric<Type>::value ) {
576  for( size_t i=n; i<NN; ++i )
577  v_[i] = Type();
578  }
579 
580  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
581 }
582 //*************************************************************************************************
583 
584 
585 //*************************************************************************************************
603 template< typename Type // Data type of the vector
604  , size_t N // Number of elements
605  , bool TF > // Transpose flag
607  : v_ () // The statically allocated vector elements
608  , size_( list.size() ) // The current size/dimension of the vector
609 {
611 
612  if( size_ > N ) {
613  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
614  }
615 
616  std::fill( std::copy( list.begin(), list.end(), v_.data() ), v_.data()+NN, Type() );
617 
618  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
619 }
620 //*************************************************************************************************
621 
622 
623 //*************************************************************************************************
646 template< typename Type // Data type of the vector
647  , size_t N // Number of elements
648  , bool TF > // Transpose flag
649 template< typename Other > // Data type of the initialization array
650 inline HybridVector<Type,N,TF>::HybridVector( size_t n, const Other* array )
651  : v_ () // The statically allocated vector elements
652  , size_( n ) // The current size/dimension of the vector
653 {
655 
656  if( n > N ) {
657  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
658  }
659 
660  for( size_t i=0UL; i<n; ++i )
661  v_[i] = array[i];
662 
663  if( IsNumeric<Type>::value ) {
664  for( size_t i=n; i<NN; ++i )
665  v_[i] = Type();
666  }
667 
668  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
669 }
670 //*************************************************************************************************
671 
672 
673 //*************************************************************************************************
691 template< typename Type // Data type of the vector
692  , size_t N // Number of elements
693  , bool TF > // Transpose flag
694 template< typename Other // Data type of the initialization array
695  , size_t M > // Number of elements of the initialization array
696 inline HybridVector<Type,N,TF>::HybridVector( const Other (&array)[M] )
697  : v_ () // The statically allocated vector elements
698  , size_( M ) // The current size/dimension of the vector
699 {
700  BLAZE_STATIC_ASSERT( M <= N );
702 
703  for( size_t i=0UL; i<M; ++i )
704  v_[i] = array[i];
705 
706  if( IsNumeric<Type>::value ) {
707  for( size_t i=M; i<NN; ++i )
708  v_[i] = Type();
709  }
710 
711  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
712 }
713 //*************************************************************************************************
714 
715 
716 //*************************************************************************************************
723 template< typename Type // Data type of the vector
724  , size_t N // Number of elements
725  , bool TF > // Transpose flag
727  : v_ () // The statically allocated vector elements
728  , size_( v.size_ ) // The current size/dimension of the vector
729 {
731 
732  for( size_t i=0UL; i<size_; ++i )
733  v_[i] = v.v_[i];
734 
735  if( IsNumeric<Type>::value ) {
736  for( size_t i=size_; i<NN; ++i )
737  v_[i] = Type();
738  }
739 
740  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
741 }
742 //*************************************************************************************************
743 
744 
745 //*************************************************************************************************
755 template< typename Type // Data type of the vector
756  , size_t N // Number of elements
757  , bool TF > // Transpose flag
758 template< typename VT > // Type of the foreign vector
760  : v_ () // The statically allocated vector elements
761  , size_( (~v).size() ) // The current size/dimension of the vector
762 {
763  using blaze::assign;
764 
766 
767  if( (~v).size() > N ) {
768  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
769  }
770 
771  for( size_t i=( IsSparseVector<VT>::value ? 0UL : size_ );
772  i<( IsNumeric<Type>::value ? NN : size_ ); ++i ) {
773  v_[i] = Type();
774  }
775 
776  assign( *this, ~v );
777 
778  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
779 }
780 //*************************************************************************************************
781 
782 
783 
784 
785 //=================================================================================================
786 //
787 // DATA ACCESS FUNCTIONS
788 //
789 //=================================================================================================
790 
791 //*************************************************************************************************
800 template< typename Type // Data type of the vector
801  , size_t N // Number of elements
802  , bool TF > // Transpose flag
804  HybridVector<Type,N,TF>::operator[]( size_t index ) noexcept
805 {
806  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
807  return v_[index];
808 }
809 //*************************************************************************************************
810 
811 
812 //*************************************************************************************************
821 template< typename Type // Data type of the vector
822  , size_t N // Number of elements
823  , bool TF > // Transpose flag
825  HybridVector<Type,N,TF>::operator[]( size_t index ) const noexcept
826 {
827  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
828  return v_[index];
829 }
830 //*************************************************************************************************
831 
832 
833 //*************************************************************************************************
843 template< typename Type // Data type of the vector
844  , size_t N // Number of elements
845  , bool TF > // Transpose flag
848 {
849  if( index >= size_ ) {
850  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
851  }
852  return (*this)[index];
853 }
854 //*************************************************************************************************
855 
856 
857 //*************************************************************************************************
867 template< typename Type // Data type of the vector
868  , size_t N // Number of elements
869  , bool TF > // Transpose flag
871  HybridVector<Type,N,TF>::at( size_t index ) const
872 {
873  if( index >= size_ ) {
874  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
875  }
876  return (*this)[index];
877 }
878 //*************************************************************************************************
879 
880 
881 //*************************************************************************************************
888 template< typename Type // Data type of the vector
889  , size_t N // Number of elements
890  , bool TF > // Transpose flag
892 {
893  return v_;
894 }
895 //*************************************************************************************************
896 
897 
898 //*************************************************************************************************
905 template< typename Type // Data type of the vector
906  , size_t N // Number of elements
907  , bool TF > // Transpose flag
909 {
910  return v_;
911 }
912 //*************************************************************************************************
913 
914 
915 //*************************************************************************************************
920 template< typename Type // Data type of the vector
921  , size_t N // Number of elements
922  , bool TF > // Transpose flag
924 {
925  return Iterator( v_ );
926 }
927 //*************************************************************************************************
928 
929 
930 //*************************************************************************************************
935 template< typename Type // Data type of the vector
936  , size_t N // Number of elements
937  , bool TF > // Transpose flag
939 {
940  return ConstIterator( v_ );
941 }
942 //*************************************************************************************************
943 
944 
945 //*************************************************************************************************
950 template< typename Type // Data type of the vector
951  , size_t N // Number of elements
952  , bool TF > // Transpose flag
954 {
955  return ConstIterator( v_ );
956 }
957 //*************************************************************************************************
958 
959 
960 //*************************************************************************************************
965 template< typename Type // Data type of the vector
966  , size_t N // Number of elements
967  , bool TF > // Transpose flag
969 {
970  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
971  return Iterator( v_ + size_ );
972 }
973 //*************************************************************************************************
974 
975 
976 //*************************************************************************************************
981 template< typename Type // Data type of the vector
982  , size_t N // Number of elements
983  , bool TF > // Transpose flag
985 {
986  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
987  return ConstIterator( v_ + size_ );
988 }
989 //*************************************************************************************************
990 
991 
992 //*************************************************************************************************
997 template< typename Type // Data type of the vector
998  , size_t N // Number of elements
999  , bool TF > // Transpose flag
1001 {
1002  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1003  return ConstIterator( v_ + size_ );
1004 }
1005 //*************************************************************************************************
1006 
1007 
1008 
1009 
1010 //=================================================================================================
1011 //
1012 // ASSIGNMENT OPERATORS
1013 //
1014 //=================================================================================================
1015 
1016 //*************************************************************************************************
1022 template< typename Type // Data type of the vector
1023  , size_t N // Number of elements
1024  , bool TF > // Transpose flag
1026 {
1027  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1028 
1029  for( size_t i=0UL; i<size_; ++i )
1030  v_[i] = rhs;
1031  return *this;
1032 }
1033 //*************************************************************************************************
1034 
1035 
1036 //*************************************************************************************************
1055 template< typename Type // Data type of the vector
1056  , size_t N // Number of elements
1057  , bool TF > // Transpose flag
1059 {
1060  if( list.size() > N ) {
1061  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to hybrid vector" );
1062  }
1063 
1064  resize( list.size(), false );
1065  std::copy( list.begin(), list.end(), v_.data() );
1066 
1067  return *this;
1068 }
1069 //*************************************************************************************************
1070 
1071 
1072 //*************************************************************************************************
1091 template< typename Type // Data type of the vector
1092  , size_t N // Number of elements
1093  , bool TF > // Transpose flag
1094 template< typename Other // Data type of the initialization array
1095  , size_t M > // Number of elements of the initialization array
1097 {
1098  BLAZE_STATIC_ASSERT( M <= N );
1099 
1100  resize( M, false );
1101 
1102  for( size_t i=0UL; i<M; ++i )
1103  v_[i] = array[i];
1104 
1105  return *this;
1106 }
1107 //*************************************************************************************************
1108 
1109 
1110 //*************************************************************************************************
1118 template< typename Type // Data type of the vector
1119  , size_t N // Number of elements
1120  , bool TF > // Transpose flag
1122 {
1123  using blaze::assign;
1124 
1125  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1126 
1127  resize( rhs.size() );
1128  assign( *this, ~rhs );
1129 
1130  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1131 
1132  return *this;
1133 }
1134 //*************************************************************************************************
1135 
1136 
1137 //*************************************************************************************************
1147 template< typename Type // Data type of the vector
1148  , size_t N // Number of elements
1149  , bool TF > // Transpose flag
1150 template< typename VT > // Type of the right-hand side vector
1152 {
1153  using blaze::assign;
1154 
1155  if( (~rhs).size() > N ) {
1156  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to hybrid vector" );
1157  }
1158 
1159  if( (~rhs).canAlias( this ) ) {
1160  HybridVector tmp( ~rhs );
1161  swap( tmp );
1162  }
1163  else {
1164  resize( (~rhs).size(), false );
1166  reset();
1167  assign( *this, ~rhs );
1168  }
1169 
1170  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1171 
1172  return *this;
1173 }
1174 //*************************************************************************************************
1175 
1176 
1177 //*************************************************************************************************
1187 template< typename Type // Data type of the vector
1188  , size_t N // Number of elements
1189  , bool TF > // Transpose flag
1190 template< typename VT > // Type of the right-hand side vector
1192 {
1193  using blaze::addAssign;
1194 
1195  if( (~rhs).size() != size_ ) {
1196  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1197  }
1198 
1199  if( (~rhs).canAlias( this ) ) {
1200  const ResultType_<VT> tmp( ~rhs );
1201  addAssign( *this, tmp );
1202  }
1203  else {
1204  addAssign( *this, ~rhs );
1205  }
1206 
1207  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1208 
1209  return *this;
1210 }
1211 //*************************************************************************************************
1212 
1213 
1214 //*************************************************************************************************
1224 template< typename Type // Data type of the vector
1225  , size_t N // Number of elements
1226  , bool TF > // Transpose flag
1227 template< typename VT > // Type of the right-hand side vector
1229 {
1230  using blaze::subAssign;
1231 
1232  if( (~rhs).size() != size_ ) {
1233  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1234  }
1235 
1236  if( (~rhs).canAlias( this ) ) {
1237  const ResultType_<VT> tmp( ~rhs );
1238  subAssign( *this, tmp );
1239  }
1240  else {
1241  subAssign( *this, ~rhs );
1242  }
1243 
1244  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1245 
1246  return *this;
1247 }
1248 //*************************************************************************************************
1249 
1250 
1251 //*************************************************************************************************
1262 template< typename Type // Data type of the vector
1263  , size_t N // Number of elements
1264  , bool TF > // Transpose flag
1265 template< typename VT > // Type of the right-hand side vector
1267 {
1268  using blaze::multAssign;
1269 
1270  if( (~rhs).size() != size_ ) {
1271  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1272  }
1273 
1274  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1275  const HybridVector tmp( *this * (~rhs) );
1276  this->operator=( tmp );
1277  }
1278  else {
1279  multAssign( *this, ~rhs );
1280  }
1281 
1282  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1283 
1284  return *this;
1285 }
1286 //*************************************************************************************************
1287 
1288 
1289 //*************************************************************************************************
1299 template< typename Type // Data type of the vector
1300  , size_t N // Number of elements
1301  , bool TF > // Transpose flag
1302 template< typename VT > // Type of the right-hand side vector
1304 {
1305  using blaze::divAssign;
1306 
1307  if( (~rhs).size() != size_ ) {
1308  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1309  }
1310 
1311  if( (~rhs).canAlias( this ) ) {
1312  const HybridVector tmp( *this / (~rhs) );
1313  this->operator=( tmp );
1314  }
1315  else {
1316  divAssign( *this, ~rhs );
1317  }
1318 
1319  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1320 
1321  return *this;
1322 }
1323 //*************************************************************************************************
1324 
1325 
1326 //*************************************************************************************************
1333 template< typename Type // Data type of the vector
1334  , size_t N // Number of elements
1335  , bool TF > // Transpose flag
1336 template< typename Other > // Data type of the right-hand side scalar
1339 {
1340  using blaze::assign;
1341 
1342  assign( *this, (*this) * rhs );
1343 
1344  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1345 
1346  return *this;
1347 }
1348 //*************************************************************************************************
1349 
1350 
1351 //*************************************************************************************************
1360 template< typename Type // Data type of the vector
1361  , size_t N // Number of elements
1362  , bool TF > // Transpose flag
1363 template< typename Other > // Data type of the right-hand side scalar
1364 inline EnableIf_<IsNumeric<Other>, HybridVector<Type,N,TF> >&
1366 {
1367  using blaze::assign;
1368 
1369  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1370 
1371  assign( *this, (*this) / rhs );
1372 
1373  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1374 
1375  return *this;
1376 }
1377 //*************************************************************************************************
1378 
1379 
1380 
1381 
1382 //=================================================================================================
1383 //
1384 // UTILITY FUNCTIONS
1385 //
1386 //=================================================================================================
1387 
1388 //*************************************************************************************************
1393 template< typename Type // Data type of the vector
1394  , size_t N // Number of elements
1395  , bool TF > // Transpose flag
1396 inline size_t HybridVector<Type,N,TF>::size() const noexcept
1397 {
1398  return size_;
1399 }
1400 //*************************************************************************************************
1401 
1402 
1403 //*************************************************************************************************
1408 template< typename Type // Data type of the vector
1409  , size_t N // Number of elements
1410  , bool TF > // Transpose flag
1411 inline size_t HybridVector<Type,N,TF>::capacity() const noexcept
1412 {
1413  return NN;
1414 }
1415 //*************************************************************************************************
1416 
1417 
1418 //*************************************************************************************************
1426 template< typename Type // Data type of the vector
1427  , size_t N // Number of elements
1428  , bool TF > // Transpose flag
1430 {
1431  size_t nonzeros( 0 );
1432 
1433  for( size_t i=0UL; i<size_; ++i ) {
1434  if( !isDefault( v_[i] ) )
1435  ++nonzeros;
1436  }
1437 
1438  return nonzeros;
1439 }
1440 //*************************************************************************************************
1441 
1442 
1443 //*************************************************************************************************
1448 template< typename Type // Data type of the vector
1449  , size_t N // Number of elements
1450  , bool TF > // Transpose flag
1452 {
1453  using blaze::clear;
1454  for( size_t i=0UL; i<size_; ++i )
1455  clear( v_[i] );
1456 }
1457 //*************************************************************************************************
1458 
1459 
1460 //*************************************************************************************************
1467 template< typename Type // Data type of the vector
1468  , size_t N // Number of elements
1469  , bool TF > // Transpose flag
1471 {
1472  resize( 0UL );
1473 }
1474 //*************************************************************************************************
1475 
1476 
1477 //*************************************************************************************************
1508 template< typename Type // Data type of the vector
1509  , size_t N // Number of elements
1510  , bool TF > // Transpose flag
1511 inline void HybridVector<Type,N,TF>::resize( size_t n, bool preserve )
1512 {
1513  UNUSED_PARAMETER( preserve );
1514 
1515  if( n > N ) {
1516  BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
1517  }
1518 
1519  if( IsVectorizable<Type>::value && n < size_ ) {
1520  for( size_t i=n; i<size_; ++i )
1521  v_[i] = Type();
1522  }
1523 
1524  size_ = n;
1525 }
1526 //*************************************************************************************************
1527 
1528 
1529 //*************************************************************************************************
1543 template< typename Type // Data type of the vector
1544  , size_t N // Number of elements
1545  , bool TF > // Transpose flag
1546 inline void HybridVector<Type,N,TF>::extend( size_t n, bool preserve )
1547 {
1548  UNUSED_PARAMETER( preserve );
1549  resize( size_+n );
1550 }
1551 //*************************************************************************************************
1552 
1553 
1554 //*************************************************************************************************
1560 template< typename Type // Data type of the vector
1561  , size_t N // Number of elements
1562  , bool TF > // Transpose flag
1563 template< typename Other > // Data type of the scalar value
1565 {
1566  for( size_t i=0; i<size_; ++i )
1567  v_[i] *= scalar;
1568  return *this;
1569 }
1570 //*************************************************************************************************
1571 
1572 
1573 //*************************************************************************************************
1579 template< typename Type // Data type of the vector
1580  , size_t N // Number of elements
1581  , bool TF > // Transpose flag
1583 {
1584  using std::swap;
1585 
1586  const size_t maxsize( max( size_, v.size_ ) );
1587  for( size_t i=0UL; i<maxsize; ++i )
1588  swap( v_[i], v.v_[i] );
1589  swap( size_, v.size_ );
1590 }
1591 //*************************************************************************************************
1592 
1593 
1594 
1595 
1596 //=================================================================================================
1597 //
1598 // MEMORY FUNCTIONS
1599 //
1600 //=================================================================================================
1601 
1602 //*************************************************************************************************
1612 template< typename Type // Data type of the vector
1613  , size_t N // Number of elements
1614  , bool TF > // Transpose flag
1615 inline void* HybridVector<Type,N,TF>::operator new( std::size_t size )
1616 {
1618 
1619  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridVector ), "Invalid number of bytes detected" );
1620 
1621  return allocate<HybridVector>( 1UL );
1622 }
1623 //*************************************************************************************************
1624 
1625 
1626 //*************************************************************************************************
1636 template< typename Type // Data type of the vector
1637  , size_t N // Number of elements
1638  , bool TF > // Transpose flag
1639 inline void* HybridVector<Type,N,TF>::operator new[]( std::size_t size )
1640 {
1641  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridVector ) , "Invalid number of bytes detected" );
1642  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridVector ) == 0UL, "Invalid number of bytes detected" );
1643 
1644  return allocate<HybridVector>( size/sizeof(HybridVector) );
1645 }
1646 //*************************************************************************************************
1647 
1648 
1649 //*************************************************************************************************
1659 template< typename Type // Data type of the vector
1660  , size_t N // Number of elements
1661  , bool TF > // Transpose flag
1662 inline void* HybridVector<Type,N,TF>::operator new( std::size_t size, const std::nothrow_t& )
1663 {
1664  UNUSED_PARAMETER( size );
1665 
1666  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridVector ), "Invalid number of bytes detected" );
1667 
1668  return allocate<HybridVector>( 1UL );
1669 }
1670 //*************************************************************************************************
1671 
1672 
1673 //*************************************************************************************************
1683 template< typename Type // Data type of the vector
1684  , size_t N // Number of elements
1685  , bool TF > // Transpose flag
1686 inline void* HybridVector<Type,N,TF>::operator new[]( std::size_t size, const std::nothrow_t& )
1687 {
1688  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridVector ) , "Invalid number of bytes detected" );
1689  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridVector ) == 0UL, "Invalid number of bytes detected" );
1690 
1691  return allocate<HybridVector>( size/sizeof(HybridVector) );
1692 }
1693 //*************************************************************************************************
1694 
1695 
1696 //*************************************************************************************************
1702 template< typename Type // Data type of the vector
1703  , size_t N // Number of elements
1704  , bool TF > // Transpose flag
1705 inline void HybridVector<Type,N,TF>::operator delete( void* ptr )
1706 {
1707  deallocate( static_cast<HybridVector*>( ptr ) );
1708 }
1709 //*************************************************************************************************
1710 
1711 
1712 //*************************************************************************************************
1718 template< typename Type // Data type of the vector
1719  , size_t N // Number of elements
1720  , bool TF > // Transpose flag
1721 inline void HybridVector<Type,N,TF>::operator delete[]( void* ptr )
1722 {
1723  deallocate( static_cast<HybridVector*>( ptr ) );
1724 }
1725 //*************************************************************************************************
1726 
1727 
1728 //*************************************************************************************************
1734 template< typename Type // Data type of the vector
1735  , size_t N // Number of elements
1736  , bool TF > // Transpose flag
1737 inline void HybridVector<Type,N,TF>::operator delete( void* ptr, const std::nothrow_t& )
1738 {
1739  deallocate( static_cast<HybridVector*>( ptr ) );
1740 }
1741 //*************************************************************************************************
1742 
1743 
1744 //*************************************************************************************************
1750 template< typename Type // Data type of the vector
1751  , size_t N // Number of elements
1752  , bool TF > // Transpose flag
1753 inline void HybridVector<Type,N,TF>::operator delete[]( void* ptr, const std::nothrow_t& )
1754 {
1755  deallocate( static_cast<HybridVector*>( ptr ) );
1756 }
1757 //*************************************************************************************************
1758 
1759 
1760 
1761 
1762 //=================================================================================================
1763 //
1764 // DEBUGGING FUNCTIONS
1765 //
1766 //=================================================================================================
1767 
1768 //*************************************************************************************************
1777 template< typename Type // Data type of the vector
1778  , size_t N // Number of elements
1779  , bool TF > // Transpose flag
1780 inline bool HybridVector<Type,N,TF>::isIntact() const noexcept
1781 {
1782  if( size_ > N )
1783  return false;
1784 
1785  if( IsNumeric<Type>::value ) {
1786  for( size_t i=size_; i<NN; ++i ) {
1787  if( v_[i] != Type() )
1788  return false;
1789  }
1790  }
1791 
1792  return true;
1793 }
1794 //*************************************************************************************************
1795 
1796 
1797 
1798 
1799 //=================================================================================================
1800 //
1801 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1802 //
1803 //=================================================================================================
1804 
1805 //*************************************************************************************************
1815 template< typename Type // Data type of the vector
1816  , size_t N // Number of elements
1817  , bool TF > // Transpose flag
1818 template< typename Other > // Data type of the foreign expression
1819 inline bool HybridVector<Type,N,TF>::canAlias( const Other* alias ) const noexcept
1820 {
1821  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1822 }
1823 //*************************************************************************************************
1824 
1825 
1826 //*************************************************************************************************
1836 template< typename Type // Data type of the vector
1837  , size_t N // Number of elements
1838  , bool TF > // Transpose flag
1839 template< typename Other > // Data type of the foreign expression
1840 inline bool HybridVector<Type,N,TF>::isAliased( const Other* alias ) const noexcept
1841 {
1842  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1843 }
1844 //*************************************************************************************************
1845 
1846 
1847 //*************************************************************************************************
1856 template< typename Type // Data type of the vector
1857  , size_t N // Number of elements
1858  , bool TF > // Transpose flag
1859 inline bool HybridVector<Type,N,TF>::isAligned() const noexcept
1860 {
1861  return true;
1862 }
1863 //*************************************************************************************************
1864 
1865 
1866 //*************************************************************************************************
1878 template< typename Type // Data type of the vector
1879  , size_t N // Number of elements
1880  , bool TF > // Transpose flag
1882  HybridVector<Type,N,TF>::load( size_t index ) const noexcept
1883 {
1884  return loada( index );
1885 }
1886 //*************************************************************************************************
1887 
1888 
1889 //*************************************************************************************************
1902 template< typename Type // Data type of the vector
1903  , size_t N // Number of elements
1904  , bool TF > // Transpose flag
1906  HybridVector<Type,N,TF>::loada( size_t index ) const noexcept
1907 {
1908  using blaze::loada;
1909 
1911 
1912  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1913  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1914  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1915  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1916 
1917  return loada( &v_[index] );
1918 }
1919 //*************************************************************************************************
1920 
1921 
1922 //*************************************************************************************************
1935 template< typename Type // Data type of the vector
1936  , size_t N // Number of elements
1937  , bool TF > // Transpose flag
1939  HybridVector<Type,N,TF>::loadu( size_t index ) const noexcept
1940 {
1941  using blaze::loadu;
1942 
1944 
1945  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1946  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1947 
1948  return loadu( &v_[index] );
1949 }
1950 //*************************************************************************************************
1951 
1952 
1953 //*************************************************************************************************
1966 template< typename Type // Data type of the vector
1967  , size_t N // Number of elements
1968  , bool TF > // Transpose flag
1970  HybridVector<Type,N,TF>::store( size_t index, const SIMDType& value ) noexcept
1971 {
1972  storea( index, value );
1973 }
1974 //*************************************************************************************************
1975 
1976 
1977 //*************************************************************************************************
1990 template< typename Type // Data type of the vector
1991  , size_t N // Number of elements
1992  , bool TF > // Transpose flag
1994  HybridVector<Type,N,TF>::storea( size_t index, const SIMDType& value ) noexcept
1995 {
1996  using blaze::storea;
1997 
1999 
2000  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2001  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2002  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2003  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2004 
2005  storea( &v_[index], value );
2006 }
2007 //*************************************************************************************************
2008 
2009 
2010 //*************************************************************************************************
2023 template< typename Type // Data type of the vector
2024  , size_t N // Number of elements
2025  , bool TF > // Transpose flag
2027  HybridVector<Type,N,TF>::storeu( size_t index, const SIMDType& value ) noexcept
2028 {
2029  using blaze::storeu;
2030 
2032 
2033  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2034  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2035 
2036  storeu( &v_[index], value );
2037 }
2038 //*************************************************************************************************
2039 
2040 
2041 //*************************************************************************************************
2055 template< typename Type // Data type of the vector
2056  , size_t N // Number of elements
2057  , bool TF > // Transpose flag
2059  HybridVector<Type,N,TF>::stream( size_t index, const SIMDType& value ) noexcept
2060 {
2061  using blaze::stream;
2062 
2064 
2065  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2066  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2067  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2068  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2069 
2070  stream( &v_[index], value );
2071 }
2072 //*************************************************************************************************
2073 
2074 
2075 //*************************************************************************************************
2086 template< typename Type // Data type of the vector
2087  , size_t N // Number of elements
2088  , bool TF > // Transpose flag
2089 template< typename VT > // Type of the right-hand side dense vector
2092 {
2093  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2094 
2095  for( size_t i=0UL; i<size_; ++i )
2096  v_[i] = (~rhs)[i];
2097 }
2098 //*************************************************************************************************
2099 
2100 
2101 //*************************************************************************************************
2112 template< typename Type // Data type of the vector
2113  , size_t N // Number of elements
2114  , bool TF > // Transpose flag
2115 template< typename VT > // Type of the right-hand side dense vector
2118 {
2120 
2121  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2122 
2123  const bool remainder( !usePadding || !IsPadded<VT>::value );
2124 
2125  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2126  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2127 
2128  size_t i( 0UL );
2129 
2130  for( ; i<ipos; i+=SIMDSIZE ) {
2131  store( i, (~rhs).load(i) );
2132  }
2133  for( ; remainder && i<size_; ++i ) {
2134  v_[i] = (~rhs)[i];
2135  }
2136 }
2137 //*************************************************************************************************
2138 
2139 
2140 //*************************************************************************************************
2151 template< typename Type // Data type of the vector
2152  , size_t N // Number of elements
2153  , bool TF > // Transpose flag
2154 template< typename VT > // Type of the right-hand side sparse vector
2156 {
2157  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2158 
2159  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2160  v_[element->index()] = element->value();
2161 }
2162 //*************************************************************************************************
2163 
2164 
2165 //*************************************************************************************************
2176 template< typename Type // Data type of the vector
2177  , size_t N // Number of elements
2178  , bool TF > // Transpose flag
2179 template< typename VT > // Type of the right-hand side dense vector
2180 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2182 {
2183  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2184 
2185  for( size_t i=0UL; i<size_; ++i )
2186  v_[i] += (~rhs)[i];
2187 }
2188 //*************************************************************************************************
2189 
2190 
2191 //*************************************************************************************************
2202 template< typename Type // Data type of the vector
2203  , size_t N // Number of elements
2204  , bool TF > // Transpose flag
2205 template< typename VT > // Type of the right-hand side dense vector
2206 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2208 {
2210 
2211  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2212 
2213  const bool remainder( !usePadding || !IsPadded<VT>::value );
2214 
2215  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2216  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2217 
2218  size_t i( 0UL );
2219 
2220  for( ; i<ipos; i+=SIMDSIZE ) {
2221  store( i, load(i) + (~rhs).load(i) );
2222  }
2223  for( ; remainder && i<size_; ++i ) {
2224  v_[i] += (~rhs)[i];
2225  }
2226 }
2227 //*************************************************************************************************
2228 
2229 
2230 //*************************************************************************************************
2241 template< typename Type // Data type of the vector
2242  , size_t N // Number of elements
2243  , bool TF > // Transpose flag
2244 template< typename VT > // Type of the right-hand side sparse vector
2246 {
2247  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2248 
2249  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2250  v_[element->index()] += element->value();
2251 }
2252 //*************************************************************************************************
2253 
2254 
2255 //*************************************************************************************************
2266 template< typename Type // Data type of the vector
2267  , size_t N // Number of elements
2268  , bool TF > // Transpose flag
2269 template< typename VT > // Type of the right-hand side dense vector
2270 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2272 {
2273  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2274 
2275  for( size_t i=0UL; i<size_; ++i )
2276  v_[i] -= (~rhs)[i];
2277 }
2278 //*************************************************************************************************
2279 
2280 
2281 //*************************************************************************************************
2292 template< typename Type // Data type of the vector
2293  , size_t N // Number of elements
2294  , bool TF > // Transpose flag
2295 template< typename VT > // Type of the right-hand side dense vector
2296 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2298 {
2300 
2301  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2302 
2303  const bool remainder( !usePadding || !IsPadded<VT>::value );
2304 
2305  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2306  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2307 
2308  size_t i( 0UL );
2309 
2310  for( ; i<ipos; i+=SIMDSIZE ) {
2311  store( i, load(i) - (~rhs).load(i) );
2312  }
2313  for( ; remainder && i<size_; ++i ) {
2314  v_[i] -= (~rhs)[i];
2315  }
2316 }
2317 //*************************************************************************************************
2318 
2319 
2320 //*************************************************************************************************
2331 template< typename Type // Data type of the vector
2332  , size_t N // Number of elements
2333  , bool TF > // Transpose flag
2334 template< typename VT > // Type of the right-hand side sparse vector
2336 {
2337  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2338 
2339  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2340  v_[element->index()] -= element->value();
2341 }
2342 //*************************************************************************************************
2343 
2344 
2345 //*************************************************************************************************
2356 template< typename Type // Data type of the vector
2357  , size_t N // Number of elements
2358  , bool TF > // Transpose flag
2359 template< typename VT > // Type of the right-hand side dense vector
2360 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2362 {
2363  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2364 
2365  for( size_t i=0UL; i<size_; ++i )
2366  v_[i] *= (~rhs)[i];
2367 }
2368 //*************************************************************************************************
2369 
2370 
2371 //*************************************************************************************************
2382 template< typename Type // Data type of the vector
2383  , size_t N // Number of elements
2384  , bool TF > // Transpose flag
2385 template< typename VT > // Type of the right-hand side dense vector
2386 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2388 {
2390 
2391  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2392 
2393  const bool remainder( !usePadding || !IsPadded<VT>::value );
2394 
2395  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2396  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2397 
2398  size_t i( 0UL );
2399 
2400  for( ; i<ipos; i+=SIMDSIZE ) {
2401  store( i, load(i) * (~rhs).load(i) );
2402  }
2403  for( ; remainder && i<size_; ++i ) {
2404  v_[i] *= (~rhs)[i];
2405  }
2406 }
2407 //*************************************************************************************************
2408 
2409 
2410 //*************************************************************************************************
2421 template< typename Type // Data type of the vector
2422  , size_t N // Number of elements
2423  , bool TF > // Transpose flag
2424 template< typename VT > // Type of the right-hand side sparse vector
2426 {
2427  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2428 
2429  const HybridVector tmp( serial( *this ) );
2430 
2431  reset();
2432 
2433  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2434  v_[element->index()] = tmp[element->index()] * element->value();
2435 }
2436 //*************************************************************************************************
2437 
2438 
2439 //*************************************************************************************************
2450 template< typename Type // Data type of the vector
2451  , size_t N // Number of elements
2452  , bool TF > // Transpose flag
2453 template< typename VT > // Type of the right-hand side dense vector
2454 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2456 {
2457  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2458 
2459  for( size_t i=0UL; i<size_; ++i )
2460  v_[i] /= (~rhs)[i];
2461 }
2462 //*************************************************************************************************
2463 
2464 
2465 //*************************************************************************************************
2476 template< typename Type // Data type of the vector
2477  , size_t N // Number of elements
2478  , bool TF > // Transpose flag
2479 template< typename VT > // Type of the right-hand side dense vector
2480 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2482 {
2484 
2485  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2486 
2487  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2488  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2489 
2490  size_t i( 0UL );
2491 
2492  for( ; i<ipos; i+=SIMDSIZE ) {
2493  store( i, load(i) / (~rhs).load(i) );
2494  }
2495  for( ; i<size_; ++i ) {
2496  v_[i] /= (~rhs)[i];
2497  }
2498 }
2499 //*************************************************************************************************
2500 
2501 
2502 
2503 
2504 
2505 
2506 
2507 
2508 //=================================================================================================
2509 //
2510 // UNDEFINED CLASS TEMPLATE SPECIALIZATION
2511 //
2512 //=================================================================================================
2513 
2514 //*************************************************************************************************
2522 template< typename Type // Data type of the vector
2523  , bool TF > // Transpose flag
2524 class HybridVector<Type,0UL,TF>;
2526 //*************************************************************************************************
2527 
2528 
2529 
2530 
2531 
2532 
2533 
2534 
2535 //=================================================================================================
2536 //
2537 // HYBRIDVECTOR OPERATORS
2538 //
2539 //=================================================================================================
2540 
2541 //*************************************************************************************************
2544 template< typename Type, size_t N, bool TF >
2545 inline void reset( HybridVector<Type,N,TF>& v );
2546 
2547 template< typename Type, size_t N, bool TF >
2548 inline void clear( HybridVector<Type,N,TF>& v );
2549 
2550 template< typename Type, size_t N, bool TF >
2551 inline bool isDefault( const HybridVector<Type,N,TF>& v );
2552 
2553 template< typename Type, size_t N, bool TF >
2554 inline bool isIntact( const HybridVector<Type,N,TF>& v );
2555 
2556 template< typename Type, size_t N, bool TF >
2557 inline void swap( HybridVector<Type,N,TF>& a, HybridVector<Type,N,TF>& b ) noexcept;
2559 //*************************************************************************************************
2560 
2561 
2562 //*************************************************************************************************
2569 template< typename Type // Data type of the vector
2570  , size_t N // Number of elements
2571  , bool TF > // Transpose flag
2573 {
2574  v.reset();
2575 }
2576 //*************************************************************************************************
2577 
2578 
2579 //*************************************************************************************************
2586 template< typename Type // Data type of the vector
2587  , size_t N // Number of elements
2588  , bool TF > // Transpose flag
2590 {
2591  v.clear();
2592 }
2593 //*************************************************************************************************
2594 
2595 
2596 //*************************************************************************************************
2613 template< typename Type // Data type of the vector
2614  , size_t N // Number of elements
2615  , bool TF > // Transpose flag
2616 inline bool isDefault( const HybridVector<Type,N,TF>& v )
2617 {
2618  return ( v.size() == 0UL );
2619 }
2620 //*************************************************************************************************
2621 
2622 
2623 //*************************************************************************************************
2641 template< typename Type // Data type of the vector
2642  , size_t N // Number of elements
2643  , bool TF > // Transpose flag
2644 inline bool isIntact( const HybridVector<Type,N,TF>& v )
2645 {
2646  return v.isIntact();
2647 }
2648 //*************************************************************************************************
2649 
2650 
2651 //*************************************************************************************************
2659 template< typename Type // Data type of the vector
2660  , size_t N // Number of elements
2661  , bool TF > // Transpose flag
2663 {
2664  a.swap( b );
2665 }
2666 //*************************************************************************************************
2667 
2668 
2669 
2670 
2671 //=================================================================================================
2672 //
2673 // HASCONSTDATAACCESS SPECIALIZATIONS
2674 //
2675 //=================================================================================================
2676 
2677 //*************************************************************************************************
2679 template< typename T, size_t N, bool TF >
2680 struct HasConstDataAccess< HybridVector<T,N,TF> > : public TrueType
2681 {};
2683 //*************************************************************************************************
2684 
2685 
2686 
2687 
2688 //=================================================================================================
2689 //
2690 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2691 //
2692 //=================================================================================================
2693 
2694 //*************************************************************************************************
2696 template< typename T, size_t N, bool TF >
2697 struct HasMutableDataAccess< HybridVector<T,N,TF> > : public TrueType
2698 {};
2700 //*************************************************************************************************
2701 
2702 
2703 
2704 
2705 //=================================================================================================
2706 //
2707 // ISALIGNED SPECIALIZATIONS
2708 //
2709 //=================================================================================================
2710 
2711 //*************************************************************************************************
2713 template< typename T, size_t N, bool TF >
2714 struct IsAligned< HybridVector<T,N,TF> > : public TrueType
2715 {};
2717 //*************************************************************************************************
2718 
2719 
2720 
2721 
2722 //=================================================================================================
2723 //
2724 // ISPADDED SPECIALIZATIONS
2725 //
2726 //=================================================================================================
2727 
2728 //*************************************************************************************************
2730 template< typename T, size_t N, bool TF >
2731 struct IsPadded< HybridVector<T,N,TF> > : public BoolConstant<usePadding>
2732 {};
2734 //*************************************************************************************************
2735 
2736 
2737 
2738 
2739 //=================================================================================================
2740 //
2741 // ISRESIZABLE SPECIALIZATIONS
2742 //
2743 //=================================================================================================
2744 
2745 //*************************************************************************************************
2747 template< typename T, size_t N, bool TF >
2748 struct IsResizable< HybridVector<T,N,TF> > : public TrueType
2749 {};
2751 //*************************************************************************************************
2752 
2753 
2754 
2755 
2756 //=================================================================================================
2757 //
2758 // ADDTRAIT SPECIALIZATIONS
2759 //
2760 //=================================================================================================
2761 
2762 //*************************************************************************************************
2764 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2765 struct AddTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2766 {
2767  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2768 };
2769 
2770 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2771 struct AddTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2772 {
2773  using Type = StaticVector< AddTrait_<T1,T2>, M, TF >;
2774 };
2775 
2776 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2777 struct AddTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2778 {
2779  using Type = HybridVector< AddTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2780 };
2782 //*************************************************************************************************
2783 
2784 
2785 
2786 
2787 //=================================================================================================
2788 //
2789 // SUBTRAIT SPECIALIZATIONS
2790 //
2791 //=================================================================================================
2792 
2793 //*************************************************************************************************
2795 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2796 struct SubTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2797 {
2798  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2799 };
2800 
2801 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2802 struct SubTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2803 {
2804  using Type = StaticVector< SubTrait_<T1,T2>, M, TF >;
2805 };
2806 
2807 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2808 struct SubTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2809 {
2810  using Type = HybridVector< SubTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2811 };
2813 //*************************************************************************************************
2814 
2815 
2816 
2817 
2818 //=================================================================================================
2819 //
2820 // MULTTRAIT SPECIALIZATIONS
2821 //
2822 //=================================================================================================
2823 
2824 //*************************************************************************************************
2826 template< typename T1, size_t N, bool TF, typename T2 >
2827 struct MultTrait< HybridVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2828 {
2829  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
2830 };
2831 
2832 template< typename T1, typename T2, size_t N, bool TF >
2833 struct MultTrait< T1, HybridVector<T2,N,TF>, EnableIf_<IsNumeric<T1> > >
2834 {
2835  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
2836 };
2837 
2838 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2839 struct MultTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2840 {
2841  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2842 };
2843 
2844 template< typename T1, size_t M, typename T2, size_t N >
2845 struct MultTrait< HybridVector<T1,M,false>, StaticVector<T2,N,true> >
2846 {
2847  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2848 };
2849 
2850 template< typename T1, size_t M, typename T2, size_t N >
2851 struct MultTrait< HybridVector<T1,M,true>, StaticVector<T2,N,false> >
2852 {
2853  using Type = MultTrait_<T1,T2>;
2854 };
2855 
2856 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2857 struct MultTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2858 {
2859  using Type = StaticVector< MultTrait_<T1,T2>, M, TF >;
2860 };
2861 
2862 template< typename T1, size_t M, typename T2, size_t N >
2863 struct MultTrait< StaticVector<T1,M,false>, HybridVector<T2,N,true> >
2864 {
2865  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2866 };
2867 
2868 template< typename T1, size_t M, typename T2, size_t N >
2869 struct MultTrait< StaticVector<T1,M,true>, HybridVector<T2,N,false> >
2870 {
2871  using Type = MultTrait_<T1,T2>;
2872 };
2873 
2874 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2875 struct MultTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2876 {
2877  using Type = HybridVector< MultTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2878 };
2879 
2880 template< typename T1, size_t M, typename T2, size_t N >
2881 struct MultTrait< HybridVector<T1,M,false>, HybridVector<T2,N,true> >
2882 {
2883  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2884 };
2885 
2886 template< typename T1, size_t M, typename T2, size_t N >
2887 struct MultTrait< HybridVector<T1,M,true>, HybridVector<T2,N,false> >
2888 {
2889  using Type = MultTrait_<T1,T2>;
2890 };
2892 //*************************************************************************************************
2893 
2894 
2895 
2896 
2897 //=================================================================================================
2898 //
2899 // CROSSTRAIT SPECIALIZATIONS
2900 //
2901 //=================================================================================================
2902 
2903 //*************************************************************************************************
2905 template< typename T1, size_t N, bool TF, typename T2 >
2906 struct CrossTrait< HybridVector<T1,N,TF>, StaticVector<T2,3UL,TF> >
2907 {
2908  private:
2909  using T = MultTrait_<T1,T2>;
2910 
2911  public:
2912  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2913 };
2914 
2915 template< typename T1, bool TF, typename T2, size_t N >
2916 struct CrossTrait< StaticVector<T1,3UL,TF>, HybridVector<T2,N,TF> >
2917 {
2918  private:
2919  using T = MultTrait_<T1,T2>;
2920 
2921  public:
2922  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2923 };
2924 
2925 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2926 struct CrossTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2927 {
2928  private:
2929  using T = MultTrait_<T1,T2>;
2930 
2931  public:
2932  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2933 };
2935 //*************************************************************************************************
2936 
2937 
2938 
2939 
2940 //=================================================================================================
2941 //
2942 // DIVTRAIT SPECIALIZATIONS
2943 //
2944 //=================================================================================================
2945 
2946 //*************************************************************************************************
2948 template< typename T1, size_t N, bool TF, typename T2 >
2949 struct DivTrait< HybridVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2950 {
2951  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
2952 };
2953 
2954 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2955 struct DivTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2956 {
2957  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2958 };
2959 
2960 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2961 struct DivTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2962 {
2963  using Type = StaticVector< DivTrait_<T1,T2>, M, TF >;
2964 };
2965 
2966 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2967 struct DivTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2968 {
2969  using Type = HybridVector< DivTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2970 };
2972 //*************************************************************************************************
2973 
2974 
2975 
2976 
2977 //=================================================================================================
2978 //
2979 // MATHTRAIT SPECIALIZATIONS
2980 //
2981 //=================================================================================================
2982 
2983 //*************************************************************************************************
2985 template< typename T1, size_t N, bool TF, typename T2 >
2986 struct MathTrait< HybridVector<T1,N,TF>, HybridVector<T2,N,TF> >
2987 {
2988  using HighType = StaticVector< typename MathTrait<T1,T2>::HighType, N, TF >;
2989  using LowType = StaticVector< typename MathTrait<T1,T2>::LowType , N, TF >;
2990 };
2992 //*************************************************************************************************
2993 
2994 
2995 
2996 
2997 //=================================================================================================
2998 //
2999 // SUBVECTORTRAIT SPECIALIZATIONS
3000 //
3001 //=================================================================================================
3002 
3003 //*************************************************************************************************
3005 template< typename T1, size_t N, bool TF >
3006 struct SubvectorTrait< HybridVector<T1,N,TF> >
3007 {
3008  using Type = HybridVector<T1,N,TF>;
3009 };
3011 //*************************************************************************************************
3012 
3013 } // namespace blaze
3014 
3015 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:133
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:79
Header file for mathematical functions.
constexpr bool useOptimizedKernels
Configuration switch for optimized kernels.This configuration switch enables/disables all optimized c...
Definition: Optimizations.h:84
Header file for the NextMultiple class template.
#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
void extend(size_t n, bool preserve=true)
Extending the size of the vector.
Definition: HybridVector.h:1546
Header file for the alignment flag values.
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: HybridVector.h:1939
Header file for the UNUSED_PARAMETER function template.
HybridVector()
The default constructor for HybridVector.
Definition: HybridVector.h:499
Header file for the subtraction trait.
Header file for basic type definitions.
Header file for the SparseVector base class.
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: HybridVector.h:459
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:79
Header file for the serial shim.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:315
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
Iterator end() noexcept
Returns an iterator just past the last element of the hybrid vector.
Definition: HybridVector.h:968
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
Type ElementType
Type of the vector elements.
Definition: HybridVector.h:182
Header file for the DenseVector base class.
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: HybridVector.h:891
size_t capacity() const noexcept
Returns the maximum capacity of the vector.
Definition: HybridVector.h:1411
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: HybridVector.h:1882
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
Header file for the SizeT class template.
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: HybridVector.h:1429
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
Header file for memory allocation and deallocation functionality.
System settings for performance optimizations.
STL namespace.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:77
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
SIMDTrait_< ElementType > SIMDType
SIMD type of the vector elements.
Definition: HybridVector.h:183
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
Header file for the std::initializer_list aliases.
Efficient implementation of a dynamically sized vector with static memory.The HybridVector class temp...
Definition: Forward.h:59
HybridVector< Type, N,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: HybridVector.h:181
Rebind mechanism to obtain a HybridVector with different data/element type.
Definition: HybridVector.h:200
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: HybridVector.h:804
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: HybridVector.h:2027
Header file for the DisableIf class template.
HybridVector< ET, N, TF > Other
The type of the other HybridVector.
Definition: HybridVector.h:201
Header file for the multiplication trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5148
Compile time assertion.
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the hybrid vector.
Definition: HybridVector.h:1000
constexpr bool defaultTransposeFlag
The default transpose flag for all vectors of the Blaze library.This value specifies the default tran...
Definition: TransposeFlag.h:56
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:76
DenseIterator< Type, aligned > Iterator
Iterator over non-constant elements.
Definition: HybridVector.h:192
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: HybridVector.h:1906
Header file for the HasSIMDAdd type trait.
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: HybridVector.h:1859
Header file for the DenseIterator class template.
Iterator begin() noexcept
Returns an iterator to the first element of the hybrid vector.
Definition: HybridVector.h:923
Header file for the subvector trait.
Header file for all SIMD functionality.
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: HybridVector.h:1840
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:78
Header file for the IsAligned type trait.
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: HybridVector.h:1994
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:80
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a vectorizable data type...
Definition: Vectorizable.h:61
bool isIntact() const noexcept
Returns whether the invariants of the hybrid vector are intact.
Definition: HybridVector.h:1780
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:538
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the hybrid vector.
Definition: HybridVector.h:953
const Type * ConstPointer
Pointer to a constant vector value.
Definition: HybridVector.h:190
DenseIterator< const Type, aligned > ConstIterator
Iterator over constant elements.
Definition: HybridVector.h:193
void clear()
Clearing the vector.
Definition: HybridVector.h:1470
const Type & ReturnType
Return type for expression template evaluations.
Definition: HybridVector.h:184
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the IsPadded type trait.
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
void resize(size_t n, bool preserve=true)
Changing the size of the vector.
Definition: HybridVector.h:1511
size_t size_
The current size/dimension of the vector.
Definition: HybridVector.h:465
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > stream(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned, non-temporal store of a vector of 1-byte integral values.
Definition: Stream.h:75
Header file for the IsSparseVector type trait.
Header file for the HasSIMDMult type trait.
const HybridVector & CompositeType
Data type for composite expression templates.
Definition: HybridVector.h:185
Header file for run time assertion macros.
HybridVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: HybridVector.h:1025
Type * Pointer
Pointer to a non-constant vector value.
Definition: HybridVector.h:189
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
Constraint on the data type.
Header file for the AlignedArray implementation.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:258
BLAZE_ALWAYS_INLINE void stream(size_t index, const SIMDType &value) noexcept
Aligned, non-temporal store of a SIMD element of the vector.
Definition: HybridVector.h:2059
Constraint on the data type.
Header file for the HasSIMDSub type trait.
Header file for the HasMutableDataAccess type trait.
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: HybridVector.h:1819
Pointer data() noexcept
Low-level data access to the array elements.
Definition: AlignedArray.h:356
void swap(HybridVector &v) noexcept
Swapping the contents of two hybrid vectors.
Definition: HybridVector.h:1582
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:100
EnableIf_< IsBuiltin< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:225
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition: Storeu.h:76
Header file for the mathematical trait.
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
Type & Reference
Reference to a non-constant vector value.
Definition: HybridVector.h:187
void reset()
Reset to the default initial values.
Definition: HybridVector.h:1451
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
Reference at(size_t index)
Checked access to the vector elements.
Definition: HybridVector.h:847
Header file for the AreSIMDCombinable type trait.
constexpr bool usePadding
Configuration of the padding of dense vectors and matrices.This configuration switch enables/disables...
Definition: Optimizations.h:52
Header file for the HasSIMDDiv type trait.
HybridVector< Type, N, TF > This
Type of this HybridVector instance.
Definition: HybridVector.h:178
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:154
const Type & ConstReference
Reference to a constant vector value.
Definition: HybridVector.h:188
Header file for the default transpose flag for all vectors of the Blaze library.
Initializer list type of the Blaze library.
Header file for the alignment check function.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:110
Header file for the IntegralConstant class template.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: HybridVector.h:1396
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#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:112
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: HybridVector.h:1970
Header file for the IsResizable type trait.
System settings for the inline keywords.
#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
DenseVector< This, TF > BaseType
Base type of this HybridVector instance.
Definition: HybridVector.h:179
Header file for the TrueType type/value trait base class.
This ResultType
Result type for expression template evaluations.
Definition: HybridVector.h:180