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>
42 #include <blaze/math/Exception.h>
45 #include <blaze/math/Forward.h>
46 #include <blaze/math/Functions.h>
48 #include <blaze/math/shims/Clear.h>
51 #include <blaze/math/SIMD.h>
75 #include <blaze/system/Inline.h>
81 #include <blaze/util/Assert.h>
87 #include <blaze/util/DisableIf.h>
88 #include <blaze/util/EnableIf.h>
90 #include <blaze/util/Memory.h>
92 #include <blaze/util/Template.h>
93 #include <blaze/util/TrueType.h>
94 #include <blaze/util/Types.h>
97 #include <blaze/util/Unused.h>
98 
99 
100 namespace blaze {
101 
102 //=================================================================================================
103 //
104 // CLASS DEFINITION
105 //
106 //=================================================================================================
107 
108 //*************************************************************************************************
178 template< typename Type // Data type of the vector
179  , size_t N // Number of elements
180  , bool TF = defaultTransposeFlag > // Transpose flag
181 class HybridVector
182  : public DenseVector< HybridVector<Type,N,TF>, TF >
183 {
184  public:
185  //**Type definitions****************************************************************************
188  using ResultType = This;
190  using ElementType = Type;
192  using ReturnType = const Type&;
193  using CompositeType = const HybridVector&;
194 
195  using Reference = Type&;
196  using ConstReference = const Type&;
197  using Pointer = Type*;
198  using ConstPointer = const Type*;
199 
202  //**********************************************************************************************
203 
204  //**Rebind struct definition********************************************************************
207  template< typename NewType > // Data type of the other vector
208  struct Rebind {
210  };
211  //**********************************************************************************************
212 
213  //**Resize struct definition********************************************************************
216  template< size_t NewN > // Number of elements of the other vector
217  struct Resize {
219  };
220  //**********************************************************************************************
221 
222  //**Compilation flags***************************************************************************
224 
228  enum : bool { simdEnabled = IsVectorizable<Type>::value };
229 
231 
234  enum : bool { smpAssignable = false };
235  //**********************************************************************************************
236 
237  //**Constructors********************************************************************************
240  explicit inline HybridVector();
241  explicit inline HybridVector( size_t n );
242  explicit inline HybridVector( size_t n, const Type& init );
243  explicit inline HybridVector( initializer_list<Type> list );
244 
245  template< typename Other >
246  explicit inline HybridVector( size_t n, const Other* array );
247 
248  template< typename Other, size_t Dim >
249  explicit inline HybridVector( const Other (&array)[Dim] );
250 
251  inline HybridVector( const HybridVector& v );
252  template< typename VT > inline HybridVector( const Vector<VT,TF>& v );
254  //**********************************************************************************************
255 
256  //**Destructor**********************************************************************************
257  // No explicitly declared destructor.
258  //**********************************************************************************************
259 
260  //**Data access functions***********************************************************************
263  inline Reference operator[]( size_t index ) noexcept;
264  inline ConstReference operator[]( size_t index ) const noexcept;
265  inline Reference at( size_t index );
266  inline ConstReference at( size_t index ) const;
267  inline Pointer data () noexcept;
268  inline ConstPointer data () const noexcept;
269  inline Iterator begin () noexcept;
270  inline ConstIterator begin () const noexcept;
271  inline ConstIterator cbegin() const noexcept;
272  inline Iterator end () noexcept;
273  inline ConstIterator end () const noexcept;
274  inline ConstIterator cend () const noexcept;
276  //**********************************************************************************************
277 
278  //**Assignment operators************************************************************************
281  inline HybridVector& operator=( const Type& rhs );
282  inline HybridVector& operator=( initializer_list<Type> list );
283 
284  template< typename Other, size_t Dim >
285  inline HybridVector& operator=( const Other (&array)[Dim] );
286 
287  inline HybridVector& operator= ( const HybridVector& rhs );
288  template< typename VT > inline HybridVector& operator= ( const Vector<VT,TF>& rhs );
289  template< typename VT > inline HybridVector& operator+=( const Vector<VT,TF>& rhs );
290  template< typename VT > inline HybridVector& operator-=( const Vector<VT,TF>& rhs );
291  template< typename VT > inline HybridVector& operator*=( const Vector<VT,TF>& rhs );
292  template< typename VT > inline HybridVector& operator/=( const DenseVector<VT,TF>& rhs );
293  template< typename VT > inline HybridVector& operator%=( const Vector<VT,TF>& rhs );
295  //**********************************************************************************************
296 
297  //**Utility functions***************************************************************************
300  inline size_t size() const noexcept;
301  inline size_t spacing() const noexcept;
302  inline size_t capacity() const noexcept;
303  inline size_t nonZeros() const;
304  inline void reset();
305  inline void clear();
306  inline void resize( size_t n, bool preserve=true );
307  inline void extend( size_t n, bool preserve=true );
308  inline void swap( HybridVector& v ) noexcept;
310  //**********************************************************************************************
311 
312  //**Numeric functions***************************************************************************
315  template< typename Other > inline HybridVector& scale( const Other& scalar );
317  //**********************************************************************************************
318 
319  //**Memory functions****************************************************************************
322  static inline void* operator new ( std::size_t size );
323  static inline void* operator new[]( std::size_t size );
324  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
325  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
326 
327  static inline void operator delete ( void* ptr );
328  static inline void operator delete[]( void* ptr );
329  static inline void operator delete ( void* ptr, const std::nothrow_t& );
330  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
332  //**********************************************************************************************
333 
334  private:
335  //**********************************************************************************************
337  template< typename VT >
339  struct VectorizedAssign {
340  enum : bool { value = useOptimizedKernels &&
341  simdEnabled && VT::simdEnabled &&
343  };
345  //**********************************************************************************************
346 
347  //**********************************************************************************************
349  template< typename VT >
351  struct VectorizedAddAssign {
352  enum : bool { value = useOptimizedKernels &&
353  simdEnabled && VT::simdEnabled &&
356  };
358  //**********************************************************************************************
359 
360  //**********************************************************************************************
362  template< typename VT >
364  struct VectorizedSubAssign {
365  enum : bool { value = useOptimizedKernels &&
366  simdEnabled && VT::simdEnabled &&
369  };
371  //**********************************************************************************************
372 
373  //**********************************************************************************************
375  template< typename VT >
377  struct VectorizedMultAssign {
378  enum : bool { value = useOptimizedKernels &&
379  simdEnabled && VT::simdEnabled &&
382  };
384  //**********************************************************************************************
385 
386  //**********************************************************************************************
388  template< typename VT >
390  struct VectorizedDivAssign {
391  enum : bool { value = useOptimizedKernels &&
392  simdEnabled && VT::simdEnabled &&
395  };
397  //**********************************************************************************************
398 
399  //**********************************************************************************************
401  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
402  //**********************************************************************************************
403 
404  public:
405  //**Debugging functions*************************************************************************
408  inline bool isIntact() const noexcept;
410  //**********************************************************************************************
411 
412  //**Expression template evaluation functions****************************************************
415  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
416  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
417 
418  inline bool isAligned() const noexcept;
419 
420  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
421  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
422  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
423 
424  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
425  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
426  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
427  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
428 
429  template< typename VT >
430  inline DisableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
431 
432  template< typename VT >
433  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
434 
435  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
436 
437  template< typename VT >
438  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
439 
440  template< typename VT >
441  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
442 
443  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
444 
445  template< typename VT >
446  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
447 
448  template< typename VT >
449  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
450 
451  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
452 
453  template< typename VT >
454  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
455 
456  template< typename VT >
457  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
458 
459  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
460 
461  template< typename VT >
462  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
463 
464  template< typename VT >
465  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
467  //**********************************************************************************************
468 
469  private:
470  //**********************************************************************************************
472  enum : size_t { NN = ( usePadding )?( nextMultiple( N, SIMDSIZE ) ):( N ) };
473  //**********************************************************************************************
474 
475  //**Member variables****************************************************************************
479 
484  size_t size_;
485 
486  //**********************************************************************************************
487 
488  //**Compile time checks*************************************************************************
494  BLAZE_STATIC_ASSERT( !usePadding || NN % SIMDSIZE == 0UL );
495  BLAZE_STATIC_ASSERT( NN >= N );
497  //**********************************************************************************************
498 };
499 //*************************************************************************************************
500 
501 
502 
503 
504 //=================================================================================================
505 //
506 // CONSTRUCTORS
507 //
508 //=================================================================================================
509 
510 //*************************************************************************************************
515 template< typename Type // Data type of the vector
516  , size_t N // Number of elements
517  , bool TF > // Transpose flag
519  : v_ () // The statically allocated vector elements
520  , size_( 0UL ) // The current size/dimension of the vector
521 {
523 
524  if( IsNumeric<Type>::value ) {
525  for( size_t i=0UL; i<NN; ++i )
526  v_[i] = Type();
527  }
528 
529  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
530 }
531 //*************************************************************************************************
532 
533 
534 //*************************************************************************************************
544 template< typename Type // Data type of the vector
545  , size_t N // Number of elements
546  , bool TF > // Transpose flag
548  : v_ () // The statically allocated vector elements
549  , size_( n ) // The current size/dimension of the vector
550 {
552 
553  if( n > N ) {
554  BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
555  }
556 
557  if( IsNumeric<Type>::value ) {
558  for( size_t i=0UL; i<NN; ++i )
559  v_[i] = Type();
560  }
561 
562  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
563 }
564 //*************************************************************************************************
565 
566 
567 //*************************************************************************************************
578 template< typename Type // Data type of the vector
579  , size_t N // Number of elements
580  , bool TF > // Transpose flag
581 inline HybridVector<Type,N,TF>::HybridVector( size_t n, const Type& init )
582  : v_ () // The statically allocated vector elements
583  , size_( n ) // The current size/dimension of the vector
584 {
586 
587  if( n > N ) {
588  BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
589  }
590 
591  for( size_t i=0UL; i<n; ++i )
592  v_[i] = init;
593 
594  if( IsNumeric<Type>::value ) {
595  for( size_t i=n; i<NN; ++i )
596  v_[i] = Type();
597  }
598 
599  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
600 }
601 //*************************************************************************************************
602 
603 
604 //*************************************************************************************************
622 template< typename Type // Data type of the vector
623  , size_t N // Number of elements
624  , bool TF > // Transpose flag
626  : v_ () // The statically allocated vector elements
627  , size_( list.size() ) // The current size/dimension of the vector
628 {
630 
631  if( size_ > N ) {
632  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
633  }
634 
635  std::fill( std::copy( list.begin(), list.end(), v_.data() ), v_.data()+NN, Type() );
636 
637  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
638 }
639 //*************************************************************************************************
640 
641 
642 //*************************************************************************************************
665 template< typename Type // Data type of the vector
666  , size_t N // Number of elements
667  , bool TF > // Transpose flag
668 template< typename Other > // Data type of the initialization array
669 inline HybridVector<Type,N,TF>::HybridVector( size_t n, const Other* array )
670  : v_ () // The statically allocated vector elements
671  , size_( n ) // The current size/dimension of the vector
672 {
674 
675  if( n > N ) {
676  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
677  }
678 
679  for( size_t i=0UL; i<n; ++i )
680  v_[i] = array[i];
681 
682  if( IsNumeric<Type>::value ) {
683  for( size_t i=n; i<NN; ++i )
684  v_[i] = Type();
685  }
686 
687  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
688 }
689 //*************************************************************************************************
690 
691 
692 //*************************************************************************************************
710 template< typename Type // Data type of the vector
711  , size_t N // Number of elements
712  , bool TF > // Transpose flag
713 template< typename Other // Data type of the initialization array
714  , size_t Dim > // Number of elements of the initialization array
715 inline HybridVector<Type,N,TF>::HybridVector( const Other (&array)[Dim] )
716  : v_ () // The statically allocated vector elements
717  , size_( Dim ) // The current size/dimension of the vector
718 {
719  BLAZE_STATIC_ASSERT( Dim <= N );
721 
722  for( size_t i=0UL; i<Dim; ++i )
723  v_[i] = array[i];
724 
725  if( IsNumeric<Type>::value ) {
726  for( size_t i=Dim; i<NN; ++i )
727  v_[i] = Type();
728  }
729 
730  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
731 }
732 //*************************************************************************************************
733 
734 
735 //*************************************************************************************************
742 template< typename Type // Data type of the vector
743  , size_t N // Number of elements
744  , bool TF > // Transpose flag
746  : v_ () // The statically allocated vector elements
747  , size_( v.size_ ) // The current size/dimension of the vector
748 {
750 
751  for( size_t i=0UL; i<size_; ++i )
752  v_[i] = v.v_[i];
753 
754  if( IsNumeric<Type>::value ) {
755  for( size_t i=size_; i<NN; ++i )
756  v_[i] = Type();
757  }
758 
759  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
760 }
761 //*************************************************************************************************
762 
763 
764 //*************************************************************************************************
774 template< typename Type // Data type of the vector
775  , size_t N // Number of elements
776  , bool TF > // Transpose flag
777 template< typename VT > // Type of the foreign vector
779  : v_ () // The statically allocated vector elements
780  , size_( (~v).size() ) // The current size/dimension of the vector
781 {
782  using blaze::assign;
783 
785 
786  if( (~v).size() > N ) {
787  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
788  }
789 
790  for( size_t i=( IsSparseVector<VT>::value ? 0UL : size_ );
791  i<( IsNumeric<Type>::value ? NN : size_ ); ++i ) {
792  v_[i] = Type();
793  }
794 
795  assign( *this, ~v );
796 
797  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
798 }
799 //*************************************************************************************************
800 
801 
802 
803 
804 //=================================================================================================
805 //
806 // DATA ACCESS FUNCTIONS
807 //
808 //=================================================================================================
809 
810 //*************************************************************************************************
819 template< typename Type // Data type of the vector
820  , size_t N // Number of elements
821  , bool TF > // Transpose flag
823  HybridVector<Type,N,TF>::operator[]( size_t index ) noexcept
824 {
825  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
826  return v_[index];
827 }
828 //*************************************************************************************************
829 
830 
831 //*************************************************************************************************
840 template< typename Type // Data type of the vector
841  , size_t N // Number of elements
842  , bool TF > // Transpose flag
844  HybridVector<Type,N,TF>::operator[]( size_t index ) const noexcept
845 {
846  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
847  return v_[index];
848 }
849 //*************************************************************************************************
850 
851 
852 //*************************************************************************************************
862 template< typename Type // Data type of the vector
863  , size_t N // Number of elements
864  , bool TF > // Transpose flag
867 {
868  if( index >= size_ ) {
869  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
870  }
871  return (*this)[index];
872 }
873 //*************************************************************************************************
874 
875 
876 //*************************************************************************************************
886 template< typename Type // Data type of the vector
887  , size_t N // Number of elements
888  , bool TF > // Transpose flag
890  HybridVector<Type,N,TF>::at( size_t index ) const
891 {
892  if( index >= size_ ) {
893  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
894  }
895  return (*this)[index];
896 }
897 //*************************************************************************************************
898 
899 
900 //*************************************************************************************************
907 template< typename Type // Data type of the vector
908  , size_t N // Number of elements
909  , bool TF > // Transpose flag
911 {
912  return v_;
913 }
914 //*************************************************************************************************
915 
916 
917 //*************************************************************************************************
924 template< typename Type // Data type of the vector
925  , size_t N // Number of elements
926  , bool TF > // Transpose flag
928 {
929  return v_;
930 }
931 //*************************************************************************************************
932 
933 
934 //*************************************************************************************************
939 template< typename Type // Data type of the vector
940  , size_t N // Number of elements
941  , bool TF > // Transpose flag
943 {
944  return Iterator( v_ );
945 }
946 //*************************************************************************************************
947 
948 
949 //*************************************************************************************************
954 template< typename Type // Data type of the vector
955  , size_t N // Number of elements
956  , bool TF > // Transpose flag
958 {
959  return ConstIterator( v_ );
960 }
961 //*************************************************************************************************
962 
963 
964 //*************************************************************************************************
969 template< typename Type // Data type of the vector
970  , size_t N // Number of elements
971  , bool TF > // Transpose flag
973 {
974  return ConstIterator( v_ );
975 }
976 //*************************************************************************************************
977 
978 
979 //*************************************************************************************************
984 template< typename Type // Data type of the vector
985  , size_t N // Number of elements
986  , bool TF > // Transpose flag
988 {
989  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
990  return Iterator( v_ + size_ );
991 }
992 //*************************************************************************************************
993 
994 
995 //*************************************************************************************************
1000 template< typename Type // Data type of the vector
1001  , size_t N // Number of elements
1002  , bool TF > // Transpose flag
1004 {
1005  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1006  return ConstIterator( v_ + size_ );
1007 }
1008 //*************************************************************************************************
1009 
1010 
1011 //*************************************************************************************************
1016 template< typename Type // Data type of the vector
1017  , size_t N // Number of elements
1018  , bool TF > // Transpose flag
1020 {
1021  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1022  return ConstIterator( v_ + size_ );
1023 }
1024 //*************************************************************************************************
1025 
1026 
1027 
1028 
1029 //=================================================================================================
1030 //
1031 // ASSIGNMENT OPERATORS
1032 //
1033 //=================================================================================================
1034 
1035 //*************************************************************************************************
1041 template< typename Type // Data type of the vector
1042  , size_t N // Number of elements
1043  , bool TF > // Transpose flag
1045 {
1046  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1047 
1048  for( size_t i=0UL; i<size_; ++i )
1049  v_[i] = rhs;
1050  return *this;
1051 }
1052 //*************************************************************************************************
1053 
1054 
1055 //*************************************************************************************************
1074 template< typename Type // Data type of the vector
1075  , size_t N // Number of elements
1076  , bool TF > // Transpose flag
1078 {
1079  if( list.size() > N ) {
1080  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to hybrid vector" );
1081  }
1082 
1083  resize( list.size(), false );
1084  std::copy( list.begin(), list.end(), v_.data() );
1085 
1086  return *this;
1087 }
1088 //*************************************************************************************************
1089 
1090 
1091 //*************************************************************************************************
1110 template< typename Type // Data type of the vector
1111  , size_t N // Number of elements
1112  , bool TF > // Transpose flag
1113 template< typename Other // Data type of the initialization array
1114  , size_t Dim > // Number of elements of the initialization array
1116 {
1117  BLAZE_STATIC_ASSERT( Dim <= N );
1118 
1119  resize( Dim, false );
1120 
1121  for( size_t i=0UL; i<Dim; ++i )
1122  v_[i] = array[i];
1123 
1124  return *this;
1125 }
1126 //*************************************************************************************************
1127 
1128 
1129 //*************************************************************************************************
1137 template< typename Type // Data type of the vector
1138  , size_t N // Number of elements
1139  , bool TF > // Transpose flag
1141 {
1142  using blaze::assign;
1143 
1144  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1145 
1146  resize( rhs.size() );
1147  assign( *this, ~rhs );
1148 
1149  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1150 
1151  return *this;
1152 }
1153 //*************************************************************************************************
1154 
1155 
1156 //*************************************************************************************************
1166 template< typename Type // Data type of the vector
1167  , size_t N // Number of elements
1168  , bool TF > // Transpose flag
1169 template< typename VT > // Type of the right-hand side vector
1171 {
1172  using blaze::assign;
1173 
1174  if( (~rhs).size() > N ) {
1175  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to hybrid vector" );
1176  }
1177 
1178  if( (~rhs).canAlias( this ) ) {
1179  HybridVector tmp( ~rhs );
1180  swap( tmp );
1181  }
1182  else {
1183  resize( (~rhs).size(), false );
1185  reset();
1186  assign( *this, ~rhs );
1187  }
1188 
1189  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1190 
1191  return *this;
1192 }
1193 //*************************************************************************************************
1194 
1195 
1196 //*************************************************************************************************
1206 template< typename Type // Data type of the vector
1207  , size_t N // Number of elements
1208  , bool TF > // Transpose flag
1209 template< typename VT > // Type of the right-hand side vector
1211 {
1212  using blaze::addAssign;
1213 
1214  if( (~rhs).size() != size_ ) {
1215  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1216  }
1217 
1218  if( (~rhs).canAlias( this ) ) {
1219  const ResultType_<VT> tmp( ~rhs );
1220  addAssign( *this, tmp );
1221  }
1222  else {
1223  addAssign( *this, ~rhs );
1224  }
1225 
1226  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1227 
1228  return *this;
1229 }
1230 //*************************************************************************************************
1231 
1232 
1233 //*************************************************************************************************
1243 template< typename Type // Data type of the vector
1244  , size_t N // Number of elements
1245  , bool TF > // Transpose flag
1246 template< typename VT > // Type of the right-hand side vector
1248 {
1249  using blaze::subAssign;
1250 
1251  if( (~rhs).size() != size_ ) {
1252  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1253  }
1254 
1255  if( (~rhs).canAlias( this ) ) {
1256  const ResultType_<VT> tmp( ~rhs );
1257  subAssign( *this, tmp );
1258  }
1259  else {
1260  subAssign( *this, ~rhs );
1261  }
1262 
1263  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1264 
1265  return *this;
1266 }
1267 //*************************************************************************************************
1268 
1269 
1270 //*************************************************************************************************
1281 template< typename Type // Data type of the vector
1282  , size_t N // Number of elements
1283  , bool TF > // Transpose flag
1284 template< typename VT > // Type of the right-hand side vector
1286 {
1287  using blaze::assign;
1288  using blaze::multAssign;
1289 
1290  if( (~rhs).size() != size_ ) {
1291  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1292  }
1293 
1294  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1295  const HybridVector tmp( *this * (~rhs) );
1296  assign( *this, tmp );
1297  }
1298  else {
1299  multAssign( *this, ~rhs );
1300  }
1301 
1302  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1303 
1304  return *this;
1305 }
1306 //*************************************************************************************************
1307 
1308 
1309 //*************************************************************************************************
1319 template< typename Type // Data type of the vector
1320  , size_t N // Number of elements
1321  , bool TF > // Transpose flag
1322 template< typename VT > // Type of the right-hand side vector
1324 {
1325  using blaze::assign;
1326  using blaze::divAssign;
1327 
1328  if( (~rhs).size() != size_ ) {
1329  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1330  }
1331 
1332  if( (~rhs).canAlias( this ) ) {
1333  const HybridVector tmp( *this / (~rhs) );
1334  assign( *this, tmp );
1335  }
1336  else {
1337  divAssign( *this, ~rhs );
1338  }
1339 
1340  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1341 
1342  return *this;
1343 }
1344 //*************************************************************************************************
1345 
1346 
1347 //*************************************************************************************************
1358 template< typename Type // Data type of the vector
1359  , size_t N // Number of elements
1360  , bool TF > // Transpose flag
1361 template< typename VT > // Type of the right-hand side vector
1363 {
1364  using blaze::assign;
1365 
1368 
1369  using CrossType = CrossTrait_< This, ResultType_<VT> >;
1370 
1374 
1375  if( size_ != 3UL || (~rhs).size() != 3UL ) {
1376  BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1377  }
1378 
1379  const CrossType tmp( *this % (~rhs) );
1380  assign( *this, tmp );
1381 
1382  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1383 
1384  return *this;
1385 }
1386 //*************************************************************************************************
1387 
1388 
1389 
1390 
1391 //=================================================================================================
1392 //
1393 // UTILITY FUNCTIONS
1394 //
1395 //=================================================================================================
1396 
1397 //*************************************************************************************************
1402 template< typename Type // Data type of the vector
1403  , size_t N // Number of elements
1404  , bool TF > // Transpose flag
1405 inline size_t HybridVector<Type,N,TF>::size() const noexcept
1406 {
1407  return size_;
1408 }
1409 //*************************************************************************************************
1410 
1411 
1412 //*************************************************************************************************
1420 template< typename Type // Data type of the vector
1421  , size_t N // Number of elements
1422  , bool TF > // Transpose flag
1423 inline size_t HybridVector<Type,N,TF>::spacing() const noexcept
1424 {
1425  return NN;
1426 }
1427 //*************************************************************************************************
1428 
1429 
1430 //*************************************************************************************************
1435 template< typename Type // Data type of the vector
1436  , size_t N // Number of elements
1437  , bool TF > // Transpose flag
1438 inline size_t HybridVector<Type,N,TF>::capacity() const noexcept
1439 {
1440  return NN;
1441 }
1442 //*************************************************************************************************
1443 
1444 
1445 //*************************************************************************************************
1453 template< typename Type // Data type of the vector
1454  , size_t N // Number of elements
1455  , bool TF > // Transpose flag
1457 {
1458  size_t nonzeros( 0 );
1459 
1460  for( size_t i=0UL; i<size_; ++i ) {
1461  if( !isDefault( v_[i] ) )
1462  ++nonzeros;
1463  }
1464 
1465  return nonzeros;
1466 }
1467 //*************************************************************************************************
1468 
1469 
1470 //*************************************************************************************************
1475 template< typename Type // Data type of the vector
1476  , size_t N // Number of elements
1477  , bool TF > // Transpose flag
1479 {
1480  using blaze::clear;
1481  for( size_t i=0UL; i<size_; ++i )
1482  clear( v_[i] );
1483 }
1484 //*************************************************************************************************
1485 
1486 
1487 //*************************************************************************************************
1494 template< typename Type // Data type of the vector
1495  , size_t N // Number of elements
1496  , bool TF > // Transpose flag
1498 {
1499  resize( 0UL );
1500 }
1501 //*************************************************************************************************
1502 
1503 
1504 //*************************************************************************************************
1535 template< typename Type // Data type of the vector
1536  , size_t N // Number of elements
1537  , bool TF > // Transpose flag
1538 inline void HybridVector<Type,N,TF>::resize( size_t n, bool preserve )
1539 {
1540  UNUSED_PARAMETER( preserve );
1541 
1542  if( n > N ) {
1543  BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
1544  }
1545 
1546  if( IsNumeric<Type>::value && n < size_ ) {
1547  for( size_t i=n; i<size_; ++i )
1548  v_[i] = Type();
1549  }
1550 
1551  size_ = n;
1552 }
1553 //*************************************************************************************************
1554 
1555 
1556 //*************************************************************************************************
1570 template< typename Type // Data type of the vector
1571  , size_t N // Number of elements
1572  , bool TF > // Transpose flag
1573 inline void HybridVector<Type,N,TF>::extend( size_t n, bool preserve )
1574 {
1575  UNUSED_PARAMETER( preserve );
1576  resize( size_+n );
1577 }
1578 //*************************************************************************************************
1579 
1580 
1581 //*************************************************************************************************
1587 template< typename Type // Data type of the vector
1588  , size_t N // Number of elements
1589  , bool TF > // Transpose flag
1591 {
1592  using std::swap;
1593 
1594  const size_t maxsize( max( size_, v.size_ ) );
1595  for( size_t i=0UL; i<maxsize; ++i )
1596  swap( v_[i], v.v_[i] );
1597  swap( size_, v.size_ );
1598 }
1599 //*************************************************************************************************
1600 
1601 
1602 
1603 
1604 //=================================================================================================
1605 //
1606 // NUMERIC FUNCTIONS
1607 //
1608 //=================================================================================================
1609 
1610 //*************************************************************************************************
1627 template< typename Type // Data type of the vector
1628  , size_t N // Number of elements
1629  , bool TF > // Transpose flag
1630 template< typename Other > // Data type of the scalar value
1632 {
1633  for( size_t i=0; i<size_; ++i )
1634  v_[i] *= scalar;
1635  return *this;
1636 }
1637 //*************************************************************************************************
1638 
1639 
1640 
1641 
1642 //=================================================================================================
1643 //
1644 // MEMORY FUNCTIONS
1645 //
1646 //=================================================================================================
1647 
1648 //*************************************************************************************************
1658 template< typename Type // Data type of the vector
1659  , size_t N // Number of elements
1660  , bool TF > // Transpose flag
1661 inline void* HybridVector<Type,N,TF>::operator new( std::size_t size )
1662 {
1664 
1665  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridVector ), "Invalid number of bytes detected" );
1666 
1667  return allocate<HybridVector>( 1UL );
1668 }
1669 //*************************************************************************************************
1670 
1671 
1672 //*************************************************************************************************
1682 template< typename Type // Data type of the vector
1683  , size_t N // Number of elements
1684  , bool TF > // Transpose flag
1685 inline void* HybridVector<Type,N,TF>::operator new[]( std::size_t size )
1686 {
1687  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridVector ) , "Invalid number of bytes detected" );
1688  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridVector ) == 0UL, "Invalid number of bytes detected" );
1689 
1690  return allocate<HybridVector>( size/sizeof(HybridVector) );
1691 }
1692 //*************************************************************************************************
1693 
1694 
1695 //*************************************************************************************************
1705 template< typename Type // Data type of the vector
1706  , size_t N // Number of elements
1707  , bool TF > // Transpose flag
1708 inline void* HybridVector<Type,N,TF>::operator new( std::size_t size, const std::nothrow_t& )
1709 {
1710  UNUSED_PARAMETER( size );
1711 
1712  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridVector ), "Invalid number of bytes detected" );
1713 
1714  return allocate<HybridVector>( 1UL );
1715 }
1716 //*************************************************************************************************
1717 
1718 
1719 //*************************************************************************************************
1729 template< typename Type // Data type of the vector
1730  , size_t N // Number of elements
1731  , bool TF > // Transpose flag
1732 inline void* HybridVector<Type,N,TF>::operator new[]( std::size_t size, const std::nothrow_t& )
1733 {
1734  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridVector ) , "Invalid number of bytes detected" );
1735  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridVector ) == 0UL, "Invalid number of bytes detected" );
1736 
1737  return allocate<HybridVector>( size/sizeof(HybridVector) );
1738 }
1739 //*************************************************************************************************
1740 
1741 
1742 //*************************************************************************************************
1748 template< typename Type // Data type of the vector
1749  , size_t N // Number of elements
1750  , bool TF > // Transpose flag
1751 inline void HybridVector<Type,N,TF>::operator delete( void* ptr )
1752 {
1753  deallocate( static_cast<HybridVector*>( ptr ) );
1754 }
1755 //*************************************************************************************************
1756 
1757 
1758 //*************************************************************************************************
1764 template< typename Type // Data type of the vector
1765  , size_t N // Number of elements
1766  , bool TF > // Transpose flag
1767 inline void HybridVector<Type,N,TF>::operator delete[]( void* ptr )
1768 {
1769  deallocate( static_cast<HybridVector*>( ptr ) );
1770 }
1771 //*************************************************************************************************
1772 
1773 
1774 //*************************************************************************************************
1780 template< typename Type // Data type of the vector
1781  , size_t N // Number of elements
1782  , bool TF > // Transpose flag
1783 inline void HybridVector<Type,N,TF>::operator delete( void* ptr, const std::nothrow_t& )
1784 {
1785  deallocate( static_cast<HybridVector*>( ptr ) );
1786 }
1787 //*************************************************************************************************
1788 
1789 
1790 //*************************************************************************************************
1796 template< typename Type // Data type of the vector
1797  , size_t N // Number of elements
1798  , bool TF > // Transpose flag
1799 inline void HybridVector<Type,N,TF>::operator delete[]( void* ptr, const std::nothrow_t& )
1800 {
1801  deallocate( static_cast<HybridVector*>( ptr ) );
1802 }
1803 //*************************************************************************************************
1804 
1805 
1806 
1807 
1808 //=================================================================================================
1809 //
1810 // DEBUGGING FUNCTIONS
1811 //
1812 //=================================================================================================
1813 
1814 //*************************************************************************************************
1823 template< typename Type // Data type of the vector
1824  , size_t N // Number of elements
1825  , bool TF > // Transpose flag
1826 inline bool HybridVector<Type,N,TF>::isIntact() const noexcept
1827 {
1828  if( size_ > N )
1829  return false;
1830 
1832  for( size_t i=size_; i<NN; ++i ) {
1833  if( v_[i] != Type() )
1834  return false;
1835  }
1836  }
1837 
1838  return true;
1839 }
1840 //*************************************************************************************************
1841 
1842 
1843 
1844 
1845 //=================================================================================================
1846 //
1847 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1848 //
1849 //=================================================================================================
1850 
1851 //*************************************************************************************************
1861 template< typename Type // Data type of the vector
1862  , size_t N // Number of elements
1863  , bool TF > // Transpose flag
1864 template< typename Other > // Data type of the foreign expression
1865 inline bool HybridVector<Type,N,TF>::canAlias( const Other* alias ) const noexcept
1866 {
1867  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1868 }
1869 //*************************************************************************************************
1870 
1871 
1872 //*************************************************************************************************
1882 template< typename Type // Data type of the vector
1883  , size_t N // Number of elements
1884  , bool TF > // Transpose flag
1885 template< typename Other > // Data type of the foreign expression
1886 inline bool HybridVector<Type,N,TF>::isAliased( const Other* alias ) const noexcept
1887 {
1888  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1889 }
1890 //*************************************************************************************************
1891 
1892 
1893 //*************************************************************************************************
1902 template< typename Type // Data type of the vector
1903  , size_t N // Number of elements
1904  , bool TF > // Transpose flag
1905 inline bool HybridVector<Type,N,TF>::isAligned() const noexcept
1906 {
1907  return true;
1908 }
1909 //*************************************************************************************************
1910 
1911 
1912 //*************************************************************************************************
1924 template< typename Type // Data type of the vector
1925  , size_t N // Number of elements
1926  , bool TF > // Transpose flag
1928  HybridVector<Type,N,TF>::load( size_t index ) const noexcept
1929 {
1930  return loada( index );
1931 }
1932 //*************************************************************************************************
1933 
1934 
1935 //*************************************************************************************************
1948 template< typename Type // Data type of the vector
1949  , size_t N // Number of elements
1950  , bool TF > // Transpose flag
1952  HybridVector<Type,N,TF>::loada( size_t index ) const noexcept
1953 {
1954  using blaze::loada;
1955 
1957 
1958  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1959  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1960  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1961  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1962 
1963  return loada( &v_[index] );
1964 }
1965 //*************************************************************************************************
1966 
1967 
1968 //*************************************************************************************************
1981 template< typename Type // Data type of the vector
1982  , size_t N // Number of elements
1983  , bool TF > // Transpose flag
1985  HybridVector<Type,N,TF>::loadu( size_t index ) const noexcept
1986 {
1987  using blaze::loadu;
1988 
1990 
1991  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1992  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1993 
1994  return loadu( &v_[index] );
1995 }
1996 //*************************************************************************************************
1997 
1998 
1999 //*************************************************************************************************
2012 template< typename Type // Data type of the vector
2013  , size_t N // Number of elements
2014  , bool TF > // Transpose flag
2016  HybridVector<Type,N,TF>::store( size_t index, const SIMDType& value ) noexcept
2017 {
2018  storea( index, value );
2019 }
2020 //*************************************************************************************************
2021 
2022 
2023 //*************************************************************************************************
2036 template< typename Type // Data type of the vector
2037  , size_t N // Number of elements
2038  , bool TF > // Transpose flag
2040  HybridVector<Type,N,TF>::storea( size_t index, const SIMDType& value ) noexcept
2041 {
2042  using blaze::storea;
2043 
2045 
2046  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2047  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2048  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2049  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2050 
2051  storea( &v_[index], value );
2052 }
2053 //*************************************************************************************************
2054 
2055 
2056 //*************************************************************************************************
2069 template< typename Type // Data type of the vector
2070  , size_t N // Number of elements
2071  , bool TF > // Transpose flag
2073  HybridVector<Type,N,TF>::storeu( size_t index, const SIMDType& value ) noexcept
2074 {
2075  using blaze::storeu;
2076 
2078 
2079  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2080  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2081 
2082  storeu( &v_[index], value );
2083 }
2084 //*************************************************************************************************
2085 
2086 
2087 //*************************************************************************************************
2101 template< typename Type // Data type of the vector
2102  , size_t N // Number of elements
2103  , bool TF > // Transpose flag
2105  HybridVector<Type,N,TF>::stream( size_t index, const SIMDType& value ) noexcept
2106 {
2107  using blaze::stream;
2108 
2110 
2111  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2112  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2113  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2114  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2115 
2116  stream( &v_[index], value );
2117 }
2118 //*************************************************************************************************
2119 
2120 
2121 //*************************************************************************************************
2132 template< typename Type // Data type of the vector
2133  , size_t N // Number of elements
2134  , bool TF > // Transpose flag
2135 template< typename VT > // Type of the right-hand side dense vector
2138 {
2139  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2140 
2141  for( size_t i=0UL; i<size_; ++i )
2142  v_[i] = (~rhs)[i];
2143 }
2144 //*************************************************************************************************
2145 
2146 
2147 //*************************************************************************************************
2158 template< typename Type // Data type of the vector
2159  , size_t N // Number of elements
2160  , bool TF > // Transpose flag
2161 template< typename VT > // Type of the right-hand side dense vector
2164 {
2166 
2167  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2168 
2169  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2170 
2171  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2172  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2173 
2174  size_t i( 0UL );
2175 
2176  for( ; i<ipos; i+=SIMDSIZE ) {
2177  store( i, (~rhs).load(i) );
2178  }
2179  for( ; remainder && i<size_; ++i ) {
2180  v_[i] = (~rhs)[i];
2181  }
2182 }
2183 //*************************************************************************************************
2184 
2185 
2186 //*************************************************************************************************
2197 template< typename Type // Data type of the vector
2198  , size_t N // Number of elements
2199  , bool TF > // Transpose flag
2200 template< typename VT > // Type of the right-hand side sparse vector
2202 {
2203  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2204 
2205  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2206  v_[element->index()] = element->value();
2207 }
2208 //*************************************************************************************************
2209 
2210 
2211 //*************************************************************************************************
2222 template< typename Type // Data type of the vector
2223  , size_t N // Number of elements
2224  , bool TF > // Transpose flag
2225 template< typename VT > // Type of the right-hand side dense vector
2226 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2228 {
2229  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2230 
2231  for( size_t i=0UL; i<size_; ++i )
2232  v_[i] += (~rhs)[i];
2233 }
2234 //*************************************************************************************************
2235 
2236 
2237 //*************************************************************************************************
2248 template< typename Type // Data type of the vector
2249  , size_t N // Number of elements
2250  , bool TF > // Transpose flag
2251 template< typename VT > // Type of the right-hand side dense vector
2252 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2254 {
2256 
2257  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2258 
2259  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2260 
2261  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2262  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2263 
2264  size_t i( 0UL );
2265 
2266  for( ; i<ipos; i+=SIMDSIZE ) {
2267  store( i, load(i) + (~rhs).load(i) );
2268  }
2269  for( ; remainder && i<size_; ++i ) {
2270  v_[i] += (~rhs)[i];
2271  }
2272 }
2273 //*************************************************************************************************
2274 
2275 
2276 //*************************************************************************************************
2287 template< typename Type // Data type of the vector
2288  , size_t N // Number of elements
2289  , bool TF > // Transpose flag
2290 template< typename VT > // Type of the right-hand side sparse vector
2292 {
2293  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2294 
2295  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2296  v_[element->index()] += element->value();
2297 }
2298 //*************************************************************************************************
2299 
2300 
2301 //*************************************************************************************************
2312 template< typename Type // Data type of the vector
2313  , size_t N // Number of elements
2314  , bool TF > // Transpose flag
2315 template< typename VT > // Type of the right-hand side dense vector
2316 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2318 {
2319  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2320 
2321  for( size_t i=0UL; i<size_; ++i )
2322  v_[i] -= (~rhs)[i];
2323 }
2324 //*************************************************************************************************
2325 
2326 
2327 //*************************************************************************************************
2338 template< typename Type // Data type of the vector
2339  , size_t N // Number of elements
2340  , bool TF > // Transpose flag
2341 template< typename VT > // Type of the right-hand side dense vector
2342 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2344 {
2346 
2347  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2348 
2349  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2350 
2351  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2352  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2353 
2354  size_t i( 0UL );
2355 
2356  for( ; i<ipos; i+=SIMDSIZE ) {
2357  store( i, load(i) - (~rhs).load(i) );
2358  }
2359  for( ; remainder && i<size_; ++i ) {
2360  v_[i] -= (~rhs)[i];
2361  }
2362 }
2363 //*************************************************************************************************
2364 
2365 
2366 //*************************************************************************************************
2377 template< typename Type // Data type of the vector
2378  , size_t N // Number of elements
2379  , bool TF > // Transpose flag
2380 template< typename VT > // Type of the right-hand side sparse vector
2382 {
2383  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2384 
2385  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2386  v_[element->index()] -= element->value();
2387 }
2388 //*************************************************************************************************
2389 
2390 
2391 //*************************************************************************************************
2402 template< typename Type // Data type of the vector
2403  , size_t N // Number of elements
2404  , bool TF > // Transpose flag
2405 template< typename VT > // Type of the right-hand side dense vector
2406 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2408 {
2409  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2410 
2411  for( size_t i=0UL; i<size_; ++i )
2412  v_[i] *= (~rhs)[i];
2413 }
2414 //*************************************************************************************************
2415 
2416 
2417 //*************************************************************************************************
2428 template< typename Type // Data type of the vector
2429  , size_t N // Number of elements
2430  , bool TF > // Transpose flag
2431 template< typename VT > // Type of the right-hand side dense vector
2432 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2434 {
2436 
2437  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2438 
2439  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2440 
2441  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2442  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2443 
2444  size_t i( 0UL );
2445 
2446  for( ; i<ipos; i+=SIMDSIZE ) {
2447  store( i, load(i) * (~rhs).load(i) );
2448  }
2449  for( ; remainder && i<size_; ++i ) {
2450  v_[i] *= (~rhs)[i];
2451  }
2452 }
2453 //*************************************************************************************************
2454 
2455 
2456 //*************************************************************************************************
2467 template< typename Type // Data type of the vector
2468  , size_t N // Number of elements
2469  , bool TF > // Transpose flag
2470 template< typename VT > // Type of the right-hand side sparse vector
2472 {
2473  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2474 
2475  const HybridVector tmp( serial( *this ) );
2476 
2477  reset();
2478 
2479  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2480  v_[element->index()] = tmp[element->index()] * element->value();
2481 }
2482 //*************************************************************************************************
2483 
2484 
2485 //*************************************************************************************************
2496 template< typename Type // Data type of the vector
2497  , size_t N // Number of elements
2498  , bool TF > // Transpose flag
2499 template< typename VT > // Type of the right-hand side dense vector
2500 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2502 {
2503  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2504 
2505  for( size_t i=0UL; i<size_; ++i )
2506  v_[i] /= (~rhs)[i];
2507 }
2508 //*************************************************************************************************
2509 
2510 
2511 //*************************************************************************************************
2522 template< typename Type // Data type of the vector
2523  , size_t N // Number of elements
2524  , bool TF > // Transpose flag
2525 template< typename VT > // Type of the right-hand side dense vector
2526 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2528 {
2530 
2531  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2532 
2533  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2534  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2535 
2536  size_t i( 0UL );
2537 
2538  for( ; i<ipos; i+=SIMDSIZE ) {
2539  store( i, load(i) / (~rhs).load(i) );
2540  }
2541  for( ; i<size_; ++i ) {
2542  v_[i] /= (~rhs)[i];
2543  }
2544 }
2545 //*************************************************************************************************
2546 
2547 
2548 
2549 
2550 
2551 
2552 
2553 
2554 //=================================================================================================
2555 //
2556 // HYBRIDVECTOR OPERATORS
2557 //
2558 //=================================================================================================
2559 
2560 //*************************************************************************************************
2563 template< typename Type, size_t N, bool TF >
2564 inline void reset( HybridVector<Type,N,TF>& v );
2565 
2566 template< typename Type, size_t N, bool TF >
2567 inline void clear( HybridVector<Type,N,TF>& v );
2568 
2569 template< bool RF, typename Type, size_t N, bool TF >
2570 inline bool isDefault( const HybridVector<Type,N,TF>& v );
2571 
2572 template< typename Type, size_t N, bool TF >
2573 inline bool isIntact( const HybridVector<Type,N,TF>& v );
2574 
2575 template< typename Type, size_t N, bool TF >
2576 inline void swap( HybridVector<Type,N,TF>& a, HybridVector<Type,N,TF>& b ) noexcept;
2578 //*************************************************************************************************
2579 
2580 
2581 //*************************************************************************************************
2588 template< typename Type // Data type of the vector
2589  , size_t N // Number of elements
2590  , bool TF > // Transpose flag
2592 {
2593  v.reset();
2594 }
2595 //*************************************************************************************************
2596 
2597 
2598 //*************************************************************************************************
2605 template< typename Type // Data type of the vector
2606  , size_t N // Number of elements
2607  , bool TF > // Transpose flag
2609 {
2610  v.clear();
2611 }
2612 //*************************************************************************************************
2613 
2614 
2615 //*************************************************************************************************
2639 template< bool RF // Relaxation flag
2640  , typename Type // Data type of the vector
2641  , size_t N // Number of elements
2642  , bool TF > // Transpose flag
2643 inline bool isDefault( const HybridVector<Type,N,TF>& v )
2644 {
2645  return ( v.size() == 0UL );
2646 }
2647 //*************************************************************************************************
2648 
2649 
2650 //*************************************************************************************************
2668 template< typename Type // Data type of the vector
2669  , size_t N // Number of elements
2670  , bool TF > // Transpose flag
2671 inline bool isIntact( const HybridVector<Type,N,TF>& v )
2672 {
2673  return v.isIntact();
2674 }
2675 //*************************************************************************************************
2676 
2677 
2678 //*************************************************************************************************
2686 template< typename Type // Data type of the vector
2687  , size_t N // Number of elements
2688  , bool TF > // Transpose flag
2690 {
2691  a.swap( b );
2692 }
2693 //*************************************************************************************************
2694 
2695 
2696 
2697 
2698 //=================================================================================================
2699 //
2700 // HASCONSTDATAACCESS SPECIALIZATIONS
2701 //
2702 //=================================================================================================
2703 
2704 //*************************************************************************************************
2706 template< typename T, size_t N, bool TF >
2707 struct HasConstDataAccess< HybridVector<T,N,TF> >
2708  : public TrueType
2709 {};
2711 //*************************************************************************************************
2712 
2713 
2714 
2715 
2716 //=================================================================================================
2717 //
2718 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2719 //
2720 //=================================================================================================
2721 
2722 //*************************************************************************************************
2724 template< typename T, size_t N, bool TF >
2725 struct HasMutableDataAccess< HybridVector<T,N,TF> >
2726  : public TrueType
2727 {};
2729 //*************************************************************************************************
2730 
2731 
2732 
2733 
2734 //=================================================================================================
2735 //
2736 // ISALIGNED SPECIALIZATIONS
2737 //
2738 //=================================================================================================
2739 
2740 //*************************************************************************************************
2742 template< typename T, size_t N, bool TF >
2743 struct IsAligned< HybridVector<T,N,TF> >
2744  : public TrueType
2745 {};
2747 //*************************************************************************************************
2748 
2749 
2750 
2751 
2752 //=================================================================================================
2753 //
2754 // ISCONTIGUOUS SPECIALIZATIONS
2755 //
2756 //=================================================================================================
2757 
2758 //*************************************************************************************************
2760 template< typename T, size_t N, bool TF >
2761 struct IsContiguous< HybridVector<T,N,TF> >
2762  : public TrueType
2763 {};
2765 //*************************************************************************************************
2766 
2767 
2768 
2769 
2770 //=================================================================================================
2771 //
2772 // ISPADDED SPECIALIZATIONS
2773 //
2774 //=================================================================================================
2775 
2776 //*************************************************************************************************
2778 template< typename T, size_t N, bool TF >
2779 struct IsPadded< HybridVector<T,N,TF> >
2780  : public BoolConstant<usePadding>
2781 {};
2783 //*************************************************************************************************
2784 
2785 
2786 
2787 
2788 //=================================================================================================
2789 //
2790 // ISRESIZABLE SPECIALIZATIONS
2791 //
2792 //=================================================================================================
2793 
2794 //*************************************************************************************************
2796 template< typename T, size_t N, bool TF >
2797 struct IsResizable< HybridVector<T,N,TF> >
2798  : public TrueType
2799 {};
2801 //*************************************************************************************************
2802 
2803 
2804 
2805 
2806 //=================================================================================================
2807 //
2808 // ADDTRAIT SPECIALIZATIONS
2809 //
2810 //=================================================================================================
2811 
2812 //*************************************************************************************************
2814 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2815 struct AddTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2816 {
2817  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2818 };
2819 
2820 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2821 struct AddTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2822 {
2823  using Type = StaticVector< AddTrait_<T1,T2>, M, TF >;
2824 };
2825 
2826 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2827 struct AddTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2828 {
2829  using Type = HybridVector< AddTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2830 };
2832 //*************************************************************************************************
2833 
2834 
2835 
2836 
2837 //=================================================================================================
2838 //
2839 // SUBTRAIT SPECIALIZATIONS
2840 //
2841 //=================================================================================================
2842 
2843 //*************************************************************************************************
2845 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2846 struct SubTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2847 {
2848  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2849 };
2850 
2851 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2852 struct SubTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2853 {
2854  using Type = StaticVector< SubTrait_<T1,T2>, M, TF >;
2855 };
2856 
2857 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2858 struct SubTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2859 {
2860  using Type = HybridVector< SubTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2861 };
2863 //*************************************************************************************************
2864 
2865 
2866 
2867 
2868 //=================================================================================================
2869 //
2870 // MULTTRAIT SPECIALIZATIONS
2871 //
2872 //=================================================================================================
2873 
2874 //*************************************************************************************************
2876 template< typename T1, size_t N, bool TF, typename T2 >
2877 struct MultTrait< HybridVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2878 {
2879  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
2880 };
2881 
2882 template< typename T1, typename T2, size_t N, bool TF >
2883 struct MultTrait< T1, HybridVector<T2,N,TF>, EnableIf_<IsNumeric<T1> > >
2884 {
2885  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
2886 };
2887 
2888 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2889 struct MultTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2890 {
2891  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2892 };
2893 
2894 template< typename T1, size_t M, typename T2, size_t N >
2895 struct MultTrait< HybridVector<T1,M,false>, StaticVector<T2,N,true> >
2896 {
2897  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2898 };
2899 
2900 template< typename T1, size_t M, typename T2, size_t N >
2901 struct MultTrait< HybridVector<T1,M,true>, StaticVector<T2,N,false> >
2902 {
2903  using Type = MultTrait_<T1,T2>;
2904 };
2905 
2906 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2907 struct MultTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2908 {
2909  using Type = StaticVector< MultTrait_<T1,T2>, M, TF >;
2910 };
2911 
2912 template< typename T1, size_t M, typename T2, size_t N >
2913 struct MultTrait< StaticVector<T1,M,false>, HybridVector<T2,N,true> >
2914 {
2915  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2916 };
2917 
2918 template< typename T1, size_t M, typename T2, size_t N >
2919 struct MultTrait< StaticVector<T1,M,true>, HybridVector<T2,N,false> >
2920 {
2921  using Type = MultTrait_<T1,T2>;
2922 };
2923 
2924 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2925 struct MultTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2926 {
2927  using Type = HybridVector< MultTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2928 };
2929 
2930 template< typename T1, size_t M, typename T2, size_t N >
2931 struct MultTrait< HybridVector<T1,M,false>, HybridVector<T2,N,true> >
2932 {
2933  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2934 };
2935 
2936 template< typename T1, size_t M, typename T2, size_t N >
2937 struct MultTrait< HybridVector<T1,M,true>, HybridVector<T2,N,false> >
2938 {
2939  using Type = MultTrait_<T1,T2>;
2940 };
2942 //*************************************************************************************************
2943 
2944 
2945 
2946 
2947 //=================================================================================================
2948 //
2949 // DIVTRAIT SPECIALIZATIONS
2950 //
2951 //=================================================================================================
2952 
2953 //*************************************************************************************************
2955 template< typename T1, size_t N, bool TF, typename T2 >
2956 struct DivTrait< HybridVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2957 {
2958  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
2959 };
2960 
2961 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2962 struct DivTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2963 {
2964  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2965 };
2966 
2967 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2968 struct DivTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2969 {
2970  using Type = StaticVector< DivTrait_<T1,T2>, M, TF >;
2971 };
2972 
2973 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2974 struct DivTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2975 {
2976  using Type = HybridVector< DivTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2977 };
2979 //*************************************************************************************************
2980 
2981 
2982 
2983 
2984 //=================================================================================================
2985 //
2986 // CROSSTRAIT SPECIALIZATIONS
2987 //
2988 //=================================================================================================
2989 
2990 //*************************************************************************************************
2992 template< typename T1, size_t N, bool TF, typename T2 >
2993 struct CrossTrait< HybridVector<T1,N,TF>, StaticVector<T2,3UL,TF> >
2994 {
2995  private:
2996  using T = MultTrait_<T1,T2>;
2997 
2998  public:
2999  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
3000 };
3001 
3002 template< typename T1, bool TF, typename T2, size_t N >
3003 struct CrossTrait< StaticVector<T1,3UL,TF>, HybridVector<T2,N,TF> >
3004 {
3005  private:
3006  using T = MultTrait_<T1,T2>;
3007 
3008  public:
3009  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
3010 };
3011 
3012 template< typename T1, size_t M, bool TF, typename T2, size_t N >
3013 struct CrossTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
3014 {
3015  private:
3016  using T = MultTrait_<T1,T2>;
3017 
3018  public:
3019  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
3020 };
3022 //*************************************************************************************************
3023 
3024 
3025 
3026 
3027 //=================================================================================================
3028 //
3029 // UNARYMAPTRAIT SPECIALIZATIONS
3030 //
3031 //=================================================================================================
3032 
3033 //*************************************************************************************************
3035 template< typename T, size_t N, bool TF, typename OP >
3036 struct UnaryMapTrait< HybridVector<T,N,TF>, OP >
3037 {
3038  using Type = HybridVector< UnaryMapTrait_<T,OP>, N, TF >;
3039 };
3041 //*************************************************************************************************
3042 
3043 
3044 
3045 
3046 //=================================================================================================
3047 //
3048 // BINARYMAPTRAIT SPECIALIZATIONS
3049 //
3050 //=================================================================================================
3051 
3052 //*************************************************************************************************
3054 template< typename T1, size_t M, bool TF, typename T2, size_t N, typename OP >
3055 struct BinaryMapTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF>, OP >
3056 {
3057  using Type = StaticVector< BinaryMapTrait_<T1,T2,OP>, N, TF >;
3058 };
3059 
3060 template< typename T1, size_t M, bool TF, typename T2, size_t N, typename OP >
3061 struct BinaryMapTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF>, OP >
3062 {
3063  using Type = StaticVector< BinaryMapTrait_<T1,T2,OP>, M, TF >;
3064 };
3065 
3066 template< typename T1, size_t M, bool TF, typename T2, size_t N, typename OP >
3067 struct BinaryMapTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF>, OP >
3068 {
3069  using Type = HybridVector< BinaryMapTrait_<T1,T2,OP>, ( M < N )?( M ):( N ), TF >;
3070 };
3072 //*************************************************************************************************
3073 
3074 
3075 
3076 
3077 //=================================================================================================
3078 //
3079 // HIGHTYPE SPECIALIZATIONS
3080 //
3081 //=================================================================================================
3082 
3083 //*************************************************************************************************
3085 template< typename T1, size_t N, bool TF, typename T2 >
3086 struct HighType< HybridVector<T1,N,TF>, HybridVector<T2,N,TF> >
3087 {
3088  using Type = StaticVector< typename HighType<T1,T2>::Type, N, TF >;
3089 };
3091 //*************************************************************************************************
3092 
3093 
3094 
3095 
3096 //=================================================================================================
3097 //
3098 // LOWTYPE SPECIALIZATIONS
3099 //
3100 //=================================================================================================
3101 
3102 //*************************************************************************************************
3104 template< typename T1, size_t N, bool TF, typename T2 >
3105 struct LowType< HybridVector<T1,N,TF>, HybridVector<T2,N,TF> >
3106 {
3107  using Type = StaticVector< typename LowType<T1,T2>::Type, N, TF >;
3108 };
3110 //*************************************************************************************************
3111 
3112 
3113 
3114 
3115 //=================================================================================================
3116 //
3117 // SUBVECTORTRAIT SPECIALIZATIONS
3118 //
3119 //=================================================================================================
3120 
3121 //*************************************************************************************************
3123 template< typename T, size_t N1, bool TF, size_t I, size_t N2 >
3124 struct SubvectorTrait< HybridVector<T,N1,TF>, I, N2 >
3125 {
3126  using Type = StaticVector<T,N2,TF>;
3127 };
3128 
3129 template< typename T, size_t N, bool TF >
3130 struct SubvectorTrait< HybridVector<T,N,TF> >
3131 {
3132  using Type = HybridVector<T,N,TF>;
3133 };
3135 //*************************************************************************************************
3136 
3137 
3138 
3139 
3140 //=================================================================================================
3141 //
3142 // ELEMENTSTRAIT SPECIALIZATIONS
3143 //
3144 //=================================================================================================
3145 
3146 //*************************************************************************************************
3148 template< typename T, size_t N1, bool TF, size_t... CEAs >
3149 struct ElementsTrait< HybridVector<T,N1,TF>, CEAs... >
3150 {
3151  using Type = StaticVector<T,sizeof...(CEAs),TF>;
3152 };
3153 
3154 template< typename T, size_t N, bool TF >
3155 struct ElementsTrait< HybridVector<T,N,TF> >
3156 {
3157  using Type = HybridVector<T,N,TF>;
3158 };
3160 //*************************************************************************************************
3161 
3162 } // namespace blaze
3163 
3164 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:135
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
Availability of a SIMD subtraction for the given data types.Depending on the available instruction se...
Definition: HasSIMDSub.h:171
Header file for mathematical functions.
Compile time check for low-level access to constant data.This type trait tests whether the given data...
Definition: HasConstDataAccess.h:75
#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:1573
Header file for the alignment flag values.
Header file for the UNUSED_PARAMETER function template.
HybridVector()
The default constructor for HybridVector.
Definition: HybridVector.h:518
Header file for the subtraction trait.
Header file for basic type definitions.
DenseIterator< const Type, aligned > ConstIterator
Iterator over constant elements.
Definition: HybridVector.h:201
Header file for the SparseVector base class.
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: HybridVector.h:478
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.
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
Availability of a SIMD multiplication for the given data types.Depending on the available instruction...
Definition: HasSIMDMult.h:172
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:316
Iterator end() noexcept
Returns an iterator just past the last element of the hybrid vector.
Definition: HybridVector.h:987
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: HybridVector.h:1405
Header file for the DenseVector base class.
Availability of a SIMD addition for the given data types.Depending on the available instruction set (...
Definition: HasSIMDAdd.h:171
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: HybridVector.h:910
#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
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:291
Header file for memory allocation and deallocation functionality.
Header file for the extended initializer_list functionality.
System settings for performance optimizations.
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:217
Compile time check for data types.This type trait tests whether or not the given types can be combine...
Definition: IsSIMDCombinable.h:120
size_t capacity() const noexcept
Returns the maximum capacity of the vector.
Definition: HybridVector.h:1438
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:343
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1950
Type ElementType
Type of the vector elements.
Definition: HybridVector.h:190
Header file for the elements trait.
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: HybridVector.h:1886
Constraint on the data type.
Base template for the CrossTrait class.
Definition: CrossTrait.h:113
Efficient implementation of a fixed-sized vector.The StaticVector class template is the representatio...
Definition: Forward.h:61
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:109
Efficient implementation of a dynamically sized vector with static memory.The HybridVector class temp...
Definition: Forward.h:59
Compile time check for low-level access to mutable data.This type trait tests whether the given data ...
Definition: HasMutableDataAccess.h:75
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
Type & Reference
Reference to a non-constant vector value.
Definition: HybridVector.h:195
Rebind mechanism to obtain a HybridVector with different data/element type.
Definition: HybridVector.h:208
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: HybridVector.h:823
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: HybridVector.h:2073
Compile time check for the memory layout of data types.This type trait tests whether the given data t...
Definition: IsContiguous.h:86
Headerfile for the generic max algorithm.
Header file for the DisableIf class template.
Header file for the LowType type trait.
Base template for the HighType type trait.
Definition: HighType.h:133
Header file for the multiplication trait.
Header file for the unary map trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#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:5908
Compile time assertion.
Header file for all forward declarations of the math module.
#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
Type * Pointer
Pointer to a non-constant vector value.
Definition: HybridVector.h:197
#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
Header file for the HasSIMDAdd type trait.
Header file for the DenseIterator class template.
Iterator begin() noexcept
Returns an iterator to the first element of the hybrid vector.
Definition: HybridVector.h:942
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: HybridVector.h:1952
Header file for the subvector trait.
Header file for all SIMD functionality.
Constraint on the data type.
Availability of a SIMD division for the given data types.Depending on the available instruction set (...
Definition: HasSIMDDiv.h:150
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:103
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:2040
Constraint on the data type.
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
Constraint on the data type.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: HybridVector.h:1985
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: HybridVector.h:1928
Base template for the ElementsTrait class.
Definition: ElementsTrait.h:108
typename CrossTrait< T1, T2 >::Type CrossTrait_
Auxiliary alias declaration for the CrossTrait class template.The CrossTrait_ alias declaration provi...
Definition: CrossTrait.h:209
Constraint on the data type.
void clear()
Clearing the vector.
Definition: HybridVector.h:1497
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:608
Header file for the IsPadded type trait.
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
Base template for the LowType type trait.
Definition: LowType.h:133
size_t spacing() const noexcept
Returns the minimum capacity of the vector.
Definition: HybridVector.h:1423
Header file for the HasConstDataAccess type trait.
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
void resize(size_t n, bool preserve=true)
Changing the size of the vector.
Definition: HybridVector.h:1538
size_t size_
The current size/dimension of the vector.
Definition: HybridVector.h:484
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
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the hybrid vector.
Definition: HybridVector.h:1019
Header file for the IsSIMDCombinable type trait.
Header file for the IsSparseVector type trait.
Header file for the HasSIMDMult type trait.
Header file for the binary map trait.
BLAZE_ALWAYS_INLINE constexpr auto nextMultiple(T1 value, T2 factor) noexcept
Rounds up an integral value to the next multiple of a given factor.
Definition: Functions.h:156
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:119
HybridVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: HybridVector.h:1044
Base template for the MultTrait class.
Definition: MultTrait.h:119
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: HybridVector.h:1905
bool isIntact() const noexcept
Returns whether the invariants of the hybrid vector are intact.
Definition: HybridVector.h:1826
Constraint on the data type.
Header file for the IsContiguous type trait.
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the hybrid vector.
Definition: HybridVector.h:972
Header file for the AlignedArray implementation.
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:296
#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
Header file for the isDefault shim.
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:2105
Constraint on the data type.
Header file for the HasSIMDSub type trait.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:816
Header file for the HasMutableDataAccess type trait.
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:1590
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
const Type & ConstReference
Reference to a constant vector value.
Definition: HybridVector.h:196
EnableIf_< IsBuiltin< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:230
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
Base template for the DivTrait class.
Definition: DivTrait.h:120
DenseIterator< Type, aligned > Iterator
Iterator over non-constant elements.
Definition: HybridVector.h:200
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
const Type * ConstPointer
Pointer to a constant vector value.
Definition: HybridVector.h:198
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
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
void reset()
Reset to the default initial values.
Definition: HybridVector.h:1478
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
SIMDTrait_< ElementType > SIMDType
SIMD type of the vector elements.
Definition: HybridVector.h:191
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
Reference at(size_t index)
Checked access to the vector elements.
Definition: HybridVector.h:866
HybridVector< Type, N, TF > This
Type of this HybridVector instance.
Definition: HybridVector.h:186
Resize mechanism to obtain a HybridVector with a different fixed number of elements.
Definition: HybridVector.h:217
Header file for the HasSIMDDiv type trait.
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:177
Header file for the default transpose flag for all vectors 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:130
Header file for the IntegralConstant class template.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
Base template for the SubTrait class.
Definition: SubTrait.h:119
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
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:2016
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
Base template for the BinaryMapTrait class.
Definition: BinaryMapTrait.h:97
Header file for the IsResizable type trait.
Base template for the UnaryMapTrait class.
Definition: UnaryMapTrait.h:95
System settings for the inline keywords.
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.In case the given data type T is not a dense or sparse vector type and in...
Definition: TransposeFlag.h:63
#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
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: HybridVector.h:1456
Header file for the HighType type trait.
Header file for the TrueType type/value trait base class.
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: HybridVector.h:1865
const Type & ReturnType
Return type for expression template evaluations.
Definition: HybridVector.h:192