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>
51 #include <blaze/math/Exception.h>
54 #include <blaze/math/Forward.h>
55 #include <blaze/math/Functions.h>
57 #include <blaze/math/shims/Clear.h>
60 #include <blaze/math/SIMD.h>
85 #include <blaze/system/Inline.h>
90 #include <blaze/util/Assert.h>
96 #include <blaze/util/DisableIf.h>
97 #include <blaze/util/EnableIf.h>
99 #include <blaze/util/Memory.h>
100 #include <blaze/util/mpl/PtrdiffT.h>
101 #include <blaze/util/StaticAssert.h>
102 #include <blaze/util/Template.h>
103 #include <blaze/util/TrueType.h>
104 #include <blaze/util/Types.h>
107 #include <blaze/util/Unused.h>
108 
109 
110 namespace blaze {
111 
112 //=================================================================================================
113 //
114 // CLASS DEFINITION
115 //
116 //=================================================================================================
117 
118 //*************************************************************************************************
184 template< typename Type // Data type of the vector
185  , size_t N // Number of elements
186  , bool TF = defaultTransposeFlag > // Transpose flag
187 class StaticVector
188  : public DenseVector< StaticVector<Type,N,TF>, TF >
189 {
190  public:
191  //**Type definitions****************************************************************************
194  using ResultType = This;
196  using ElementType = Type;
198  using ReturnType = const Type&;
199  using CompositeType = const StaticVector&;
200 
201  using Reference = Type&;
202  using ConstReference = const Type&;
203  using Pointer = Type*;
204  using ConstPointer = const Type*;
205 
208  //**********************************************************************************************
209 
210  //**Rebind struct definition********************************************************************
213  template< typename NewType > // Data type of the other vector
214  struct Rebind {
216  };
217  //**********************************************************************************************
218 
219  //**Resize struct definition********************************************************************
222  template< size_t NewN > // Number of elements of the other vector
223  struct Resize {
225  };
226  //**********************************************************************************************
227 
228  //**Compilation flags***************************************************************************
230 
234  enum : bool { simdEnabled = IsVectorizable<Type>::value };
235 
237 
240  enum : bool { smpAssignable = false };
241  //**********************************************************************************************
242 
243  //**Constructors********************************************************************************
246  explicit inline StaticVector();
247  explicit inline StaticVector( const Type& init );
248  explicit inline StaticVector( initializer_list<Type> list );
249 
250  template< typename Other >
251  explicit inline StaticVector( size_t n, const Other* array );
252 
253  template< typename Other, size_t Dim >
254  explicit inline StaticVector( const Other (&array)[Dim] );
255 
256  inline StaticVector( const StaticVector& v );
257  template< typename Other > inline StaticVector( const StaticVector<Other,N,TF>& v );
258  template< typename VT > inline StaticVector( const Vector<VT,TF>& v );
260  //**********************************************************************************************
261 
262  //**Destructor**********************************************************************************
263  // No explicitly declared destructor.
264  //**********************************************************************************************
265 
266  //**Data access functions***********************************************************************
269  inline Reference operator[]( size_t index ) noexcept;
270  inline ConstReference operator[]( size_t index ) const noexcept;
271  inline Reference at( size_t index );
272  inline ConstReference at( size_t index ) const;
273  inline Pointer data () noexcept;
274  inline ConstPointer data () const noexcept;
275  inline Iterator begin () noexcept;
276  inline ConstIterator begin () const noexcept;
277  inline ConstIterator cbegin() const noexcept;
278  inline Iterator end () noexcept;
279  inline ConstIterator end () const noexcept;
280  inline ConstIterator cend () const noexcept;
282  //**********************************************************************************************
283 
284  //**Assignment operators************************************************************************
287  inline StaticVector& operator=( const Type& rhs );
288  inline StaticVector& operator=( initializer_list<Type> list );
289 
290  template< typename Other, size_t Dim >
291  inline StaticVector& operator=( const Other (&array)[Dim] );
292 
293  inline StaticVector& operator=( const StaticVector& rhs );
294  template< typename Other > inline StaticVector& operator=( const StaticVector<Other,N,TF>& rhs );
295 
296  template< typename VT > inline StaticVector& operator= ( const Vector<VT,TF>& rhs );
297  template< typename VT > inline StaticVector& operator+=( const Vector<VT,TF>& rhs );
298  template< typename VT > inline StaticVector& operator-=( const Vector<VT,TF>& rhs );
299  template< typename VT > inline StaticVector& operator*=( const Vector<VT,TF>& rhs );
300  template< typename VT > inline StaticVector& operator/=( const DenseVector<VT,TF>& rhs );
301  template< typename VT > inline StaticVector& operator%=( const Vector<VT,TF>& rhs );
303  //**********************************************************************************************
304 
305  //**Utility functions***************************************************************************
308  static inline constexpr size_t size() noexcept;
309  static inline constexpr size_t spacing() noexcept;
310  static inline constexpr size_t capacity() noexcept;
311  inline size_t nonZeros() const;
312  inline void reset();
313  inline void swap( StaticVector& v ) noexcept;
315  //**********************************************************************************************
316 
317  //**Numeric functions***************************************************************************
320  template< typename Other > inline StaticVector& scale( const Other& scalar );
322  //**********************************************************************************************
323 
324  //**Memory functions****************************************************************************
327  static inline void* operator new ( std::size_t size );
328  static inline void* operator new[]( std::size_t size );
329  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
330  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
331 
332  static inline void operator delete ( void* ptr );
333  static inline void operator delete[]( void* ptr );
334  static inline void operator delete ( void* ptr, const std::nothrow_t& );
335  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
337  //**********************************************************************************************
338 
339  private:
340  //**********************************************************************************************
342  template< typename VT >
344  struct VectorizedAssign {
345  enum : bool { value = useOptimizedKernels &&
346  simdEnabled && VT::simdEnabled &&
348  };
350  //**********************************************************************************************
351 
352  //**********************************************************************************************
354  template< typename VT >
356  struct VectorizedAddAssign {
357  enum : bool { value = useOptimizedKernels &&
358  simdEnabled && VT::simdEnabled &&
361  };
363  //**********************************************************************************************
364 
365  //**********************************************************************************************
367  template< typename VT >
369  struct VectorizedSubAssign {
370  enum : bool { value = useOptimizedKernels &&
371  simdEnabled && VT::simdEnabled &&
374  };
376  //**********************************************************************************************
377 
378  //**********************************************************************************************
380  template< typename VT >
382  struct VectorizedMultAssign {
383  enum : bool { value = useOptimizedKernels &&
384  simdEnabled && VT::simdEnabled &&
387  };
389  //**********************************************************************************************
390 
391  //**********************************************************************************************
393  template< typename VT >
395  struct VectorizedDivAssign {
396  enum : bool { value = useOptimizedKernels &&
397  simdEnabled && VT::simdEnabled &&
400  };
402  //**********************************************************************************************
403 
404  //**********************************************************************************************
406  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
407  //**********************************************************************************************
408 
409  public:
410  //**Debugging functions*************************************************************************
413  inline bool isIntact() const noexcept;
415  //**********************************************************************************************
416 
417  //**Expression template evaluation functions****************************************************
420  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
421  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
422 
423  inline bool isAligned() const noexcept;
424 
425  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
426  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
427  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
428 
429  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
430  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
431  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
432  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
433 
434  template< typename VT >
435  inline DisableIf_< VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
436 
437  template< typename VT >
438  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
439 
440  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
441 
442  template< typename VT >
443  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
444 
445  template< typename VT >
446  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
447 
448  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
449 
450  template< typename VT >
451  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
452 
453  template< typename VT >
454  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
455 
456  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
457 
458  template< typename VT >
459  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
460 
461  template< typename VT >
462  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
463 
464  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
465 
466  template< typename VT >
467  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
468 
469  template< typename VT >
470  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
472  //**********************************************************************************************
473 
474  private:
475  //**********************************************************************************************
477  enum : size_t { NN = ( usePadding )?( nextMultiple( N, SIMDSIZE ) ):( N ) };
478  //**********************************************************************************************
479 
480  //**Member variables****************************************************************************
484 
490  //**********************************************************************************************
491 
492  //**Compile time checks*************************************************************************
498  BLAZE_STATIC_ASSERT( !usePadding || ( NN % SIMDSIZE == 0UL ) );
499  BLAZE_STATIC_ASSERT( NN >= N );
501  //**********************************************************************************************
502 };
503 //*************************************************************************************************
504 
505 
506 
507 
508 //=================================================================================================
509 //
510 // CONSTRUCTORS
511 //
512 //=================================================================================================
513 
514 //*************************************************************************************************
519 template< typename Type // Data type of the vector
520  , size_t N // Number of elements
521  , bool TF > // Transpose flag
523  : v_() // The statically allocated vector elements
524 {
526 
527  if( IsNumeric<Type>::value ) {
528  for( size_t i=0UL; i<NN; ++i )
529  v_[i] = Type();
530  }
531 
532  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
533 }
534 //*************************************************************************************************
535 
536 
537 //*************************************************************************************************
542 template< typename Type // Data type of the vector
543  , size_t N // Number of elements
544  , bool TF > // Transpose flag
545 inline StaticVector<Type,N,TF>::StaticVector( const Type& init )
546  : v_() // The statically allocated vector elements
547 {
549 
550  for( size_t i=0UL; i<N; ++i )
551  v_[i] = init;
552 
553  for( size_t i=N; i<NN; ++i )
554  v_[i] = Type();
555 
556  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
557 }
558 //*************************************************************************************************
559 
560 
561 //*************************************************************************************************
578 template< typename Type // Data type of the vector
579  , size_t N // Number of elements
580  , bool TF > // Transpose flag
582  : v_() // The statically allocated vector elements
583 {
585 
586  if( list.size() > N ) {
587  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
588  }
589 
590  std::fill( std::copy( list.begin(), list.end(), v_.data() ), v_.data()+NN, Type() );
591 
592  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
593 }
594 //*************************************************************************************************
595 
596 
597 //*************************************************************************************************
619 template< typename Type // Data type of the vector
620  , size_t N // Number of elements
621  , bool TF > // Transpose flag
622 template< typename Other > // Data type of the initialization array
623 inline StaticVector<Type,N,TF>::StaticVector( size_t n, const Other* array )
624  : v_() // The statically allocated vector elements
625 {
627 
628  if( n > N ) {
629  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
630  }
631 
632  for( size_t i=0UL; i<n; ++i )
633  v_[i] = array[i];
634 
635  if( IsNumeric<Type>::value ) {
636  for( size_t i=n; i<NN; ++i )
637  v_[i] = Type();
638  }
639 
640  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
641 }
642 //*************************************************************************************************
643 
644 
645 //*************************************************************************************************
661 template< typename Type // Data type of the vector
662  , size_t N // Number of elements
663  , bool TF > // Transpose flag
664 template< typename Other // Data type of the initialization array
665  , size_t Dim > // Dimension of the initialization array
666 inline StaticVector<Type,N,TF>::StaticVector( const Other (&array)[Dim] )
667  : v_() // The statically allocated vector elements
668 {
670  BLAZE_STATIC_ASSERT( Dim == N );
671 
672  for( size_t i=0UL; i<N; ++i )
673  v_[i] = array[i];
674 
675  for( size_t i=N; i<NN; ++i )
676  v_[i] = Type();
677 
678  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
679 }
680 //*************************************************************************************************
681 
682 
683 //*************************************************************************************************
690 template< typename Type // Data type of the vector
691  , size_t N // Number of elements
692  , bool TF > // Transpose flag
693 inline StaticVector<Type,N,TF>::StaticVector( const StaticVector& v )
694  : v_() // The statically allocated vector elements
695 {
697 
698  for( size_t i=0UL; i<NN; ++i )
699  v_[i] = v.v_[i];
700 
701  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
702 }
703 //*************************************************************************************************
704 
705 
706 //*************************************************************************************************
711 template< typename Type // Data type of the vector
712  , size_t N // Number of elements
713  , bool TF > // Transpose flag
714 template< typename Other > // Data type of the foreign vector
716  : v_() // The statically allocated vector elements
717 {
719 
720  for( size_t i=0UL; i<N; ++i )
721  v_[i] = v[i];
722 
723  for( size_t i=N; i<NN; ++i )
724  v_[i] = Type();
725 
726  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
727 }
728 //*************************************************************************************************
729 
730 
731 //*************************************************************************************************
741 template< typename Type // Data type of the vector
742  , size_t N // Number of elements
743  , bool TF > // Transpose flag
744 template< typename VT > // Type of the foreign vector
746  : v_() // The statically allocated vector elements
747 {
748  using blaze::assign;
749 
751 
752  if( (~v).size() != N ) {
753  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
754  }
755 
756  for( size_t i=( IsSparseVector<VT>::value ? 0UL : N ); i<NN; ++i ) {
757  v_[i] = Type();
758  }
759 
760  assign( *this, ~v );
761 
762  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
763 }
764 //*************************************************************************************************
765 
766 
767 
768 
769 //=================================================================================================
770 //
771 // DATA ACCESS FUNCTIONS
772 //
773 //=================================================================================================
774 
775 //*************************************************************************************************
784 template< typename Type // Data type of the vector
785  , size_t N // Number of elements
786  , bool TF > // Transpose flag
788  StaticVector<Type,N,TF>::operator[]( size_t index ) noexcept
789 {
790  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
791  return v_[index];
792 }
793 //*************************************************************************************************
794 
795 
796 //*************************************************************************************************
805 template< typename Type // Data type of the vector
806  , size_t N // Number of elements
807  , bool TF > // Transpose flag
809  StaticVector<Type,N,TF>::operator[]( size_t index ) const noexcept
810 {
811  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
812  return v_[index];
813 }
814 //*************************************************************************************************
815 
816 
817 //*************************************************************************************************
827 template< typename Type // Data type of the vector
828  , size_t N // Number of elements
829  , bool TF > // Transpose flag
832 {
833  if( index >= N ) {
834  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
835  }
836  return (*this)[index];
837 }
838 //*************************************************************************************************
839 
840 
841 //*************************************************************************************************
851 template< typename Type // Data type of the vector
852  , size_t N // Number of elements
853  , bool TF > // Transpose flag
855  StaticVector<Type,N,TF>::at( size_t index ) const
856 {
857  if( index >= N ) {
858  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
859  }
860  return (*this)[index];
861 }
862 //*************************************************************************************************
863 
864 
865 //*************************************************************************************************
872 template< typename Type // Data type of the vector
873  , size_t N // Number of elements
874  , bool TF > // Transpose flag
876 {
877  return v_;
878 }
879 //*************************************************************************************************
880 
881 
882 //*************************************************************************************************
889 template< typename Type // Data type of the vector
890  , size_t N // Number of elements
891  , bool TF > // Transpose flag
893 {
894  return v_;
895 }
896 //*************************************************************************************************
897 
898 
899 //*************************************************************************************************
904 template< typename Type // Data type of the vector
905  , size_t N // Number of elements
906  , bool TF > // Transpose flag
908 {
909  return Iterator( v_ );
910 }
911 //*************************************************************************************************
912 
913 
914 //*************************************************************************************************
919 template< typename Type // Data type of the vector
920  , size_t N // Number of elements
921  , bool TF > // Transpose flag
923 {
924  return ConstIterator( v_ );
925 }
926 //*************************************************************************************************
927 
928 
929 //*************************************************************************************************
934 template< typename Type // Data type of the vector
935  , size_t N // Number of elements
936  , bool TF > // Transpose flag
938 {
939  return ConstIterator( v_ );
940 }
941 //*************************************************************************************************
942 
943 
944 //*************************************************************************************************
949 template< typename Type // Data type of the vector
950  , size_t N // Number of elements
951  , bool TF > // Transpose flag
953 {
954  return Iterator( v_ + N );
955 }
956 //*************************************************************************************************
957 
958 
959 //*************************************************************************************************
964 template< typename Type // Data type of the vector
965  , size_t N // Number of elements
966  , bool TF > // Transpose flag
968 {
969  return ConstIterator( v_ + N );
970 }
971 //*************************************************************************************************
972 
973 
974 //*************************************************************************************************
979 template< typename Type // Data type of the vector
980  , size_t N // Number of elements
981  , bool TF > // Transpose flag
983 {
984  return ConstIterator( v_ + N );
985 }
986 //*************************************************************************************************
987 
988 
989 
990 
991 //=================================================================================================
992 //
993 // ASSIGNMENT OPERATORS
994 //
995 //=================================================================================================
996 
997 //*************************************************************************************************
1003 template< typename Type // Data type of the vector
1004  , size_t N // Number of elements
1005  , bool TF > // Transpose flag
1007 {
1008  for( size_t i=0UL; i<N; ++i )
1009  v_[i] = rhs;
1010  return *this;
1011 }
1012 //*************************************************************************************************
1013 
1014 
1015 //*************************************************************************************************
1033 template< typename Type // Data type of the vector
1034  , size_t N // Number of elements
1035  , bool TF > // Transpose flag
1037 {
1038  if( list.size() > N ) {
1039  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to static vector" );
1040  }
1041 
1042  std::fill( std::copy( list.begin(), list.end(), v_.data() ), v_.data()+N, Type() );
1043 
1044  return *this;
1045 }
1046 //*************************************************************************************************
1047 
1048 
1049 //*************************************************************************************************
1066 template< typename Type // Data type of the vector
1067  , size_t N // Number of elements
1068  , bool TF > // Transpose flag
1069 template< typename Other // Data type of the initialization array
1070  , size_t Dim > // Dimension of the initialization array
1072 {
1073  BLAZE_STATIC_ASSERT( Dim == N );
1074 
1075  for( size_t i=0UL; i<N; ++i )
1076  v_[i] = array[i];
1077  return *this;
1078 }
1079 //*************************************************************************************************
1080 
1081 
1082 //*************************************************************************************************
1090 template< typename Type // Data type of the vector
1091  , size_t N // Number of elements
1092  , bool TF > // Transpose flag
1094 {
1095  using blaze::assign;
1096 
1097  assign( *this, ~rhs );
1098 
1099  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1100 
1101  return *this;
1102 }
1103 //*************************************************************************************************
1104 
1105 
1106 //*************************************************************************************************
1112 template< typename Type // Data type of the vector
1113  , size_t N // Number of elements
1114  , bool TF > // Transpose flag
1115 template< typename Other > // Data type of the foreign vector
1117 {
1118  using blaze::assign;
1119 
1120  assign( *this, ~rhs );
1121 
1122  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1123 
1124  return *this;
1125 }
1126 //*************************************************************************************************
1127 
1128 
1129 //*************************************************************************************************
1139 template< typename Type // Data type of the vector
1140  , size_t N // Number of elements
1141  , bool TF > // Transpose flag
1142 template< typename VT > // Type of the right-hand side vector
1144 {
1145  using blaze::assign;
1146 
1147  if( (~rhs).size() != N ) {
1148  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to static vector" );
1149  }
1150 
1151  if( (~rhs).canAlias( this ) ) {
1152  StaticVector tmp( ~rhs );
1153  swap( tmp );
1154  }
1155  else {
1157  reset();
1158  assign( *this, ~rhs );
1159  }
1160 
1161  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1162 
1163  return *this;
1164 }
1165 //*************************************************************************************************
1166 
1167 
1168 //*************************************************************************************************
1178 template< typename Type // Data type of the vector
1179  , size_t N // Number of elements
1180  , bool TF > // Transpose flag
1181 template< typename VT > // Type of the right-hand side vector
1183 {
1184  using blaze::addAssign;
1185 
1186  if( (~rhs).size() != N ) {
1187  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1188  }
1189 
1190  if( (~rhs).canAlias( this ) ) {
1191  StaticVector tmp( ~rhs );
1192  addAssign( *this, tmp );
1193  }
1194  else {
1195  addAssign( *this, ~rhs );
1196  }
1197 
1198  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1199 
1200  return *this;
1201 }
1202 //*************************************************************************************************
1203 
1204 
1205 //*************************************************************************************************
1215 template< typename Type // Data type of the vector
1216  , size_t N // Number of elements
1217  , bool TF > // Transpose flag
1218 template< typename VT > // Type of the right-hand side vector
1220 {
1221  using blaze::subAssign;
1222 
1223  if( (~rhs).size() != N ) {
1224  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1225  }
1226 
1227  if( (~rhs).canAlias( this ) ) {
1228  StaticVector tmp( ~rhs );
1229  subAssign( *this, tmp );
1230  }
1231  else {
1232  subAssign( *this, ~rhs );
1233  }
1234 
1235  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1236 
1237  return *this;
1238 }
1239 //*************************************************************************************************
1240 
1241 
1242 //*************************************************************************************************
1253 template< typename Type // Data type of the vector
1254  , size_t N // Number of elements
1255  , bool TF > // Transpose flag
1256 template< typename VT > // Type of the right-hand side vector
1258 {
1259  using blaze::assign;
1260  using blaze::multAssign;
1261 
1262  if( (~rhs).size() != N ) {
1263  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1264  }
1265 
1266  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1267  const StaticVector tmp( *this * (~rhs) );
1268  assign( *this, tmp );
1269  }
1270  else {
1271  multAssign( *this, ~rhs );
1272  }
1273 
1274  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1275 
1276  return *this;
1277 }
1278 //*************************************************************************************************
1279 
1280 
1281 //*************************************************************************************************
1291 template< typename Type // Data type of the vector
1292  , size_t N // Number of elements
1293  , bool TF > // Transpose flag
1294 template< typename VT > // Type of the right-hand side vector
1296 {
1297  using blaze::assign;
1298  using blaze::divAssign;
1299 
1300  if( (~rhs).size() != N ) {
1301  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1302  }
1303 
1304  if( (~rhs).canAlias( this ) ) {
1305  const StaticVector tmp( *this / (~rhs) );
1306  assign( *this, tmp );
1307  }
1308  else {
1309  divAssign( *this, ~rhs );
1310  }
1311 
1312  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1313 
1314  return *this;
1315 }
1316 //*************************************************************************************************
1317 
1318 
1319 //*************************************************************************************************
1330 template< typename Type // Data type of the vector
1331  , size_t N // Number of elements
1332  , bool TF > // Transpose flag
1333 template< typename VT > // Type of the right-hand side vector
1335 {
1336  using blaze::assign;
1337 
1340 
1341  using CrossType = CrossTrait_< This, ResultType_<VT> >;
1342 
1346 
1347  if( N != 3UL || (~rhs).size() != 3UL ) {
1348  BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1349  }
1350 
1351  const CrossType tmp( *this % (~rhs) );
1352  assign( *this, tmp );
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() noexcept
1378 {
1379  return N;
1380 }
1381 //*************************************************************************************************
1382 
1383 
1384 //*************************************************************************************************
1392 template< typename Type // Data type of the vector
1393  , size_t N // Number of elements
1394  , bool TF > // Transpose flag
1395 inline constexpr size_t StaticVector<Type,N,TF>::spacing() noexcept
1396 {
1397  return NN;
1398 }
1399 //*************************************************************************************************
1400 
1401 
1402 //*************************************************************************************************
1407 template< typename Type // Data type of the vector
1408  , size_t N // Number of elements
1409  , bool TF > // Transpose flag
1410 inline constexpr size_t StaticVector<Type,N,TF>::capacity() noexcept
1411 {
1412  return NN;
1413 }
1414 //*************************************************************************************************
1415 
1416 
1417 //*************************************************************************************************
1425 template< typename Type // Data type of the vector
1426  , size_t N // Number of elements
1427  , bool TF > // Transpose flag
1429 {
1430  size_t nonzeros( 0 );
1431 
1432  for( size_t i=0UL; i<N; ++i ) {
1433  if( !isDefault( v_[i] ) )
1434  ++nonzeros;
1435  }
1436 
1437  return nonzeros;
1438 }
1439 //*************************************************************************************************
1440 
1441 
1442 //*************************************************************************************************
1447 template< typename Type // Data type of the vector
1448  , size_t N // Number of elements
1449  , bool TF > // Transpose flag
1451 {
1452  using blaze::clear;
1453  for( size_t i=0UL; i<N; ++i )
1454  clear( v_[i] );
1455 }
1456 //*************************************************************************************************
1457 
1458 
1459 //*************************************************************************************************
1465 template< typename Type // Data type of the vector
1466  , size_t N // Number of elements
1467  , bool TF > // Transpose flag
1468 inline void StaticVector<Type,N,TF>::swap( StaticVector& v ) noexcept
1469 {
1470  using std::swap;
1471 
1472  for( size_t i=0UL; i<N; ++i )
1473  swap( v_[i], v.v_[i] );
1474 }
1475 //*************************************************************************************************
1476 
1477 
1478 
1479 
1480 //=================================================================================================
1481 //
1482 // NUMERIC FUNCTIONS
1483 //
1484 //=================================================================================================
1485 
1486 //*************************************************************************************************
1503 template< typename Type // Data type of the vector
1504  , size_t N // Number of elements
1505  , bool TF > // Transpose flag
1506 template< typename Other > // Data type of the scalar value
1508 {
1509  for( size_t i=0; i<N; ++i )
1510  v_[i] *= scalar;
1511  return *this;
1512 }
1513 //*************************************************************************************************
1514 
1515 
1516 
1517 
1518 //=================================================================================================
1519 //
1520 // MEMORY FUNCTIONS
1521 //
1522 //=================================================================================================
1523 
1524 //*************************************************************************************************
1534 template< typename Type // Data type of the vector
1535  , size_t N // Number of elements
1536  , bool TF > // Transpose flag
1537 inline void* StaticVector<Type,N,TF>::operator new( std::size_t size )
1538 {
1539  UNUSED_PARAMETER( size );
1540 
1541  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1542 
1543  return allocate<StaticVector>( 1UL );
1544 }
1545 //*************************************************************************************************
1546 
1547 
1548 //*************************************************************************************************
1558 template< typename Type // Data type of the vector
1559  , size_t N // Number of elements
1560  , bool TF > // Transpose flag
1561 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size )
1562 {
1563  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1564  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1565 
1566  return allocate<StaticVector>( size/sizeof(StaticVector) );
1567 }
1568 //*************************************************************************************************
1569 
1570 
1571 //*************************************************************************************************
1581 template< typename Type // Data type of the vector
1582  , size_t N // Number of elements
1583  , bool TF > // Transpose flag
1584 inline void* StaticVector<Type,N,TF>::operator new( std::size_t size, const std::nothrow_t& )
1585 {
1586  UNUSED_PARAMETER( size );
1587 
1588  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1589 
1590  return allocate<StaticVector>( 1UL );
1591 }
1592 //*************************************************************************************************
1593 
1594 
1595 //*************************************************************************************************
1605 template< typename Type // Data type of the vector
1606  , size_t N // Number of elements
1607  , bool TF > // Transpose flag
1608 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size, const std::nothrow_t& )
1609 {
1610  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1611  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1612 
1613  return allocate<StaticVector>( size/sizeof(StaticVector) );
1614 }
1615 //*************************************************************************************************
1616 
1617 
1618 //*************************************************************************************************
1624 template< typename Type // Data type of the vector
1625  , size_t N // Number of elements
1626  , bool TF > // Transpose flag
1627 inline void StaticVector<Type,N,TF>::operator delete( void* ptr )
1628 {
1629  deallocate( static_cast<StaticVector*>( ptr ) );
1630 }
1631 //*************************************************************************************************
1632 
1633 
1634 //*************************************************************************************************
1640 template< typename Type // Data type of the vector
1641  , size_t N // Number of elements
1642  , bool TF > // Transpose flag
1643 inline void StaticVector<Type,N,TF>::operator delete[]( void* ptr )
1644 {
1645  deallocate( static_cast<StaticVector*>( ptr ) );
1646 }
1647 //*************************************************************************************************
1648 
1649 
1650 //*************************************************************************************************
1656 template< typename Type // Data type of the vector
1657  , size_t N // Number of elements
1658  , bool TF > // Transpose flag
1659 inline void StaticVector<Type,N,TF>::operator delete( void* ptr, const std::nothrow_t& )
1660 {
1661  deallocate( static_cast<StaticVector*>( ptr ) );
1662 }
1663 //*************************************************************************************************
1664 
1665 
1666 //*************************************************************************************************
1672 template< typename Type // Data type of the vector
1673  , size_t N // Number of elements
1674  , bool TF > // Transpose flag
1675 inline void StaticVector<Type,N,TF>::operator delete[]( void* ptr, const std::nothrow_t& )
1676 {
1677  deallocate( static_cast<StaticVector*>( ptr ) );
1678 }
1679 //*************************************************************************************************
1680 
1681 
1682 
1683 
1684 //=================================================================================================
1685 //
1686 // DEBUGGING FUNCTIONS
1687 //
1688 //=================================================================================================
1689 
1690 //*************************************************************************************************
1699 template< typename Type // Data type of the vector
1700  , size_t N // Number of elements
1701  , bool TF > // Transpose flag
1702 inline bool StaticVector<Type,N,TF>::isIntact() const noexcept
1703 {
1704  if( IsNumeric<Type>::value ) {
1705  for( size_t i=N; i<NN; ++i ) {
1706  if( v_[i] != Type() )
1707  return false;
1708  }
1709  }
1710 
1711  return true;
1712 }
1713 //*************************************************************************************************
1714 
1715 
1716 
1717 
1718 //=================================================================================================
1719 //
1720 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1721 //
1722 //=================================================================================================
1723 
1724 //*************************************************************************************************
1734 template< typename Type // Data type of the vector
1735  , size_t N // Number of elements
1736  , bool TF > // Transpose flag
1737 template< typename Other > // Data type of the foreign expression
1738 inline bool StaticVector<Type,N,TF>::canAlias( const Other* alias ) const noexcept
1739 {
1740  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1741 }
1742 //*************************************************************************************************
1743 
1744 
1745 //*************************************************************************************************
1755 template< typename Type // Data type of the vector
1756  , size_t N // Number of elements
1757  , bool TF > // Transpose flag
1758 template< typename Other > // Data type of the foreign expression
1759 inline bool StaticVector<Type,N,TF>::isAliased( const Other* alias ) const noexcept
1760 {
1761  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1762 }
1763 //*************************************************************************************************
1764 
1765 
1766 //*************************************************************************************************
1775 template< typename Type // Data type of the vector
1776  , size_t N // Number of elements
1777  , bool TF > // Transpose flag
1778 inline bool StaticVector<Type,N,TF>::isAligned() const noexcept
1779 {
1780  return true;
1781 }
1782 //*************************************************************************************************
1783 
1784 
1785 //*************************************************************************************************
1797 template< typename Type // Data type of the vector
1798  , size_t N // Number of elements
1799  , bool TF > // Transpose flag
1801  StaticVector<Type,N,TF>::load( size_t index ) const noexcept
1802 {
1803  return loada( index );
1804 }
1805 //*************************************************************************************************
1806 
1807 
1808 //*************************************************************************************************
1821 template< typename Type // Data type of the vector
1822  , size_t N // Number of elements
1823  , bool TF > // Transpose flag
1825  StaticVector<Type,N,TF>::loada( size_t index ) const noexcept
1826 {
1827  using blaze::loada;
1828 
1830 
1831  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1832  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1833  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1834  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1835 
1836  return loada( &v_[index] );
1837 }
1838 //*************************************************************************************************
1839 
1840 
1841 //*************************************************************************************************
1854 template< typename Type // Data type of the vector
1855  , size_t N // Number of elements
1856  , bool TF > // Transpose flag
1858  StaticVector<Type,N,TF>::loadu( size_t index ) const noexcept
1859 {
1860  using blaze::loadu;
1861 
1863 
1864  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1865  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1866 
1867  return loadu( &v_[index] );
1868 }
1869 //*************************************************************************************************
1870 
1871 
1872 //*************************************************************************************************
1885 template< typename Type // Data type of the vector
1886  , size_t N // Number of elements
1887  , bool TF > // Transpose flag
1889  StaticVector<Type,N,TF>::store( size_t index, const SIMDType& value ) noexcept
1890 {
1891  storea( index, value );
1892 }
1893 //*************************************************************************************************
1894 
1895 
1896 //*************************************************************************************************
1909 template< typename Type // Data type of the vector
1910  , size_t N // Number of elements
1911  , bool TF > // Transpose flag
1913  StaticVector<Type,N,TF>::storea( size_t index, const SIMDType& value ) noexcept
1914 {
1915  using blaze::storea;
1916 
1918 
1919  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1920  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN , "Invalid vector access index" );
1921  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1922  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1923 
1924  storea( &v_[index], value );
1925 }
1926 //*************************************************************************************************
1927 
1928 
1929 //*************************************************************************************************
1942 template< typename Type // Data type of the vector
1943  , size_t N // Number of elements
1944  , bool TF > // Transpose flag
1946  StaticVector<Type,N,TF>::storeu( size_t index, const SIMDType& value ) noexcept
1947 {
1948  using blaze::storeu;
1949 
1951 
1952  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1953  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1954 
1955  storeu( &v_[index], value );
1956 }
1957 //*************************************************************************************************
1958 
1959 
1960 //*************************************************************************************************
1974 template< typename Type // Data type of the vector
1975  , size_t N // Number of elements
1976  , bool TF > // Transpose flag
1978  StaticVector<Type,N,TF>::stream( size_t index, const SIMDType& value ) noexcept
1979 {
1980  using blaze::stream;
1981 
1983 
1984  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1985  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1986  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1987  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1988 
1989  stream( &v_[index], value );
1990 }
1991 //*************************************************************************************************
1992 
1993 
1994 //*************************************************************************************************
2005 template< typename Type // Data type of the vector
2006  , size_t N // Number of elements
2007  , bool TF > // Transpose flag
2008 template< typename VT > // Type of the right-hand side dense vector
2011 {
2012  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2013 
2014  for( size_t i=0UL; i<N; ++i )
2015  v_[i] = (~rhs)[i];
2016 }
2017 //*************************************************************************************************
2018 
2019 
2020 //*************************************************************************************************
2031 template< typename Type // Data type of the vector
2032  , size_t N // Number of elements
2033  , bool TF > // Transpose flag
2034 template< typename VT > // Type of the right-hand side dense vector
2037 {
2039 
2040  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2041 
2042  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2043 
2044  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2045  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2046 
2047  size_t i( 0UL );
2048 
2049  for( ; i<ipos; i+=SIMDSIZE ) {
2050  store( i, (~rhs).load(i) );
2051  }
2052  for( ; remainder && i<N; ++i ) {
2053  v_[i] = (~rhs)[i];
2054  }
2055 }
2056 //*************************************************************************************************
2057 
2058 
2059 //*************************************************************************************************
2070 template< typename Type // Data type of the vector
2071  , size_t N // Number of elements
2072  , bool TF > // Transpose flag
2073 template< typename VT > // Type of the right-hand side sparse vector
2075 {
2076  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2077 
2078  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2079  v_[element->index()] = element->value();
2080 }
2081 //*************************************************************************************************
2082 
2083 
2084 //*************************************************************************************************
2095 template< typename Type // Data type of the vector
2096  , size_t N // Number of elements
2097  , bool TF > // Transpose flag
2098 template< typename VT > // Type of the right-hand side dense vector
2099 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2101 {
2102  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2103 
2104  for( size_t i=0UL; i<N; ++i )
2105  v_[i] += (~rhs)[i];
2106 }
2107 //*************************************************************************************************
2108 
2109 
2110 //*************************************************************************************************
2121 template< typename Type // Data type of the vector
2122  , size_t N // Number of elements
2123  , bool TF > // Transpose flag
2124 template< typename VT > // Type of the right-hand side dense vector
2125 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2127 {
2129 
2130  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2131 
2132  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2133 
2134  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2135  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2136 
2137  size_t i( 0UL );
2138 
2139  for( ; i<ipos; i+=SIMDSIZE ) {
2140  store( i, load(i) + (~rhs).load(i) );
2141  }
2142  for( ; remainder && i<N; ++i ) {
2143  v_[i] += (~rhs)[i];
2144  }
2145 }
2146 //*************************************************************************************************
2147 
2148 
2149 //*************************************************************************************************
2160 template< typename Type // Data type of the vector
2161  , size_t N // Number of elements
2162  , bool TF > // Transpose flag
2163 template< typename VT > // Type of the right-hand side sparse vector
2165 {
2166  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2167 
2168  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2169  v_[element->index()] += element->value();
2170 }
2171 //*************************************************************************************************
2172 
2173 
2174 //*************************************************************************************************
2185 template< typename Type // Data type of the vector
2186  , size_t N // Number of elements
2187  , bool TF > // Transpose flag
2188 template< typename VT > // Type of the right-hand side dense vector
2189 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2191 {
2192  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2193 
2194  for( size_t i=0UL; i<N; ++i )
2195  v_[i] -= (~rhs)[i];
2196 }
2197 //*************************************************************************************************
2198 
2199 
2200 //*************************************************************************************************
2211 template< typename Type // Data type of the vector
2212  , size_t N // Number of elements
2213  , bool TF > // Transpose flag
2214 template< typename VT > // Type of the right-hand side dense vector
2215 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2217 {
2219 
2220  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2221 
2222  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2223 
2224  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2225  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2226 
2227  size_t i( 0UL );
2228 
2229  for( ; i<ipos; i+=SIMDSIZE ) {
2230  store( i, load(i) - (~rhs).load(i) );
2231  }
2232  for( ; remainder && i<N; ++i ) {
2233  v_[i] -= (~rhs)[i];
2234  }
2235 }
2236 //*************************************************************************************************
2237 
2238 
2239 //*************************************************************************************************
2250 template< typename Type // Data type of the vector
2251  , size_t N // Number of elements
2252  , bool TF > // Transpose flag
2253 template< typename VT > // Type of the right-hand side sparse vector
2255 {
2256  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2257 
2258  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2259  v_[element->index()] -= element->value();
2260 }
2261 //*************************************************************************************************
2262 
2263 
2264 //*************************************************************************************************
2275 template< typename Type // Data type of the vector
2276  , size_t N // Number of elements
2277  , bool TF > // Transpose flag
2278 template< typename VT > // Type of the right-hand side dense vector
2279 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2281 {
2282  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2283 
2284  for( size_t i=0UL; i<N; ++i )
2285  v_[i] *= (~rhs)[i];
2286 }
2287 //*************************************************************************************************
2288 
2289 
2290 //*************************************************************************************************
2301 template< typename Type // Data type of the vector
2302  , size_t N // Number of elements
2303  , bool TF > // Transpose flag
2304 template< typename VT > // Type of the right-hand side dense vector
2305 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2307 {
2309 
2310  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2311 
2312  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2313 
2314  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2315  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2316 
2317  size_t i( 0UL );
2318 
2319  for( ; i<ipos; i+=SIMDSIZE ) {
2320  store( i, load(i) * (~rhs).load(i) );
2321  }
2322  for( ; remainder && i<N; ++i ) {
2323  v_[i] *= (~rhs)[i];
2324  }
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 sparse vector
2345 {
2346  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2347 
2348  const StaticVector tmp( serial( *this ) );
2349 
2350  reset();
2351 
2352  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2353  v_[element->index()] = tmp[element->index()] * element->value();
2354 }
2355 //*************************************************************************************************
2356 
2357 
2358 //*************************************************************************************************
2369 template< typename Type // Data type of the vector
2370  , size_t N // Number of elements
2371  , bool TF > // Transpose flag
2372 template< typename VT > // Type of the right-hand side dense vector
2373 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2375 {
2376  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2377 
2378  for( size_t i=0UL; i<N; ++i )
2379  v_[i] /= (~rhs)[i];
2380 }
2381 //*************************************************************************************************
2382 
2383 
2384 //*************************************************************************************************
2395 template< typename Type // Data type of the vector
2396  , size_t N // Number of elements
2397  , bool TF > // Transpose flag
2398 template< typename VT > // Type of the right-hand side dense vector
2399 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2401 {
2403 
2404  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2405 
2406  const size_t ipos( N & size_t(-SIMDSIZE) );
2407  BLAZE_INTERNAL_ASSERT( ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2408 
2409  size_t i( 0UL );
2410 
2411  for( ; i<ipos; i+=SIMDSIZE ) {
2412  store( i, load(i) / (~rhs).load(i) );
2413  }
2414  for( ; i<N; ++i ) {
2415  v_[i] /= (~rhs)[i];
2416  }
2417 }
2418 //*************************************************************************************************
2419 
2420 
2421 
2422 
2423 
2424 
2425 
2426 
2427 //=================================================================================================
2428 //
2429 // STATICVECTOR OPERATORS
2430 //
2431 //=================================================================================================
2432 
2433 //*************************************************************************************************
2436 template< typename Type, size_t N, bool TF >
2437 inline void reset( StaticVector<Type,N,TF>& v );
2438 
2439 template< typename Type, size_t N, bool TF >
2440 inline void clear( StaticVector<Type,N,TF>& v );
2441 
2442 template< bool RF, typename Type, size_t N, bool TF >
2443 inline bool isDefault( const StaticVector<Type,N,TF>& v );
2444 
2445 template< typename Type, size_t N, bool TF >
2446 inline bool isIntact( const StaticVector<Type,N,TF>& v ) noexcept;
2447 
2448 template< typename Type, bool TF >
2450 
2451 template< typename Type, bool TF >
2453 
2454 template< typename Type, size_t N, bool TF >
2455 inline void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) noexcept;
2457 //*************************************************************************************************
2458 
2459 
2460 //*************************************************************************************************
2467 template< typename Type // Data type of the vector
2468  , size_t N // Number of elements
2469  , bool TF > // Transpose flag
2471 {
2472  v.reset();
2473 }
2474 //*************************************************************************************************
2475 
2476 
2477 //*************************************************************************************************
2486 template< typename Type // Data type of the vector
2487  , size_t N // Number of elements
2488  , bool TF > // Transpose flag
2490 {
2491  v.reset();
2492 }
2493 //*************************************************************************************************
2494 
2495 
2496 //*************************************************************************************************
2521 template< bool RF // Relaxation flag
2522  , typename Type // Data type of the vector
2523  , size_t N // Number of elements
2524  , bool TF > // Transpose flag
2525 inline bool isDefault( const StaticVector<Type,N,TF>& v )
2526 {
2527  for( size_t i=0UL; i<N; ++i )
2528  if( !isDefault<RF>( v[i] ) ) return false;
2529  return true;
2530 }
2531 //*************************************************************************************************
2532 
2533 
2534 //*************************************************************************************************
2552 template< typename Type // Data type of the vector
2553  , size_t N // Number of elements
2554  , bool TF > // Transpose flag
2555 inline bool isIntact( const StaticVector<Type,N,TF>& v ) noexcept
2556 {
2557  return v.isIntact();
2558 }
2559 //*************************************************************************************************
2560 
2561 
2562 //*************************************************************************************************
2573 template< typename Type // Data type of the vector
2574  , bool TF > // Transpose flag
2576 {
2577  return StaticVector<Type,2UL,TF>( -v[1UL], v[0UL] );
2578 }
2579 //*************************************************************************************************
2580 
2581 
2582 //*************************************************************************************************
2590 template< typename Type // Data type of the vector
2591  , bool TF > // Transpose flag
2593 {
2594  if( v[0] != Type() || v[1] != Type() )
2595  return StaticVector<Type,3UL,TF>( v[1UL], -v[0UL], Type() );
2596  else
2597  return StaticVector<Type,3UL,TF>( Type(), v[2UL], -v[1UL] );
2598 }
2599 //*************************************************************************************************
2600 
2601 
2602 //*************************************************************************************************
2610 template< typename Type // Data type of the vector
2611  , size_t N // Number of elements
2612  , bool TF > // Transpose flag
2614 {
2615  a.swap( b );
2616 }
2617 //*************************************************************************************************
2618 
2619 
2620 
2621 
2622 //=================================================================================================
2623 //
2624 // SIZE SPECIALIZATIONS
2625 //
2626 //=================================================================================================
2627 
2628 //*************************************************************************************************
2630 template< typename T, size_t N, bool TF >
2631 struct Size< StaticVector<T,N,TF>, 0UL >
2632  : public PtrdiffT<N>
2633 {};
2635 //*************************************************************************************************
2636 
2637 
2638 
2639 
2640 //=================================================================================================
2641 //
2642 // HASCONSTDATAACCESS SPECIALIZATIONS
2643 //
2644 //=================================================================================================
2645 
2646 //*************************************************************************************************
2648 template< typename T, size_t N, bool TF >
2649 struct HasConstDataAccess< StaticVector<T,N,TF> >
2650  : public TrueType
2651 {};
2653 //*************************************************************************************************
2654 
2655 
2656 
2657 
2658 //=================================================================================================
2659 //
2660 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2661 //
2662 //=================================================================================================
2663 
2664 //*************************************************************************************************
2666 template< typename T, size_t N, bool TF >
2667 struct HasMutableDataAccess< StaticVector<T,N,TF> >
2668  : public TrueType
2669 {};
2671 //*************************************************************************************************
2672 
2673 
2674 
2675 
2676 //=================================================================================================
2677 //
2678 // ISSTATIC SPECIALIZATIONS
2679 //
2680 //=================================================================================================
2681 
2682 //*************************************************************************************************
2684 template< typename T, size_t N, bool TF >
2685 struct IsStatic< StaticVector<T,N,TF> >
2686  : public TrueType
2687 {};
2689 //*************************************************************************************************
2690 
2691 
2692 
2693 
2694 //=================================================================================================
2695 //
2696 // ISALIGNED SPECIALIZATIONS
2697 //
2698 //=================================================================================================
2699 
2700 //*************************************************************************************************
2702 template< typename T, size_t N, bool TF >
2703 struct IsAligned< StaticVector<T,N,TF> >
2704  : public TrueType
2705 {};
2707 //*************************************************************************************************
2708 
2709 
2710 
2711 
2712 //=================================================================================================
2713 //
2714 // ISCONTIGUOUS SPECIALIZATIONS
2715 //
2716 //=================================================================================================
2717 
2718 //*************************************************************************************************
2720 template< typename T, size_t N, bool TF >
2721 struct IsContiguous< StaticVector<T,N,TF> >
2722  : public TrueType
2723 {};
2725 //*************************************************************************************************
2726 
2727 
2728 
2729 
2730 //=================================================================================================
2731 //
2732 // ISPADDED SPECIALIZATIONS
2733 //
2734 //=================================================================================================
2735 
2736 //*************************************************************************************************
2738 template< typename T, size_t N, bool TF >
2739 struct IsPadded< StaticVector<T,N,TF> >
2740  : public BoolConstant<usePadding>
2741 {};
2743 //*************************************************************************************************
2744 
2745 
2746 
2747 
2748 //=================================================================================================
2749 //
2750 // ADDTRAIT SPECIALIZATIONS
2751 //
2752 //=================================================================================================
2753 
2754 //*************************************************************************************************
2756 template< typename T1, size_t N, bool TF, typename T2 >
2757 struct AddTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2758 {
2759  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2760 };
2762 //*************************************************************************************************
2763 
2764 
2765 
2766 
2767 //=================================================================================================
2768 //
2769 // SUBTRAIT SPECIALIZATIONS
2770 //
2771 //=================================================================================================
2772 
2773 //*************************************************************************************************
2775 template< typename T1, size_t N, bool TF, typename T2 >
2776 struct SubTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2777 {
2778  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2779 };
2781 //*************************************************************************************************
2782 
2783 
2784 
2785 
2786 //=================================================================================================
2787 //
2788 // MULTTRAIT SPECIALIZATIONS
2789 //
2790 //=================================================================================================
2791 
2792 //*************************************************************************************************
2794 template< typename T1, size_t N, bool TF, typename T2 >
2795 struct MultTrait< StaticVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2796 {
2797  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2798 };
2799 
2800 template< typename T1, typename T2, size_t N, bool TF >
2801 struct MultTrait< T1, StaticVector<T2,N,TF>, EnableIf_<IsNumeric<T1> > >
2802 {
2803  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2804 };
2805 
2806 template< typename T1, size_t N, bool TF, typename T2 >
2807 struct MultTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2808 {
2809  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2810 };
2811 
2812 template< typename T1, size_t M, typename T2, size_t N >
2813 struct MultTrait< StaticVector<T1,M,false>, StaticVector<T2,N,true> >
2814 {
2815  using Type = StaticMatrix< MultTrait_<T1,T2>, M, N, false >;
2816 };
2817 
2818 template< typename T1, size_t N, typename T2 >
2819 struct MultTrait< StaticVector<T1,N,true>, StaticVector<T2,N,false> >
2820 {
2821  using Type = MultTrait_<T1,T2>;
2822 };
2824 //*************************************************************************************************
2825 
2826 
2827 
2828 
2829 //=================================================================================================
2830 //
2831 // DIVTRAIT SPECIALIZATIONS
2832 //
2833 //=================================================================================================
2834 
2835 //*************************************************************************************************
2837 template< typename T1, size_t N, bool TF, typename T2 >
2838 struct DivTrait< StaticVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2839 {
2840  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2841 };
2842 
2843 template< typename T1, size_t N, bool TF, typename T2 >
2844 struct DivTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2845 {
2846  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2847 };
2849 //*************************************************************************************************
2850 
2851 
2852 
2853 
2854 //=================================================================================================
2855 //
2856 // CROSSTRAIT SPECIALIZATIONS
2857 //
2858 //=================================================================================================
2859 
2860 //*************************************************************************************************
2862 template< typename T1, typename T2, bool TF >
2863 struct CrossTrait< StaticVector<T1,3UL,TF>, StaticVector<T2,3UL,TF> >
2864 {
2865  private:
2866  using T = MultTrait_<T1,T2>;
2867 
2868  public:
2869  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2870 };
2872 //*************************************************************************************************
2873 
2874 
2875 
2876 
2877 //=================================================================================================
2878 //
2879 // UNARYMAPTRAIT SPECIALIZATIONS
2880 //
2881 //=================================================================================================
2882 
2883 //*************************************************************************************************
2885 template< typename T, size_t N, bool TF, typename OP >
2886 struct UnaryMapTrait< StaticVector<T,N,TF>, OP >
2887 {
2888  using Type = StaticVector< UnaryMapTrait_<T,OP>, N, TF >;
2889 };
2891 //*************************************************************************************************
2892 
2893 
2894 
2895 
2896 //=================================================================================================
2897 //
2898 // BINARYMAPTRAIT SPECIALIZATIONS
2899 //
2900 //=================================================================================================
2901 
2902 //*************************************************************************************************
2904 template< typename T1, size_t N, bool TF, typename T2, typename OP >
2905 struct BinaryMapTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF>, OP >
2906 {
2907  using Type = StaticVector< BinaryMapTrait_<T1,T2,OP>, N, TF >;
2908 };
2910 //*************************************************************************************************
2911 
2912 
2913 
2914 
2915 //=================================================================================================
2916 //
2917 // HIGHTYPE SPECIALIZATIONS
2918 //
2919 //=================================================================================================
2920 
2921 //*************************************************************************************************
2923 template< typename T1, size_t N, bool TF, typename T2 >
2924 struct HighType< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2925 {
2926  using Type = StaticVector< typename HighType<T1,T2>::Type, N, TF >;
2927 };
2929 //*************************************************************************************************
2930 
2931 
2932 
2933 
2934 //=================================================================================================
2935 //
2936 // LOWTYPE SPECIALIZATIONS
2937 //
2938 //=================================================================================================
2939 
2940 //*************************************************************************************************
2942 template< typename T1, size_t N, bool TF, typename T2 >
2943 struct LowType< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2944 {
2945  using Type = StaticVector< typename LowType<T1,T2>::Type, N, TF >;
2946 };
2948 //*************************************************************************************************
2949 
2950 
2951 
2952 
2953 //=================================================================================================
2954 //
2955 // SUBVECTORTRAIT SPECIALIZATIONS
2956 //
2957 //=================================================================================================
2958 
2959 //*************************************************************************************************
2961 template< typename T, size_t N1, bool TF, size_t I, size_t N2 >
2962 struct SubvectorTrait< StaticVector<T,N1,TF>, I, N2 >
2963 {
2964  using Type = StaticVector<T,N2,TF>;
2965 };
2966 
2967 template< typename T, size_t N, bool TF >
2968 struct SubvectorTrait< StaticVector<T,N,TF> >
2969 {
2970  using Type = HybridVector<T,N,TF>;
2971 };
2973 //*************************************************************************************************
2974 
2975 
2976 
2977 
2978 //=================================================================================================
2979 //
2980 // ELEMENTSTRAIT SPECIALIZATIONS
2981 //
2982 //=================================================================================================
2983 
2984 //*************************************************************************************************
2986 template< typename T, size_t N1, bool TF, size_t... CEAs >
2987 struct ElementsTrait< StaticVector<T,N1,TF>, CEAs... >
2988 {
2989  using Type = StaticVector<T,sizeof...(CEAs),TF>;
2990 };
2991 
2992 template< typename T, size_t N, bool TF >
2993 struct ElementsTrait< StaticVector<T,N,TF> >
2994 {
2995  using Type = HybridVector<T,N,TF>;
2996 };
2998 //*************************************************************************************************
2999 
3000 } // namespace blaze
3001 
3002 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:135
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:79
Availability of a SIMD subtraction for the given data types.Depending on the available instruction se...
Definition: HasSIMDSub.h:171
Header file for mathematical functions.
Compile time check for low-level access to constant data.This type trait tests whether the given data...
Definition: HasConstDataAccess.h:75
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: StaticVector.h:1759
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:937
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.
DenseIterator< Type, aligned > Iterator
Iterator over non-constant elements.
Definition: StaticVector.h:206
static constexpr size_t spacing() noexcept
Returns the minimum capacity of the vector.
Definition: StaticVector.h:1395
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:79
Header file for the serial shim.
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
Availability of a SIMD multiplication for the given data types.Depending on the available instruction...
Definition: HasSIMDMult.h:172
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:316
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
Header file for the DenseVector base class.
Availability of a SIMD addition for the given data types.Depending on the available instruction set (...
Definition: HasSIMDAdd.h:171
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:291
Iterator end() noexcept
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:952
Header file for memory allocation and deallocation functionality.
Header file for the extended initializer_list functionality.
System settings for performance optimizations.
Compile time check for data types.This type trait tests whether or not the given types can be combine...
Definition: IsSIMDCombinable.h:120
Compile time check for static data types.This type trait tests whether the given data type is a stati...
Definition: IsStatic.h:85
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:77
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
Header file for the elements trait.
Constraint on the data type.
Base template for the CrossTrait class.
Definition: CrossTrait.h:113
Type ElementType
Type of the vector elements.
Definition: StaticVector.h:196
Efficient implementation of a fixed-sized vector.The StaticVector class template is the representatio...
Definition: Forward.h:61
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:109
Efficient implementation of a dynamically sized vector with static memory.The HybridVector class temp...
Definition: Forward.h:59
Compile time check for low-level access to mutable data.This type trait tests whether the given data ...
Definition: HasMutableDataAccess.h:75
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
void swap(StaticVector &v) noexcept
Swapping the contents of two static vectors.
Definition: StaticVector.h:1468
Compile time check for the memory layout of data types.This type trait tests whether the given data t...
Definition: IsContiguous.h:86
Header file for the DisableIf class template.
Header file for the LowType type trait.
Base template for the HighType type trait.
Definition: HighType.h:133
Header file for the multiplication trait.
Header file for the unary map trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5908
Resize mechanism to obtain a StaticVector with a different fixed number of elements.
Definition: StaticVector.h:223
Compile time assertion.
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: StaticVector.h:1778
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:1978
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:831
Type & Reference
Reference to a non-constant vector value.
Definition: StaticVector.h:201
StaticVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: StaticVector.h:1006
#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.
static constexpr size_t capacity() noexcept
Returns the maximum capacity of the vector.
Definition: StaticVector.h:1410
Efficient implementation of a fixed-sized matrix.The StaticMatrix class template is the representatio...
Definition: Forward.h:60
Header file for the DenseIterator class template.
const Type * ConstPointer
Pointer to a constant vector value.
Definition: StaticVector.h:204
Header file for the subvector trait.
static constexpr size_t size() noexcept
Returns the current size/dimension of the vector.
Definition: StaticVector.h:1377
Header file for all SIMD functionality.
Constraint on the data type.
Availability of a SIMD division for the given data types.Depending on the available instruction set (...
Definition: HasSIMDDiv.h:150
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:103
SIMDTrait_< ElementType > SIMDType
SIMD type of the vector elements.
Definition: StaticVector.h:197
Header file for the IsAligned type trait.
Constraint on the data type.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:80
StaticVector< Type, N, TF > This
Type of this StaticVector instance.
Definition: StaticVector.h:192
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: StaticVector.h:1825
void reset()
Reset to the default initial values.
Definition: StaticVector.h:1450
#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:875
Constraint on the data type.
Header file for the exception macros of the math module.
Base template for the ElementsTrait class.
Definition: ElementsTrait.h:108
typename CrossTrait< T1, T2 >::Type CrossTrait_
Auxiliary alias declaration for the CrossTrait class template.The CrossTrait_ alias declaration provi...
Definition: CrossTrait.h:209
Iterator begin() noexcept
Returns an iterator to the first element of the static vector.
Definition: StaticVector.h:907
Constraint on the data type.
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:2575
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:608
Header file for the IsPadded type trait.
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
Base template for the LowType type trait.
Definition: LowType.h:133
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: StaticVector.h:483
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 PtrdiffT class template.
Header file for the IsSparseVector type trait.
Header file for the HasSIMDMult type trait.
Header file for the binary map trait.
BLAZE_ALWAYS_INLINE constexpr auto nextMultiple(T1 value, T2 factor) noexcept
Rounds up an integral value to the next multiple of a given factor.
Definition: Functions.h:156
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
StaticVector()
The default constructor for StaticVector.
Definition: StaticVector.h:522
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:119
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:982
Base template for the MultTrait class.
Definition: MultTrait.h:119
Header file for the addition trait.
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:1738
Header file for the division trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticVector.h:198
Constraint on the data type.
Header file for the IsContiguous type trait.
Compile time integral constant wrapper for ptrdiff_t.The PtrdiffT class template represents an integr...
Definition: PtrdiffT.h:72
Header file for the AlignedArray implementation.
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:296
Header file for the IsStatic type trait.
#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:1858
Header file for the isDefault shim.
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: StaticVector.h:788
DenseIterator< const Type, aligned > ConstIterator
Iterator over constant elements.
Definition: StaticVector.h:207
Constraint on the data type.
Header file for the HasSIMDSub type trait.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:816
Type * Pointer
Pointer to a non-constant vector value.
Definition: StaticVector.h:203
Header file for the HasMutableDataAccess type trait.
Pointer data() noexcept
Low-level data access to the array elements.
Definition: AlignedArray.h:356
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
bool isIntact() const noexcept
Returns whether the invariants of the static vector are intact.
Definition: StaticVector.h:1702
EnableIf_< IsBuiltin< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:230
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
Base template for the DivTrait class.
Definition: DivTrait.h:120
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
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
Header file for the HasSIMDDiv type trait.
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: StaticVector.h:1428
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:177
Header file for the default transpose flag for all vectors of the Blaze library.
Header file for the alignment check function.
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: StaticVector.h:1913
Compile time evaluation of the size of vectors and matrices.The Size type trait evaluates the size of...
Definition: Size.h:80
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:130
Header file for the IntegralConstant class template.
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: StaticVector.h:1946
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
Base template for the SubTrait class.
Definition: SubTrait.h:119
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
Base template for the BinaryMapTrait class.
Definition: BinaryMapTrait.h:97
Base template for the UnaryMapTrait class.
Definition: UnaryMapTrait.h:95
System settings for the inline keywords.
const Type & ConstReference
Reference to a constant vector value.
Definition: StaticVector.h:202
Header file for the Size type trait.
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.In case the given data type T is not a dense or sparse vector type and in...
Definition: TransposeFlag.h:63
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: StaticVector.h:1801
Rebind mechanism to obtain a StaticVector with different data/element type.
Definition: StaticVector.h:214
Header file for the HighType type trait.
Header file for the TrueType type/value trait base class.
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: StaticVector.h:1889