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>
52 #include <blaze/math/Functions.h>
54 #include <blaze/math/shims/Clear.h>
57 #include <blaze/math/SIMD.h>
77 #include <blaze/system/Inline.h>
82 #include <blaze/util/Assert.h>
88 #include <blaze/util/DisableIf.h>
89 #include <blaze/util/EnableIf.h>
91 #include <blaze/util/Memory.h>
92 #include <blaze/util/mpl/SizeT.h>
94 #include <blaze/util/Template.h>
95 #include <blaze/util/TrueType.h>
96 #include <blaze/util/Types.h>
99 #include <blaze/util/Unused.h>
100 
101 
102 namespace blaze {
103 
104 //=================================================================================================
105 //
106 // CLASS DEFINITION
107 //
108 //=================================================================================================
109 
110 //*************************************************************************************************
176 template< typename Type // Data type of the vector
177  , size_t N // Number of elements
178  , bool TF = defaultTransposeFlag > // Transpose flag
179 class StaticVector : public DenseVector< StaticVector<Type,N,TF>, TF >
180 {
181  public:
182  //**Type definitions****************************************************************************
185  typedef This ResultType;
187  typedef Type ElementType;
189  typedef const Type& ReturnType;
190  typedef const StaticVector& CompositeType;
191 
192  typedef Type& Reference;
193  typedef const Type& ConstReference;
194  typedef Type* Pointer;
195  typedef const Type* ConstPointer;
196 
199  //**********************************************************************************************
200 
201  //**Rebind struct definition********************************************************************
204  template< typename NewType > // Data type of the other vector
205  struct Rebind {
207  };
208  //**********************************************************************************************
209 
210  //**Resize struct definition********************************************************************
213  template< size_t NewN > // Number of elements of the other vector
214  struct Resize {
216  };
217  //**********************************************************************************************
218 
219  //**Compilation flags***************************************************************************
221 
225  enum : bool { simdEnabled = IsVectorizable<Type>::value };
226 
228 
231  enum : bool { smpAssignable = false };
232  //**********************************************************************************************
233 
234  //**Constructors********************************************************************************
237  explicit inline StaticVector();
238  explicit inline StaticVector( const Type& init );
239  explicit inline StaticVector( initializer_list<Type> list );
240 
241  template< typename Other >
242  explicit inline StaticVector( size_t n, const Other* array );
243 
244  template< typename Other >
245  explicit inline StaticVector( const Other (&array)[N] );
246 
247  inline StaticVector( const StaticVector& v );
248  template< typename Other > inline StaticVector( const StaticVector<Other,N,TF>& v );
249  template< typename VT > inline StaticVector( const Vector<VT,TF>& v );
251  //**********************************************************************************************
252 
253  //**Destructor**********************************************************************************
254  // No explicitly declared destructor.
255  //**********************************************************************************************
256 
257  //**Data access functions***********************************************************************
260  inline Reference operator[]( size_t index ) noexcept;
261  inline ConstReference operator[]( size_t index ) const noexcept;
262  inline Reference at( size_t index );
263  inline ConstReference at( size_t index ) const;
264  inline Pointer data () noexcept;
265  inline ConstPointer data () const noexcept;
266  inline Iterator begin () noexcept;
267  inline ConstIterator begin () const noexcept;
268  inline ConstIterator cbegin() const noexcept;
269  inline Iterator end () noexcept;
270  inline ConstIterator end () const noexcept;
271  inline ConstIterator cend () const noexcept;
273  //**********************************************************************************************
274 
275  //**Assignment operators************************************************************************
278  inline StaticVector& operator=( const Type& rhs );
280 
281  template< typename Other >
282  inline StaticVector& operator=( const Other (&array)[N] );
283 
284  inline StaticVector& operator=( const StaticVector& rhs );
285  template< typename Other > inline StaticVector& operator=( const StaticVector<Other,N,TF>& rhs );
286 
287  template< typename VT > inline StaticVector& operator= ( const Vector<VT,TF>& rhs );
288  template< typename VT > inline StaticVector& operator+=( const Vector<VT,TF>& rhs );
289  template< typename VT > inline StaticVector& operator-=( const Vector<VT,TF>& rhs );
290  template< typename VT > inline StaticVector& operator*=( const Vector<VT,TF>& rhs );
291  template< typename VT > inline StaticVector& operator/=( const DenseVector<VT,TF>& rhs );
292 
293  template< typename Other >
294  inline EnableIf_<IsNumeric<Other>, StaticVector >& operator*=( Other rhs );
295 
296  template< typename Other >
297  inline EnableIf_<IsNumeric<Other>, StaticVector >& operator/=( Other rhs );
299  //**********************************************************************************************
300 
301  //**Utility functions***************************************************************************
304  inline constexpr size_t size() const noexcept;
305  inline constexpr size_t capacity() const noexcept;
306  inline size_t nonZeros() const;
307  inline void reset();
308  inline void swap( StaticVector& v ) noexcept;
310  //**********************************************************************************************
311 
312  //**Numeric functions***************************************************************************
315  template< typename Other > inline StaticVector& scale( const Other& scalar );
317  //**********************************************************************************************
318 
319  //**Memory functions****************************************************************************
322  static inline void* operator new ( std::size_t size );
323  static inline void* operator new[]( std::size_t size );
324  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
325  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
326 
327  static inline void operator delete ( void* ptr );
328  static inline void operator delete[]( void* ptr );
329  static inline void operator delete ( void* ptr, const std::nothrow_t& );
330  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
332  //**********************************************************************************************
333 
334  private:
335  //**********************************************************************************************
337  template< typename VT >
339  struct VectorizedAssign {
340  enum : bool { value = useOptimizedKernels &&
341  simdEnabled && VT::simdEnabled &&
343  };
345  //**********************************************************************************************
346 
347  //**********************************************************************************************
349  template< typename VT >
351  struct VectorizedAddAssign {
352  enum : bool { value = useOptimizedKernels &&
353  simdEnabled && VT::simdEnabled &&
356  };
358  //**********************************************************************************************
359 
360  //**********************************************************************************************
362  template< typename VT >
364  struct VectorizedSubAssign {
365  enum : bool { value = useOptimizedKernels &&
366  simdEnabled && VT::simdEnabled &&
369  };
371  //**********************************************************************************************
372 
373  //**********************************************************************************************
375  template< typename VT >
377  struct VectorizedMultAssign {
378  enum : bool { value = useOptimizedKernels &&
379  simdEnabled && VT::simdEnabled &&
382  };
384  //**********************************************************************************************
385 
386  //**********************************************************************************************
388  template< typename VT >
390  struct VectorizedDivAssign {
391  enum : bool { value = useOptimizedKernels &&
392  simdEnabled && VT::simdEnabled &&
395  };
397  //**********************************************************************************************
398 
399  //**********************************************************************************************
401  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
402  //**********************************************************************************************
403 
404  public:
405  //**Debugging functions*************************************************************************
408  inline bool isIntact() const noexcept;
410  //**********************************************************************************************
411 
412  //**Expression template evaluation functions****************************************************
415  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
416  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
417 
418  inline bool isAligned() const noexcept;
419 
420  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
421  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
422  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
423 
424  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
425  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
426  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
427  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
428 
429  template< typename VT >
430  inline DisableIf_< VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
431 
432  template< typename VT >
433  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
434 
435  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
436 
437  template< typename VT >
438  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
439 
440  template< typename VT >
441  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
442 
443  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
444 
445  template< typename VT >
446  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
447 
448  template< typename VT >
449  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
450 
451  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
452 
453  template< typename VT >
454  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
455 
456  template< typename VT >
457  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
458 
459  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
460 
461  template< typename VT >
462  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
463 
464  template< typename VT >
465  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
467  //**********************************************************************************************
468 
469  private:
470  //**********************************************************************************************
472  enum : size_t { NN = ( usePadding )?( nextMultiple( N, SIMDSIZE ) ):( N ) };
473  //**********************************************************************************************
474 
475  //**Member variables****************************************************************************
479 
485  //**********************************************************************************************
486 
487  //**Compile time checks*************************************************************************
493  BLAZE_STATIC_ASSERT( !usePadding || ( NN % SIMDSIZE == 0UL ) );
494  BLAZE_STATIC_ASSERT( NN >= N );
496  //**********************************************************************************************
497 };
498 //*************************************************************************************************
499 
500 
501 
502 
503 //=================================================================================================
504 //
505 // CONSTRUCTORS
506 //
507 //=================================================================================================
508 
509 //*************************************************************************************************
514 template< typename Type // Data type of the vector
515  , size_t N // Number of elements
516  , bool TF > // Transpose flag
518  : v_() // The statically allocated vector elements
519 {
521 
522  if( IsNumeric<Type>::value ) {
523  for( size_t i=0UL; i<NN; ++i )
524  v_[i] = Type();
525  }
526 
527  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
528 }
529 //*************************************************************************************************
530 
531 
532 //*************************************************************************************************
537 template< typename Type // Data type of the vector
538  , size_t N // Number of elements
539  , bool TF > // Transpose flag
540 inline StaticVector<Type,N,TF>::StaticVector( const Type& init )
541  : v_() // The statically allocated vector elements
542 {
544 
545  for( size_t i=0UL; i<N; ++i )
546  v_[i] = init;
547 
548  for( size_t i=N; i<NN; ++i )
549  v_[i] = Type();
550 
551  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
552 }
553 //*************************************************************************************************
554 
555 
556 //*************************************************************************************************
573 template< typename Type // Data type of the vector
574  , size_t N // Number of elements
575  , bool TF > // Transpose flag
577  : v_() // The statically allocated vector elements
578 {
580 
581  if( list.size() > N ) {
582  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
583  }
584 
585  std::fill( std::copy( list.begin(), list.end(), v_.data() ), v_.data()+NN, Type() );
586 
587  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
588 }
589 //*************************************************************************************************
590 
591 
592 //*************************************************************************************************
614 template< typename Type // Data type of the vector
615  , size_t N // Number of elements
616  , bool TF > // Transpose flag
617 template< typename Other > // Data type of the initialization array
618 inline StaticVector<Type,N,TF>::StaticVector( size_t n, const Other* array )
619  : v_() // The statically allocated vector elements
620 {
622 
623  if( n > N ) {
624  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
625  }
626 
627  for( size_t i=0UL; i<n; ++i )
628  v_[i] = array[i];
629 
630  if( IsNumeric<Type>::value ) {
631  for( size_t i=n; i<NN; ++i )
632  v_[i] = Type();
633  }
634 
635  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
636 }
637 //*************************************************************************************************
638 
639 
640 //*************************************************************************************************
656 template< typename Type // Data type of the vector
657  , size_t N // Number of elements
658  , bool TF > // Transpose flag
659 template< typename Other > // Data type of the initialization array
660 inline StaticVector<Type,N,TF>::StaticVector( const Other (&array)[N] )
661  : v_() // The statically allocated vector elements
662 {
664 
665  for( size_t i=0UL; i<N; ++i )
666  v_[i] = array[i];
667 
668  for( size_t i=N; i<NN; ++i )
669  v_[i] = Type();
670 
671  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
672 }
673 //*************************************************************************************************
674 
675 
676 //*************************************************************************************************
683 template< typename Type // Data type of the vector
684  , size_t N // Number of elements
685  , bool TF > // Transpose flag
687  : v_() // The statically allocated vector elements
688 {
690 
691  for( size_t i=0UL; i<NN; ++i )
692  v_[i] = v.v_[i];
693 
694  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
695 }
696 //*************************************************************************************************
697 
698 
699 //*************************************************************************************************
704 template< typename Type // Data type of the vector
705  , size_t N // Number of elements
706  , bool TF > // Transpose flag
707 template< typename Other > // Data type of the foreign vector
709  : v_() // The statically allocated vector elements
710 {
712 
713  for( size_t i=0UL; i<N; ++i )
714  v_[i] = v[i];
715 
716  for( size_t i=N; i<NN; ++i )
717  v_[i] = Type();
718 
719  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
720 }
721 //*************************************************************************************************
722 
723 
724 //*************************************************************************************************
734 template< typename Type // Data type of the vector
735  , size_t N // Number of elements
736  , bool TF > // Transpose flag
737 template< typename VT > // Type of the foreign vector
739  : v_() // The statically allocated vector elements
740 {
741  using blaze::assign;
742 
744 
745  if( (~v).size() != N ) {
746  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
747  }
748 
749  for( size_t i=( IsSparseVector<VT>::value ? 0UL : N ); i<NN; ++i ) {
750  v_[i] = Type();
751  }
752 
753  assign( *this, ~v );
754 
755  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
756 }
757 //*************************************************************************************************
758 
759 
760 
761 
762 //=================================================================================================
763 //
764 // DATA ACCESS FUNCTIONS
765 //
766 //=================================================================================================
767 
768 //*************************************************************************************************
777 template< typename Type // Data type of the vector
778  , size_t N // Number of elements
779  , bool TF > // Transpose flag
781  StaticVector<Type,N,TF>::operator[]( size_t index ) noexcept
782 {
783  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
784  return v_[index];
785 }
786 //*************************************************************************************************
787 
788 
789 //*************************************************************************************************
798 template< typename Type // Data type of the vector
799  , size_t N // Number of elements
800  , bool TF > // Transpose flag
802  StaticVector<Type,N,TF>::operator[]( size_t index ) const noexcept
803 {
804  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
805  return v_[index];
806 }
807 //*************************************************************************************************
808 
809 
810 //*************************************************************************************************
820 template< typename Type // Data type of the vector
821  , size_t N // Number of elements
822  , bool TF > // Transpose flag
825 {
826  if( index >= N ) {
827  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
828  }
829  return (*this)[index];
830 }
831 //*************************************************************************************************
832 
833 
834 //*************************************************************************************************
844 template< typename Type // Data type of the vector
845  , size_t N // Number of elements
846  , bool TF > // Transpose flag
848  StaticVector<Type,N,TF>::at( size_t index ) const
849 {
850  if( index >= N ) {
851  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
852  }
853  return (*this)[index];
854 }
855 //*************************************************************************************************
856 
857 
858 //*************************************************************************************************
865 template< typename Type // Data type of the vector
866  , size_t N // Number of elements
867  , bool TF > // Transpose flag
869 {
870  return v_;
871 }
872 //*************************************************************************************************
873 
874 
875 //*************************************************************************************************
882 template< typename Type // Data type of the vector
883  , size_t N // Number of elements
884  , bool TF > // Transpose flag
886 {
887  return v_;
888 }
889 //*************************************************************************************************
890 
891 
892 //*************************************************************************************************
897 template< typename Type // Data type of the vector
898  , size_t N // Number of elements
899  , bool TF > // Transpose flag
901 {
902  return Iterator( v_ );
903 }
904 //*************************************************************************************************
905 
906 
907 //*************************************************************************************************
912 template< typename Type // Data type of the vector
913  , size_t N // Number of elements
914  , bool TF > // Transpose flag
916 {
917  return ConstIterator( v_ );
918 }
919 //*************************************************************************************************
920 
921 
922 //*************************************************************************************************
927 template< typename Type // Data type of the vector
928  , size_t N // Number of elements
929  , bool TF > // Transpose flag
931 {
932  return ConstIterator( v_ );
933 }
934 //*************************************************************************************************
935 
936 
937 //*************************************************************************************************
942 template< typename Type // Data type of the vector
943  , size_t N // Number of elements
944  , bool TF > // Transpose flag
946 {
947  return Iterator( v_ + N );
948 }
949 //*************************************************************************************************
950 
951 
952 //*************************************************************************************************
957 template< typename Type // Data type of the vector
958  , size_t N // Number of elements
959  , bool TF > // Transpose flag
961 {
962  return ConstIterator( v_ + N );
963 }
964 //*************************************************************************************************
965 
966 
967 //*************************************************************************************************
972 template< typename Type // Data type of the vector
973  , size_t N // Number of elements
974  , bool TF > // Transpose flag
976 {
977  return ConstIterator( v_ + N );
978 }
979 //*************************************************************************************************
980 
981 
982 
983 
984 //=================================================================================================
985 //
986 // ASSIGNMENT OPERATORS
987 //
988 //=================================================================================================
989 
990 //*************************************************************************************************
996 template< typename Type // Data type of the vector
997  , size_t N // Number of elements
998  , bool TF > // Transpose flag
1000 {
1001  for( size_t i=0UL; i<N; ++i )
1002  v_[i] = rhs;
1003  return *this;
1004 }
1005 //*************************************************************************************************
1006 
1007 
1008 //*************************************************************************************************
1026 template< typename Type // Data type of the vector
1027  , size_t N // Number of elements
1028  , bool TF > // Transpose flag
1030 {
1031  if( list.size() > N ) {
1032  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to static vector" );
1033  }
1034 
1035  std::fill( std::copy( list.begin(), list.end(), v_.data() ), v_.data()+N, Type() );
1036 
1037  return *this;
1038 }
1039 //*************************************************************************************************
1040 
1041 
1042 //*************************************************************************************************
1059 template< typename Type // Data type of the vector
1060  , size_t N // Number of elements
1061  , bool TF > // Transpose flag
1062 template< typename Other > // Data type of the initialization array
1064 {
1065  for( size_t i=0UL; i<N; ++i )
1066  v_[i] = array[i];
1067  return *this;
1068 }
1069 //*************************************************************************************************
1070 
1071 
1072 //*************************************************************************************************
1080 template< typename Type // Data type of the vector
1081  , size_t N // Number of elements
1082  , bool TF > // Transpose flag
1084 {
1085  using blaze::assign;
1086 
1087  assign( *this, ~rhs );
1088 
1089  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1090 
1091  return *this;
1092 }
1093 //*************************************************************************************************
1094 
1095 
1096 //*************************************************************************************************
1102 template< typename Type // Data type of the vector
1103  , size_t N // Number of elements
1104  , bool TF > // Transpose flag
1105 template< typename Other > // Data type of the foreign vector
1107 {
1108  using blaze::assign;
1109 
1110  assign( *this, ~rhs );
1111 
1112  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1113 
1114  return *this;
1115 }
1116 //*************************************************************************************************
1117 
1118 
1119 //*************************************************************************************************
1129 template< typename Type // Data type of the vector
1130  , size_t N // Number of elements
1131  , bool TF > // Transpose flag
1132 template< typename VT > // Type of the right-hand side vector
1134 {
1135  using blaze::assign;
1136 
1137  if( (~rhs).size() != N ) {
1138  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to static vector" );
1139  }
1140 
1141  if( (~rhs).canAlias( this ) ) {
1142  StaticVector tmp( ~rhs );
1143  swap( tmp );
1144  }
1145  else {
1147  reset();
1148  assign( *this, ~rhs );
1149  }
1150 
1151  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1152 
1153  return *this;
1154 }
1155 //*************************************************************************************************
1156 
1157 
1158 //*************************************************************************************************
1168 template< typename Type // Data type of the vector
1169  , size_t N // Number of elements
1170  , bool TF > // Transpose flag
1171 template< typename VT > // Type of the right-hand side vector
1173 {
1174  using blaze::addAssign;
1175 
1176  if( (~rhs).size() != N ) {
1177  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1178  }
1179 
1180  if( (~rhs).canAlias( this ) ) {
1181  StaticVector tmp( ~rhs );
1182  addAssign( *this, tmp );
1183  }
1184  else {
1185  addAssign( *this, ~rhs );
1186  }
1187 
1188  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1189 
1190  return *this;
1191 }
1192 //*************************************************************************************************
1193 
1194 
1195 //*************************************************************************************************
1205 template< typename Type // Data type of the vector
1206  , size_t N // Number of elements
1207  , bool TF > // Transpose flag
1208 template< typename VT > // Type of the right-hand side vector
1210 {
1211  using blaze::subAssign;
1212 
1213  if( (~rhs).size() != N ) {
1214  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1215  }
1216 
1217  if( (~rhs).canAlias( this ) ) {
1218  StaticVector tmp( ~rhs );
1219  subAssign( *this, tmp );
1220  }
1221  else {
1222  subAssign( *this, ~rhs );
1223  }
1224 
1225  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1226 
1227  return *this;
1228 }
1229 //*************************************************************************************************
1230 
1231 
1232 //*************************************************************************************************
1243 template< typename Type // Data type of the vector
1244  , size_t N // Number of elements
1245  , bool TF > // Transpose flag
1246 template< typename VT > // Type of the right-hand side vector
1248 {
1249  using blaze::multAssign;
1250 
1251  if( (~rhs).size() != N ) {
1252  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1253  }
1254 
1255  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1256  const StaticVector tmp( *this * (~rhs) );
1257  this->operator=( tmp );
1258  }
1259  else {
1260  multAssign( *this, ~rhs );
1261  }
1262 
1263  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1264 
1265  return *this;
1266 }
1267 //*************************************************************************************************
1268 
1269 
1270 //*************************************************************************************************
1280 template< typename Type // Data type of the vector
1281  , size_t N // Number of elements
1282  , bool TF > // Transpose flag
1283 template< typename VT > // Type of the right-hand side vector
1285 {
1286  using blaze::divAssign;
1287 
1288  if( (~rhs).size() != N ) {
1289  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1290  }
1291 
1292  if( (~rhs).canAlias( this ) ) {
1293  const StaticVector tmp( *this / (~rhs) );
1294  this->operator=( tmp );
1295  }
1296  else {
1297  divAssign( *this, ~rhs );
1298  }
1299 
1300  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1301 
1302  return *this;
1303 }
1304 //*************************************************************************************************
1305 
1306 
1307 //*************************************************************************************************
1314 template< typename Type // Data type of the vector
1315  , size_t N // Number of elements
1316  , bool TF > // Transpose flag
1317 template< typename Other > // Data type of the right-hand side scalar
1320 {
1321  using blaze::assign;
1322 
1323  assign( *this, (*this) * rhs );
1324 
1325  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1326 
1327  return *this;
1328 }
1329 //*************************************************************************************************
1330 
1331 
1332 //*************************************************************************************************
1341 template< typename Type // Data type of the vector
1342  , size_t N // Number of elements
1343  , bool TF > // Transpose flag
1344 template< typename Other > // Data type of the right-hand side scalar
1345 inline EnableIf_<IsNumeric<Other>, StaticVector<Type,N,TF> >&
1347 {
1348  using blaze::assign;
1349 
1350  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1351 
1352  assign( *this, (*this) / rhs );
1353 
1354  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1355 
1356  return *this;
1357 }
1358 //*************************************************************************************************
1359 
1360 
1361 
1362 
1363 //=================================================================================================
1364 //
1365 // UTILITY FUNCTIONS
1366 //
1367 //=================================================================================================
1368 
1369 //*************************************************************************************************
1374 template< typename Type // Data type of the vector
1375  , size_t N // Number of elements
1376  , bool TF > // Transpose flag
1377 inline constexpr size_t StaticVector<Type,N,TF>::size() const noexcept
1378 {
1379  return N;
1380 }
1381 //*************************************************************************************************
1382 
1383 
1384 //*************************************************************************************************
1389 template< typename Type // Data type of the vector
1390  , size_t N // Number of elements
1391  , bool TF > // Transpose flag
1392 inline constexpr size_t StaticVector<Type,N,TF>::capacity() const noexcept
1393 {
1394  return NN;
1395 }
1396 //*************************************************************************************************
1397 
1398 
1399 //*************************************************************************************************
1407 template< typename Type // Data type of the vector
1408  , size_t N // Number of elements
1409  , bool TF > // Transpose flag
1411 {
1412  size_t nonzeros( 0 );
1413 
1414  for( size_t i=0UL; i<N; ++i ) {
1415  if( !isDefault( v_[i] ) )
1416  ++nonzeros;
1417  }
1418 
1419  return nonzeros;
1420 }
1421 //*************************************************************************************************
1422 
1423 
1424 //*************************************************************************************************
1429 template< typename Type // Data type of the vector
1430  , size_t N // Number of elements
1431  , bool TF > // Transpose flag
1433 {
1434  using blaze::clear;
1435  for( size_t i=0UL; i<N; ++i )
1436  clear( v_[i] );
1437 }
1438 //*************************************************************************************************
1439 
1440 
1441 //*************************************************************************************************
1447 template< typename Type // Data type of the vector
1448  , size_t N // Number of elements
1449  , bool TF > // Transpose flag
1451 {
1452  using std::swap;
1453 
1454  for( size_t i=0UL; i<N; ++i )
1455  swap( v_[i], v.v_[i] );
1456 }
1457 //*************************************************************************************************
1458 
1459 
1460 
1461 
1462 //=================================================================================================
1463 //
1464 // NUMERIC FUNCTIONS
1465 //
1466 //=================================================================================================
1467 
1468 //*************************************************************************************************
1474 template< typename Type // Data type of the vector
1475  , size_t N // Number of elements
1476  , bool TF > // Transpose flag
1477 template< typename Other > // Data type of the scalar value
1479 {
1480  for( size_t i=0; i<N; ++i )
1481  v_[i] *= scalar;
1482  return *this;
1483 }
1484 //*************************************************************************************************
1485 
1486 
1487 
1488 
1489 //=================================================================================================
1490 //
1491 // MEMORY FUNCTIONS
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  UNUSED_PARAMETER( size );
1511 
1512  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1513 
1514  return allocate<StaticVector>( 1UL );
1515 }
1516 //*************************************************************************************************
1517 
1518 
1519 //*************************************************************************************************
1529 template< typename Type // Data type of the vector
1530  , size_t N // Number of elements
1531  , bool TF > // Transpose flag
1532 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size )
1533 {
1534  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1535  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1536 
1537  return allocate<StaticVector>( size/sizeof(StaticVector) );
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  UNUSED_PARAMETER( size );
1558 
1559  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1560 
1561  return allocate<StaticVector>( 1UL );
1562 }
1563 //*************************************************************************************************
1564 
1565 
1566 //*************************************************************************************************
1576 template< typename Type // Data type of the vector
1577  , size_t N // Number of elements
1578  , bool TF > // Transpose flag
1579 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size, const std::nothrow_t& )
1580 {
1581  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1582  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1583 
1584  return allocate<StaticVector>( size/sizeof(StaticVector) );
1585 }
1586 //*************************************************************************************************
1587 
1588 
1589 //*************************************************************************************************
1595 template< typename Type // Data type of the vector
1596  , size_t N // Number of elements
1597  , bool TF > // Transpose flag
1598 inline void StaticVector<Type,N,TF>::operator delete( void* ptr )
1599 {
1600  deallocate( static_cast<StaticVector*>( ptr ) );
1601 }
1602 //*************************************************************************************************
1603 
1604 
1605 //*************************************************************************************************
1611 template< typename Type // Data type of the vector
1612  , size_t N // Number of elements
1613  , bool TF > // Transpose flag
1614 inline void StaticVector<Type,N,TF>::operator delete[]( void* ptr )
1615 {
1616  deallocate( static_cast<StaticVector*>( ptr ) );
1617 }
1618 //*************************************************************************************************
1619 
1620 
1621 //*************************************************************************************************
1627 template< typename Type // Data type of the vector
1628  , size_t N // Number of elements
1629  , bool TF > // Transpose flag
1630 inline void StaticVector<Type,N,TF>::operator delete( void* ptr, const std::nothrow_t& )
1631 {
1632  deallocate( static_cast<StaticVector*>( ptr ) );
1633 }
1634 //*************************************************************************************************
1635 
1636 
1637 //*************************************************************************************************
1643 template< typename Type // Data type of the vector
1644  , size_t N // Number of elements
1645  , bool TF > // Transpose flag
1646 inline void StaticVector<Type,N,TF>::operator delete[]( void* ptr, const std::nothrow_t& )
1647 {
1648  deallocate( static_cast<StaticVector*>( ptr ) );
1649 }
1650 //*************************************************************************************************
1651 
1652 
1653 
1654 
1655 //=================================================================================================
1656 //
1657 // DEBUGGING FUNCTIONS
1658 //
1659 //=================================================================================================
1660 
1661 //*************************************************************************************************
1670 template< typename Type // Data type of the vector
1671  , size_t N // Number of elements
1672  , bool TF > // Transpose flag
1673 inline bool StaticVector<Type,N,TF>::isIntact() const noexcept
1674 {
1675  if( IsNumeric<Type>::value ) {
1676  for( size_t i=N; i<NN; ++i ) {
1677  if( v_[i] != Type() )
1678  return false;
1679  }
1680  }
1681 
1682  return true;
1683 }
1684 //*************************************************************************************************
1685 
1686 
1687 
1688 
1689 //=================================================================================================
1690 //
1691 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
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 template< typename Other > // Data type of the foreign expression
1709 inline bool StaticVector<Type,N,TF>::canAlias( const Other* alias ) const noexcept
1710 {
1711  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1712 }
1713 //*************************************************************************************************
1714 
1715 
1716 //*************************************************************************************************
1726 template< typename Type // Data type of the vector
1727  , size_t N // Number of elements
1728  , bool TF > // Transpose flag
1729 template< typename Other > // Data type of the foreign expression
1730 inline bool StaticVector<Type,N,TF>::isAliased( const Other* alias ) const noexcept
1731 {
1732  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1733 }
1734 //*************************************************************************************************
1735 
1736 
1737 //*************************************************************************************************
1746 template< typename Type // Data type of the vector
1747  , size_t N // Number of elements
1748  , bool TF > // Transpose flag
1749 inline bool StaticVector<Type,N,TF>::isAligned() const noexcept
1750 {
1751  return true;
1752 }
1753 //*************************************************************************************************
1754 
1755 
1756 //*************************************************************************************************
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>::load( size_t index ) const noexcept
1773 {
1774  return loada( index );
1775 }
1776 //*************************************************************************************************
1777 
1778 
1779 //*************************************************************************************************
1792 template< typename Type // Data type of the vector
1793  , size_t N // Number of elements
1794  , bool TF > // Transpose flag
1796  StaticVector<Type,N,TF>::loada( size_t index ) const noexcept
1797 {
1798  using blaze::loada;
1799 
1801 
1802  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1803  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1804  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1805  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1806 
1807  return loada( &v_[index] );
1808 }
1809 //*************************************************************************************************
1810 
1811 
1812 //*************************************************************************************************
1825 template< typename Type // Data type of the vector
1826  , size_t N // Number of elements
1827  , bool TF > // Transpose flag
1829  StaticVector<Type,N,TF>::loadu( size_t index ) const noexcept
1830 {
1831  using blaze::loadu;
1832 
1834 
1835  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1836  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1837 
1838  return loadu( &v_[index] );
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>::store( size_t index, const SIMDType& value ) noexcept
1861 {
1862  storea( index, value );
1863 }
1864 //*************************************************************************************************
1865 
1866 
1867 //*************************************************************************************************
1880 template< typename Type // Data type of the vector
1881  , size_t N // Number of elements
1882  , bool TF > // Transpose flag
1884  StaticVector<Type,N,TF>::storea( size_t index, const SIMDType& value ) noexcept
1885 {
1886  using blaze::storea;
1887 
1889 
1890  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1891  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN , "Invalid vector access index" );
1892  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1893  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1894 
1895  storea( &v_[index], value );
1896 }
1897 //*************************************************************************************************
1898 
1899 
1900 //*************************************************************************************************
1913 template< typename Type // Data type of the vector
1914  , size_t N // Number of elements
1915  , bool TF > // Transpose flag
1917  StaticVector<Type,N,TF>::storeu( size_t index, const SIMDType& value ) noexcept
1918 {
1919  using blaze::storeu;
1920 
1922 
1923  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1924  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1925 
1926  storeu( &v_[index], value );
1927 }
1928 //*************************************************************************************************
1929 
1930 
1931 //*************************************************************************************************
1945 template< typename Type // Data type of the vector
1946  , size_t N // Number of elements
1947  , bool TF > // Transpose flag
1949  StaticVector<Type,N,TF>::stream( size_t index, const SIMDType& value ) noexcept
1950 {
1951  using blaze::stream;
1952 
1954 
1955  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1956  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1957  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1958  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1959 
1960  stream( &v_[index], value );
1961 }
1962 //*************************************************************************************************
1963 
1964 
1965 //*************************************************************************************************
1976 template< typename Type // Data type of the vector
1977  , size_t N // Number of elements
1978  , bool TF > // Transpose flag
1979 template< typename VT > // Type of the right-hand side dense vector
1982 {
1983  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1984 
1985  for( size_t i=0UL; i<N; ++i )
1986  v_[i] = (~rhs)[i];
1987 }
1988 //*************************************************************************************************
1989 
1990 
1991 //*************************************************************************************************
2002 template< typename Type // Data type of the vector
2003  , size_t N // Number of elements
2004  , bool TF > // Transpose flag
2005 template< typename VT > // Type of the right-hand side dense vector
2008 {
2010 
2011  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2012 
2013  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2014 
2015  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2016  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2017 
2018  size_t i( 0UL );
2019 
2020  for( ; i<ipos; i+=SIMDSIZE ) {
2021  store( i, (~rhs).load(i) );
2022  }
2023  for( ; remainder && i<N; ++i ) {
2024  v_[i] = (~rhs)[i];
2025  }
2026 }
2027 //*************************************************************************************************
2028 
2029 
2030 //*************************************************************************************************
2041 template< typename Type // Data type of the vector
2042  , size_t N // Number of elements
2043  , bool TF > // Transpose flag
2044 template< typename VT > // Type of the right-hand side sparse vector
2046 {
2047  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2048 
2049  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2050  v_[element->index()] = element->value();
2051 }
2052 //*************************************************************************************************
2053 
2054 
2055 //*************************************************************************************************
2066 template< typename Type // Data type of the vector
2067  , size_t N // Number of elements
2068  , bool TF > // Transpose flag
2069 template< typename VT > // Type of the right-hand side dense vector
2070 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2072 {
2073  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2074 
2075  for( size_t i=0UL; i<N; ++i )
2076  v_[i] += (~rhs)[i];
2077 }
2078 //*************************************************************************************************
2079 
2080 
2081 //*************************************************************************************************
2092 template< typename Type // Data type of the vector
2093  , size_t N // Number of elements
2094  , bool TF > // Transpose flag
2095 template< typename VT > // Type of the right-hand side dense vector
2096 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2098 {
2100 
2101  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2102 
2103  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2104 
2105  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2106  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2107 
2108  size_t i( 0UL );
2109 
2110  for( ; i<ipos; i+=SIMDSIZE ) {
2111  store( i, load(i) + (~rhs).load(i) );
2112  }
2113  for( ; remainder && i<N; ++i ) {
2114  v_[i] += (~rhs)[i];
2115  }
2116 }
2117 //*************************************************************************************************
2118 
2119 
2120 //*************************************************************************************************
2131 template< typename Type // Data type of the vector
2132  , size_t N // Number of elements
2133  , bool TF > // Transpose flag
2134 template< typename VT > // Type of the right-hand side sparse vector
2136 {
2137  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2138 
2139  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2140  v_[element->index()] += element->value();
2141 }
2142 //*************************************************************************************************
2143 
2144 
2145 //*************************************************************************************************
2156 template< typename Type // Data type of the vector
2157  , size_t N // Number of elements
2158  , bool TF > // Transpose flag
2159 template< typename VT > // Type of the right-hand side dense vector
2160 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2162 {
2163  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2164 
2165  for( size_t i=0UL; i<N; ++i )
2166  v_[i] -= (~rhs)[i];
2167 }
2168 //*************************************************************************************************
2169 
2170 
2171 //*************************************************************************************************
2182 template< typename Type // Data type of the vector
2183  , size_t N // Number of elements
2184  , bool TF > // Transpose flag
2185 template< typename VT > // Type of the right-hand side dense vector
2186 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2188 {
2190 
2191  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2192 
2193  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2194 
2195  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2196  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2197 
2198  size_t i( 0UL );
2199 
2200  for( ; i<ipos; i+=SIMDSIZE ) {
2201  store( i, load(i) - (~rhs).load(i) );
2202  }
2203  for( ; remainder && i<N; ++i ) {
2204  v_[i] -= (~rhs)[i];
2205  }
2206 }
2207 //*************************************************************************************************
2208 
2209 
2210 //*************************************************************************************************
2221 template< typename Type // Data type of the vector
2222  , size_t N // Number of elements
2223  , bool TF > // Transpose flag
2224 template< typename VT > // Type of the right-hand side sparse vector
2226 {
2227  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2228 
2229  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2230  v_[element->index()] -= element->value();
2231 }
2232 //*************************************************************************************************
2233 
2234 
2235 //*************************************************************************************************
2246 template< typename Type // Data type of the vector
2247  , size_t N // Number of elements
2248  , bool TF > // Transpose flag
2249 template< typename VT > // Type of the right-hand side dense vector
2250 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2252 {
2253  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2254 
2255  for( size_t i=0UL; i<N; ++i )
2256  v_[i] *= (~rhs)[i];
2257 }
2258 //*************************************************************************************************
2259 
2260 
2261 //*************************************************************************************************
2272 template< typename Type // Data type of the vector
2273  , size_t N // Number of elements
2274  , bool TF > // Transpose flag
2275 template< typename VT > // Type of the right-hand side dense vector
2276 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2278 {
2280 
2281  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2282 
2283  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2284 
2285  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2286  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2287 
2288  size_t i( 0UL );
2289 
2290  for( ; i<ipos; i+=SIMDSIZE ) {
2291  store( i, load(i) * (~rhs).load(i) );
2292  }
2293  for( ; remainder && i<N; ++i ) {
2294  v_[i] *= (~rhs)[i];
2295  }
2296 }
2297 //*************************************************************************************************
2298 
2299 
2300 //*************************************************************************************************
2311 template< typename Type // Data type of the vector
2312  , size_t N // Number of elements
2313  , bool TF > // Transpose flag
2314 template< typename VT > // Type of the right-hand side sparse vector
2316 {
2317  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2318 
2319  const StaticVector tmp( serial( *this ) );
2320 
2321  reset();
2322 
2323  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2324  v_[element->index()] = tmp[element->index()] * element->value();
2325 }
2326 //*************************************************************************************************
2327 
2328 
2329 //*************************************************************************************************
2340 template< typename Type // Data type of the vector
2341  , size_t N // Number of elements
2342  , bool TF > // Transpose flag
2343 template< typename VT > // Type of the right-hand side dense vector
2344 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2346 {
2347  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2348 
2349  for( size_t i=0UL; i<N; ++i )
2350  v_[i] /= (~rhs)[i];
2351 }
2352 //*************************************************************************************************
2353 
2354 
2355 //*************************************************************************************************
2366 template< typename Type // Data type of the vector
2367  , size_t N // Number of elements
2368  , bool TF > // Transpose flag
2369 template< typename VT > // Type of the right-hand side dense vector
2370 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2372 {
2374 
2375  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2376 
2377  const size_t ipos( N & size_t(-SIMDSIZE) );
2378  BLAZE_INTERNAL_ASSERT( ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2379 
2380  size_t i( 0UL );
2381 
2382  for( ; i<ipos; i+=SIMDSIZE ) {
2383  store( i, load(i) / (~rhs).load(i) );
2384  }
2385  for( ; i<N; ++i ) {
2386  v_[i] /= (~rhs)[i];
2387  }
2388 }
2389 //*************************************************************************************************
2390 
2391 
2392 
2393 
2394 
2395 
2396 
2397 
2398 //=================================================================================================
2399 //
2400 // UNDEFINED CLASS TEMPLATE SPECIALIZATION
2401 //
2402 //=================================================================================================
2403 
2404 //*************************************************************************************************
2412 template< typename Type // Data type of the vector
2413  , bool TF > // Transpose flag
2414 class StaticVector<Type,0UL,TF>;
2416 //*************************************************************************************************
2417 
2418 
2419 
2420 
2421 
2422 
2423 
2424 
2425 //=================================================================================================
2426 //
2427 // STATICVECTOR OPERATORS
2428 //
2429 //=================================================================================================
2430 
2431 //*************************************************************************************************
2434 template< typename Type, size_t N, bool TF >
2435 inline void reset( StaticVector<Type,N,TF>& v );
2436 
2437 template< typename Type, size_t N, bool TF >
2438 inline void clear( StaticVector<Type,N,TF>& v );
2439 
2440 template< bool RF, typename Type, size_t N, bool TF >
2441 inline bool isDefault( const StaticVector<Type,N,TF>& v );
2442 
2443 template< typename Type, size_t N, bool TF >
2444 inline bool isIntact( const StaticVector<Type,N,TF>& v ) noexcept;
2445 
2446 template< typename Type, bool TF >
2448 
2449 template< typename Type, bool TF >
2451 
2452 template< typename Type, size_t N, bool TF >
2453 inline void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) noexcept;
2455 //*************************************************************************************************
2456 
2457 
2458 //*************************************************************************************************
2465 template< typename Type // Data type of the vector
2466  , size_t N // Number of elements
2467  , bool TF > // Transpose flag
2469 {
2470  v.reset();
2471 }
2472 //*************************************************************************************************
2473 
2474 
2475 //*************************************************************************************************
2484 template< typename Type // Data type of the vector
2485  , size_t N // Number of elements
2486  , bool TF > // Transpose flag
2488 {
2489  v.reset();
2490 }
2491 //*************************************************************************************************
2492 
2493 
2494 //*************************************************************************************************
2519 template< bool RF // Relaxation flag
2520  , typename Type // Data type of the vector
2521  , size_t N // Number of elements
2522  , bool TF > // Transpose flag
2523 inline bool isDefault( const StaticVector<Type,N,TF>& v )
2524 {
2525  for( size_t i=0UL; i<N; ++i )
2526  if( !isDefault<RF>( v[i] ) ) return false;
2527  return true;
2528 }
2529 //*************************************************************************************************
2530 
2531 
2532 //*************************************************************************************************
2550 template< typename Type // Data type of the vector
2551  , size_t N // Number of elements
2552  , bool TF > // Transpose flag
2553 inline bool isIntact( const StaticVector<Type,N,TF>& v ) noexcept
2554 {
2555  return v.isIntact();
2556 }
2557 //*************************************************************************************************
2558 
2559 
2560 //*************************************************************************************************
2571 template< typename Type // Data type of the vector
2572  , bool TF > // Transpose flag
2574 {
2575  return StaticVector<Type,2UL,TF>( -v[1UL], v[0UL] );
2576 }
2577 //*************************************************************************************************
2578 
2579 
2580 //*************************************************************************************************
2588 template< typename Type // Data type of the vector
2589  , bool TF > // Transpose flag
2591 {
2592  if( v[0] != Type() || v[1] != Type() )
2593  return StaticVector<Type,3UL,TF>( v[1UL], -v[0UL], Type() );
2594  else
2595  return StaticVector<Type,3UL,TF>( Type(), v[2UL], -v[1UL] );
2596 }
2597 //*************************************************************************************************
2598 
2599 
2600 //*************************************************************************************************
2608 template< typename Type // Data type of the vector
2609  , size_t N // Number of elements
2610  , bool TF > // Transpose flag
2612 {
2613  a.swap( b );
2614 }
2615 //*************************************************************************************************
2616 
2617 
2618 
2619 
2620 //=================================================================================================
2621 //
2622 // SIZE SPECIALIZATIONS
2623 //
2624 //=================================================================================================
2625 
2626 //*************************************************************************************************
2628 template< typename T, size_t N, bool TF >
2629 struct Size< StaticVector<T,N,TF> > : public SizeT<N>
2630 {};
2632 //*************************************************************************************************
2633 
2634 
2635 
2636 
2637 //=================================================================================================
2638 //
2639 // HASCONSTDATAACCESS SPECIALIZATIONS
2640 //
2641 //=================================================================================================
2642 
2643 //*************************************************************************************************
2645 template< typename T, size_t N, bool TF >
2646 struct HasConstDataAccess< StaticVector<T,N,TF> > : public TrueType
2647 {};
2649 //*************************************************************************************************
2650 
2651 
2652 
2653 
2654 //=================================================================================================
2655 //
2656 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2657 //
2658 //=================================================================================================
2659 
2660 //*************************************************************************************************
2662 template< typename T, size_t N, bool TF >
2663 struct HasMutableDataAccess< StaticVector<T,N,TF> > : public TrueType
2664 {};
2666 //*************************************************************************************************
2667 
2668 
2669 
2670 
2671 //=================================================================================================
2672 //
2673 // ISALIGNED SPECIALIZATIONS
2674 //
2675 //=================================================================================================
2676 
2677 //*************************************************************************************************
2679 template< typename T, size_t N, bool TF >
2680 struct IsAligned< StaticVector<T,N,TF> > : public TrueType
2681 {};
2683 //*************************************************************************************************
2684 
2685 
2686 
2687 
2688 //=================================================================================================
2689 //
2690 // ISPADDED SPECIALIZATIONS
2691 //
2692 //=================================================================================================
2693 
2694 //*************************************************************************************************
2696 template< typename T, size_t N, bool TF >
2697 struct IsPadded< StaticVector<T,N,TF> > : public BoolConstant<usePadding>
2698 {};
2700 //*************************************************************************************************
2701 
2702 
2703 
2704 
2705 //=================================================================================================
2706 //
2707 // ADDTRAIT SPECIALIZATIONS
2708 //
2709 //=================================================================================================
2710 
2711 //*************************************************************************************************
2713 template< typename T1, size_t N, bool TF, typename T2 >
2714 struct AddTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2715 {
2716  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2717 };
2719 //*************************************************************************************************
2720 
2721 
2722 
2723 
2724 //=================================================================================================
2725 //
2726 // SUBTRAIT SPECIALIZATIONS
2727 //
2728 //=================================================================================================
2729 
2730 //*************************************************************************************************
2732 template< typename T1, size_t N, bool TF, typename T2 >
2733 struct SubTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2734 {
2735  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2736 };
2738 //*************************************************************************************************
2739 
2740 
2741 
2742 
2743 //=================================================================================================
2744 //
2745 // MULTTRAIT SPECIALIZATIONS
2746 //
2747 //=================================================================================================
2748 
2749 //*************************************************************************************************
2751 template< typename T1, size_t N, bool TF, typename T2 >
2752 struct MultTrait< StaticVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2753 {
2754  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2755 };
2756 
2757 template< typename T1, typename T2, size_t N, bool TF >
2758 struct MultTrait< T1, StaticVector<T2,N,TF>, EnableIf_<IsNumeric<T1> > >
2759 {
2760  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2761 };
2762 
2763 template< typename T1, size_t N, bool TF, typename T2 >
2764 struct MultTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2765 {
2766  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2767 };
2768 
2769 template< typename T1, size_t M, typename T2, size_t N >
2770 struct MultTrait< StaticVector<T1,M,false>, StaticVector<T2,N,true> >
2771 {
2772  using Type = StaticMatrix< MultTrait_<T1,T2>, M, N, false >;
2773 };
2774 
2775 template< typename T1, size_t N, typename T2 >
2776 struct MultTrait< StaticVector<T1,N,true>, StaticVector<T2,N,false> >
2777 {
2778  using Type = MultTrait_<T1,T2>;
2779 };
2781 //*************************************************************************************************
2782 
2783 
2784 
2785 
2786 //=================================================================================================
2787 //
2788 // CROSSTRAIT SPECIALIZATIONS
2789 //
2790 //=================================================================================================
2791 
2792 //*************************************************************************************************
2794 template< typename T1, typename T2, bool TF >
2795 struct CrossTrait< StaticVector<T1,3UL,TF>, StaticVector<T2,3UL,TF> >
2796 {
2797  private:
2798  using T = MultTrait_<T1,T2>;
2799 
2800  public:
2801  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2802 };
2804 //*************************************************************************************************
2805 
2806 
2807 
2808 
2809 //=================================================================================================
2810 //
2811 // DIVTRAIT SPECIALIZATIONS
2812 //
2813 //=================================================================================================
2814 
2815 //*************************************************************************************************
2817 template< typename T1, size_t N, bool TF, typename T2 >
2818 struct DivTrait< StaticVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2819 {
2820  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2821 };
2822 
2823 template< typename T1, size_t N, bool TF, typename T2 >
2824 struct DivTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2825 {
2826  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2827 };
2829 //*************************************************************************************************
2830 
2831 
2832 
2833 
2834 //=================================================================================================
2835 //
2836 // HIGHTYPE SPECIALIZATIONS
2837 //
2838 //=================================================================================================
2839 
2840 //*************************************************************************************************
2842 template< typename T1, size_t N, bool TF, typename T2 >
2843 struct HighType< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2844 {
2845  using Type = StaticVector< typename HighType<T1,T2>::Type, N, TF >;
2846 };
2848 //*************************************************************************************************
2849 
2850 
2851 
2852 
2853 //=================================================================================================
2854 //
2855 // LOWTYPE SPECIALIZATIONS
2856 //
2857 //=================================================================================================
2858 
2859 //*************************************************************************************************
2861 template< typename T1, size_t N, bool TF, typename T2 >
2862 struct LowType< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2863 {
2864  using Type = StaticVector< typename LowType<T1,T2>::Type, N, TF >;
2865 };
2867 //*************************************************************************************************
2868 
2869 
2870 
2871 
2872 //=================================================================================================
2873 //
2874 // SUBVECTORTRAIT SPECIALIZATIONS
2875 //
2876 //=================================================================================================
2877 
2878 //*************************************************************************************************
2880 template< typename T1, size_t N, bool TF >
2881 struct SubvectorTrait< StaticVector<T1,N,TF> >
2882 {
2883  using Type = HybridVector<T1,N,TF>;
2884 };
2886 //*************************************************************************************************
2887 
2888 } // namespace blaze
2889 
2890 #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
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: StaticVector.h:1730
Header file for the alignment flag values.
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the static vector.
Definition: StaticVector.h:930
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:194
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
DenseVector< This, TF > BaseType
Base type of this StaticVector instance.
Definition: StaticVector.h:184
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.
Availability of a SIMD addition for the given data types.Depending on the available instruction set (...
Definition: HasSIMDAdd.h:163
#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 the SizeT class template.
Iterator end() noexcept
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:945
Header file for memory allocation and deallocation functionality.
System settings for performance optimizations.
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
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
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
void swap(StaticVector &v) noexcept
Swapping the contents of two static vectors.
Definition: StaticVector.h:1450
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.
const StaticVector & CompositeType
Data type for composite expression templates.
Definition: StaticVector.h:190
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
Resize mechanism to obtain a StaticVector with a different fixed number of elements.
Definition: StaticVector.h:214
Compile time assertion.
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: StaticVector.h:1749
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
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:1949
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:824
StaticVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: StaticVector.h:999
#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.
Efficient implementation of a fixed-sized matrix.The StaticMatrix class template is the representatio...
Definition: Forward.h:60
constexpr size_t capacity() const noexcept
Returns the maximum capacity of the vector.
Definition: StaticVector.h:1392
Header file for the DenseIterator class template.
const Type * ConstPointer
Pointer to a constant vector value.
Definition: StaticVector.h:195
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
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticVector.h:189
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
StaticVector< NewType, N, TF > Other
The type of the other StaticVector.
Definition: StaticVector.h:206
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: StaticVector.h:1796
void reset()
Reset to the default initial values.
Definition: StaticVector.h:1432
#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:868
Header file for the exception macros of the math module.
Iterator begin() noexcept
Returns an iterator to the first element of the static vector.
Definition: StaticVector.h:900
This ResultType
Result type for expression template evaluations.
Definition: StaticVector.h:185
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:2573
DenseIterator< const Type, aligned > ConstIterator
Iterator over constant elements.
Definition: StaticVector.h:198
constexpr size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: StaticVector.h:1377
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.
StaticVector< Type, NewN, TF > Other
The type of the other StaticVector.
Definition: StaticVector.h:215
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
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: StaticVector.h:478
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 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
Compile time integral constant wrapper for size_t.The SizeT class template represents an integral wra...
Definition: SizeT.h:72
Type ElementType
Type of the vector elements.
Definition: StaticVector.h:187
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
StaticVector()
The default constructor for StaticVector.
Definition: StaticVector.h:517
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:143
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:975
Base template for the MultTrait class.
Definition: MultTrait.h:143
Header file for the addition trait.
DenseIterator< Type, aligned > Iterator
Iterator over non-constant elements.
Definition: StaticVector.h:197
Header file for the cross product trait.
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: StaticVector.h:1709
Header file for the division trait.
Constraint on the data type.
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
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: StaticVector.h:1829
Header file for the isDefault shim.
StaticVector< Type, N, TF > This
Type of this StaticVector instance.
Definition: StaticVector.h:183
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: StaticVector.h:781
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
bool isIntact() const noexcept
Returns whether the invariants of the static vector are intact.
Definition: StaticVector.h:1673
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
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
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.
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: StaticVector.h:1410
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:164
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:186
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:1884
Compile time evaluation of the size of a vector.The Size type trait evaluates the size of the given v...
Definition: Size.h:75
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.
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: StaticVector.h:1917
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
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
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: StaticVector.h:1772
Rebind mechanism to obtain a StaticVector with different data/element type.
Definition: StaticVector.h:205
const Type & ConstReference
Reference to a constant vector value.
Definition: StaticVector.h:193
Header file for the HighType type trait.
Header file for the TrueType type/value trait base class.
Type & Reference
Reference to a non-constant vector value.
Definition: StaticVector.h:192
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: StaticVector.h:1860
SIMDTrait_< ElementType > SIMDType
SIMD type of the vector elements.
Definition: StaticVector.h:188