StaticVector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_DENSE_STATICVECTOR_H_
36 #define _BLAZE_MATH_DENSE_STATICVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <utility>
45 #include <blaze/math/Aliases.h>
48 #include <blaze/math/Exception.h>
51 #include <blaze/math/Forward.h>
53 #include <blaze/math/shims/Clear.h>
56 #include <blaze/math/SIMD.h>
75 #include <blaze/system/Inline.h>
80 #include <blaze/util/Assert.h>
86 #include <blaze/util/DisableIf.h>
87 #include <blaze/util/EnableIf.h>
89 #include <blaze/util/Memory.h>
91 #include <blaze/util/mpl/SizeT.h>
93 #include <blaze/util/Template.h>
94 #include <blaze/util/TrueType.h>
95 #include <blaze/util/Types.h>
98 #include <blaze/util/Unused.h>
99 
100 
101 namespace blaze {
102 
103 //=================================================================================================
104 //
105 // CLASS DEFINITION
106 //
107 //=================================================================================================
108 
109 //*************************************************************************************************
175 template< typename Type // Data type of the vector
176  , size_t N // Number of elements
177  , bool TF = defaultTransposeFlag > // Transpose flag
178 class StaticVector : public DenseVector< StaticVector<Type,N,TF>, TF >
179 {
180  public:
181  //**Type definitions****************************************************************************
184  typedef This ResultType;
186  typedef Type ElementType;
188  typedef const Type& ReturnType;
189  typedef const StaticVector& CompositeType;
190 
191  typedef Type& Reference;
192  typedef const Type& ConstReference;
193  typedef Type* Pointer;
194  typedef const Type* ConstPointer;
195 
198  //**********************************************************************************************
199 
200  //**Rebind struct definition********************************************************************
203  template< typename ET > // Data type of the other vector
204  struct Rebind {
206  };
207  //**********************************************************************************************
208 
209  //**Compilation flags***************************************************************************
211 
215  enum : bool { simdEnabled = IsVectorizable<Type>::value };
216 
218 
221  enum : bool { smpAssignable = false };
222  //**********************************************************************************************
223 
224  //**Constructors********************************************************************************
227  explicit inline StaticVector();
228  explicit inline StaticVector( const Type& init );
229  explicit inline StaticVector( initializer_list<Type> list );
230 
231  template< typename Other >
232  explicit inline StaticVector( size_t n, const Other* array );
233 
234  template< typename Other >
235  explicit inline StaticVector( const Other (&array)[N] );
236 
237  inline StaticVector( const StaticVector& v );
238  template< typename Other > inline StaticVector( const StaticVector<Other,N,TF>& v );
239  template< typename VT > inline StaticVector( const Vector<VT,TF>& v );
241  //**********************************************************************************************
242 
243  //**Destructor**********************************************************************************
244  // No explicitly declared destructor.
245  //**********************************************************************************************
246 
247  //**Data access functions***********************************************************************
250  inline Reference operator[]( size_t index ) noexcept;
251  inline ConstReference operator[]( size_t index ) const noexcept;
252  inline Reference at( size_t index );
253  inline ConstReference at( size_t index ) const;
254  inline Pointer data () noexcept;
255  inline ConstPointer data () const noexcept;
256  inline Iterator begin () noexcept;
257  inline ConstIterator begin () const noexcept;
258  inline ConstIterator cbegin() const noexcept;
259  inline Iterator end () noexcept;
260  inline ConstIterator end () const noexcept;
261  inline ConstIterator cend () const noexcept;
263  //**********************************************************************************************
264 
265  //**Assignment operators************************************************************************
268  inline StaticVector& operator=( const Type& rhs );
269  inline StaticVector& operator=( initializer_list<Type> list );
270 
271  template< typename Other >
272  inline StaticVector& operator=( const Other (&array)[N] );
273 
274  inline StaticVector& operator=( const StaticVector& rhs );
275  template< typename Other > inline StaticVector& operator=( const StaticVector<Other,N,TF>& rhs );
276 
277  template< typename VT > inline StaticVector& operator= ( const Vector<VT,TF>& rhs );
278  template< typename VT > inline StaticVector& operator+=( const Vector<VT,TF>& rhs );
279  template< typename VT > inline StaticVector& operator-=( const Vector<VT,TF>& rhs );
280  template< typename VT > inline StaticVector& operator*=( const Vector<VT,TF>& rhs );
281  template< typename VT > inline StaticVector& operator/=( const DenseVector<VT,TF>& rhs );
282 
283  template< typename Other >
284  inline EnableIf_<IsNumeric<Other>, StaticVector >& operator*=( Other rhs );
285 
286  template< typename Other >
287  inline EnableIf_<IsNumeric<Other>, StaticVector >& operator/=( Other rhs );
289  //**********************************************************************************************
290 
291  //**Utility functions***************************************************************************
294  inline constexpr size_t size() const noexcept;
295  inline constexpr size_t capacity() const noexcept;
296  inline size_t nonZeros() const;
297  inline void reset();
298  template< typename Other > inline StaticVector& scale( const Other& scalar );
299  inline void swap( StaticVector& v ) noexcept;
301  //**********************************************************************************************
302 
303  //**Memory functions****************************************************************************
306  static inline void* operator new ( std::size_t size );
307  static inline void* operator new[]( std::size_t size );
308  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
309  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
310 
311  static inline void operator delete ( void* ptr );
312  static inline void operator delete[]( void* ptr );
313  static inline void operator delete ( void* ptr, const std::nothrow_t& );
314  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
316  //**********************************************************************************************
317 
318  private:
319  //**********************************************************************************************
321  template< typename VT >
323  struct VectorizedAssign {
324  enum : bool { value = useOptimizedKernels &&
325  simdEnabled && VT::simdEnabled &&
326  AreSIMDCombinable< Type, ElementType_<VT> >::value };
327  };
329  //**********************************************************************************************
330 
331  //**********************************************************************************************
333  template< typename VT >
335  struct VectorizedAddAssign {
336  enum : bool { value = useOptimizedKernels &&
337  simdEnabled && VT::simdEnabled &&
338  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
339  HasSIMDAdd< Type, ElementType_<VT> >::value };
340  };
342  //**********************************************************************************************
343 
344  //**********************************************************************************************
346  template< typename VT >
348  struct VectorizedSubAssign {
349  enum : bool { value = useOptimizedKernels &&
350  simdEnabled && VT::simdEnabled &&
351  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
352  HasSIMDSub< Type, ElementType_<VT> >::value };
353  };
355  //**********************************************************************************************
356 
357  //**********************************************************************************************
359  template< typename VT >
361  struct VectorizedMultAssign {
362  enum : bool { value = useOptimizedKernels &&
363  simdEnabled && VT::simdEnabled &&
364  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
365  HasSIMDMult< Type, ElementType_<VT> >::value };
366  };
368  //**********************************************************************************************
369 
370  //**********************************************************************************************
372  template< typename VT >
374  struct VectorizedDivAssign {
375  enum : bool { value = useOptimizedKernels &&
376  simdEnabled && VT::simdEnabled &&
377  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
378  HasSIMDDiv< Type, ElementType_<VT> >::value };
379  };
381  //**********************************************************************************************
382 
383  //**********************************************************************************************
385  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
386  //**********************************************************************************************
387 
388  public:
389  //**Debugging functions*************************************************************************
392  inline bool isIntact() const noexcept;
394  //**********************************************************************************************
395 
396  //**Expression template evaluation functions****************************************************
399  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
400  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
401 
402  inline bool isAligned() const noexcept;
403 
404  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
405  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
406  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
407 
408  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
409  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
410  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
411  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
412 
413  template< typename VT >
414  inline DisableIf_< VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
415 
416  template< typename VT >
417  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
418 
419  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
420 
421  template< typename VT >
422  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
423 
424  template< typename VT >
425  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
426 
427  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
428 
429  template< typename VT >
430  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
431 
432  template< typename VT >
433  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
434 
435  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
436 
437  template< typename VT >
438  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
439 
440  template< typename VT >
441  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
442 
443  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
444 
445  template< typename VT >
446  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
447 
448  template< typename VT >
449  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
451  //**********************************************************************************************
452 
453  private:
454  //**********************************************************************************************
456  enum : size_t { NN = ( usePadding )?( NextMultiple< SizeT<N>, SizeT<SIMDSIZE> >::value ):( N ) };
457  //**********************************************************************************************
458 
459  //**Member variables****************************************************************************
463 
469  //**********************************************************************************************
470 
471  //**Compile time checks*************************************************************************
477  BLAZE_STATIC_ASSERT( !usePadding || ( NN % SIMDSIZE == 0UL ) );
478  BLAZE_STATIC_ASSERT( NN >= N );
480  //**********************************************************************************************
481 };
482 //*************************************************************************************************
483 
484 
485 
486 
487 //=================================================================================================
488 //
489 // CONSTRUCTORS
490 //
491 //=================================================================================================
492 
493 //*************************************************************************************************
498 template< typename Type // Data type of the vector
499  , size_t N // Number of elements
500  , bool TF > // Transpose flag
502  : v_() // The statically allocated vector elements
503 {
505 
506  if( IsNumeric<Type>::value ) {
507  for( size_t i=0UL; i<NN; ++i )
508  v_[i] = Type();
509  }
510 
511  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
512 }
513 //*************************************************************************************************
514 
515 
516 //*************************************************************************************************
521 template< typename Type // Data type of the vector
522  , size_t N // Number of elements
523  , bool TF > // Transpose flag
524 inline StaticVector<Type,N,TF>::StaticVector( const Type& init )
525  : v_() // The statically allocated vector elements
526 {
528 
529  for( size_t i=0UL; i<N; ++i )
530  v_[i] = init;
531 
532  for( size_t i=N; i<NN; ++i )
533  v_[i] = Type();
534 
535  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
536 }
537 //*************************************************************************************************
538 
539 
540 //*************************************************************************************************
557 template< typename Type // Data type of the vector
558  , size_t N // Number of elements
559  , bool TF > // Transpose flag
561  : v_() // The statically allocated vector elements
562 {
564 
565  if( list.size() > N ) {
566  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
567  }
568 
569  std::fill( std::copy( list.begin(), list.end(), v_.data() ), v_.data()+NN, Type() );
570 
571  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
572 }
573 //*************************************************************************************************
574 
575 
576 //*************************************************************************************************
598 template< typename Type // Data type of the vector
599  , size_t N // Number of elements
600  , bool TF > // Transpose flag
601 template< typename Other > // Data type of the initialization array
602 inline StaticVector<Type,N,TF>::StaticVector( size_t n, const Other* array )
603  : v_() // The statically allocated vector elements
604 {
606 
607  if( n > N ) {
608  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
609  }
610 
611  for( size_t i=0UL; i<n; ++i )
612  v_[i] = array[i];
613 
614  if( IsNumeric<Type>::value ) {
615  for( size_t i=n; i<NN; ++i )
616  v_[i] = Type();
617  }
618 
619  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
620 }
621 //*************************************************************************************************
622 
623 
624 //*************************************************************************************************
640 template< typename Type // Data type of the vector
641  , size_t N // Number of elements
642  , bool TF > // Transpose flag
643 template< typename Other > // Data type of the initialization array
644 inline StaticVector<Type,N,TF>::StaticVector( const Other (&array)[N] )
645  : v_() // The statically allocated vector elements
646 {
648 
649  for( size_t i=0UL; i<N; ++i )
650  v_[i] = array[i];
651 
652  for( size_t i=N; i<NN; ++i )
653  v_[i] = Type();
654 
655  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
656 }
657 //*************************************************************************************************
658 
659 
660 //*************************************************************************************************
667 template< typename Type // Data type of the vector
668  , size_t N // Number of elements
669  , bool TF > // Transpose flag
671  : v_() // The statically allocated vector elements
672 {
674 
675  for( size_t i=0UL; i<NN; ++i )
676  v_[i] = v.v_[i];
677 
678  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
679 }
680 //*************************************************************************************************
681 
682 
683 //*************************************************************************************************
688 template< typename Type // Data type of the vector
689  , size_t N // Number of elements
690  , bool TF > // Transpose flag
691 template< typename Other > // Data type of the foreign vector
693  : v_() // The statically allocated vector elements
694 {
696 
697  for( size_t i=0UL; i<N; ++i )
698  v_[i] = v[i];
699 
700  for( size_t i=N; i<NN; ++i )
701  v_[i] = Type();
702 
703  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
704 }
705 //*************************************************************************************************
706 
707 
708 //*************************************************************************************************
718 template< typename Type // Data type of the vector
719  , size_t N // Number of elements
720  , bool TF > // Transpose flag
721 template< typename VT > // Type of the foreign vector
723  : v_() // The statically allocated vector elements
724 {
725  using blaze::assign;
726 
728 
729  if( (~v).size() != N ) {
730  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
731  }
732 
733  for( size_t i=( IsSparseVector<VT>::value ? 0UL : N ); i<NN; ++i ) {
734  v_[i] = Type();
735  }
736 
737  assign( *this, ~v );
738 
739  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
740 }
741 //*************************************************************************************************
742 
743 
744 
745 
746 //=================================================================================================
747 //
748 // DATA ACCESS FUNCTIONS
749 //
750 //=================================================================================================
751 
752 //*************************************************************************************************
761 template< typename Type // Data type of the vector
762  , size_t N // Number of elements
763  , bool TF > // Transpose flag
765  StaticVector<Type,N,TF>::operator[]( size_t index ) noexcept
766 {
767  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
768  return v_[index];
769 }
770 //*************************************************************************************************
771 
772 
773 //*************************************************************************************************
782 template< typename Type // Data type of the vector
783  , size_t N // Number of elements
784  , bool TF > // Transpose flag
786  StaticVector<Type,N,TF>::operator[]( size_t index ) const noexcept
787 {
788  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
789  return v_[index];
790 }
791 //*************************************************************************************************
792 
793 
794 //*************************************************************************************************
804 template< typename Type // Data type of the vector
805  , size_t N // Number of elements
806  , bool TF > // Transpose flag
809 {
810  if( index >= N ) {
811  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
812  }
813  return (*this)[index];
814 }
815 //*************************************************************************************************
816 
817 
818 //*************************************************************************************************
828 template< typename Type // Data type of the vector
829  , size_t N // Number of elements
830  , bool TF > // Transpose flag
832  StaticVector<Type,N,TF>::at( size_t index ) const
833 {
834  if( index >= N ) {
835  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
836  }
837  return (*this)[index];
838 }
839 //*************************************************************************************************
840 
841 
842 //*************************************************************************************************
849 template< typename Type // Data type of the vector
850  , size_t N // Number of elements
851  , bool TF > // Transpose flag
853 {
854  return v_;
855 }
856 //*************************************************************************************************
857 
858 
859 //*************************************************************************************************
866 template< typename Type // Data type of the vector
867  , size_t N // Number of elements
868  , bool TF > // Transpose flag
870 {
871  return v_;
872 }
873 //*************************************************************************************************
874 
875 
876 //*************************************************************************************************
881 template< typename Type // Data type of the vector
882  , size_t N // Number of elements
883  , bool TF > // Transpose flag
885 {
886  return Iterator( v_ );
887 }
888 //*************************************************************************************************
889 
890 
891 //*************************************************************************************************
896 template< typename Type // Data type of the vector
897  , size_t N // Number of elements
898  , bool TF > // Transpose flag
900 {
901  return ConstIterator( v_ );
902 }
903 //*************************************************************************************************
904 
905 
906 //*************************************************************************************************
911 template< typename Type // Data type of the vector
912  , size_t N // Number of elements
913  , bool TF > // Transpose flag
915 {
916  return ConstIterator( v_ );
917 }
918 //*************************************************************************************************
919 
920 
921 //*************************************************************************************************
926 template< typename Type // Data type of the vector
927  , size_t N // Number of elements
928  , bool TF > // Transpose flag
930 {
931  return Iterator( v_ + N );
932 }
933 //*************************************************************************************************
934 
935 
936 //*************************************************************************************************
941 template< typename Type // Data type of the vector
942  , size_t N // Number of elements
943  , bool TF > // Transpose flag
945 {
946  return ConstIterator( v_ + N );
947 }
948 //*************************************************************************************************
949 
950 
951 //*************************************************************************************************
956 template< typename Type // Data type of the vector
957  , size_t N // Number of elements
958  , bool TF > // Transpose flag
960 {
961  return ConstIterator( v_ + N );
962 }
963 //*************************************************************************************************
964 
965 
966 
967 
968 //=================================================================================================
969 //
970 // ASSIGNMENT OPERATORS
971 //
972 //=================================================================================================
973 
974 //*************************************************************************************************
980 template< typename Type // Data type of the vector
981  , size_t N // Number of elements
982  , bool TF > // Transpose flag
984 {
985  for( size_t i=0UL; i<N; ++i )
986  v_[i] = rhs;
987  return *this;
988 }
989 //*************************************************************************************************
990 
991 
992 //*************************************************************************************************
1010 template< typename Type // Data type of the vector
1011  , size_t N // Number of elements
1012  , bool TF > // Transpose flag
1014 {
1015  if( list.size() > N ) {
1016  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to static vector" );
1017  }
1018 
1019  std::fill( std::copy( list.begin(), list.end(), v_.data() ), v_.data()+N, Type() );
1020 
1021  return *this;
1022 }
1023 //*************************************************************************************************
1024 
1025 
1026 //*************************************************************************************************
1043 template< typename Type // Data type of the vector
1044  , size_t N // Number of elements
1045  , bool TF > // Transpose flag
1046 template< typename Other > // Data type of the initialization array
1048 {
1049  for( size_t i=0UL; i<N; ++i )
1050  v_[i] = array[i];
1051  return *this;
1052 }
1053 //*************************************************************************************************
1054 
1055 
1056 //*************************************************************************************************
1064 template< typename Type // Data type of the vector
1065  , size_t N // Number of elements
1066  , bool TF > // Transpose flag
1068 {
1069  using blaze::assign;
1070 
1071  assign( *this, ~rhs );
1072 
1073  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1074 
1075  return *this;
1076 }
1077 //*************************************************************************************************
1078 
1079 
1080 //*************************************************************************************************
1086 template< typename Type // Data type of the vector
1087  , size_t N // Number of elements
1088  , bool TF > // Transpose flag
1089 template< typename Other > // Data type of the foreign vector
1091 {
1092  using blaze::assign;
1093 
1094  assign( *this, ~rhs );
1095 
1096  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1097 
1098  return *this;
1099 }
1100 //*************************************************************************************************
1101 
1102 
1103 //*************************************************************************************************
1113 template< typename Type // Data type of the vector
1114  , size_t N // Number of elements
1115  , bool TF > // Transpose flag
1116 template< typename VT > // Type of the right-hand side vector
1118 {
1119  using blaze::assign;
1120 
1121  if( (~rhs).size() != N ) {
1122  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to static vector" );
1123  }
1124 
1125  if( (~rhs).canAlias( this ) ) {
1126  StaticVector tmp( ~rhs );
1127  swap( tmp );
1128  }
1129  else {
1131  reset();
1132  assign( *this, ~rhs );
1133  }
1134 
1135  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1136 
1137  return *this;
1138 }
1139 //*************************************************************************************************
1140 
1141 
1142 //*************************************************************************************************
1152 template< typename Type // Data type of the vector
1153  , size_t N // Number of elements
1154  , bool TF > // Transpose flag
1155 template< typename VT > // Type of the right-hand side vector
1157 {
1158  using blaze::addAssign;
1159 
1160  if( (~rhs).size() != N ) {
1161  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1162  }
1163 
1164  if( (~rhs).canAlias( this ) ) {
1165  StaticVector tmp( ~rhs );
1166  addAssign( *this, tmp );
1167  }
1168  else {
1169  addAssign( *this, ~rhs );
1170  }
1171 
1172  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1173 
1174  return *this;
1175 }
1176 //*************************************************************************************************
1177 
1178 
1179 //*************************************************************************************************
1189 template< typename Type // Data type of the vector
1190  , size_t N // Number of elements
1191  , bool TF > // Transpose flag
1192 template< typename VT > // Type of the right-hand side vector
1194 {
1195  using blaze::subAssign;
1196 
1197  if( (~rhs).size() != N ) {
1198  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1199  }
1200 
1201  if( (~rhs).canAlias( this ) ) {
1202  StaticVector tmp( ~rhs );
1203  subAssign( *this, tmp );
1204  }
1205  else {
1206  subAssign( *this, ~rhs );
1207  }
1208 
1209  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1210 
1211  return *this;
1212 }
1213 //*************************************************************************************************
1214 
1215 
1216 //*************************************************************************************************
1227 template< typename Type // Data type of the vector
1228  , size_t N // Number of elements
1229  , bool TF > // Transpose flag
1230 template< typename VT > // Type of the right-hand side vector
1232 {
1233  using blaze::multAssign;
1234 
1235  if( (~rhs).size() != N ) {
1236  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1237  }
1238 
1239  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1240  const StaticVector tmp( *this * (~rhs) );
1241  this->operator=( tmp );
1242  }
1243  else {
1244  multAssign( *this, ~rhs );
1245  }
1246 
1247  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1248 
1249  return *this;
1250 }
1251 //*************************************************************************************************
1252 
1253 
1254 //*************************************************************************************************
1264 template< typename Type // Data type of the vector
1265  , size_t N // Number of elements
1266  , bool TF > // Transpose flag
1267 template< typename VT > // Type of the right-hand side vector
1269 {
1270  using blaze::divAssign;
1271 
1272  if( (~rhs).size() != N ) {
1273  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1274  }
1275 
1276  if( (~rhs).canAlias( this ) ) {
1277  const StaticVector tmp( *this / (~rhs) );
1278  this->operator=( tmp );
1279  }
1280  else {
1281  divAssign( *this, ~rhs );
1282  }
1283 
1284  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1285 
1286  return *this;
1287 }
1288 //*************************************************************************************************
1289 
1290 
1291 //*************************************************************************************************
1298 template< typename Type // Data type of the vector
1299  , size_t N // Number of elements
1300  , bool TF > // Transpose flag
1301 template< typename Other > // Data type of the right-hand side scalar
1304 {
1305  using blaze::assign;
1306 
1307  assign( *this, (*this) * rhs );
1308 
1309  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1310 
1311  return *this;
1312 }
1313 //*************************************************************************************************
1314 
1315 
1316 //*************************************************************************************************
1325 template< typename Type // Data type of the vector
1326  , size_t N // Number of elements
1327  , bool TF > // Transpose flag
1328 template< typename Other > // Data type of the right-hand side scalar
1329 inline EnableIf_<IsNumeric<Other>, StaticVector<Type,N,TF> >&
1331 {
1332  using blaze::assign;
1333 
1334  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1335 
1336  assign( *this, (*this) / rhs );
1337 
1338  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1339 
1340  return *this;
1341 }
1342 //*************************************************************************************************
1343 
1344 
1345 
1346 
1347 //=================================================================================================
1348 //
1349 // UTILITY FUNCTIONS
1350 //
1351 //=================================================================================================
1352 
1353 //*************************************************************************************************
1358 template< typename Type // Data type of the vector
1359  , size_t N // Number of elements
1360  , bool TF > // Transpose flag
1361 inline constexpr size_t StaticVector<Type,N,TF>::size() const noexcept
1362 {
1363  return N;
1364 }
1365 //*************************************************************************************************
1366 
1367 
1368 //*************************************************************************************************
1373 template< typename Type // Data type of the vector
1374  , size_t N // Number of elements
1375  , bool TF > // Transpose flag
1376 inline constexpr size_t StaticVector<Type,N,TF>::capacity() const noexcept
1377 {
1378  return NN;
1379 }
1380 //*************************************************************************************************
1381 
1382 
1383 //*************************************************************************************************
1391 template< typename Type // Data type of the vector
1392  , size_t N // Number of elements
1393  , bool TF > // Transpose flag
1395 {
1396  size_t nonzeros( 0 );
1397 
1398  for( size_t i=0UL; i<N; ++i ) {
1399  if( !isDefault( v_[i] ) )
1400  ++nonzeros;
1401  }
1402 
1403  return nonzeros;
1404 }
1405 //*************************************************************************************************
1406 
1407 
1408 //*************************************************************************************************
1413 template< typename Type // Data type of the vector
1414  , size_t N // Number of elements
1415  , bool TF > // Transpose flag
1417 {
1418  using blaze::clear;
1419  for( size_t i=0UL; i<N; ++i )
1420  clear( v_[i] );
1421 }
1422 //*************************************************************************************************
1423 
1424 
1425 //*************************************************************************************************
1431 template< typename Type // Data type of the vector
1432  , size_t N // Number of elements
1433  , bool TF > // Transpose flag
1434 template< typename Other > // Data type of the scalar value
1436 {
1437  for( size_t i=0; i<N; ++i )
1438  v_[i] *= scalar;
1439  return *this;
1440 }
1441 //*************************************************************************************************
1442 
1443 
1444 //*************************************************************************************************
1450 template< typename Type // Data type of the vector
1451  , size_t N // Number of elements
1452  , bool TF > // Transpose flag
1454 {
1455  using std::swap;
1456 
1457  for( size_t i=0UL; i<N; ++i )
1458  swap( v_[i], v.v_[i] );
1459 }
1460 //*************************************************************************************************
1461 
1462 
1463 
1464 
1465 //=================================================================================================
1466 //
1467 // MEMORY FUNCTIONS
1468 //
1469 //=================================================================================================
1470 
1471 //*************************************************************************************************
1481 template< typename Type // Data type of the vector
1482  , size_t N // Number of elements
1483  , bool TF > // Transpose flag
1484 inline void* StaticVector<Type,N,TF>::operator new( std::size_t size )
1485 {
1487 
1488  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1489 
1490  return allocate<StaticVector>( 1UL );
1491 }
1492 //*************************************************************************************************
1493 
1494 
1495 //*************************************************************************************************
1505 template< typename Type // Data type of the vector
1506  , size_t N // Number of elements
1507  , bool TF > // Transpose flag
1508 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size )
1509 {
1510  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1511  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1512 
1513  return allocate<StaticVector>( size/sizeof(StaticVector) );
1514 }
1515 //*************************************************************************************************
1516 
1517 
1518 //*************************************************************************************************
1528 template< typename Type // Data type of the vector
1529  , size_t N // Number of elements
1530  , bool TF > // Transpose flag
1531 inline void* StaticVector<Type,N,TF>::operator new( std::size_t size, const std::nothrow_t& )
1532 {
1533  UNUSED_PARAMETER( size );
1534 
1535  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1536 
1537  return allocate<StaticVector>( 1UL );
1538 }
1539 //*************************************************************************************************
1540 
1541 
1542 //*************************************************************************************************
1552 template< typename Type // Data type of the vector
1553  , size_t N // Number of elements
1554  , bool TF > // Transpose flag
1555 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size, const std::nothrow_t& )
1556 {
1557  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1558  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1559 
1560  return allocate<StaticVector>( size/sizeof(StaticVector) );
1561 }
1562 //*************************************************************************************************
1563 
1564 
1565 //*************************************************************************************************
1571 template< typename Type // Data type of the vector
1572  , size_t N // Number of elements
1573  , bool TF > // Transpose flag
1574 inline void StaticVector<Type,N,TF>::operator delete( void* ptr )
1575 {
1576  deallocate( static_cast<StaticVector*>( ptr ) );
1577 }
1578 //*************************************************************************************************
1579 
1580 
1581 //*************************************************************************************************
1587 template< typename Type // Data type of the vector
1588  , size_t N // Number of elements
1589  , bool TF > // Transpose flag
1590 inline void StaticVector<Type,N,TF>::operator delete[]( void* ptr )
1591 {
1592  deallocate( static_cast<StaticVector*>( ptr ) );
1593 }
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 inline void StaticVector<Type,N,TF>::operator delete( void* ptr, const std::nothrow_t& )
1607 {
1608  deallocate( static_cast<StaticVector*>( ptr ) );
1609 }
1610 //*************************************************************************************************
1611 
1612 
1613 //*************************************************************************************************
1619 template< typename Type // Data type of the vector
1620  , size_t N // Number of elements
1621  , bool TF > // Transpose flag
1622 inline void StaticVector<Type,N,TF>::operator delete[]( void* ptr, const std::nothrow_t& )
1623 {
1624  deallocate( static_cast<StaticVector*>( ptr ) );
1625 }
1626 //*************************************************************************************************
1627 
1628 
1629 
1630 
1631 //=================================================================================================
1632 //
1633 // DEBUGGING FUNCTIONS
1634 //
1635 //=================================================================================================
1636 
1637 //*************************************************************************************************
1646 template< typename Type // Data type of the vector
1647  , size_t N // Number of elements
1648  , bool TF > // Transpose flag
1649 inline bool StaticVector<Type,N,TF>::isIntact() const noexcept
1650 {
1651  if( IsNumeric<Type>::value ) {
1652  for( size_t i=N; i<NN; ++i ) {
1653  if( v_[i] != Type() )
1654  return false;
1655  }
1656  }
1657 
1658  return true;
1659 }
1660 //*************************************************************************************************
1661 
1662 
1663 
1664 
1665 //=================================================================================================
1666 //
1667 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
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 template< typename Other > // Data type of the foreign expression
1685 inline bool StaticVector<Type,N,TF>::canAlias( const Other* alias ) const noexcept
1686 {
1687  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1688 }
1689 //*************************************************************************************************
1690 
1691 
1692 //*************************************************************************************************
1702 template< typename Type // Data type of the vector
1703  , size_t N // Number of elements
1704  , bool TF > // Transpose flag
1705 template< typename Other > // Data type of the foreign expression
1706 inline bool StaticVector<Type,N,TF>::isAliased( const Other* alias ) const noexcept
1707 {
1708  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1709 }
1710 //*************************************************************************************************
1711 
1712 
1713 //*************************************************************************************************
1722 template< typename Type // Data type of the vector
1723  , size_t N // Number of elements
1724  , bool TF > // Transpose flag
1725 inline bool StaticVector<Type,N,TF>::isAligned() const noexcept
1726 {
1727  return true;
1728 }
1729 //*************************************************************************************************
1730 
1731 
1732 //*************************************************************************************************
1744 template< typename Type // Data type of the vector
1745  , size_t N // Number of elements
1746  , bool TF > // Transpose flag
1748  StaticVector<Type,N,TF>::load( size_t index ) const noexcept
1749 {
1750  return loada( index );
1751 }
1752 //*************************************************************************************************
1753 
1754 
1755 //*************************************************************************************************
1768 template< typename Type // Data type of the vector
1769  , size_t N // Number of elements
1770  , bool TF > // Transpose flag
1772  StaticVector<Type,N,TF>::loada( size_t index ) const noexcept
1773 {
1774  using blaze::loada;
1775 
1777 
1778  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1779  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1780  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1781  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1782 
1783  return loada( &v_[index] );
1784 }
1785 //*************************************************************************************************
1786 
1787 
1788 //*************************************************************************************************
1801 template< typename Type // Data type of the vector
1802  , size_t N // Number of elements
1803  , bool TF > // Transpose flag
1805  StaticVector<Type,N,TF>::loadu( size_t index ) const noexcept
1806 {
1807  using blaze::loadu;
1808 
1810 
1811  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1812  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1813 
1814  return loadu( &v_[index] );
1815 }
1816 //*************************************************************************************************
1817 
1818 
1819 //*************************************************************************************************
1832 template< typename Type // Data type of the vector
1833  , size_t N // Number of elements
1834  , bool TF > // Transpose flag
1836  StaticVector<Type,N,TF>::store( size_t index, const SIMDType& value ) noexcept
1837 {
1838  storea( index, value );
1839 }
1840 //*************************************************************************************************
1841 
1842 
1843 //*************************************************************************************************
1856 template< typename Type // Data type of the vector
1857  , size_t N // Number of elements
1858  , bool TF > // Transpose flag
1860  StaticVector<Type,N,TF>::storea( size_t index, const SIMDType& value ) noexcept
1861 {
1862  using blaze::storea;
1863 
1865 
1866  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1867  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN , "Invalid vector access index" );
1868  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1869  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1870 
1871  storea( &v_[index], value );
1872 }
1873 //*************************************************************************************************
1874 
1875 
1876 //*************************************************************************************************
1889 template< typename Type // Data type of the vector
1890  , size_t N // Number of elements
1891  , bool TF > // Transpose flag
1893  StaticVector<Type,N,TF>::storeu( size_t index, const SIMDType& value ) noexcept
1894 {
1895  using blaze::storeu;
1896 
1898 
1899  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1900  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1901 
1902  storeu( &v_[index], value );
1903 }
1904 //*************************************************************************************************
1905 
1906 
1907 //*************************************************************************************************
1921 template< typename Type // Data type of the vector
1922  , size_t N // Number of elements
1923  , bool TF > // Transpose flag
1925  StaticVector<Type,N,TF>::stream( size_t index, const SIMDType& value ) noexcept
1926 {
1927  using blaze::stream;
1928 
1930 
1931  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1932  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1933  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1934  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1935 
1936  stream( &v_[index], value );
1937 }
1938 //*************************************************************************************************
1939 
1940 
1941 //*************************************************************************************************
1952 template< typename Type // Data type of the vector
1953  , size_t N // Number of elements
1954  , bool TF > // Transpose flag
1955 template< typename VT > // Type of the right-hand side dense vector
1958 {
1959  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1960 
1961  for( size_t i=0UL; i<N; ++i )
1962  v_[i] = (~rhs)[i];
1963 }
1964 //*************************************************************************************************
1965 
1966 
1967 //*************************************************************************************************
1978 template< typename Type // Data type of the vector
1979  , size_t N // Number of elements
1980  , bool TF > // Transpose flag
1981 template< typename VT > // Type of the right-hand side dense vector
1984 {
1986 
1987  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1988 
1989  const bool remainder( !usePadding || !IsPadded<VT>::value );
1990 
1991  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
1992  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
1993 
1994  size_t i( 0UL );
1995 
1996  for( ; i<ipos; i+=SIMDSIZE ) {
1997  store( i, (~rhs).load(i) );
1998  }
1999  for( ; remainder && i<N; ++i ) {
2000  v_[i] = (~rhs)[i];
2001  }
2002 }
2003 //*************************************************************************************************
2004 
2005 
2006 //*************************************************************************************************
2017 template< typename Type // Data type of the vector
2018  , size_t N // Number of elements
2019  , bool TF > // Transpose flag
2020 template< typename VT > // Type of the right-hand side sparse vector
2022 {
2023  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2024 
2025  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2026  v_[element->index()] = element->value();
2027 }
2028 //*************************************************************************************************
2029 
2030 
2031 //*************************************************************************************************
2042 template< typename Type // Data type of the vector
2043  , size_t N // Number of elements
2044  , bool TF > // Transpose flag
2045 template< typename VT > // Type of the right-hand side dense vector
2046 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2048 {
2049  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2050 
2051  for( size_t i=0UL; i<N; ++i )
2052  v_[i] += (~rhs)[i];
2053 }
2054 //*************************************************************************************************
2055 
2056 
2057 //*************************************************************************************************
2068 template< typename Type // Data type of the vector
2069  , size_t N // Number of elements
2070  , bool TF > // Transpose flag
2071 template< typename VT > // Type of the right-hand side dense vector
2072 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2074 {
2076 
2077  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2078 
2079  const bool remainder( !usePadding || !IsPadded<VT>::value );
2080 
2081  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2082  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2083 
2084  size_t i( 0UL );
2085 
2086  for( ; i<ipos; i+=SIMDSIZE ) {
2087  store( i, load(i) + (~rhs).load(i) );
2088  }
2089  for( ; remainder && i<N; ++i ) {
2090  v_[i] += (~rhs)[i];
2091  }
2092 }
2093 //*************************************************************************************************
2094 
2095 
2096 //*************************************************************************************************
2107 template< typename Type // Data type of the vector
2108  , size_t N // Number of elements
2109  , bool TF > // Transpose flag
2110 template< typename VT > // Type of the right-hand side sparse vector
2112 {
2113  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2114 
2115  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2116  v_[element->index()] += element->value();
2117 }
2118 //*************************************************************************************************
2119 
2120 
2121 //*************************************************************************************************
2132 template< typename Type // Data type of the vector
2133  , size_t N // Number of elements
2134  , bool TF > // Transpose flag
2135 template< typename VT > // Type of the right-hand side dense vector
2136 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2138 {
2139  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2140 
2141  for( size_t i=0UL; i<N; ++i )
2142  v_[i] -= (~rhs)[i];
2143 }
2144 //*************************************************************************************************
2145 
2146 
2147 //*************************************************************************************************
2158 template< typename Type // Data type of the vector
2159  , size_t N // Number of elements
2160  , bool TF > // Transpose flag
2161 template< typename VT > // Type of the right-hand side dense vector
2162 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2164 {
2166 
2167  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2168 
2169  const bool remainder( !usePadding || !IsPadded<VT>::value );
2170 
2171  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2172  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2173 
2174  size_t i( 0UL );
2175 
2176  for( ; i<ipos; i+=SIMDSIZE ) {
2177  store( i, load(i) - (~rhs).load(i) );
2178  }
2179  for( ; remainder && i<N; ++i ) {
2180  v_[i] -= (~rhs)[i];
2181  }
2182 }
2183 //*************************************************************************************************
2184 
2185 
2186 //*************************************************************************************************
2197 template< typename Type // Data type of the vector
2198  , size_t N // Number of elements
2199  , bool TF > // Transpose flag
2200 template< typename VT > // Type of the right-hand side sparse vector
2202 {
2203  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2204 
2205  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2206  v_[element->index()] -= element->value();
2207 }
2208 //*************************************************************************************************
2209 
2210 
2211 //*************************************************************************************************
2222 template< typename Type // Data type of the vector
2223  , size_t N // Number of elements
2224  , bool TF > // Transpose flag
2225 template< typename VT > // Type of the right-hand side dense vector
2226 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2228 {
2229  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2230 
2231  for( size_t i=0UL; i<N; ++i )
2232  v_[i] *= (~rhs)[i];
2233 }
2234 //*************************************************************************************************
2235 
2236 
2237 //*************************************************************************************************
2248 template< typename Type // Data type of the vector
2249  , size_t N // Number of elements
2250  , bool TF > // Transpose flag
2251 template< typename VT > // Type of the right-hand side dense vector
2252 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2254 {
2256 
2257  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2258 
2259  const bool remainder( !usePadding || !IsPadded<VT>::value );
2260 
2261  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2262  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2263 
2264  size_t i( 0UL );
2265 
2266  for( ; i<ipos; i+=SIMDSIZE ) {
2267  store( i, load(i) * (~rhs).load(i) );
2268  }
2269  for( ; remainder && i<N; ++i ) {
2270  v_[i] *= (~rhs)[i];
2271  }
2272 }
2273 //*************************************************************************************************
2274 
2275 
2276 //*************************************************************************************************
2287 template< typename Type // Data type of the vector
2288  , size_t N // Number of elements
2289  , bool TF > // Transpose flag
2290 template< typename VT > // Type of the right-hand side sparse vector
2292 {
2293  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2294 
2295  const StaticVector tmp( serial( *this ) );
2296 
2297  reset();
2298 
2299  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2300  v_[element->index()] = tmp[element->index()] * element->value();
2301 }
2302 //*************************************************************************************************
2303 
2304 
2305 //*************************************************************************************************
2316 template< typename Type // Data type of the vector
2317  , size_t N // Number of elements
2318  , bool TF > // Transpose flag
2319 template< typename VT > // Type of the right-hand side dense vector
2320 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2322 {
2323  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2324 
2325  for( size_t i=0UL; i<N; ++i )
2326  v_[i] /= (~rhs)[i];
2327 }
2328 //*************************************************************************************************
2329 
2330 
2331 //*************************************************************************************************
2342 template< typename Type // Data type of the vector
2343  , size_t N // Number of elements
2344  , bool TF > // Transpose flag
2345 template< typename VT > // Type of the right-hand side dense vector
2346 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2348 {
2350 
2351  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2352 
2353  const size_t ipos( N & size_t(-SIMDSIZE) );
2354  BLAZE_INTERNAL_ASSERT( ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2355 
2356  size_t i( 0UL );
2357 
2358  for( ; i<ipos; i+=SIMDSIZE ) {
2359  store( i, load(i) / (~rhs).load(i) );
2360  }
2361  for( ; i<N; ++i ) {
2362  v_[i] /= (~rhs)[i];
2363  }
2364 }
2365 //*************************************************************************************************
2366 
2367 
2368 
2369 
2370 
2371 
2372 
2373 
2374 //=================================================================================================
2375 //
2376 // UNDEFINED CLASS TEMPLATE SPECIALIZATION
2377 //
2378 //=================================================================================================
2379 
2380 //*************************************************************************************************
2388 template< typename Type // Data type of the vector
2389  , bool TF > // Transpose flag
2390 class StaticVector<Type,0UL,TF>;
2392 //*************************************************************************************************
2393 
2394 
2395 
2396 
2397 
2398 
2399 
2400 
2401 //=================================================================================================
2402 //
2403 // STATICVECTOR OPERATORS
2404 //
2405 //=================================================================================================
2406 
2407 //*************************************************************************************************
2410 template< typename Type, size_t N, bool TF >
2411 inline void reset( StaticVector<Type,N,TF>& v );
2412 
2413 template< typename Type, size_t N, bool TF >
2414 inline void clear( StaticVector<Type,N,TF>& v );
2415 
2416 template< typename Type, size_t N, bool TF >
2417 inline bool isDefault( const StaticVector<Type,N,TF>& v );
2418 
2419 template< typename Type, size_t N, bool TF >
2420 inline bool isIntact( const StaticVector<Type,N,TF>& v ) noexcept;
2421 
2422 template< typename Type, bool TF >
2424 
2425 template< typename Type, bool TF >
2427 
2428 template< typename Type, size_t N, bool TF >
2429 inline void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) noexcept;
2431 //*************************************************************************************************
2432 
2433 
2434 //*************************************************************************************************
2441 template< typename Type // Data type of the vector
2442  , size_t N // Number of elements
2443  , bool TF > // Transpose flag
2445 {
2446  v.reset();
2447 }
2448 //*************************************************************************************************
2449 
2450 
2451 //*************************************************************************************************
2460 template< typename Type // Data type of the vector
2461  , size_t N // Number of elements
2462  , bool TF > // Transpose flag
2464 {
2465  v.reset();
2466 }
2467 //*************************************************************************************************
2468 
2469 
2470 //*************************************************************************************************
2488 template< typename Type // Data type of the vector
2489  , size_t N // Number of elements
2490  , bool TF > // Transpose flag
2491 inline bool isDefault( const StaticVector<Type,N,TF>& v )
2492 {
2493  for( size_t i=0UL; i<N; ++i )
2494  if( !isDefault( v[i] ) ) return false;
2495  return true;
2496 }
2497 //*************************************************************************************************
2498 
2499 
2500 //*************************************************************************************************
2518 template< typename Type // Data type of the vector
2519  , size_t N // Number of elements
2520  , bool TF > // Transpose flag
2521 inline bool isIntact( const StaticVector<Type,N,TF>& v ) noexcept
2522 {
2523  return v.isIntact();
2524 }
2525 //*************************************************************************************************
2526 
2527 
2528 //*************************************************************************************************
2539 template< typename Type // Data type of the vector
2540  , bool TF > // Transpose flag
2542 {
2543  return StaticVector<Type,2UL,TF>( -v[1UL], v[0UL] );
2544 }
2545 //*************************************************************************************************
2546 
2547 
2548 //*************************************************************************************************
2556 template< typename Type // Data type of the vector
2557  , bool TF > // Transpose flag
2559 {
2560  if( v[0] != Type() || v[1] != Type() )
2561  return StaticVector<Type,3UL,TF>( v[1UL], -v[0UL], Type() );
2562  else
2563  return StaticVector<Type,3UL,TF>( Type(), v[2UL], -v[1UL] );
2564 }
2565 //*************************************************************************************************
2566 
2567 
2568 //*************************************************************************************************
2576 template< typename Type // Data type of the vector
2577  , size_t N // Number of elements
2578  , bool TF > // Transpose flag
2580 {
2581  a.swap( b );
2582 }
2583 //*************************************************************************************************
2584 
2585 
2586 
2587 
2588 //=================================================================================================
2589 //
2590 // SIZE SPECIALIZATIONS
2591 //
2592 //=================================================================================================
2593 
2594 //*************************************************************************************************
2596 template< typename T, size_t N, bool TF >
2597 struct Size< StaticVector<T,N,TF> >
2598 {
2599  static const size_t value = N;
2600 };
2602 //*************************************************************************************************
2603 
2604 
2605 
2606 
2607 //=================================================================================================
2608 //
2609 // HASCONSTDATAACCESS SPECIALIZATIONS
2610 //
2611 //=================================================================================================
2612 
2613 //*************************************************************************************************
2615 template< typename T, size_t N, bool TF >
2616 struct HasConstDataAccess< StaticVector<T,N,TF> > : public TrueType
2617 {};
2619 //*************************************************************************************************
2620 
2621 
2622 
2623 
2624 //=================================================================================================
2625 //
2626 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2627 //
2628 //=================================================================================================
2629 
2630 //*************************************************************************************************
2632 template< typename T, size_t N, bool TF >
2633 struct HasMutableDataAccess< StaticVector<T,N,TF> > : public TrueType
2634 {};
2636 //*************************************************************************************************
2637 
2638 
2639 
2640 
2641 //=================================================================================================
2642 //
2643 // ISALIGNED SPECIALIZATIONS
2644 //
2645 //=================================================================================================
2646 
2647 //*************************************************************************************************
2649 template< typename T, size_t N, bool TF >
2650 struct IsAligned< StaticVector<T,N,TF> > : public TrueType
2651 {};
2653 //*************************************************************************************************
2654 
2655 
2656 
2657 
2658 //=================================================================================================
2659 //
2660 // ISPADDED SPECIALIZATIONS
2661 //
2662 //=================================================================================================
2663 
2664 //*************************************************************************************************
2666 template< typename T, size_t N, bool TF >
2667 struct IsPadded< StaticVector<T,N,TF> > : public BoolConstant<usePadding>
2668 {};
2670 //*************************************************************************************************
2671 
2672 
2673 
2674 
2675 //=================================================================================================
2676 //
2677 // ADDTRAIT SPECIALIZATIONS
2678 //
2679 //=================================================================================================
2680 
2681 //*************************************************************************************************
2683 template< typename T1, size_t N, bool TF, typename T2 >
2684 struct AddTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2685 {
2686  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2687 };
2689 //*************************************************************************************************
2690 
2691 
2692 
2693 
2694 //=================================================================================================
2695 //
2696 // SUBTRAIT SPECIALIZATIONS
2697 //
2698 //=================================================================================================
2699 
2700 //*************************************************************************************************
2702 template< typename T1, size_t N, bool TF, typename T2 >
2703 struct SubTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2704 {
2705  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2706 };
2708 //*************************************************************************************************
2709 
2710 
2711 
2712 
2713 //=================================================================================================
2714 //
2715 // MULTTRAIT SPECIALIZATIONS
2716 //
2717 //=================================================================================================
2718 
2719 //*************************************************************************************************
2721 template< typename T1, size_t N, bool TF, typename T2 >
2722 struct MultTrait< StaticVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2723 {
2724  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2725 };
2726 
2727 template< typename T1, typename T2, size_t N, bool TF >
2728 struct MultTrait< T1, StaticVector<T2,N,TF>, EnableIf_<IsNumeric<T1> > >
2729 {
2730  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2731 };
2732 
2733 template< typename T1, size_t N, bool TF, typename T2 >
2734 struct MultTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2735 {
2736  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2737 };
2738 
2739 template< typename T1, size_t M, typename T2, size_t N >
2740 struct MultTrait< StaticVector<T1,M,false>, StaticVector<T2,N,true> >
2741 {
2742  using Type = StaticMatrix< MultTrait_<T1,T2>, M, N, false >;
2743 };
2744 
2745 template< typename T1, size_t N, typename T2 >
2746 struct MultTrait< StaticVector<T1,N,true>, StaticVector<T2,N,false> >
2747 {
2748  using Type = MultTrait_<T1,T2>;
2749 };
2751 //*************************************************************************************************
2752 
2753 
2754 
2755 
2756 //=================================================================================================
2757 //
2758 // CROSSTRAIT SPECIALIZATIONS
2759 //
2760 //=================================================================================================
2761 
2762 //*************************************************************************************************
2764 template< typename T1, typename T2, bool TF >
2765 struct CrossTrait< StaticVector<T1,3UL,TF>, StaticVector<T2,3UL,TF> >
2766 {
2767  private:
2768  using T = MultTrait_<T1,T2>;
2769 
2770  public:
2771  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2772 };
2774 //*************************************************************************************************
2775 
2776 
2777 
2778 
2779 //=================================================================================================
2780 //
2781 // DIVTRAIT SPECIALIZATIONS
2782 //
2783 //=================================================================================================
2784 
2785 //*************************************************************************************************
2787 template< typename T1, size_t N, bool TF, typename T2 >
2788 struct DivTrait< StaticVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2789 {
2790  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2791 };
2792 
2793 template< typename T1, size_t N, bool TF, typename T2 >
2794 struct DivTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2795 {
2796  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2797 };
2799 //*************************************************************************************************
2800 
2801 
2802 
2803 
2804 //=================================================================================================
2805 //
2806 // MATHTRAIT SPECIALIZATIONS
2807 //
2808 //=================================================================================================
2809 
2810 //*************************************************************************************************
2812 template< typename T1, size_t N, bool TF, typename T2 >
2813 struct MathTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2814 {
2815  using HighType = StaticVector< typename MathTrait<T1,T2>::HighType, N, TF >;
2816  using LowType = StaticVector< typename MathTrait<T1,T2>::LowType , N, TF >;
2817 };
2819 //*************************************************************************************************
2820 
2821 
2822 
2823 
2824 //=================================================================================================
2825 //
2826 // SUBVECTORTRAIT SPECIALIZATIONS
2827 //
2828 //=================================================================================================
2829 
2830 //*************************************************************************************************
2832 template< typename T1, size_t N, bool TF >
2833 struct SubvectorTrait< StaticVector<T1,N,TF> >
2834 {
2835  using Type = HybridVector<T1,N,TF>;
2836 };
2838 //*************************************************************************************************
2839 
2840 } // namespace blaze
2841 
2842 #endif
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: StaticVector.h:1685
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
constexpr bool useOptimizedKernels
Configuration switch for optimized kernels.This configuration switch enables/disables all optimized c...
Definition: Optimizations.h:84
Header file for the NextMultiple class template.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the alignment flag values.
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
Header file for basic type definitions.
Header file for the SparseVector base class.
Type * Pointer
Pointer to a non-constant vector value.
Definition: StaticVector.h:193
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:79
Header file for the serial shim.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the static vector.
Definition: StaticVector.h:914
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:315
DenseVector< This, TF > BaseType
Base type of this StaticVector instance.
Definition: StaticVector.h:183
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
Header file for the DenseVector base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: StaticVector.h:1772
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
Header file for the SizeT class template.
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: StaticVector.h:1394
Iterator end() noexcept
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:929
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
Header file for memory allocation and deallocation functionality.
System settings for performance optimizations.
STL namespace.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:77
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
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.
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:959
void swap(StaticVector &v) noexcept
Swapping the contents of two static vectors.
Definition: StaticVector.h:1453
constexpr size_t capacity() const noexcept
Returns the maximum capacity of the vector.
Definition: StaticVector.h:1376
Header file for the DisableIf class template.
Header file for the multiplication trait.
const StaticVector & CompositeType
Data type for composite expression templates.
Definition: StaticVector.h:189
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5148
Compile time assertion.
constexpr bool defaultTransposeFlag
The default transpose flag for all vectors of the Blaze library.This value specifies the default tran...
Definition: TransposeFlag.h:56
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: StaticVector.h:1805
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: StaticVector.h:1748
#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
BLAZE_ALWAYS_INLINE void stream(size_t index, const SIMDType &value) noexcept
Aligned, non-temporal store of a SIMD element of the vector.
Definition: StaticVector.h:1925
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:76
Reference at(size_t index)
Checked access to the vector elements.
Definition: StaticVector.h:808
StaticVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: StaticVector.h:983
#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.
const Type * ConstPointer
Pointer to a constant vector value.
Definition: StaticVector.h:194
Header file for the subvector trait.
Header file for all SIMD functionality.
Constraint on the data type.
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:78
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticVector.h:188
bool isIntact() const noexcept
Returns whether the invariants of the static vector are intact.
Definition: StaticVector.h:1649
Header file for the IsAligned type trait.
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
void reset()
Reset to the default initial values.
Definition: StaticVector.h:1416
#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
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: StaticVector.h:852
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: StaticVector.h:1706
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
Iterator begin() noexcept
Returns an iterator to the first element of the static vector.
Definition: StaticVector.h:884
This ResultType
Result type for expression template evaluations.
Definition: StaticVector.h:184
const StaticVector< Type, 2UL, TF > perp(const StaticVector< Type, 2UL, TF > &v)
Unary perp dot product operator for the calculation of a perpendicular vector ( ).
Definition: StaticVector.h:2541
DenseIterator< const Type, aligned > ConstIterator
Iterator over constant elements.
Definition: StaticVector.h:197
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the IsPadded type trait.
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: StaticVector.h:462
Header file for the HasConstDataAccess type trait.
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > stream(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned, non-temporal store of a vector of 1-byte integral values.
Definition: Stream.h:75
Header file for the IsSparseVector type trait.
Header file for the HasSIMDMult type trait.
Type ElementType
Type of the vector elements.
Definition: StaticVector.h:186
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: StaticVector.h:1725
StaticVector()
The default constructor for StaticVector.
Definition: StaticVector.h:501
Header file for run time assertion macros.
Header file for the addition trait.
DenseIterator< Type, aligned > Iterator
Iterator over non-constant elements.
Definition: StaticVector.h:196
Header file for the cross product trait.
Header file for the division trait.
Constraint on the data type.
Header file for the AlignedArray implementation.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:258
StaticVector< Type, N, TF > This
Type of this StaticVector instance.
Definition: StaticVector.h:182
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: StaticVector.h:765
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
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:100
EnableIf_< IsBuiltin< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:225
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition: Storeu.h:76
Header file for the mathematical trait.
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
Header file for the AreSIMDCombinable type trait.
constexpr bool usePadding
Configuration of the padding of dense vectors and matrices.This configuration switch enables/disables...
Definition: Optimizations.h:52
Header file for the HasSIMDDiv type trait.
StaticVector< ET, N, TF > Other
The type of the other StaticVector.
Definition: StaticVector.h:205
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:154
Header file for the default transpose flag for all vectors of the Blaze library.
Initializer list type of the Blaze library.
StaticVector< Type, N,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: StaticVector.h:185
Header file for the alignment check function.
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: StaticVector.h:1860
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:110
Header file for the IntegralConstant class template.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: StaticVector.h:1893
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
constexpr size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: StaticVector.h:1361
#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
System settings for the inline keywords.
Header file for the Size type trait.
#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
Rebind mechanism to obtain a StaticVector with different data/element type.
Definition: StaticVector.h:204
const Type & ConstReference
Reference to a constant vector value.
Definition: StaticVector.h:192
Header file for the TrueType type/value trait base class.
Type & Reference
Reference to a non-constant vector value.
Definition: StaticVector.h:191
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: StaticVector.h:1836
SIMDTrait_< ElementType > SIMDType
SIMD type of the vector elements.
Definition: StaticVector.h:187