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>
73 #include <blaze/system/Inline.h>
79 #include <blaze/util/Assert.h>
85 #include <blaze/util/DisableIf.h>
86 #include <blaze/util/EnableIf.h>
88 #include <blaze/util/Memory.h>
90 #include <blaze/util/Template.h>
91 #include <blaze/util/TrueType.h>
92 #include <blaze/util/Types.h>
95 #include <blaze/util/Unused.h>
96 
97 
98 namespace blaze {
99 
100 //=================================================================================================
101 //
102 // CLASS DEFINITION
103 //
104 //=================================================================================================
105 
106 //*************************************************************************************************
176 template< typename Type // Data type of the vector
177  , size_t N // Number of elements
178  , bool TF = defaultTransposeFlag > // Transpose flag
179 class HybridVector
180  : public DenseVector< HybridVector<Type,N,TF>, TF >
181 {
182  public:
183  //**Type definitions****************************************************************************
186  using ResultType = This;
188  using ElementType = Type;
190  using ReturnType = const Type&;
191  using CompositeType = const HybridVector&;
192 
193  using Reference = Type&;
194  using ConstReference = const Type&;
195  using Pointer = Type*;
196  using ConstPointer = const Type*;
197 
200  //**********************************************************************************************
201 
202  //**Rebind struct definition********************************************************************
205  template< typename NewType > // Data type of the other vector
206  struct Rebind {
208  };
209  //**********************************************************************************************
210 
211  //**Resize struct definition********************************************************************
214  template< size_t NewN > // Number of elements of the other vector
215  struct Resize {
217  };
218  //**********************************************************************************************
219 
220  //**Compilation flags***************************************************************************
222 
226  enum : bool { simdEnabled = IsVectorizable<Type>::value };
227 
229 
232  enum : bool { smpAssignable = false };
233  //**********************************************************************************************
234 
235  //**Constructors********************************************************************************
238  explicit inline HybridVector();
239  explicit inline HybridVector( size_t n );
240  explicit inline HybridVector( size_t n, const Type& init );
241  explicit inline HybridVector( initializer_list<Type> list );
242 
243  template< typename Other >
244  explicit inline HybridVector( size_t n, const Other* array );
245 
246  template< typename Other, size_t Dim >
247  explicit inline HybridVector( const Other (&array)[Dim] );
248 
249  inline HybridVector( const HybridVector& v );
250  template< typename VT > inline HybridVector( const Vector<VT,TF>& v );
252  //**********************************************************************************************
253 
254  //**Destructor**********************************************************************************
255  // No explicitly declared destructor.
256  //**********************************************************************************************
257 
258  //**Data access functions***********************************************************************
261  inline Reference operator[]( size_t index ) noexcept;
262  inline ConstReference operator[]( size_t index ) const noexcept;
263  inline Reference at( size_t index );
264  inline ConstReference at( size_t index ) const;
265  inline Pointer data () noexcept;
266  inline ConstPointer data () const noexcept;
267  inline Iterator begin () noexcept;
268  inline ConstIterator begin () const noexcept;
269  inline ConstIterator cbegin() const noexcept;
270  inline Iterator end () noexcept;
271  inline ConstIterator end () const noexcept;
272  inline ConstIterator cend () const noexcept;
274  //**********************************************************************************************
275 
276  //**Assignment operators************************************************************************
279  inline HybridVector& operator=( const Type& rhs );
280  inline HybridVector& operator=( initializer_list<Type> list );
281 
282  template< typename Other, size_t Dim >
283  inline HybridVector& operator=( const Other (&array)[Dim] );
284 
285  inline HybridVector& operator= ( const HybridVector& rhs );
286  template< typename VT > inline HybridVector& operator= ( const Vector<VT,TF>& rhs );
287  template< typename VT > inline HybridVector& operator+=( const Vector<VT,TF>& 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 DenseVector<VT,TF>& rhs );
291  template< typename VT > inline HybridVector& operator%=( const Vector<VT,TF>& rhs );
292 
293  template< typename Other >
294  inline EnableIf_<IsNumeric<Other>, HybridVector >& operator*=( Other rhs );
295 
296  template< typename Other >
297  inline EnableIf_<IsNumeric<Other>, HybridVector >& operator/=( Other rhs );
299  //**********************************************************************************************
300 
301  //**Utility functions***************************************************************************
304  inline size_t size() const noexcept;
305  inline size_t spacing() const noexcept;
306  inline size_t capacity() const noexcept;
307  inline size_t nonZeros() const;
308  inline void reset();
309  inline void clear();
310  inline void resize( size_t n, bool preserve=true );
311  inline void extend( size_t n, bool preserve=true );
312  inline void swap( HybridVector& v ) noexcept;
314  //**********************************************************************************************
315 
316  //**Numeric functions***************************************************************************
319  template< typename Other > inline HybridVector& scale( const Other& scalar );
321  //**********************************************************************************************
322 
323  //**Memory functions****************************************************************************
326  static inline void* operator new ( std::size_t size );
327  static inline void* operator new[]( std::size_t size );
328  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
329  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
330 
331  static inline void operator delete ( void* ptr );
332  static inline void operator delete[]( void* ptr );
333  static inline void operator delete ( void* ptr, const std::nothrow_t& );
334  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
336  //**********************************************************************************************
337 
338  private:
339  //**********************************************************************************************
341  template< typename VT >
343  struct VectorizedAssign {
344  enum : bool { value = useOptimizedKernels &&
345  simdEnabled && VT::simdEnabled &&
347  };
349  //**********************************************************************************************
350 
351  //**********************************************************************************************
353  template< typename VT >
355  struct VectorizedAddAssign {
356  enum : bool { value = useOptimizedKernels &&
357  simdEnabled && VT::simdEnabled &&
360  };
362  //**********************************************************************************************
363 
364  //**********************************************************************************************
366  template< typename VT >
368  struct VectorizedSubAssign {
369  enum : bool { value = useOptimizedKernels &&
370  simdEnabled && VT::simdEnabled &&
373  };
375  //**********************************************************************************************
376 
377  //**********************************************************************************************
379  template< typename VT >
381  struct VectorizedMultAssign {
382  enum : bool { value = useOptimizedKernels &&
383  simdEnabled && VT::simdEnabled &&
386  };
388  //**********************************************************************************************
389 
390  //**********************************************************************************************
392  template< typename VT >
394  struct VectorizedDivAssign {
395  enum : bool { value = useOptimizedKernels &&
396  simdEnabled && VT::simdEnabled &&
399  };
401  //**********************************************************************************************
402 
403  //**********************************************************************************************
405  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
406  //**********************************************************************************************
407 
408  public:
409  //**Debugging functions*************************************************************************
412  inline bool isIntact() const noexcept;
414  //**********************************************************************************************
415 
416  //**Expression template evaluation functions****************************************************
419  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
420  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
421 
422  inline bool isAligned() const noexcept;
423 
424  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
425  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
426  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
427 
428  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
429  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
430  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
431  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
432 
433  template< typename VT >
434  inline DisableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
435 
436  template< typename VT >
437  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
438 
439  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
440 
441  template< typename VT >
442  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
443 
444  template< typename VT >
445  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
446 
447  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
448 
449  template< typename VT >
450  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
451 
452  template< typename VT >
453  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
454 
455  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
456 
457  template< typename VT >
458  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
459 
460  template< typename VT >
461  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
462 
463  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
464 
465  template< typename VT >
466  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
467 
468  template< typename VT >
469  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
471  //**********************************************************************************************
472 
473  private:
474  //**********************************************************************************************
476  enum : size_t { NN = ( usePadding )?( nextMultiple( N, SIMDSIZE ) ):( N ) };
477  //**********************************************************************************************
478 
479  //**Member variables****************************************************************************
483 
488  size_t size_;
489 
490  //**********************************************************************************************
491 
492  //**Compile time checks*************************************************************************
498  BLAZE_STATIC_ASSERT( !usePadding || NN % SIMDSIZE == 0UL );
499  BLAZE_STATIC_ASSERT( NN >= N );
501  //**********************************************************************************************
502 };
503 //*************************************************************************************************
504 
505 
506 
507 
508 //=================================================================================================
509 //
510 // CONSTRUCTORS
511 //
512 //=================================================================================================
513 
514 //*************************************************************************************************
519 template< typename Type // Data type of the vector
520  , size_t N // Number of elements
521  , bool TF > // Transpose flag
523  : v_ () // The statically allocated vector elements
524  , size_( 0UL ) // The current size/dimension of the vector
525 {
527 
528  if( IsNumeric<Type>::value ) {
529  for( size_t i=0UL; i<NN; ++i )
530  v_[i] = Type();
531  }
532 
533  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
534 }
535 //*************************************************************************************************
536 
537 
538 //*************************************************************************************************
548 template< typename Type // Data type of the vector
549  , size_t N // Number of elements
550  , bool TF > // Transpose flag
552  : v_ () // The statically allocated vector elements
553  , size_( n ) // The current size/dimension of the vector
554 {
556 
557  if( n > N ) {
558  BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
559  }
560 
561  if( IsNumeric<Type>::value ) {
562  for( size_t i=0UL; i<NN; ++i )
563  v_[i] = Type();
564  }
565 
566  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
567 }
568 //*************************************************************************************************
569 
570 
571 //*************************************************************************************************
582 template< typename Type // Data type of the vector
583  , size_t N // Number of elements
584  , bool TF > // Transpose flag
585 inline HybridVector<Type,N,TF>::HybridVector( size_t n, const Type& init )
586  : v_ () // The statically allocated vector elements
587  , size_( n ) // The current size/dimension of the vector
588 {
590 
591  if( n > N ) {
592  BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
593  }
594 
595  for( size_t i=0UL; i<n; ++i )
596  v_[i] = init;
597 
598  if( IsNumeric<Type>::value ) {
599  for( size_t i=n; i<NN; ++i )
600  v_[i] = Type();
601  }
602 
603  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
604 }
605 //*************************************************************************************************
606 
607 
608 //*************************************************************************************************
626 template< typename Type // Data type of the vector
627  , size_t N // Number of elements
628  , bool TF > // Transpose flag
630  : v_ () // The statically allocated vector elements
631  , size_( list.size() ) // The current size/dimension of the vector
632 {
634 
635  if( size_ > N ) {
636  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
637  }
638 
639  std::fill( std::copy( list.begin(), list.end(), v_.data() ), v_.data()+NN, Type() );
640 
641  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
642 }
643 //*************************************************************************************************
644 
645 
646 //*************************************************************************************************
669 template< typename Type // Data type of the vector
670  , size_t N // Number of elements
671  , bool TF > // Transpose flag
672 template< typename Other > // Data type of the initialization array
673 inline HybridVector<Type,N,TF>::HybridVector( size_t n, const Other* array )
674  : v_ () // The statically allocated vector elements
675  , size_( n ) // The current size/dimension of the vector
676 {
678 
679  if( n > N ) {
680  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
681  }
682 
683  for( size_t i=0UL; i<n; ++i )
684  v_[i] = array[i];
685 
686  if( IsNumeric<Type>::value ) {
687  for( size_t i=n; i<NN; ++i )
688  v_[i] = Type();
689  }
690 
691  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
692 }
693 //*************************************************************************************************
694 
695 
696 //*************************************************************************************************
714 template< typename Type // Data type of the vector
715  , size_t N // Number of elements
716  , bool TF > // Transpose flag
717 template< typename Other // Data type of the initialization array
718  , size_t Dim > // Number of elements of the initialization array
719 inline HybridVector<Type,N,TF>::HybridVector( const Other (&array)[Dim] )
720  : v_ () // The statically allocated vector elements
721  , size_( Dim ) // The current size/dimension of the vector
722 {
723  BLAZE_STATIC_ASSERT( Dim <= N );
725 
726  for( size_t i=0UL; i<Dim; ++i )
727  v_[i] = array[i];
728 
729  if( IsNumeric<Type>::value ) {
730  for( size_t i=Dim; i<NN; ++i )
731  v_[i] = Type();
732  }
733 
734  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
735 }
736 //*************************************************************************************************
737 
738 
739 //*************************************************************************************************
746 template< typename Type // Data type of the vector
747  , size_t N // Number of elements
748  , bool TF > // Transpose flag
750  : v_ () // The statically allocated vector elements
751  , size_( v.size_ ) // The current size/dimension of the vector
752 {
754 
755  for( size_t i=0UL; i<size_; ++i )
756  v_[i] = v.v_[i];
757 
758  if( IsNumeric<Type>::value ) {
759  for( size_t i=size_; i<NN; ++i )
760  v_[i] = Type();
761  }
762 
763  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
764 }
765 //*************************************************************************************************
766 
767 
768 //*************************************************************************************************
778 template< typename Type // Data type of the vector
779  , size_t N // Number of elements
780  , bool TF > // Transpose flag
781 template< typename VT > // Type of the foreign vector
783  : v_ () // The statically allocated vector elements
784  , size_( (~v).size() ) // The current size/dimension of the vector
785 {
786  using blaze::assign;
787 
789 
790  if( (~v).size() > N ) {
791  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
792  }
793 
794  for( size_t i=( IsSparseVector<VT>::value ? 0UL : size_ );
795  i<( IsNumeric<Type>::value ? NN : size_ ); ++i ) {
796  v_[i] = Type();
797  }
798 
799  assign( *this, ~v );
800 
801  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
802 }
803 //*************************************************************************************************
804 
805 
806 
807 
808 //=================================================================================================
809 //
810 // DATA ACCESS FUNCTIONS
811 //
812 //=================================================================================================
813 
814 //*************************************************************************************************
823 template< typename Type // Data type of the vector
824  , size_t N // Number of elements
825  , bool TF > // Transpose flag
827  HybridVector<Type,N,TF>::operator[]( size_t index ) noexcept
828 {
829  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
830  return v_[index];
831 }
832 //*************************************************************************************************
833 
834 
835 //*************************************************************************************************
844 template< typename Type // Data type of the vector
845  , size_t N // Number of elements
846  , bool TF > // Transpose flag
848  HybridVector<Type,N,TF>::operator[]( size_t index ) const noexcept
849 {
850  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
851  return v_[index];
852 }
853 //*************************************************************************************************
854 
855 
856 //*************************************************************************************************
866 template< typename Type // Data type of the vector
867  , size_t N // Number of elements
868  , bool TF > // Transpose flag
871 {
872  if( index >= size_ ) {
873  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
874  }
875  return (*this)[index];
876 }
877 //*************************************************************************************************
878 
879 
880 //*************************************************************************************************
890 template< typename Type // Data type of the vector
891  , size_t N // Number of elements
892  , bool TF > // Transpose flag
894  HybridVector<Type,N,TF>::at( size_t index ) const
895 {
896  if( index >= size_ ) {
897  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
898  }
899  return (*this)[index];
900 }
901 //*************************************************************************************************
902 
903 
904 //*************************************************************************************************
911 template< typename Type // Data type of the vector
912  , size_t N // Number of elements
913  , bool TF > // Transpose flag
915 {
916  return v_;
917 }
918 //*************************************************************************************************
919 
920 
921 //*************************************************************************************************
928 template< typename Type // Data type of the vector
929  , size_t N // Number of elements
930  , bool TF > // Transpose flag
932 {
933  return v_;
934 }
935 //*************************************************************************************************
936 
937 
938 //*************************************************************************************************
943 template< typename Type // Data type of the vector
944  , size_t N // Number of elements
945  , bool TF > // Transpose flag
947 {
948  return Iterator( v_ );
949 }
950 //*************************************************************************************************
951 
952 
953 //*************************************************************************************************
958 template< typename Type // Data type of the vector
959  , size_t N // Number of elements
960  , bool TF > // Transpose flag
962 {
963  return ConstIterator( v_ );
964 }
965 //*************************************************************************************************
966 
967 
968 //*************************************************************************************************
973 template< typename Type // Data type of the vector
974  , size_t N // Number of elements
975  , bool TF > // Transpose flag
977 {
978  return ConstIterator( v_ );
979 }
980 //*************************************************************************************************
981 
982 
983 //*************************************************************************************************
988 template< typename Type // Data type of the vector
989  , size_t N // Number of elements
990  , bool TF > // Transpose flag
992 {
993  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
994  return Iterator( v_ + size_ );
995 }
996 //*************************************************************************************************
997 
998 
999 //*************************************************************************************************
1004 template< typename Type // Data type of the vector
1005  , size_t N // Number of elements
1006  , bool TF > // Transpose flag
1008 {
1009  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1010  return ConstIterator( v_ + size_ );
1011 }
1012 //*************************************************************************************************
1013 
1014 
1015 //*************************************************************************************************
1020 template< typename Type // Data type of the vector
1021  , size_t N // Number of elements
1022  , bool TF > // Transpose flag
1024 {
1025  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1026  return ConstIterator( v_ + size_ );
1027 }
1028 //*************************************************************************************************
1029 
1030 
1031 
1032 
1033 //=================================================================================================
1034 //
1035 // ASSIGNMENT OPERATORS
1036 //
1037 //=================================================================================================
1038 
1039 //*************************************************************************************************
1045 template< typename Type // Data type of the vector
1046  , size_t N // Number of elements
1047  , bool TF > // Transpose flag
1049 {
1050  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1051 
1052  for( size_t i=0UL; i<size_; ++i )
1053  v_[i] = rhs;
1054  return *this;
1055 }
1056 //*************************************************************************************************
1057 
1058 
1059 //*************************************************************************************************
1078 template< typename Type // Data type of the vector
1079  , size_t N // Number of elements
1080  , bool TF > // Transpose flag
1082 {
1083  if( list.size() > N ) {
1084  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to hybrid vector" );
1085  }
1086 
1087  resize( list.size(), false );
1088  std::copy( list.begin(), list.end(), v_.data() );
1089 
1090  return *this;
1091 }
1092 //*************************************************************************************************
1093 
1094 
1095 //*************************************************************************************************
1114 template< typename Type // Data type of the vector
1115  , size_t N // Number of elements
1116  , bool TF > // Transpose flag
1117 template< typename Other // Data type of the initialization array
1118  , size_t Dim > // Number of elements of the initialization array
1120 {
1121  BLAZE_STATIC_ASSERT( Dim <= N );
1122 
1123  resize( Dim, false );
1124 
1125  for( size_t i=0UL; i<Dim; ++i )
1126  v_[i] = array[i];
1127 
1128  return *this;
1129 }
1130 //*************************************************************************************************
1131 
1132 
1133 //*************************************************************************************************
1141 template< typename Type // Data type of the vector
1142  , size_t N // Number of elements
1143  , bool TF > // Transpose flag
1145 {
1146  using blaze::assign;
1147 
1148  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1149 
1150  resize( rhs.size() );
1151  assign( *this, ~rhs );
1152 
1153  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1154 
1155  return *this;
1156 }
1157 //*************************************************************************************************
1158 
1159 
1160 //*************************************************************************************************
1170 template< typename Type // Data type of the vector
1171  , size_t N // Number of elements
1172  , bool TF > // Transpose flag
1173 template< typename VT > // Type of the right-hand side vector
1175 {
1176  using blaze::assign;
1177 
1178  if( (~rhs).size() > N ) {
1179  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to hybrid vector" );
1180  }
1181 
1182  if( (~rhs).canAlias( this ) ) {
1183  HybridVector tmp( ~rhs );
1184  swap( tmp );
1185  }
1186  else {
1187  resize( (~rhs).size(), false );
1189  reset();
1190  assign( *this, ~rhs );
1191  }
1192 
1193  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1194 
1195  return *this;
1196 }
1197 //*************************************************************************************************
1198 
1199 
1200 //*************************************************************************************************
1210 template< typename Type // Data type of the vector
1211  , size_t N // Number of elements
1212  , bool TF > // Transpose flag
1213 template< typename VT > // Type of the right-hand side vector
1215 {
1216  using blaze::addAssign;
1217 
1218  if( (~rhs).size() != size_ ) {
1219  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1220  }
1221 
1222  if( (~rhs).canAlias( this ) ) {
1223  const ResultType_<VT> tmp( ~rhs );
1224  addAssign( *this, tmp );
1225  }
1226  else {
1227  addAssign( *this, ~rhs );
1228  }
1229 
1230  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1231 
1232  return *this;
1233 }
1234 //*************************************************************************************************
1235 
1236 
1237 //*************************************************************************************************
1247 template< typename Type // Data type of the vector
1248  , size_t N // Number of elements
1249  , bool TF > // Transpose flag
1250 template< typename VT > // Type of the right-hand side vector
1252 {
1253  using blaze::subAssign;
1254 
1255  if( (~rhs).size() != size_ ) {
1256  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1257  }
1258 
1259  if( (~rhs).canAlias( this ) ) {
1260  const ResultType_<VT> tmp( ~rhs );
1261  subAssign( *this, tmp );
1262  }
1263  else {
1264  subAssign( *this, ~rhs );
1265  }
1266 
1267  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1268 
1269  return *this;
1270 }
1271 //*************************************************************************************************
1272 
1273 
1274 //*************************************************************************************************
1285 template< typename Type // Data type of the vector
1286  , size_t N // Number of elements
1287  , bool TF > // Transpose flag
1288 template< typename VT > // Type of the right-hand side vector
1290 {
1291  using blaze::assign;
1292  using blaze::multAssign;
1293 
1294  if( (~rhs).size() != size_ ) {
1295  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1296  }
1297 
1298  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1299  const HybridVector tmp( *this * (~rhs) );
1300  assign( *this, tmp );
1301  }
1302  else {
1303  multAssign( *this, ~rhs );
1304  }
1305 
1306  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1307 
1308  return *this;
1309 }
1310 //*************************************************************************************************
1311 
1312 
1313 //*************************************************************************************************
1323 template< typename Type // Data type of the vector
1324  , size_t N // Number of elements
1325  , bool TF > // Transpose flag
1326 template< typename VT > // Type of the right-hand side vector
1328 {
1329  using blaze::assign;
1330  using blaze::divAssign;
1331 
1332  if( (~rhs).size() != size_ ) {
1333  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1334  }
1335 
1336  if( (~rhs).canAlias( this ) ) {
1337  const HybridVector tmp( *this / (~rhs) );
1338  assign( *this, tmp );
1339  }
1340  else {
1341  divAssign( *this, ~rhs );
1342  }
1343 
1344  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1345 
1346  return *this;
1347 }
1348 //*************************************************************************************************
1349 
1350 
1351 //*************************************************************************************************
1362 template< typename Type // Data type of the vector
1363  , size_t N // Number of elements
1364  , bool TF > // Transpose flag
1365 template< typename VT > // Type of the right-hand side vector
1367 {
1368  using blaze::assign;
1369 
1372 
1373  using CrossType = CrossTrait_< This, ResultType_<VT> >;
1374 
1378 
1379  if( size_ != 3UL || (~rhs).size() != 3UL ) {
1380  BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1381  }
1382 
1383  const CrossType tmp( *this % (~rhs) );
1384  assign( *this, tmp );
1385 
1386  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1387 
1388  return *this;
1389 }
1390 //*************************************************************************************************
1391 
1392 
1393 //*************************************************************************************************
1400 template< typename Type // Data type of the vector
1401  , size_t N // Number of elements
1402  , bool TF > // Transpose flag
1403 template< typename Other > // Data type of the right-hand side scalar
1406 {
1407  using blaze::assign;
1408 
1409  assign( *this, (*this) * rhs );
1410 
1411  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1412 
1413  return *this;
1414 }
1415 //*************************************************************************************************
1416 
1417 
1418 //*************************************************************************************************
1427 template< typename Type // Data type of the vector
1428  , size_t N // Number of elements
1429  , bool TF > // Transpose flag
1430 template< typename Other > // Data type of the right-hand side scalar
1431 inline EnableIf_<IsNumeric<Other>, HybridVector<Type,N,TF> >&
1433 {
1434  using blaze::assign;
1435 
1436  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1437 
1438  assign( *this, (*this) / rhs );
1439 
1440  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1441 
1442  return *this;
1443 }
1444 //*************************************************************************************************
1445 
1446 
1447 
1448 
1449 //=================================================================================================
1450 //
1451 // UTILITY FUNCTIONS
1452 //
1453 //=================================================================================================
1454 
1455 //*************************************************************************************************
1460 template< typename Type // Data type of the vector
1461  , size_t N // Number of elements
1462  , bool TF > // Transpose flag
1463 inline size_t HybridVector<Type,N,TF>::size() const noexcept
1464 {
1465  return size_;
1466 }
1467 //*************************************************************************************************
1468 
1469 
1470 //*************************************************************************************************
1478 template< typename Type // Data type of the vector
1479  , size_t N // Number of elements
1480  , bool TF > // Transpose flag
1481 inline size_t HybridVector<Type,N,TF>::spacing() const noexcept
1482 {
1483  return NN;
1484 }
1485 //*************************************************************************************************
1486 
1487 
1488 //*************************************************************************************************
1493 template< typename Type // Data type of the vector
1494  , size_t N // Number of elements
1495  , bool TF > // Transpose flag
1496 inline size_t HybridVector<Type,N,TF>::capacity() const noexcept
1497 {
1498  return NN;
1499 }
1500 //*************************************************************************************************
1501 
1502 
1503 //*************************************************************************************************
1511 template< typename Type // Data type of the vector
1512  , size_t N // Number of elements
1513  , bool TF > // Transpose flag
1515 {
1516  size_t nonzeros( 0 );
1517 
1518  for( size_t i=0UL; i<size_; ++i ) {
1519  if( !isDefault( v_[i] ) )
1520  ++nonzeros;
1521  }
1522 
1523  return nonzeros;
1524 }
1525 //*************************************************************************************************
1526 
1527 
1528 //*************************************************************************************************
1533 template< typename Type // Data type of the vector
1534  , size_t N // Number of elements
1535  , bool TF > // Transpose flag
1537 {
1538  using blaze::clear;
1539  for( size_t i=0UL; i<size_; ++i )
1540  clear( v_[i] );
1541 }
1542 //*************************************************************************************************
1543 
1544 
1545 //*************************************************************************************************
1552 template< typename Type // Data type of the vector
1553  , size_t N // Number of elements
1554  , bool TF > // Transpose flag
1556 {
1557  resize( 0UL );
1558 }
1559 //*************************************************************************************************
1560 
1561 
1562 //*************************************************************************************************
1593 template< typename Type // Data type of the vector
1594  , size_t N // Number of elements
1595  , bool TF > // Transpose flag
1596 inline void HybridVector<Type,N,TF>::resize( size_t n, bool preserve )
1597 {
1598  UNUSED_PARAMETER( preserve );
1599 
1600  if( n > N ) {
1601  BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
1602  }
1603 
1604  if( IsVectorizable<Type>::value && n < size_ ) {
1605  for( size_t i=n; i<size_; ++i )
1606  v_[i] = Type();
1607  }
1608 
1609  size_ = n;
1610 }
1611 //*************************************************************************************************
1612 
1613 
1614 //*************************************************************************************************
1628 template< typename Type // Data type of the vector
1629  , size_t N // Number of elements
1630  , bool TF > // Transpose flag
1631 inline void HybridVector<Type,N,TF>::extend( size_t n, bool preserve )
1632 {
1633  UNUSED_PARAMETER( preserve );
1634  resize( size_+n );
1635 }
1636 //*************************************************************************************************
1637 
1638 
1639 //*************************************************************************************************
1645 template< typename Type // Data type of the vector
1646  , size_t N // Number of elements
1647  , bool TF > // Transpose flag
1649 {
1650  using std::swap;
1651 
1652  const size_t maxsize( max( size_, v.size_ ) );
1653  for( size_t i=0UL; i<maxsize; ++i )
1654  swap( v_[i], v.v_[i] );
1655  swap( size_, v.size_ );
1656 }
1657 //*************************************************************************************************
1658 
1659 
1660 
1661 
1662 //=================================================================================================
1663 //
1664 // NUMERIC FUNCTIONS
1665 //
1666 //=================================================================================================
1667 
1668 //*************************************************************************************************
1685 template< typename Type // Data type of the vector
1686  , size_t N // Number of elements
1687  , bool TF > // Transpose flag
1688 template< typename Other > // Data type of the scalar value
1690 {
1691  for( size_t i=0; i<size_; ++i )
1692  v_[i] *= scalar;
1693  return *this;
1694 }
1695 //*************************************************************************************************
1696 
1697 
1698 
1699 
1700 //=================================================================================================
1701 //
1702 // MEMORY FUNCTIONS
1703 //
1704 //=================================================================================================
1705 
1706 //*************************************************************************************************
1716 template< typename Type // Data type of the vector
1717  , size_t N // Number of elements
1718  , bool TF > // Transpose flag
1719 inline void* HybridVector<Type,N,TF>::operator new( std::size_t size )
1720 {
1722 
1723  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridVector ), "Invalid number of bytes detected" );
1724 
1725  return allocate<HybridVector>( 1UL );
1726 }
1727 //*************************************************************************************************
1728 
1729 
1730 //*************************************************************************************************
1740 template< typename Type // Data type of the vector
1741  , size_t N // Number of elements
1742  , bool TF > // Transpose flag
1743 inline void* HybridVector<Type,N,TF>::operator new[]( std::size_t size )
1744 {
1745  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridVector ) , "Invalid number of bytes detected" );
1746  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridVector ) == 0UL, "Invalid number of bytes detected" );
1747 
1748  return allocate<HybridVector>( size/sizeof(HybridVector) );
1749 }
1750 //*************************************************************************************************
1751 
1752 
1753 //*************************************************************************************************
1763 template< typename Type // Data type of the vector
1764  , size_t N // Number of elements
1765  , bool TF > // Transpose flag
1766 inline void* HybridVector<Type,N,TF>::operator new( std::size_t size, const std::nothrow_t& )
1767 {
1768  UNUSED_PARAMETER( size );
1769 
1770  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridVector ), "Invalid number of bytes detected" );
1771 
1772  return allocate<HybridVector>( 1UL );
1773 }
1774 //*************************************************************************************************
1775 
1776 
1777 //*************************************************************************************************
1787 template< typename Type // Data type of the vector
1788  , size_t N // Number of elements
1789  , bool TF > // Transpose flag
1790 inline void* HybridVector<Type,N,TF>::operator new[]( std::size_t size, const std::nothrow_t& )
1791 {
1792  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridVector ) , "Invalid number of bytes detected" );
1793  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridVector ) == 0UL, "Invalid number of bytes detected" );
1794 
1795  return allocate<HybridVector>( size/sizeof(HybridVector) );
1796 }
1797 //*************************************************************************************************
1798 
1799 
1800 //*************************************************************************************************
1806 template< typename Type // Data type of the vector
1807  , size_t N // Number of elements
1808  , bool TF > // Transpose flag
1809 inline void HybridVector<Type,N,TF>::operator delete( void* ptr )
1810 {
1811  deallocate( static_cast<HybridVector*>( ptr ) );
1812 }
1813 //*************************************************************************************************
1814 
1815 
1816 //*************************************************************************************************
1822 template< typename Type // Data type of the vector
1823  , size_t N // Number of elements
1824  , bool TF > // Transpose flag
1825 inline void HybridVector<Type,N,TF>::operator delete[]( void* ptr )
1826 {
1827  deallocate( static_cast<HybridVector*>( ptr ) );
1828 }
1829 //*************************************************************************************************
1830 
1831 
1832 //*************************************************************************************************
1838 template< typename Type // Data type of the vector
1839  , size_t N // Number of elements
1840  , bool TF > // Transpose flag
1841 inline void HybridVector<Type,N,TF>::operator delete( void* ptr, const std::nothrow_t& )
1842 {
1843  deallocate( static_cast<HybridVector*>( ptr ) );
1844 }
1845 //*************************************************************************************************
1846 
1847 
1848 //*************************************************************************************************
1854 template< typename Type // Data type of the vector
1855  , size_t N // Number of elements
1856  , bool TF > // Transpose flag
1857 inline void HybridVector<Type,N,TF>::operator delete[]( void* ptr, const std::nothrow_t& )
1858 {
1859  deallocate( static_cast<HybridVector*>( ptr ) );
1860 }
1861 //*************************************************************************************************
1862 
1863 
1864 
1865 
1866 //=================================================================================================
1867 //
1868 // DEBUGGING FUNCTIONS
1869 //
1870 //=================================================================================================
1871 
1872 //*************************************************************************************************
1881 template< typename Type // Data type of the vector
1882  , size_t N // Number of elements
1883  , bool TF > // Transpose flag
1884 inline bool HybridVector<Type,N,TF>::isIntact() const noexcept
1885 {
1886  if( size_ > N )
1887  return false;
1888 
1889  if( IsNumeric<Type>::value ) {
1890  for( size_t i=size_; i<NN; ++i ) {
1891  if( v_[i] != Type() )
1892  return false;
1893  }
1894  }
1895 
1896  return true;
1897 }
1898 //*************************************************************************************************
1899 
1900 
1901 
1902 
1903 //=================================================================================================
1904 //
1905 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1906 //
1907 //=================================================================================================
1908 
1909 //*************************************************************************************************
1919 template< typename Type // Data type of the vector
1920  , size_t N // Number of elements
1921  , bool TF > // Transpose flag
1922 template< typename Other > // Data type of the foreign expression
1923 inline bool HybridVector<Type,N,TF>::canAlias( const Other* alias ) const noexcept
1924 {
1925  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1926 }
1927 //*************************************************************************************************
1928 
1929 
1930 //*************************************************************************************************
1940 template< typename Type // Data type of the vector
1941  , size_t N // Number of elements
1942  , bool TF > // Transpose flag
1943 template< typename Other > // Data type of the foreign expression
1944 inline bool HybridVector<Type,N,TF>::isAliased( const Other* alias ) const noexcept
1945 {
1946  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1947 }
1948 //*************************************************************************************************
1949 
1950 
1951 //*************************************************************************************************
1960 template< typename Type // Data type of the vector
1961  , size_t N // Number of elements
1962  , bool TF > // Transpose flag
1963 inline bool HybridVector<Type,N,TF>::isAligned() const noexcept
1964 {
1965  return true;
1966 }
1967 //*************************************************************************************************
1968 
1969 
1970 //*************************************************************************************************
1982 template< typename Type // Data type of the vector
1983  , size_t N // Number of elements
1984  , bool TF > // Transpose flag
1986  HybridVector<Type,N,TF>::load( size_t index ) const noexcept
1987 {
1988  return loada( index );
1989 }
1990 //*************************************************************************************************
1991 
1992 
1993 //*************************************************************************************************
2006 template< typename Type // Data type of the vector
2007  , size_t N // Number of elements
2008  , bool TF > // Transpose flag
2010  HybridVector<Type,N,TF>::loada( size_t index ) const noexcept
2011 {
2012  using blaze::loada;
2013 
2015 
2016  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2017  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2018  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2019  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2020 
2021  return loada( &v_[index] );
2022 }
2023 //*************************************************************************************************
2024 
2025 
2026 //*************************************************************************************************
2039 template< typename Type // Data type of the vector
2040  , size_t N // Number of elements
2041  , bool TF > // Transpose flag
2043  HybridVector<Type,N,TF>::loadu( size_t index ) const noexcept
2044 {
2045  using blaze::loadu;
2046 
2048 
2049  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2050  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2051 
2052  return loadu( &v_[index] );
2053 }
2054 //*************************************************************************************************
2055 
2056 
2057 //*************************************************************************************************
2070 template< typename Type // Data type of the vector
2071  , size_t N // Number of elements
2072  , bool TF > // Transpose flag
2074  HybridVector<Type,N,TF>::store( size_t index, const SIMDType& value ) noexcept
2075 {
2076  storea( index, value );
2077 }
2078 //*************************************************************************************************
2079 
2080 
2081 //*************************************************************************************************
2094 template< typename Type // Data type of the vector
2095  , size_t N // Number of elements
2096  , bool TF > // Transpose flag
2098  HybridVector<Type,N,TF>::storea( size_t index, const SIMDType& value ) noexcept
2099 {
2100  using blaze::storea;
2101 
2103 
2104  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2105  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2106  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2107  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2108 
2109  storea( &v_[index], value );
2110 }
2111 //*************************************************************************************************
2112 
2113 
2114 //*************************************************************************************************
2127 template< typename Type // Data type of the vector
2128  , size_t N // Number of elements
2129  , bool TF > // Transpose flag
2131  HybridVector<Type,N,TF>::storeu( size_t index, const SIMDType& value ) noexcept
2132 {
2133  using blaze::storeu;
2134 
2136 
2137  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2138  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2139 
2140  storeu( &v_[index], value );
2141 }
2142 //*************************************************************************************************
2143 
2144 
2145 //*************************************************************************************************
2159 template< typename Type // Data type of the vector
2160  , size_t N // Number of elements
2161  , bool TF > // Transpose flag
2163  HybridVector<Type,N,TF>::stream( size_t index, const SIMDType& value ) noexcept
2164 {
2165  using blaze::stream;
2166 
2168 
2169  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2170  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2171  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2172  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2173 
2174  stream( &v_[index], value );
2175 }
2176 //*************************************************************************************************
2177 
2178 
2179 //*************************************************************************************************
2190 template< typename Type // Data type of the vector
2191  , size_t N // Number of elements
2192  , bool TF > // Transpose flag
2193 template< typename VT > // Type of the right-hand side dense vector
2196 {
2197  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2198 
2199  for( size_t i=0UL; i<size_; ++i )
2200  v_[i] = (~rhs)[i];
2201 }
2202 //*************************************************************************************************
2203 
2204 
2205 //*************************************************************************************************
2216 template< typename Type // Data type of the vector
2217  , size_t N // Number of elements
2218  , bool TF > // Transpose flag
2219 template< typename VT > // Type of the right-hand side dense vector
2222 {
2224 
2225  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2226 
2227  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2228 
2229  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2230  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2231 
2232  size_t i( 0UL );
2233 
2234  for( ; i<ipos; i+=SIMDSIZE ) {
2235  store( i, (~rhs).load(i) );
2236  }
2237  for( ; remainder && i<size_; ++i ) {
2238  v_[i] = (~rhs)[i];
2239  }
2240 }
2241 //*************************************************************************************************
2242 
2243 
2244 //*************************************************************************************************
2255 template< typename Type // Data type of the vector
2256  , size_t N // Number of elements
2257  , bool TF > // Transpose flag
2258 template< typename VT > // Type of the right-hand side sparse vector
2260 {
2261  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2262 
2263  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2264  v_[element->index()] = element->value();
2265 }
2266 //*************************************************************************************************
2267 
2268 
2269 //*************************************************************************************************
2280 template< typename Type // Data type of the vector
2281  , size_t N // Number of elements
2282  , bool TF > // Transpose flag
2283 template< typename VT > // Type of the right-hand side dense vector
2284 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2286 {
2287  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2288 
2289  for( size_t i=0UL; i<size_; ++i )
2290  v_[i] += (~rhs)[i];
2291 }
2292 //*************************************************************************************************
2293 
2294 
2295 //*************************************************************************************************
2306 template< typename Type // Data type of the vector
2307  , size_t N // Number of elements
2308  , bool TF > // Transpose flag
2309 template< typename VT > // Type of the right-hand side dense vector
2310 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2312 {
2314 
2315  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2316 
2317  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2318 
2319  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2320  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2321 
2322  size_t i( 0UL );
2323 
2324  for( ; i<ipos; i+=SIMDSIZE ) {
2325  store( i, load(i) + (~rhs).load(i) );
2326  }
2327  for( ; remainder && i<size_; ++i ) {
2328  v_[i] += (~rhs)[i];
2329  }
2330 }
2331 //*************************************************************************************************
2332 
2333 
2334 //*************************************************************************************************
2345 template< typename Type // Data type of the vector
2346  , size_t N // Number of elements
2347  , bool TF > // Transpose flag
2348 template< typename VT > // Type of the right-hand side sparse vector
2350 {
2351  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2352 
2353  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2354  v_[element->index()] += element->value();
2355 }
2356 //*************************************************************************************************
2357 
2358 
2359 //*************************************************************************************************
2370 template< typename Type // Data type of the vector
2371  , size_t N // Number of elements
2372  , bool TF > // Transpose flag
2373 template< typename VT > // Type of the right-hand side dense vector
2374 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2376 {
2377  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2378 
2379  for( size_t i=0UL; i<size_; ++i )
2380  v_[i] -= (~rhs)[i];
2381 }
2382 //*************************************************************************************************
2383 
2384 
2385 //*************************************************************************************************
2396 template< typename Type // Data type of the vector
2397  , size_t N // Number of elements
2398  , bool TF > // Transpose flag
2399 template< typename VT > // Type of the right-hand side dense vector
2400 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2402 {
2404 
2405  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2406 
2407  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2408 
2409  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2410  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2411 
2412  size_t i( 0UL );
2413 
2414  for( ; i<ipos; i+=SIMDSIZE ) {
2415  store( i, load(i) - (~rhs).load(i) );
2416  }
2417  for( ; remainder && i<size_; ++i ) {
2418  v_[i] -= (~rhs)[i];
2419  }
2420 }
2421 //*************************************************************************************************
2422 
2423 
2424 //*************************************************************************************************
2435 template< typename Type // Data type of the vector
2436  , size_t N // Number of elements
2437  , bool TF > // Transpose flag
2438 template< typename VT > // Type of the right-hand side sparse vector
2440 {
2441  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2442 
2443  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2444  v_[element->index()] -= element->value();
2445 }
2446 //*************************************************************************************************
2447 
2448 
2449 //*************************************************************************************************
2460 template< typename Type // Data type of the vector
2461  , size_t N // Number of elements
2462  , bool TF > // Transpose flag
2463 template< typename VT > // Type of the right-hand side dense vector
2464 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2466 {
2467  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2468 
2469  for( size_t i=0UL; i<size_; ++i )
2470  v_[i] *= (~rhs)[i];
2471 }
2472 //*************************************************************************************************
2473 
2474 
2475 //*************************************************************************************************
2486 template< typename Type // Data type of the vector
2487  , size_t N // Number of elements
2488  , bool TF > // Transpose flag
2489 template< typename VT > // Type of the right-hand side dense vector
2490 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2492 {
2494 
2495  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2496 
2497  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2498 
2499  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2500  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2501 
2502  size_t i( 0UL );
2503 
2504  for( ; i<ipos; i+=SIMDSIZE ) {
2505  store( i, load(i) * (~rhs).load(i) );
2506  }
2507  for( ; remainder && i<size_; ++i ) {
2508  v_[i] *= (~rhs)[i];
2509  }
2510 }
2511 //*************************************************************************************************
2512 
2513 
2514 //*************************************************************************************************
2525 template< typename Type // Data type of the vector
2526  , size_t N // Number of elements
2527  , bool TF > // Transpose flag
2528 template< typename VT > // Type of the right-hand side sparse vector
2530 {
2531  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2532 
2533  const HybridVector tmp( serial( *this ) );
2534 
2535  reset();
2536 
2537  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2538  v_[element->index()] = tmp[element->index()] * element->value();
2539 }
2540 //*************************************************************************************************
2541 
2542 
2543 //*************************************************************************************************
2554 template< typename Type // Data type of the vector
2555  , size_t N // Number of elements
2556  , bool TF > // Transpose flag
2557 template< typename VT > // Type of the right-hand side dense vector
2558 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2560 {
2561  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2562 
2563  for( size_t i=0UL; i<size_; ++i )
2564  v_[i] /= (~rhs)[i];
2565 }
2566 //*************************************************************************************************
2567 
2568 
2569 //*************************************************************************************************
2580 template< typename Type // Data type of the vector
2581  , size_t N // Number of elements
2582  , bool TF > // Transpose flag
2583 template< typename VT > // Type of the right-hand side dense vector
2584 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2586 {
2588 
2589  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2590 
2591  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2592  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2593 
2594  size_t i( 0UL );
2595 
2596  for( ; i<ipos; i+=SIMDSIZE ) {
2597  store( i, load(i) / (~rhs).load(i) );
2598  }
2599  for( ; i<size_; ++i ) {
2600  v_[i] /= (~rhs)[i];
2601  }
2602 }
2603 //*************************************************************************************************
2604 
2605 
2606 
2607 
2608 
2609 
2610 
2611 
2612 //=================================================================================================
2613 //
2614 // HYBRIDVECTOR OPERATORS
2615 //
2616 //=================================================================================================
2617 
2618 //*************************************************************************************************
2621 template< typename Type, size_t N, bool TF >
2622 inline void reset( HybridVector<Type,N,TF>& v );
2623 
2624 template< typename Type, size_t N, bool TF >
2625 inline void clear( HybridVector<Type,N,TF>& v );
2626 
2627 template< bool RF, typename Type, size_t N, bool TF >
2628 inline bool isDefault( const HybridVector<Type,N,TF>& v );
2629 
2630 template< typename Type, size_t N, bool TF >
2631 inline bool isIntact( const HybridVector<Type,N,TF>& v );
2632 
2633 template< typename Type, size_t N, bool TF >
2634 inline void swap( HybridVector<Type,N,TF>& a, HybridVector<Type,N,TF>& b ) noexcept;
2636 //*************************************************************************************************
2637 
2638 
2639 //*************************************************************************************************
2646 template< typename Type // Data type of the vector
2647  , size_t N // Number of elements
2648  , bool TF > // Transpose flag
2650 {
2651  v.reset();
2652 }
2653 //*************************************************************************************************
2654 
2655 
2656 //*************************************************************************************************
2663 template< typename Type // Data type of the vector
2664  , size_t N // Number of elements
2665  , bool TF > // Transpose flag
2667 {
2668  v.clear();
2669 }
2670 //*************************************************************************************************
2671 
2672 
2673 //*************************************************************************************************
2697 template< bool RF // Relaxation flag
2698  , typename Type // Data type of the vector
2699  , size_t N // Number of elements
2700  , bool TF > // Transpose flag
2701 inline bool isDefault( const HybridVector<Type,N,TF>& v )
2702 {
2703  return ( v.size() == 0UL );
2704 }
2705 //*************************************************************************************************
2706 
2707 
2708 //*************************************************************************************************
2726 template< typename Type // Data type of the vector
2727  , size_t N // Number of elements
2728  , bool TF > // Transpose flag
2729 inline bool isIntact( const HybridVector<Type,N,TF>& v )
2730 {
2731  return v.isIntact();
2732 }
2733 //*************************************************************************************************
2734 
2735 
2736 //*************************************************************************************************
2744 template< typename Type // Data type of the vector
2745  , size_t N // Number of elements
2746  , bool TF > // Transpose flag
2748 {
2749  a.swap( b );
2750 }
2751 //*************************************************************************************************
2752 
2753 
2754 
2755 
2756 //=================================================================================================
2757 //
2758 // HASCONSTDATAACCESS SPECIALIZATIONS
2759 //
2760 //=================================================================================================
2761 
2762 //*************************************************************************************************
2764 template< typename T, size_t N, bool TF >
2765 struct HasConstDataAccess< HybridVector<T,N,TF> >
2766  : public TrueType
2767 {};
2769 //*************************************************************************************************
2770 
2771 
2772 
2773 
2774 //=================================================================================================
2775 //
2776 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2777 //
2778 //=================================================================================================
2779 
2780 //*************************************************************************************************
2782 template< typename T, size_t N, bool TF >
2783 struct HasMutableDataAccess< HybridVector<T,N,TF> >
2784  : public TrueType
2785 {};
2787 //*************************************************************************************************
2788 
2789 
2790 
2791 
2792 //=================================================================================================
2793 //
2794 // ISALIGNED SPECIALIZATIONS
2795 //
2796 //=================================================================================================
2797 
2798 //*************************************************************************************************
2800 template< typename T, size_t N, bool TF >
2801 struct IsAligned< HybridVector<T,N,TF> >
2802  : public TrueType
2803 {};
2805 //*************************************************************************************************
2806 
2807 
2808 
2809 
2810 //=================================================================================================
2811 //
2812 // ISPADDED SPECIALIZATIONS
2813 //
2814 //=================================================================================================
2815 
2816 //*************************************************************************************************
2818 template< typename T, size_t N, bool TF >
2819 struct IsPadded< HybridVector<T,N,TF> >
2820  : public BoolConstant<usePadding>
2821 {};
2823 //*************************************************************************************************
2824 
2825 
2826 
2827 
2828 //=================================================================================================
2829 //
2830 // ISRESIZABLE SPECIALIZATIONS
2831 //
2832 //=================================================================================================
2833 
2834 //*************************************************************************************************
2836 template< typename T, size_t N, bool TF >
2837 struct IsResizable< HybridVector<T,N,TF> >
2838  : public TrueType
2839 {};
2841 //*************************************************************************************************
2842 
2843 
2844 
2845 
2846 //=================================================================================================
2847 //
2848 // ADDTRAIT SPECIALIZATIONS
2849 //
2850 //=================================================================================================
2851 
2852 //*************************************************************************************************
2854 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2855 struct AddTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2856 {
2857  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2858 };
2859 
2860 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2861 struct AddTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2862 {
2863  using Type = StaticVector< AddTrait_<T1,T2>, M, TF >;
2864 };
2865 
2866 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2867 struct AddTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2868 {
2869  using Type = HybridVector< AddTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2870 };
2872 //*************************************************************************************************
2873 
2874 
2875 
2876 
2877 //=================================================================================================
2878 //
2879 // SUBTRAIT SPECIALIZATIONS
2880 //
2881 //=================================================================================================
2882 
2883 //*************************************************************************************************
2885 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2886 struct SubTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2887 {
2888  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2889 };
2890 
2891 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2892 struct SubTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2893 {
2894  using Type = StaticVector< SubTrait_<T1,T2>, M, TF >;
2895 };
2896 
2897 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2898 struct SubTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2899 {
2900  using Type = HybridVector< SubTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2901 };
2903 //*************************************************************************************************
2904 
2905 
2906 
2907 
2908 //=================================================================================================
2909 //
2910 // MULTTRAIT SPECIALIZATIONS
2911 //
2912 //=================================================================================================
2913 
2914 //*************************************************************************************************
2916 template< typename T1, size_t N, bool TF, typename T2 >
2917 struct MultTrait< HybridVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2918 {
2919  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
2920 };
2921 
2922 template< typename T1, typename T2, size_t N, bool TF >
2923 struct MultTrait< T1, HybridVector<T2,N,TF>, EnableIf_<IsNumeric<T1> > >
2924 {
2925  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
2926 };
2927 
2928 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2929 struct MultTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2930 {
2931  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2932 };
2933 
2934 template< typename T1, size_t M, typename T2, size_t N >
2935 struct MultTrait< HybridVector<T1,M,false>, StaticVector<T2,N,true> >
2936 {
2937  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2938 };
2939 
2940 template< typename T1, size_t M, typename T2, size_t N >
2941 struct MultTrait< HybridVector<T1,M,true>, StaticVector<T2,N,false> >
2942 {
2943  using Type = MultTrait_<T1,T2>;
2944 };
2945 
2946 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2947 struct MultTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2948 {
2949  using Type = StaticVector< MultTrait_<T1,T2>, M, TF >;
2950 };
2951 
2952 template< typename T1, size_t M, typename T2, size_t N >
2953 struct MultTrait< StaticVector<T1,M,false>, HybridVector<T2,N,true> >
2954 {
2955  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2956 };
2957 
2958 template< typename T1, size_t M, typename T2, size_t N >
2959 struct MultTrait< StaticVector<T1,M,true>, HybridVector<T2,N,false> >
2960 {
2961  using Type = MultTrait_<T1,T2>;
2962 };
2963 
2964 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2965 struct MultTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2966 {
2967  using Type = HybridVector< MultTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2968 };
2969 
2970 template< typename T1, size_t M, typename T2, size_t N >
2971 struct MultTrait< HybridVector<T1,M,false>, HybridVector<T2,N,true> >
2972 {
2973  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2974 };
2975 
2976 template< typename T1, size_t M, typename T2, size_t N >
2977 struct MultTrait< HybridVector<T1,M,true>, HybridVector<T2,N,false> >
2978 {
2979  using Type = MultTrait_<T1,T2>;
2980 };
2982 //*************************************************************************************************
2983 
2984 
2985 
2986 
2987 //=================================================================================================
2988 //
2989 // DIVTRAIT SPECIALIZATIONS
2990 //
2991 //=================================================================================================
2992 
2993 //*************************************************************************************************
2995 template< typename T1, size_t N, bool TF, typename T2 >
2996 struct DivTrait< HybridVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2997 {
2998  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
2999 };
3000 
3001 template< typename T1, size_t M, bool TF, typename T2, size_t N >
3002 struct DivTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
3003 {
3004  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
3005 };
3006 
3007 template< typename T1, size_t M, bool TF, typename T2, size_t N >
3008 struct DivTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
3009 {
3010  using Type = StaticVector< DivTrait_<T1,T2>, M, TF >;
3011 };
3012 
3013 template< typename T1, size_t M, bool TF, typename T2, size_t N >
3014 struct DivTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
3015 {
3016  using Type = HybridVector< DivTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
3017 };
3019 //*************************************************************************************************
3020 
3021 
3022 
3023 
3024 //=================================================================================================
3025 //
3026 // CROSSTRAIT SPECIALIZATIONS
3027 //
3028 //=================================================================================================
3029 
3030 //*************************************************************************************************
3032 template< typename T1, size_t N, bool TF, typename T2 >
3033 struct CrossTrait< HybridVector<T1,N,TF>, StaticVector<T2,3UL,TF> >
3034 {
3035  private:
3036  using T = MultTrait_<T1,T2>;
3037 
3038  public:
3039  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
3040 };
3041 
3042 template< typename T1, bool TF, typename T2, size_t N >
3043 struct CrossTrait< StaticVector<T1,3UL,TF>, HybridVector<T2,N,TF> >
3044 {
3045  private:
3046  using T = MultTrait_<T1,T2>;
3047 
3048  public:
3049  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
3050 };
3051 
3052 template< typename T1, size_t M, bool TF, typename T2, size_t N >
3053 struct CrossTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
3054 {
3055  private:
3056  using T = MultTrait_<T1,T2>;
3057 
3058  public:
3059  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
3060 };
3062 //*************************************************************************************************
3063 
3064 
3065 
3066 
3067 //=================================================================================================
3068 //
3069 // UNARYMAPTRAIT SPECIALIZATIONS
3070 //
3071 //=================================================================================================
3072 
3073 //*************************************************************************************************
3075 template< typename T, size_t N, bool TF, typename OP >
3076 struct UnaryMapTrait< HybridVector<T,N,TF>, OP >
3077 {
3078  using Type = HybridVector< UnaryMapTrait_<T,OP>, N, TF >;
3079 };
3081 //*************************************************************************************************
3082 
3083 
3084 
3085 
3086 //=================================================================================================
3087 //
3088 // BINARYMAPTRAIT SPECIALIZATIONS
3089 //
3090 //=================================================================================================
3091 
3092 //*************************************************************************************************
3094 template< typename T1, size_t M, bool TF, typename T2, size_t N, typename OP >
3095 struct BinaryMapTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF>, OP >
3096 {
3097  using Type = StaticVector< BinaryMapTrait_<T1,T2,OP>, N, TF >;
3098 };
3099 
3100 template< typename T1, size_t M, bool TF, typename T2, size_t N, typename OP >
3101 struct BinaryMapTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF>, OP >
3102 {
3103  using Type = StaticVector< BinaryMapTrait_<T1,T2,OP>, M, TF >;
3104 };
3105 
3106 template< typename T1, size_t M, bool TF, typename T2, size_t N, typename OP >
3107 struct BinaryMapTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF>, OP >
3108 {
3109  using Type = HybridVector< BinaryMapTrait_<T1,T2,OP>, ( M < N )?( M ):( N ), TF >;
3110 };
3112 //*************************************************************************************************
3113 
3114 
3115 
3116 
3117 //=================================================================================================
3118 //
3119 // HIGHTYPE SPECIALIZATIONS
3120 //
3121 //=================================================================================================
3122 
3123 //*************************************************************************************************
3125 template< typename T1, size_t N, bool TF, typename T2 >
3126 struct HighType< HybridVector<T1,N,TF>, HybridVector<T2,N,TF> >
3127 {
3128  using Type = StaticVector< typename HighType<T1,T2>::Type, N, TF >;
3129 };
3131 //*************************************************************************************************
3132 
3133 
3134 
3135 
3136 //=================================================================================================
3137 //
3138 // LOWTYPE SPECIALIZATIONS
3139 //
3140 //=================================================================================================
3141 
3142 //*************************************************************************************************
3144 template< typename T1, size_t N, bool TF, typename T2 >
3145 struct LowType< HybridVector<T1,N,TF>, HybridVector<T2,N,TF> >
3146 {
3147  using Type = StaticVector< typename LowType<T1,T2>::Type, N, TF >;
3148 };
3150 //*************************************************************************************************
3151 
3152 
3153 
3154 
3155 //=================================================================================================
3156 //
3157 // SUBVECTORTRAIT SPECIALIZATIONS
3158 //
3159 //=================================================================================================
3160 
3161 //*************************************************************************************************
3163 template< typename T, size_t N, bool TF >
3164 struct SubvectorTrait< HybridVector<T,N,TF> >
3165 {
3166  using Type = HybridVector<T,N,TF>;
3167 };
3169 //*************************************************************************************************
3170 
3171 } // namespace blaze
3172 
3173 #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:1631
Header file for the alignment flag values.
Header file for the UNUSED_PARAMETER function template.
HybridVector()
The default constructor for HybridVector.
Definition: HybridVector.h:522
Header file for the subtraction trait.
Header file for basic type definitions.
DenseIterator< const Type, aligned > ConstIterator
Iterator over constant elements.
Definition: HybridVector.h:199
Header file for the SparseVector base class.
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: HybridVector.h:482
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
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1411
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:991
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:1463
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:914
#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:250
Header file for memory allocation and deallocation functionality.
System settings for performance optimizations.
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:212
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1393
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:1496
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:1809
Type ElementType
Type of the vector elements.
Definition: HybridVector.h:188
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: HybridVector.h:1944
Constraint on the data type.
Base template for the CrossTrait class.
Definition: CrossTrait.h:116
Efficient implementation of a fixed-sized vector.The StaticVector class template is the representatio...
Definition: Forward.h:61
Header file for the std::initializer_list aliases.
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:120
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:193
Rebind mechanism to obtain a HybridVector with different data/element type.
Definition: HybridVector.h:206
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: HybridVector.h:827
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: HybridVector.h:2131
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:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5924
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:195
#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:946
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: HybridVector.h:2010
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:70
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:2098
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:2043
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: HybridVector.h:1986
typename CrossTrait< T1, T2 >::Type CrossTrait_
Auxiliary alias declaration for the CrossTrait class template.The CrossTrait_ alias declaration provi...
Definition: CrossTrait.h:159
Constraint on the data type.
void clear()
Clearing the vector.
Definition: HybridVector.h:1555
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:580
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:1481
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:1596
size_t size_
The current size/dimension of the vector.
Definition: HybridVector.h:488
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:1023
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:139
HybridVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: HybridVector.h:1048
Base template for the MultTrait class.
Definition: MultTrait.h:139
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:1963
bool isIntact() const noexcept
Returns whether the invariants of the hybrid vector are intact.
Definition: HybridVector.h:1884
Constraint on the data type.
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the hybrid vector.
Definition: HybridVector.h:976
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:2163
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:819
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:1648
#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:194
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:139
DenseIterator< Type, aligned > Iterator
Iterator over non-constant elements.
Definition: HybridVector.h:198
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:196
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:1536
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:189
Reference at(size_t index)
Checked access to the vector elements.
Definition: HybridVector.h:870
HybridVector< Type, N, TF > This
Type of this HybridVector instance.
Definition: HybridVector.h:184
Resize mechanism to obtain a HybridVector with a different fixed number of elements.
Definition: HybridVector.h:215
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.
Initializer list type of the Blaze library.
Header file for the alignment check function.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h: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:600
Base template for the SubTrait class.
Definition: SubTrait.h:139
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:2074
Base template for the BinaryMapTrait class.
Definition: BinaryMapTrait.h:119
Header file for the IsResizable type trait.
Base template for the UnaryMapTrait class.
Definition: UnaryMapTrait.h:117
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:1514
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:1923
const Type & ReturnType
Return type for expression template evaluations.
Definition: HybridVector.h:190