HybridVector.h
Go to the documentation of this file.
1 //=================================================================================================
24 //=================================================================================================
25 
26 #ifndef _BLAZE_MATH_DENSE_HYBRIDVECTOR_H_
27 #define _BLAZE_MATH_DENSE_HYBRIDVECTOR_H_
28 
29 
30 //*************************************************************************************************
31 // Includes
32 //*************************************************************************************************
33 
34 #include <algorithm>
35 #include <utility>
36 #include <blaze/math/Aliases.h>
39 #include <blaze/math/Exception.h>
42 #include <blaze/math/Forward.h>
43 #include <blaze/math/Functions.h>
45 #include <blaze/math/shims/Clear.h>
48 #include <blaze/math/SIMD.h>
68 #include <blaze/system/Inline.h>
73 #include <blaze/util/Assert.h>
79 #include <blaze/util/DisableIf.h>
80 #include <blaze/util/EnableIf.h>
82 #include <blaze/util/Memory.h>
84 #include <blaze/util/Template.h>
85 #include <blaze/util/TrueType.h>
86 #include <blaze/util/Types.h>
89 #include <blaze/util/Unused.h>
90 
91 
92 namespace blaze {
93 
94 //=================================================================================================
95 //
96 // CLASS DEFINITION
97 //
98 //=================================================================================================
99 
100 //*************************************************************************************************
170 template< typename Type // Data type of the vector
171  , size_t N // Number of elements
172  , bool TF = defaultTransposeFlag > // Transpose flag
173 class HybridVector : public DenseVector< HybridVector<Type,N,TF>, TF >
174 {
175  public:
176  //**Type definitions****************************************************************************
179  typedef This ResultType;
181  typedef Type ElementType;
183  typedef const Type& ReturnType;
184  typedef const HybridVector& CompositeType;
185 
186  typedef Type& Reference;
187  typedef const Type& ConstReference;
188  typedef Type* Pointer;
189  typedef const Type* ConstPointer;
190 
193  //**********************************************************************************************
194 
195  //**Rebind struct definition********************************************************************
198  template< typename NewType > // Data type of the other vector
199  struct Rebind {
201  };
202  //**********************************************************************************************
203 
204  //**Resize struct definition********************************************************************
207  template< size_t NewN > // Number of elements of the other vector
208  struct Resize {
210  };
211  //**********************************************************************************************
212 
213  //**Compilation flags***************************************************************************
215 
219  enum : bool { simdEnabled = IsVectorizable<Type>::value };
220 
222 
225  enum : bool { smpAssignable = false };
226  //**********************************************************************************************
227 
228  //**Constructors********************************************************************************
231  explicit inline HybridVector();
232  explicit inline HybridVector( size_t n );
233  explicit inline HybridVector( size_t n, const Type& init );
234  explicit inline HybridVector( initializer_list<Type> list );
235 
236  template< typename Other >
237  explicit inline HybridVector( size_t n, const Other* array );
238 
239  template< typename Other, size_t M >
240  explicit inline HybridVector( const Other (&array)[M] );
241 
242  inline HybridVector( const HybridVector& v );
243  template< typename VT > inline HybridVector( const Vector<VT,TF>& v );
245  //**********************************************************************************************
246 
247  //**Destructor**********************************************************************************
248  // No explicitly declared destructor.
249  //**********************************************************************************************
250 
251  //**Data access functions***********************************************************************
254  inline Reference operator[]( size_t index ) noexcept;
255  inline ConstReference operator[]( size_t index ) const noexcept;
256  inline Reference at( size_t index );
257  inline ConstReference at( size_t index ) const;
258  inline Pointer data () noexcept;
259  inline ConstPointer data () const noexcept;
260  inline Iterator begin () noexcept;
261  inline ConstIterator begin () const noexcept;
262  inline ConstIterator cbegin() const noexcept;
263  inline Iterator end () noexcept;
264  inline ConstIterator end () const noexcept;
265  inline ConstIterator cend () const noexcept;
267  //**********************************************************************************************
268 
269  //**Assignment operators************************************************************************
272  inline HybridVector& operator=( const Type& rhs );
273  inline HybridVector& operator=( initializer_list<Type> list );
274 
275  template< typename Other, size_t M >
276  inline HybridVector& operator=( const Other (&array)[M] );
277 
278  inline HybridVector& operator= ( const HybridVector& rhs );
279  template< typename VT > inline HybridVector& operator= ( const Vector<VT,TF>& rhs );
280  template< typename VT > inline HybridVector& operator+=( const Vector<VT,TF>& rhs );
281  template< typename VT > inline HybridVector& operator-=( const Vector<VT,TF>& rhs );
282  template< typename VT > inline HybridVector& operator*=( const Vector<VT,TF>& rhs );
283  template< typename VT > inline HybridVector& operator/=( const DenseVector<VT,TF>& rhs );
284 
285  template< typename Other >
286  inline EnableIf_<IsNumeric<Other>, HybridVector >& operator*=( Other rhs );
287 
288  template< typename Other >
289  inline EnableIf_<IsNumeric<Other>, HybridVector >& operator/=( Other rhs );
291  //**********************************************************************************************
292 
293  //**Utility functions***************************************************************************
296  inline size_t size() const noexcept;
297  inline size_t capacity() const noexcept;
298  inline size_t nonZeros() const;
299  inline void reset();
300  inline void clear();
301  inline void resize( size_t n, bool preserve=true );
302  inline void extend( size_t n, bool preserve=true );
303  inline void swap( HybridVector& v ) noexcept;
305  //**********************************************************************************************
306 
307  //**Numeric functions***************************************************************************
310  template< typename Other > inline HybridVector& scale( const Other& scalar );
312  //**********************************************************************************************
313 
314  //**Memory functions****************************************************************************
317  static inline void* operator new ( std::size_t size );
318  static inline void* operator new[]( std::size_t size );
319  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
320  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
321 
322  static inline void operator delete ( void* ptr );
323  static inline void operator delete[]( void* ptr );
324  static inline void operator delete ( void* ptr, const std::nothrow_t& );
325  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
327  //**********************************************************************************************
328 
329  private:
330  //**********************************************************************************************
332  template< typename VT >
334  struct VectorizedAssign {
335  enum : bool { value = useOptimizedKernels &&
336  simdEnabled && VT::simdEnabled &&
338  };
340  //**********************************************************************************************
341 
342  //**********************************************************************************************
344  template< typename VT >
346  struct VectorizedAddAssign {
347  enum : bool { value = useOptimizedKernels &&
348  simdEnabled && VT::simdEnabled &&
351  };
353  //**********************************************************************************************
354 
355  //**********************************************************************************************
357  template< typename VT >
359  struct VectorizedSubAssign {
360  enum : bool { value = useOptimizedKernels &&
361  simdEnabled && VT::simdEnabled &&
364  };
366  //**********************************************************************************************
367 
368  //**********************************************************************************************
370  template< typename VT >
372  struct VectorizedMultAssign {
373  enum : bool { value = useOptimizedKernels &&
374  simdEnabled && VT::simdEnabled &&
377  };
379  //**********************************************************************************************
380 
381  //**********************************************************************************************
383  template< typename VT >
385  struct VectorizedDivAssign {
386  enum : bool { value = useOptimizedKernels &&
387  simdEnabled && VT::simdEnabled &&
390  };
392  //**********************************************************************************************
393 
394  //**********************************************************************************************
396  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
397  //**********************************************************************************************
398 
399  public:
400  //**Debugging functions*************************************************************************
403  inline bool isIntact() const noexcept;
405  //**********************************************************************************************
406 
407  //**Expression template evaluation functions****************************************************
410  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
411  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
412 
413  inline bool isAligned() const noexcept;
414 
415  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
416  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
417  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
418 
419  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
420  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
421  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
422  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
423 
424  template< typename VT >
425  inline DisableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
426 
427  template< typename VT >
428  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
429 
430  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
431 
432  template< typename VT >
433  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
434 
435  template< typename VT >
436  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
437 
438  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
439 
440  template< typename VT >
441  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
442 
443  template< typename VT >
444  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
445 
446  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
447 
448  template< typename VT >
449  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
450 
451  template< typename VT >
452  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
453 
454  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
455 
456  template< typename VT >
457  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
458 
459  template< typename VT >
460  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
462  //**********************************************************************************************
463 
464  private:
465  //**********************************************************************************************
467  enum : size_t { NN = ( usePadding )?( nextMultiple( N, SIMDSIZE ) ):( N ) };
468  //**********************************************************************************************
469 
470  //**Member variables****************************************************************************
474 
479  size_t size_;
480 
481  //**********************************************************************************************
482 
483  //**Compile time checks*************************************************************************
489  BLAZE_STATIC_ASSERT( !usePadding || NN % SIMDSIZE == 0UL );
490  BLAZE_STATIC_ASSERT( NN >= N );
492  //**********************************************************************************************
493 };
494 //*************************************************************************************************
495 
496 
497 
498 
499 //=================================================================================================
500 //
501 // CONSTRUCTORS
502 //
503 //=================================================================================================
504 
505 //*************************************************************************************************
510 template< typename Type // Data type of the vector
511  , size_t N // Number of elements
512  , bool TF > // Transpose flag
514  : v_ () // The statically allocated vector elements
515  , size_( 0UL ) // The current size/dimension of the vector
516 {
518 
519  if( IsNumeric<Type>::value ) {
520  for( size_t i=0UL; i<NN; ++i )
521  v_[i] = Type();
522  }
523 
524  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
525 }
526 //*************************************************************************************************
527 
528 
529 //*************************************************************************************************
539 template< typename Type // Data type of the vector
540  , size_t N // Number of elements
541  , bool TF > // Transpose flag
543  : v_ () // The statically allocated vector elements
544  , size_( n ) // The current size/dimension of the vector
545 {
547 
548  if( n > N ) {
549  BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
550  }
551 
552  if( IsNumeric<Type>::value ) {
553  for( size_t i=0UL; i<NN; ++i )
554  v_[i] = Type();
555  }
556 
557  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
558 }
559 //*************************************************************************************************
560 
561 
562 //*************************************************************************************************
573 template< typename Type // Data type of the vector
574  , size_t N // Number of elements
575  , bool TF > // Transpose flag
576 inline HybridVector<Type,N,TF>::HybridVector( size_t n, const Type& init )
577  : v_ () // The statically allocated vector elements
578  , size_( n ) // The current size/dimension of the vector
579 {
581 
582  if( n > N ) {
583  BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
584  }
585 
586  for( size_t i=0UL; i<n; ++i )
587  v_[i] = init;
588 
589  if( IsNumeric<Type>::value ) {
590  for( size_t i=n; i<NN; ++i )
591  v_[i] = Type();
592  }
593 
594  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
595 }
596 //*************************************************************************************************
597 
598 
599 //*************************************************************************************************
617 template< typename Type // Data type of the vector
618  , size_t N // Number of elements
619  , bool TF > // Transpose flag
621  : v_ () // The statically allocated vector elements
622  , size_( list.size() ) // The current size/dimension of the vector
623 {
625 
626  if( size_ > N ) {
627  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
628  }
629 
630  std::fill( std::copy( list.begin(), list.end(), v_.data() ), v_.data()+NN, Type() );
631 
632  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
633 }
634 //*************************************************************************************************
635 
636 
637 //*************************************************************************************************
660 template< typename Type // Data type of the vector
661  , size_t N // Number of elements
662  , bool TF > // Transpose flag
663 template< typename Other > // Data type of the initialization array
664 inline HybridVector<Type,N,TF>::HybridVector( size_t n, const Other* array )
665  : v_ () // The statically allocated vector elements
666  , size_( n ) // The current size/dimension of the vector
667 {
669 
670  if( n > N ) {
671  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
672  }
673 
674  for( size_t i=0UL; i<n; ++i )
675  v_[i] = array[i];
676 
677  if( IsNumeric<Type>::value ) {
678  for( size_t i=n; i<NN; ++i )
679  v_[i] = Type();
680  }
681 
682  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
683 }
684 //*************************************************************************************************
685 
686 
687 //*************************************************************************************************
705 template< typename Type // Data type of the vector
706  , size_t N // Number of elements
707  , bool TF > // Transpose flag
708 template< typename Other // Data type of the initialization array
709  , size_t M > // Number of elements of the initialization array
710 inline HybridVector<Type,N,TF>::HybridVector( const Other (&array)[M] )
711  : v_ () // The statically allocated vector elements
712  , size_( M ) // The current size/dimension of the vector
713 {
714  BLAZE_STATIC_ASSERT( M <= N );
716 
717  for( size_t i=0UL; i<M; ++i )
718  v_[i] = array[i];
719 
720  if( IsNumeric<Type>::value ) {
721  for( size_t i=M; i<NN; ++i )
722  v_[i] = Type();
723  }
724 
725  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
726 }
727 //*************************************************************************************************
728 
729 
730 //*************************************************************************************************
737 template< typename Type // Data type of the vector
738  , size_t N // Number of elements
739  , bool TF > // Transpose flag
741  : v_ () // The statically allocated vector elements
742  , size_( v.size_ ) // The current size/dimension of the vector
743 {
745 
746  for( size_t i=0UL; i<size_; ++i )
747  v_[i] = v.v_[i];
748 
749  if( IsNumeric<Type>::value ) {
750  for( size_t i=size_; i<NN; ++i )
751  v_[i] = Type();
752  }
753 
754  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
755 }
756 //*************************************************************************************************
757 
758 
759 //*************************************************************************************************
769 template< typename Type // Data type of the vector
770  , size_t N // Number of elements
771  , bool TF > // Transpose flag
772 template< typename VT > // Type of the foreign vector
774  : v_ () // The statically allocated vector elements
775  , size_( (~v).size() ) // The current size/dimension of the vector
776 {
777  using blaze::assign;
778 
780 
781  if( (~v).size() > N ) {
782  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
783  }
784 
785  for( size_t i=( IsSparseVector<VT>::value ? 0UL : size_ );
786  i<( IsNumeric<Type>::value ? NN : size_ ); ++i ) {
787  v_[i] = Type();
788  }
789 
790  assign( *this, ~v );
791 
792  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
793 }
794 //*************************************************************************************************
795 
796 
797 
798 
799 //=================================================================================================
800 //
801 // DATA ACCESS FUNCTIONS
802 //
803 //=================================================================================================
804 
805 //*************************************************************************************************
814 template< typename Type // Data type of the vector
815  , size_t N // Number of elements
816  , bool TF > // Transpose flag
818  HybridVector<Type,N,TF>::operator[]( size_t index ) noexcept
819 {
820  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
821  return v_[index];
822 }
823 //*************************************************************************************************
824 
825 
826 //*************************************************************************************************
835 template< typename Type // Data type of the vector
836  , size_t N // Number of elements
837  , bool TF > // Transpose flag
839  HybridVector<Type,N,TF>::operator[]( size_t index ) const noexcept
840 {
841  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
842  return v_[index];
843 }
844 //*************************************************************************************************
845 
846 
847 //*************************************************************************************************
857 template< typename Type // Data type of the vector
858  , size_t N // Number of elements
859  , bool TF > // Transpose flag
862 {
863  if( index >= size_ ) {
864  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
865  }
866  return (*this)[index];
867 }
868 //*************************************************************************************************
869 
870 
871 //*************************************************************************************************
881 template< typename Type // Data type of the vector
882  , size_t N // Number of elements
883  , bool TF > // Transpose flag
885  HybridVector<Type,N,TF>::at( size_t index ) const
886 {
887  if( index >= size_ ) {
888  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
889  }
890  return (*this)[index];
891 }
892 //*************************************************************************************************
893 
894 
895 //*************************************************************************************************
902 template< typename Type // Data type of the vector
903  , size_t N // Number of elements
904  , bool TF > // Transpose flag
906 {
907  return v_;
908 }
909 //*************************************************************************************************
910 
911 
912 //*************************************************************************************************
919 template< typename Type // Data type of the vector
920  , size_t N // Number of elements
921  , bool TF > // Transpose flag
923 {
924  return v_;
925 }
926 //*************************************************************************************************
927 
928 
929 //*************************************************************************************************
934 template< typename Type // Data type of the vector
935  , size_t N // Number of elements
936  , bool TF > // Transpose flag
938 {
939  return Iterator( v_ );
940 }
941 //*************************************************************************************************
942 
943 
944 //*************************************************************************************************
949 template< typename Type // Data type of the vector
950  , size_t N // Number of elements
951  , bool TF > // Transpose flag
953 {
954  return ConstIterator( v_ );
955 }
956 //*************************************************************************************************
957 
958 
959 //*************************************************************************************************
964 template< typename Type // Data type of the vector
965  , size_t N // Number of elements
966  , bool TF > // Transpose flag
968 {
969  return ConstIterator( v_ );
970 }
971 //*************************************************************************************************
972 
973 
974 //*************************************************************************************************
979 template< typename Type // Data type of the vector
980  , size_t N // Number of elements
981  , bool TF > // Transpose flag
983 {
984  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
985  return Iterator( v_ + size_ );
986 }
987 //*************************************************************************************************
988 
989 
990 //*************************************************************************************************
995 template< typename Type // Data type of the vector
996  , size_t N // Number of elements
997  , bool TF > // Transpose flag
999 {
1000  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1001  return ConstIterator( v_ + size_ );
1002 }
1003 //*************************************************************************************************
1004 
1005 
1006 //*************************************************************************************************
1011 template< typename Type // Data type of the vector
1012  , size_t N // Number of elements
1013  , bool TF > // Transpose flag
1015 {
1016  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1017  return ConstIterator( v_ + size_ );
1018 }
1019 //*************************************************************************************************
1020 
1021 
1022 
1023 
1024 //=================================================================================================
1025 //
1026 // ASSIGNMENT OPERATORS
1027 //
1028 //=================================================================================================
1029 
1030 //*************************************************************************************************
1036 template< typename Type // Data type of the vector
1037  , size_t N // Number of elements
1038  , bool TF > // Transpose flag
1040 {
1041  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1042 
1043  for( size_t i=0UL; i<size_; ++i )
1044  v_[i] = rhs;
1045  return *this;
1046 }
1047 //*************************************************************************************************
1048 
1049 
1050 //*************************************************************************************************
1069 template< typename Type // Data type of the vector
1070  , size_t N // Number of elements
1071  , bool TF > // Transpose flag
1073 {
1074  if( list.size() > N ) {
1075  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to hybrid vector" );
1076  }
1077 
1078  resize( list.size(), false );
1079  std::copy( list.begin(), list.end(), v_.data() );
1080 
1081  return *this;
1082 }
1083 //*************************************************************************************************
1084 
1085 
1086 //*************************************************************************************************
1105 template< typename Type // Data type of the vector
1106  , size_t N // Number of elements
1107  , bool TF > // Transpose flag
1108 template< typename Other // Data type of the initialization array
1109  , size_t M > // Number of elements of the initialization array
1111 {
1112  BLAZE_STATIC_ASSERT( M <= N );
1113 
1114  resize( M, false );
1115 
1116  for( size_t i=0UL; i<M; ++i )
1117  v_[i] = array[i];
1118 
1119  return *this;
1120 }
1121 //*************************************************************************************************
1122 
1123 
1124 //*************************************************************************************************
1132 template< typename Type // Data type of the vector
1133  , size_t N // Number of elements
1134  , bool TF > // Transpose flag
1136 {
1137  using blaze::assign;
1138 
1139  BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1140 
1141  resize( rhs.size() );
1142  assign( *this, ~rhs );
1143 
1144  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1145 
1146  return *this;
1147 }
1148 //*************************************************************************************************
1149 
1150 
1151 //*************************************************************************************************
1161 template< typename Type // Data type of the vector
1162  , size_t N // Number of elements
1163  , bool TF > // Transpose flag
1164 template< typename VT > // Type of the right-hand side vector
1166 {
1167  using blaze::assign;
1168 
1169  if( (~rhs).size() > N ) {
1170  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to hybrid vector" );
1171  }
1172 
1173  if( (~rhs).canAlias( this ) ) {
1174  HybridVector tmp( ~rhs );
1175  swap( tmp );
1176  }
1177  else {
1178  resize( (~rhs).size(), false );
1180  reset();
1181  assign( *this, ~rhs );
1182  }
1183 
1184  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1185 
1186  return *this;
1187 }
1188 //*************************************************************************************************
1189 
1190 
1191 //*************************************************************************************************
1201 template< typename Type // Data type of the vector
1202  , size_t N // Number of elements
1203  , bool TF > // Transpose flag
1204 template< typename VT > // Type of the right-hand side vector
1206 {
1207  using blaze::addAssign;
1208 
1209  if( (~rhs).size() != size_ ) {
1210  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1211  }
1212 
1213  if( (~rhs).canAlias( this ) ) {
1214  const ResultType_<VT> tmp( ~rhs );
1215  addAssign( *this, tmp );
1216  }
1217  else {
1218  addAssign( *this, ~rhs );
1219  }
1220 
1221  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1222 
1223  return *this;
1224 }
1225 //*************************************************************************************************
1226 
1227 
1228 //*************************************************************************************************
1238 template< typename Type // Data type of the vector
1239  , size_t N // Number of elements
1240  , bool TF > // Transpose flag
1241 template< typename VT > // Type of the right-hand side vector
1243 {
1244  using blaze::subAssign;
1245 
1246  if( (~rhs).size() != size_ ) {
1247  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1248  }
1249 
1250  if( (~rhs).canAlias( this ) ) {
1251  const ResultType_<VT> tmp( ~rhs );
1252  subAssign( *this, tmp );
1253  }
1254  else {
1255  subAssign( *this, ~rhs );
1256  }
1257 
1258  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1259 
1260  return *this;
1261 }
1262 //*************************************************************************************************
1263 
1264 
1265 //*************************************************************************************************
1276 template< typename Type // Data type of the vector
1277  , size_t N // Number of elements
1278  , bool TF > // Transpose flag
1279 template< typename VT > // Type of the right-hand side vector
1281 {
1282  using blaze::multAssign;
1283 
1284  if( (~rhs).size() != size_ ) {
1285  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1286  }
1287 
1288  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1289  const HybridVector tmp( *this * (~rhs) );
1290  this->operator=( tmp );
1291  }
1292  else {
1293  multAssign( *this, ~rhs );
1294  }
1295 
1296  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1297 
1298  return *this;
1299 }
1300 //*************************************************************************************************
1301 
1302 
1303 //*************************************************************************************************
1313 template< typename Type // Data type of the vector
1314  , size_t N // Number of elements
1315  , bool TF > // Transpose flag
1316 template< typename VT > // Type of the right-hand side vector
1318 {
1319  using blaze::divAssign;
1320 
1321  if( (~rhs).size() != size_ ) {
1322  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1323  }
1324 
1325  if( (~rhs).canAlias( this ) ) {
1326  const HybridVector tmp( *this / (~rhs) );
1327  this->operator=( tmp );
1328  }
1329  else {
1330  divAssign( *this, ~rhs );
1331  }
1332 
1333  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1334 
1335  return *this;
1336 }
1337 //*************************************************************************************************
1338 
1339 
1340 //*************************************************************************************************
1347 template< typename Type // Data type of the vector
1348  , size_t N // Number of elements
1349  , bool TF > // Transpose flag
1350 template< typename Other > // Data type of the right-hand side scalar
1353 {
1354  using blaze::assign;
1355 
1356  assign( *this, (*this) * rhs );
1357 
1358  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1359 
1360  return *this;
1361 }
1362 //*************************************************************************************************
1363 
1364 
1365 //*************************************************************************************************
1374 template< typename Type // Data type of the vector
1375  , size_t N // Number of elements
1376  , bool TF > // Transpose flag
1377 template< typename Other > // Data type of the right-hand side scalar
1378 inline EnableIf_<IsNumeric<Other>, HybridVector<Type,N,TF> >&
1380 {
1381  using blaze::assign;
1382 
1383  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1384 
1385  assign( *this, (*this) / rhs );
1386 
1387  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1388 
1389  return *this;
1390 }
1391 //*************************************************************************************************
1392 
1393 
1394 
1395 
1396 //=================================================================================================
1397 //
1398 // UTILITY FUNCTIONS
1399 //
1400 //=================================================================================================
1401 
1402 //*************************************************************************************************
1407 template< typename Type // Data type of the vector
1408  , size_t N // Number of elements
1409  , bool TF > // Transpose flag
1410 inline size_t HybridVector<Type,N,TF>::size() const noexcept
1411 {
1412  return size_;
1413 }
1414 //*************************************************************************************************
1415 
1416 
1417 //*************************************************************************************************
1422 template< typename Type // Data type of the vector
1423  , size_t N // Number of elements
1424  , bool TF > // Transpose flag
1425 inline size_t HybridVector<Type,N,TF>::capacity() const noexcept
1426 {
1427  return NN;
1428 }
1429 //*************************************************************************************************
1430 
1431 
1432 //*************************************************************************************************
1440 template< typename Type // Data type of the vector
1441  , size_t N // Number of elements
1442  , bool TF > // Transpose flag
1444 {
1445  size_t nonzeros( 0 );
1446 
1447  for( size_t i=0UL; i<size_; ++i ) {
1448  if( !isDefault( v_[i] ) )
1449  ++nonzeros;
1450  }
1451 
1452  return nonzeros;
1453 }
1454 //*************************************************************************************************
1455 
1456 
1457 //*************************************************************************************************
1462 template< typename Type // Data type of the vector
1463  , size_t N // Number of elements
1464  , bool TF > // Transpose flag
1466 {
1467  using blaze::clear;
1468  for( size_t i=0UL; i<size_; ++i )
1469  clear( v_[i] );
1470 }
1471 //*************************************************************************************************
1472 
1473 
1474 //*************************************************************************************************
1481 template< typename Type // Data type of the vector
1482  , size_t N // Number of elements
1483  , bool TF > // Transpose flag
1485 {
1486  resize( 0UL );
1487 }
1488 //*************************************************************************************************
1489 
1490 
1491 //*************************************************************************************************
1522 template< typename Type // Data type of the vector
1523  , size_t N // Number of elements
1524  , bool TF > // Transpose flag
1525 inline void HybridVector<Type,N,TF>::resize( size_t n, bool preserve )
1526 {
1527  UNUSED_PARAMETER( preserve );
1528 
1529  if( n > N ) {
1530  BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
1531  }
1532 
1533  if( IsVectorizable<Type>::value && n < size_ ) {
1534  for( size_t i=n; i<size_; ++i )
1535  v_[i] = Type();
1536  }
1537 
1538  size_ = n;
1539 }
1540 //*************************************************************************************************
1541 
1542 
1543 //*************************************************************************************************
1557 template< typename Type // Data type of the vector
1558  , size_t N // Number of elements
1559  , bool TF > // Transpose flag
1560 inline void HybridVector<Type,N,TF>::extend( size_t n, bool preserve )
1561 {
1562  UNUSED_PARAMETER( preserve );
1563  resize( size_+n );
1564 }
1565 //*************************************************************************************************
1566 
1567 
1568 //*************************************************************************************************
1574 template< typename Type // Data type of the vector
1575  , size_t N // Number of elements
1576  , bool TF > // Transpose flag
1578 {
1579  using std::swap;
1580 
1581  const size_t maxsize( max( size_, v.size_ ) );
1582  for( size_t i=0UL; i<maxsize; ++i )
1583  swap( v_[i], v.v_[i] );
1584  swap( size_, v.size_ );
1585 }
1586 //*************************************************************************************************
1587 
1588 
1589 
1590 
1591 //=================================================================================================
1592 //
1593 // NUMERIC FUNCTIONS
1594 //
1595 //=================================================================================================
1596 
1597 //*************************************************************************************************
1603 template< typename Type // Data type of the vector
1604  , size_t N // Number of elements
1605  , bool TF > // Transpose flag
1606 template< typename Other > // Data type of the scalar value
1608 {
1609  for( size_t i=0; i<size_; ++i )
1610  v_[i] *= scalar;
1611  return *this;
1612 }
1613 //*************************************************************************************************
1614 
1615 
1616 
1617 
1618 //=================================================================================================
1619 //
1620 // MEMORY FUNCTIONS
1621 //
1622 //=================================================================================================
1623 
1624 //*************************************************************************************************
1634 template< typename Type // Data type of the vector
1635  , size_t N // Number of elements
1636  , bool TF > // Transpose flag
1637 inline void* HybridVector<Type,N,TF>::operator new( std::size_t size )
1638 {
1640 
1641  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridVector ), "Invalid number of bytes detected" );
1642 
1643  return allocate<HybridVector>( 1UL );
1644 }
1645 //*************************************************************************************************
1646 
1647 
1648 //*************************************************************************************************
1658 template< typename Type // Data type of the vector
1659  , size_t N // Number of elements
1660  , bool TF > // Transpose flag
1661 inline void* HybridVector<Type,N,TF>::operator new[]( std::size_t size )
1662 {
1663  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridVector ) , "Invalid number of bytes detected" );
1664  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridVector ) == 0UL, "Invalid number of bytes detected" );
1665 
1666  return allocate<HybridVector>( size/sizeof(HybridVector) );
1667 }
1668 //*************************************************************************************************
1669 
1670 
1671 //*************************************************************************************************
1681 template< typename Type // Data type of the vector
1682  , size_t N // Number of elements
1683  , bool TF > // Transpose flag
1684 inline void* HybridVector<Type,N,TF>::operator new( std::size_t size, const std::nothrow_t& )
1685 {
1686  UNUSED_PARAMETER( size );
1687 
1688  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridVector ), "Invalid number of bytes detected" );
1689 
1690  return allocate<HybridVector>( 1UL );
1691 }
1692 //*************************************************************************************************
1693 
1694 
1695 //*************************************************************************************************
1705 template< typename Type // Data type of the vector
1706  , size_t N // Number of elements
1707  , bool TF > // Transpose flag
1708 inline void* HybridVector<Type,N,TF>::operator new[]( std::size_t size, const std::nothrow_t& )
1709 {
1710  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridVector ) , "Invalid number of bytes detected" );
1711  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridVector ) == 0UL, "Invalid number of bytes detected" );
1712 
1713  return allocate<HybridVector>( size/sizeof(HybridVector) );
1714 }
1715 //*************************************************************************************************
1716 
1717 
1718 //*************************************************************************************************
1724 template< typename Type // Data type of the vector
1725  , size_t N // Number of elements
1726  , bool TF > // Transpose flag
1727 inline void HybridVector<Type,N,TF>::operator delete( void* ptr )
1728 {
1729  deallocate( static_cast<HybridVector*>( ptr ) );
1730 }
1731 //*************************************************************************************************
1732 
1733 
1734 //*************************************************************************************************
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 delete[]( void* ptr )
1744 {
1745  deallocate( static_cast<HybridVector*>( ptr ) );
1746 }
1747 //*************************************************************************************************
1748 
1749 
1750 //*************************************************************************************************
1756 template< typename Type // Data type of the vector
1757  , size_t N // Number of elements
1758  , bool TF > // Transpose flag
1759 inline void HybridVector<Type,N,TF>::operator delete( void* ptr, const std::nothrow_t& )
1760 {
1761  deallocate( static_cast<HybridVector*>( ptr ) );
1762 }
1763 //*************************************************************************************************
1764 
1765 
1766 //*************************************************************************************************
1772 template< typename Type // Data type of the vector
1773  , size_t N // Number of elements
1774  , bool TF > // Transpose flag
1775 inline void HybridVector<Type,N,TF>::operator delete[]( void* ptr, const std::nothrow_t& )
1776 {
1777  deallocate( static_cast<HybridVector*>( ptr ) );
1778 }
1779 //*************************************************************************************************
1780 
1781 
1782 
1783 
1784 //=================================================================================================
1785 //
1786 // DEBUGGING FUNCTIONS
1787 //
1788 //=================================================================================================
1789 
1790 //*************************************************************************************************
1799 template< typename Type // Data type of the vector
1800  , size_t N // Number of elements
1801  , bool TF > // Transpose flag
1802 inline bool HybridVector<Type,N,TF>::isIntact() const noexcept
1803 {
1804  if( size_ > N )
1805  return false;
1806 
1807  if( IsNumeric<Type>::value ) {
1808  for( size_t i=size_; i<NN; ++i ) {
1809  if( v_[i] != Type() )
1810  return false;
1811  }
1812  }
1813 
1814  return true;
1815 }
1816 //*************************************************************************************************
1817 
1818 
1819 
1820 
1821 //=================================================================================================
1822 //
1823 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1824 //
1825 //=================================================================================================
1826 
1827 //*************************************************************************************************
1837 template< typename Type // Data type of the vector
1838  , size_t N // Number of elements
1839  , bool TF > // Transpose flag
1840 template< typename Other > // Data type of the foreign expression
1841 inline bool HybridVector<Type,N,TF>::canAlias( const Other* alias ) const noexcept
1842 {
1843  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1844 }
1845 //*************************************************************************************************
1846 
1847 
1848 //*************************************************************************************************
1858 template< typename Type // Data type of the vector
1859  , size_t N // Number of elements
1860  , bool TF > // Transpose flag
1861 template< typename Other > // Data type of the foreign expression
1862 inline bool HybridVector<Type,N,TF>::isAliased( const Other* alias ) const noexcept
1863 {
1864  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1865 }
1866 //*************************************************************************************************
1867 
1868 
1869 //*************************************************************************************************
1878 template< typename Type // Data type of the vector
1879  , size_t N // Number of elements
1880  , bool TF > // Transpose flag
1881 inline bool HybridVector<Type,N,TF>::isAligned() const noexcept
1882 {
1883  return true;
1884 }
1885 //*************************************************************************************************
1886 
1887 
1888 //*************************************************************************************************
1900 template< typename Type // Data type of the vector
1901  , size_t N // Number of elements
1902  , bool TF > // Transpose flag
1904  HybridVector<Type,N,TF>::load( size_t index ) const noexcept
1905 {
1906  return loada( index );
1907 }
1908 //*************************************************************************************************
1909 
1910 
1911 //*************************************************************************************************
1924 template< typename Type // Data type of the vector
1925  , size_t N // Number of elements
1926  , bool TF > // Transpose flag
1928  HybridVector<Type,N,TF>::loada( size_t index ) const noexcept
1929 {
1930  using blaze::loada;
1931 
1933 
1934  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1935  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1936  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1937  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1938 
1939  return loada( &v_[index] );
1940 }
1941 //*************************************************************************************************
1942 
1943 
1944 //*************************************************************************************************
1957 template< typename Type // Data type of the vector
1958  , size_t N // Number of elements
1959  , bool TF > // Transpose flag
1961  HybridVector<Type,N,TF>::loadu( size_t index ) const noexcept
1962 {
1963  using blaze::loadu;
1964 
1966 
1967  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1968  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1969 
1970  return loadu( &v_[index] );
1971 }
1972 //*************************************************************************************************
1973 
1974 
1975 //*************************************************************************************************
1988 template< typename Type // Data type of the vector
1989  , size_t N // Number of elements
1990  , bool TF > // Transpose flag
1992  HybridVector<Type,N,TF>::store( size_t index, const SIMDType& value ) noexcept
1993 {
1994  storea( index, value );
1995 }
1996 //*************************************************************************************************
1997 
1998 
1999 //*************************************************************************************************
2012 template< typename Type // Data type of the vector
2013  , size_t N // Number of elements
2014  , bool TF > // Transpose flag
2016  HybridVector<Type,N,TF>::storea( size_t index, const SIMDType& value ) noexcept
2017 {
2018  using blaze::storea;
2019 
2021 
2022  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2023  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2024  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2025  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2026 
2027  storea( &v_[index], value );
2028 }
2029 //*************************************************************************************************
2030 
2031 
2032 //*************************************************************************************************
2045 template< typename Type // Data type of the vector
2046  , size_t N // Number of elements
2047  , bool TF > // Transpose flag
2049  HybridVector<Type,N,TF>::storeu( size_t index, const SIMDType& value ) noexcept
2050 {
2051  using blaze::storeu;
2052 
2054 
2055  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2056  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2057 
2058  storeu( &v_[index], value );
2059 }
2060 //*************************************************************************************************
2061 
2062 
2063 //*************************************************************************************************
2077 template< typename Type // Data type of the vector
2078  , size_t N // Number of elements
2079  , bool TF > // Transpose flag
2081  HybridVector<Type,N,TF>::stream( size_t index, const SIMDType& value ) noexcept
2082 {
2083  using blaze::stream;
2084 
2086 
2087  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2088  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2089  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2090  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2091 
2092  stream( &v_[index], value );
2093 }
2094 //*************************************************************************************************
2095 
2096 
2097 //*************************************************************************************************
2108 template< typename Type // Data type of the vector
2109  , size_t N // Number of elements
2110  , bool TF > // Transpose flag
2111 template< typename VT > // Type of the right-hand side dense vector
2114 {
2115  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2116 
2117  for( size_t i=0UL; i<size_; ++i )
2118  v_[i] = (~rhs)[i];
2119 }
2120 //*************************************************************************************************
2121 
2122 
2123 //*************************************************************************************************
2134 template< typename Type // Data type of the vector
2135  , size_t N // Number of elements
2136  , bool TF > // Transpose flag
2137 template< typename VT > // Type of the right-hand side dense vector
2140 {
2142 
2143  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2144 
2145  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2146 
2147  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2148  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2149 
2150  size_t i( 0UL );
2151 
2152  for( ; i<ipos; i+=SIMDSIZE ) {
2153  store( i, (~rhs).load(i) );
2154  }
2155  for( ; remainder && i<size_; ++i ) {
2156  v_[i] = (~rhs)[i];
2157  }
2158 }
2159 //*************************************************************************************************
2160 
2161 
2162 //*************************************************************************************************
2173 template< typename Type // Data type of the vector
2174  , size_t N // Number of elements
2175  , bool TF > // Transpose flag
2176 template< typename VT > // Type of the right-hand side sparse vector
2178 {
2179  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2180 
2181  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2182  v_[element->index()] = element->value();
2183 }
2184 //*************************************************************************************************
2185 
2186 
2187 //*************************************************************************************************
2198 template< typename Type // Data type of the vector
2199  , size_t N // Number of elements
2200  , bool TF > // Transpose flag
2201 template< typename VT > // Type of the right-hand side dense vector
2202 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2204 {
2205  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2206 
2207  for( size_t i=0UL; i<size_; ++i )
2208  v_[i] += (~rhs)[i];
2209 }
2210 //*************************************************************************************************
2211 
2212 
2213 //*************************************************************************************************
2224 template< typename Type // Data type of the vector
2225  , size_t N // Number of elements
2226  , bool TF > // Transpose flag
2227 template< typename VT > // Type of the right-hand side dense vector
2228 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2230 {
2232 
2233  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2234 
2235  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2236 
2237  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2238  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2239 
2240  size_t i( 0UL );
2241 
2242  for( ; i<ipos; i+=SIMDSIZE ) {
2243  store( i, load(i) + (~rhs).load(i) );
2244  }
2245  for( ; remainder && i<size_; ++i ) {
2246  v_[i] += (~rhs)[i];
2247  }
2248 }
2249 //*************************************************************************************************
2250 
2251 
2252 //*************************************************************************************************
2263 template< typename Type // Data type of the vector
2264  , size_t N // Number of elements
2265  , bool TF > // Transpose flag
2266 template< typename VT > // Type of the right-hand side sparse vector
2268 {
2269  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2270 
2271  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2272  v_[element->index()] += element->value();
2273 }
2274 //*************************************************************************************************
2275 
2276 
2277 //*************************************************************************************************
2288 template< typename Type // Data type of the vector
2289  , size_t N // Number of elements
2290  , bool TF > // Transpose flag
2291 template< typename VT > // Type of the right-hand side dense vector
2292 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2294 {
2295  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2296 
2297  for( size_t i=0UL; i<size_; ++i )
2298  v_[i] -= (~rhs)[i];
2299 }
2300 //*************************************************************************************************
2301 
2302 
2303 //*************************************************************************************************
2314 template< typename Type // Data type of the vector
2315  , size_t N // Number of elements
2316  , bool TF > // Transpose flag
2317 template< typename VT > // Type of the right-hand side dense vector
2318 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2320 {
2322 
2323  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2324 
2325  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2326 
2327  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2328  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2329 
2330  size_t i( 0UL );
2331 
2332  for( ; i<ipos; i+=SIMDSIZE ) {
2333  store( i, load(i) - (~rhs).load(i) );
2334  }
2335  for( ; remainder && i<size_; ++i ) {
2336  v_[i] -= (~rhs)[i];
2337  }
2338 }
2339 //*************************************************************************************************
2340 
2341 
2342 //*************************************************************************************************
2353 template< typename Type // Data type of the vector
2354  , size_t N // Number of elements
2355  , bool TF > // Transpose flag
2356 template< typename VT > // Type of the right-hand side sparse vector
2358 {
2359  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2360 
2361  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2362  v_[element->index()] -= element->value();
2363 }
2364 //*************************************************************************************************
2365 
2366 
2367 //*************************************************************************************************
2378 template< typename Type // Data type of the vector
2379  , size_t N // Number of elements
2380  , bool TF > // Transpose flag
2381 template< typename VT > // Type of the right-hand side dense vector
2382 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2384 {
2385  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2386 
2387  for( size_t i=0UL; i<size_; ++i )
2388  v_[i] *= (~rhs)[i];
2389 }
2390 //*************************************************************************************************
2391 
2392 
2393 //*************************************************************************************************
2404 template< typename Type // Data type of the vector
2405  , size_t N // Number of elements
2406  , bool TF > // Transpose flag
2407 template< typename VT > // Type of the right-hand side dense vector
2408 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2410 {
2412 
2413  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2414 
2415  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2416 
2417  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
2418  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2419 
2420  size_t i( 0UL );
2421 
2422  for( ; i<ipos; i+=SIMDSIZE ) {
2423  store( i, load(i) * (~rhs).load(i) );
2424  }
2425  for( ; remainder && i<size_; ++i ) {
2426  v_[i] *= (~rhs)[i];
2427  }
2428 }
2429 //*************************************************************************************************
2430 
2431 
2432 //*************************************************************************************************
2443 template< typename Type // Data type of the vector
2444  , size_t N // Number of elements
2445  , bool TF > // Transpose flag
2446 template< typename VT > // Type of the right-hand side sparse vector
2448 {
2449  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2450 
2451  const HybridVector tmp( serial( *this ) );
2452 
2453  reset();
2454 
2455  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2456  v_[element->index()] = tmp[element->index()] * element->value();
2457 }
2458 //*************************************************************************************************
2459 
2460 
2461 //*************************************************************************************************
2472 template< typename Type // Data type of the vector
2473  , size_t N // Number of elements
2474  , bool TF > // Transpose flag
2475 template< typename VT > // Type of the right-hand side dense vector
2476 inline DisableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2478 {
2479  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2480 
2481  for( size_t i=0UL; i<size_; ++i )
2482  v_[i] /= (~rhs)[i];
2483 }
2484 //*************************************************************************************************
2485 
2486 
2487 //*************************************************************************************************
2498 template< typename Type // Data type of the vector
2499  , size_t N // Number of elements
2500  , bool TF > // Transpose flag
2501 template< typename VT > // Type of the right-hand side dense vector
2502 inline EnableIf_<typename HybridVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2504 {
2506 
2507  BLAZE_INTERNAL_ASSERT( (~rhs).size() == size_, "Invalid vector sizes" );
2508 
2509  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2510  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2511 
2512  size_t i( 0UL );
2513 
2514  for( ; i<ipos; i+=SIMDSIZE ) {
2515  store( i, load(i) / (~rhs).load(i) );
2516  }
2517  for( ; i<size_; ++i ) {
2518  v_[i] /= (~rhs)[i];
2519  }
2520 }
2521 //*************************************************************************************************
2522 
2523 
2524 
2525 
2526 
2527 
2528 
2529 
2530 //=================================================================================================
2531 //
2532 // UNDEFINED CLASS TEMPLATE SPECIALIZATION
2533 //
2534 //=================================================================================================
2535 
2536 //*************************************************************************************************
2544 template< typename Type // Data type of the vector
2545  , bool TF > // Transpose flag
2546 class HybridVector<Type,0UL,TF>;
2548 //*************************************************************************************************
2549 
2550 
2551 
2552 
2553 
2554 
2555 
2556 
2557 //=================================================================================================
2558 //
2559 // HYBRIDVECTOR OPERATORS
2560 //
2561 //=================================================================================================
2562 
2563 //*************************************************************************************************
2566 template< typename Type, size_t N, bool TF >
2567 inline void reset( HybridVector<Type,N,TF>& v );
2568 
2569 template< typename Type, size_t N, bool TF >
2570 inline void clear( HybridVector<Type,N,TF>& v );
2571 
2572 template< bool RF, typename Type, size_t N, bool TF >
2573 inline bool isDefault( const HybridVector<Type,N,TF>& v );
2574 
2575 template< typename Type, size_t N, bool TF >
2576 inline bool isIntact( const HybridVector<Type,N,TF>& v );
2577 
2578 template< typename Type, size_t N, bool TF >
2579 inline void swap( HybridVector<Type,N,TF>& a, HybridVector<Type,N,TF>& b ) noexcept;
2581 //*************************************************************************************************
2582 
2583 
2584 //*************************************************************************************************
2591 template< typename Type // Data type of the vector
2592  , size_t N // Number of elements
2593  , bool TF > // Transpose flag
2595 {
2596  v.reset();
2597 }
2598 //*************************************************************************************************
2599 
2600 
2601 //*************************************************************************************************
2608 template< typename Type // Data type of the vector
2609  , size_t N // Number of elements
2610  , bool TF > // Transpose flag
2612 {
2613  v.clear();
2614 }
2615 //*************************************************************************************************
2616 
2617 
2618 //*************************************************************************************************
2642 template< bool RF // Relaxation flag
2643  , typename Type // Data type of the vector
2644  , size_t N // Number of elements
2645  , bool TF > // Transpose flag
2646 inline bool isDefault( const HybridVector<Type,N,TF>& v )
2647 {
2648  return ( v.size() == 0UL );
2649 }
2650 //*************************************************************************************************
2651 
2652 
2653 //*************************************************************************************************
2671 template< typename Type // Data type of the vector
2672  , size_t N // Number of elements
2673  , bool TF > // Transpose flag
2674 inline bool isIntact( const HybridVector<Type,N,TF>& v )
2675 {
2676  return v.isIntact();
2677 }
2678 //*************************************************************************************************
2679 
2680 
2681 //*************************************************************************************************
2689 template< typename Type // Data type of the vector
2690  , size_t N // Number of elements
2691  , bool TF > // Transpose flag
2693 {
2694  a.swap( b );
2695 }
2696 //*************************************************************************************************
2697 
2698 
2699 
2700 
2701 //=================================================================================================
2702 //
2703 // HASCONSTDATAACCESS SPECIALIZATIONS
2704 //
2705 //=================================================================================================
2706 
2707 //*************************************************************************************************
2709 template< typename T, size_t N, bool TF >
2710 struct HasConstDataAccess< HybridVector<T,N,TF> > : public TrueType
2711 {};
2713 //*************************************************************************************************
2714 
2715 
2716 
2717 
2718 //=================================================================================================
2719 //
2720 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2721 //
2722 //=================================================================================================
2723 
2724 //*************************************************************************************************
2726 template< typename T, size_t N, bool TF >
2727 struct HasMutableDataAccess< HybridVector<T,N,TF> > : public TrueType
2728 {};
2730 //*************************************************************************************************
2731 
2732 
2733 
2734 
2735 //=================================================================================================
2736 //
2737 // ISALIGNED SPECIALIZATIONS
2738 //
2739 //=================================================================================================
2740 
2741 //*************************************************************************************************
2743 template< typename T, size_t N, bool TF >
2744 struct IsAligned< HybridVector<T,N,TF> > : public TrueType
2745 {};
2747 //*************************************************************************************************
2748 
2749 
2750 
2751 
2752 //=================================================================================================
2753 //
2754 // ISPADDED SPECIALIZATIONS
2755 //
2756 //=================================================================================================
2757 
2758 //*************************************************************************************************
2760 template< typename T, size_t N, bool TF >
2761 struct IsPadded< HybridVector<T,N,TF> > : public BoolConstant<usePadding>
2762 {};
2764 //*************************************************************************************************
2765 
2766 
2767 
2768 
2769 //=================================================================================================
2770 //
2771 // ISRESIZABLE SPECIALIZATIONS
2772 //
2773 //=================================================================================================
2774 
2775 //*************************************************************************************************
2777 template< typename T, size_t N, bool TF >
2778 struct IsResizable< HybridVector<T,N,TF> > : public TrueType
2779 {};
2781 //*************************************************************************************************
2782 
2783 
2784 
2785 
2786 //=================================================================================================
2787 //
2788 // ADDTRAIT SPECIALIZATIONS
2789 //
2790 //=================================================================================================
2791 
2792 //*************************************************************************************************
2794 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2795 struct AddTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2796 {
2797  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2798 };
2799 
2800 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2801 struct AddTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2802 {
2803  using Type = StaticVector< AddTrait_<T1,T2>, M, TF >;
2804 };
2805 
2806 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2807 struct AddTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2808 {
2809  using Type = HybridVector< AddTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2810 };
2812 //*************************************************************************************************
2813 
2814 
2815 
2816 
2817 //=================================================================================================
2818 //
2819 // SUBTRAIT SPECIALIZATIONS
2820 //
2821 //=================================================================================================
2822 
2823 //*************************************************************************************************
2825 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2826 struct SubTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2827 {
2828  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2829 };
2830 
2831 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2832 struct SubTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2833 {
2834  using Type = StaticVector< SubTrait_<T1,T2>, M, TF >;
2835 };
2836 
2837 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2838 struct SubTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2839 {
2840  using Type = HybridVector< SubTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2841 };
2843 //*************************************************************************************************
2844 
2845 
2846 
2847 
2848 //=================================================================================================
2849 //
2850 // MULTTRAIT SPECIALIZATIONS
2851 //
2852 //=================================================================================================
2853 
2854 //*************************************************************************************************
2856 template< typename T1, size_t N, bool TF, typename T2 >
2857 struct MultTrait< HybridVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2858 {
2859  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
2860 };
2861 
2862 template< typename T1, typename T2, size_t N, bool TF >
2863 struct MultTrait< T1, HybridVector<T2,N,TF>, EnableIf_<IsNumeric<T1> > >
2864 {
2865  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
2866 };
2867 
2868 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2869 struct MultTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2870 {
2871  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2872 };
2873 
2874 template< typename T1, size_t M, typename T2, size_t N >
2875 struct MultTrait< HybridVector<T1,M,false>, StaticVector<T2,N,true> >
2876 {
2877  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2878 };
2879 
2880 template< typename T1, size_t M, typename T2, size_t N >
2881 struct MultTrait< HybridVector<T1,M,true>, StaticVector<T2,N,false> >
2882 {
2883  using Type = MultTrait_<T1,T2>;
2884 };
2885 
2886 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2887 struct MultTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2888 {
2889  using Type = StaticVector< MultTrait_<T1,T2>, M, TF >;
2890 };
2891 
2892 template< typename T1, size_t M, typename T2, size_t N >
2893 struct MultTrait< StaticVector<T1,M,false>, HybridVector<T2,N,true> >
2894 {
2895  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2896 };
2897 
2898 template< typename T1, size_t M, typename T2, size_t N >
2899 struct MultTrait< StaticVector<T1,M,true>, HybridVector<T2,N,false> >
2900 {
2901  using Type = MultTrait_<T1,T2>;
2902 };
2903 
2904 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2905 struct MultTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2906 {
2907  using Type = HybridVector< MultTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
2908 };
2909 
2910 template< typename T1, size_t M, typename T2, size_t N >
2911 struct MultTrait< HybridVector<T1,M,false>, HybridVector<T2,N,true> >
2912 {
2913  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
2914 };
2915 
2916 template< typename T1, size_t M, typename T2, size_t N >
2917 struct MultTrait< HybridVector<T1,M,true>, HybridVector<T2,N,false> >
2918 {
2919  using Type = MultTrait_<T1,T2>;
2920 };
2922 //*************************************************************************************************
2923 
2924 
2925 
2926 
2927 //=================================================================================================
2928 //
2929 // CROSSTRAIT SPECIALIZATIONS
2930 //
2931 //=================================================================================================
2932 
2933 //*************************************************************************************************
2935 template< typename T1, size_t N, bool TF, typename T2 >
2936 struct CrossTrait< HybridVector<T1,N,TF>, StaticVector<T2,3UL,TF> >
2937 {
2938  private:
2939  using T = MultTrait_<T1,T2>;
2940 
2941  public:
2942  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2943 };
2944 
2945 template< typename T1, bool TF, typename T2, size_t N >
2946 struct CrossTrait< StaticVector<T1,3UL,TF>, HybridVector<T2,N,TF> >
2947 {
2948  private:
2949  using T = MultTrait_<T1,T2>;
2950 
2951  public:
2952  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2953 };
2954 
2955 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2956 struct CrossTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2957 {
2958  private:
2959  using T = MultTrait_<T1,T2>;
2960 
2961  public:
2962  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2963 };
2965 //*************************************************************************************************
2966 
2967 
2968 
2969 
2970 //=================================================================================================
2971 //
2972 // DIVTRAIT SPECIALIZATIONS
2973 //
2974 //=================================================================================================
2975 
2976 //*************************************************************************************************
2978 template< typename T1, size_t N, bool TF, typename T2 >
2979 struct DivTrait< HybridVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2980 {
2981  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
2982 };
2983 
2984 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2985 struct DivTrait< HybridVector<T1,M,TF>, StaticVector<T2,N,TF> >
2986 {
2987  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2988 };
2989 
2990 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2991 struct DivTrait< StaticVector<T1,M,TF>, HybridVector<T2,N,TF> >
2992 {
2993  using Type = StaticVector< DivTrait_<T1,T2>, M, TF >;
2994 };
2995 
2996 template< typename T1, size_t M, bool TF, typename T2, size_t N >
2997 struct DivTrait< HybridVector<T1,M,TF>, HybridVector<T2,N,TF> >
2998 {
2999  using Type = HybridVector< DivTrait_<T1,T2>, ( M < N )?( M ):( N ), TF >;
3000 };
3002 //*************************************************************************************************
3003 
3004 
3005 
3006 
3007 //=================================================================================================
3008 //
3009 // HIGHTYPE SPECIALIZATIONS
3010 //
3011 //=================================================================================================
3012 
3013 //*************************************************************************************************
3015 template< typename T1, size_t N, bool TF, typename T2 >
3016 struct HighType< HybridVector<T1,N,TF>, HybridVector<T2,N,TF> >
3017 {
3018  using Type = StaticVector< typename HighType<T1,T2>::Type, N, TF >;
3019 };
3021 //*************************************************************************************************
3022 
3023 
3024 
3025 
3026 //=================================================================================================
3027 //
3028 // LOWTYPE SPECIALIZATIONS
3029 //
3030 //=================================================================================================
3031 
3032 //*************************************************************************************************
3034 template< typename T1, size_t N, bool TF, typename T2 >
3035 struct LowType< HybridVector<T1,N,TF>, HybridVector<T2,N,TF> >
3036 {
3037  using Type = StaticVector< typename LowType<T1,T2>::Type, N, TF >;
3038 };
3040 //*************************************************************************************************
3041 
3042 
3043 
3044 
3045 //=================================================================================================
3046 //
3047 // SUBVECTORTRAIT SPECIALIZATIONS
3048 //
3049 //=================================================================================================
3050 
3051 //*************************************************************************************************
3053 template< typename T1, size_t N, bool TF >
3054 struct SubvectorTrait< HybridVector<T1,N,TF> >
3055 {
3056  using Type = HybridVector<T1,N,TF>;
3057 };
3059 //*************************************************************************************************
3060 
3061 } // namespace blaze
3062 
3063 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:133
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:79
Availability of a SIMD subtraction for the given data types.Depending on the available instruction se...
Definition: HasSIMDSub.h:163
Header file for mathematical functions.
constexpr bool useOptimizedKernels
Configuration switch for optimized kernels.This configuration switch enables/disables all optimized c...
Definition: Optimizations.h:84
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:1560
Header file for the alignment flag values.
Header file for the UNUSED_PARAMETER function template.
HybridVector()
The default constructor for HybridVector.
Definition: HybridVector.h:513
Header file for the subtraction trait.
Header file for basic type definitions.
Header file for the SparseVector base class.
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: HybridVector.h:473
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:1339
Availability of a SIMD multiplication for the given data types.Depending on the available instruction...
Definition: HasSIMDMult.h:162
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:315
Iterator end() noexcept
Returns an iterator just past the last element of the hybrid vector.
Definition: HybridVector.h:982
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
Type ElementType
Type of the vector elements.
Definition: HybridVector.h:181
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: HybridVector.h:1410
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:163
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: HybridVector.h:905
#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
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
Header file for memory allocation and deallocation functionality.
HybridVector< Type, NewN, TF > Other
The type of the other HybridVector.
Definition: HybridVector.h:209
System settings for performance optimizations.
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:204
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:1321
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:1425
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:77
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1802
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: HybridVector.h:1862
SIMDTrait_< ElementType > SIMDType
SIMD type of the vector elements.
Definition: HybridVector.h:182
Constraint on the data type.
Base template for the CrossTrait class.
Definition: CrossTrait.h:110
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
HybridVector< Type, N,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: HybridVector.h:180
Rebind mechanism to obtain a HybridVector with different data/element type.
Definition: HybridVector.h:199
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: HybridVector.h:818
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: HybridVector.h:2049
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 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:5635
Compile time assertion.
constexpr bool defaultTransposeFlag
The default transpose flag for all vectors of the Blaze library.This value specifies the default tran...
Definition: TransposeFlag.h:56
Header file for all forward declarations of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:76
DenseIterator< Type, aligned > Iterator
Iterator over non-constant elements.
Definition: HybridVector.h:191
#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:937
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: HybridVector.h:1928
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:144
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:78
Header file for the IsAligned type trait.
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: HybridVector.h:2016
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
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:1961
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: HybridVector.h:1904
const Type * ConstPointer
Pointer to a constant vector value.
Definition: HybridVector.h:189
DenseIterator< const Type, aligned > ConstIterator
Iterator over constant elements.
Definition: HybridVector.h:192
void clear()
Clearing the vector.
Definition: HybridVector.h:1484
const Type & ReturnType
Return type for expression template evaluations.
Definition: HybridVector.h:183
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the IsPadded type trait.
HybridVector< NewType, N, TF > Other
The type of the other HybridVector.
Definition: HybridVector.h:200
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
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:1525
size_t size_
The current size/dimension of the vector.
Definition: HybridVector.h:479
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:1014
Header file for the IsSIMDCombinable type trait.
Header file for the IsSparseVector type trait.
Header file for the HasSIMDMult type 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:261
const HybridVector & CompositeType
Data type for composite expression templates.
Definition: HybridVector.h:184
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:1285
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:143
HybridVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: HybridVector.h:1039
Base template for the MultTrait class.
Definition: MultTrait.h:143
Type * Pointer
Pointer to a non-constant vector value.
Definition: HybridVector.h:188
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:1881
bool isIntact() const noexcept
Returns whether the invariants of the hybrid vector are intact.
Definition: HybridVector.h:1802
Constraint on the data type.
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the hybrid vector.
Definition: HybridVector.h:967
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:2081
Constraint on the data type.
Header file for the HasSIMDSub type trait.
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:1577
EnableIf_< IsBuiltin< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:225
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Base template for the DivTrait class.
Definition: DivTrait.h:143
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition: Storeu.h:76
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
Type & Reference
Reference to a non-constant vector value.
Definition: HybridVector.h:186
void reset()
Reset to the default initial values.
Definition: HybridVector.h:1465
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
Reference at(size_t index)
Checked access to the vector elements.
Definition: HybridVector.h:861
constexpr bool usePadding
Configuration of the padding of dense vectors and matrices.This configuration switch enables/disables...
Definition: Optimizations.h:52
Resize mechanism to obtain a HybridVector with a different fixed number of elements.
Definition: HybridVector.h:208
Header file for the HasSIMDDiv type trait.
HybridVector< Type, N, TF > This
Type of this HybridVector instance.
Definition: HybridVector.h:177
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:164
const Type & ConstReference
Reference to a constant vector value.
Definition: HybridVector.h:187
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:120
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:573
Base template for the SubTrait class.
Definition: SubTrait.h:143
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:1303
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:1992
Header file for the IsResizable type trait.
System settings for the inline keywords.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: HybridVector.h:1443
DenseVector< This, TF > BaseType
Base type of this HybridVector instance.
Definition: HybridVector.h:178
Header file for the HighType type trait.
Header file for the TrueType type/value trait base class.
This ResultType
Result type for expression template evaluations.
Definition: HybridVector.h:179
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: HybridVector.h:1841