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>
83 #include <blaze/system/Inline.h>
88 #include <blaze/util/Assert.h>
94 #include <blaze/util/DisableIf.h>
95 #include <blaze/util/EnableIf.h>
97 #include <blaze/util/Memory.h>
100 #include <blaze/util/Template.h>
101 #include <blaze/util/TrueType.h>
102 #include <blaze/util/Types.h>
105 #include <blaze/util/Unused.h>
106 
107 
108 namespace blaze {
109 
110 //=================================================================================================
111 //
112 // CLASS DEFINITION
113 //
114 //=================================================================================================
115 
116 //*************************************************************************************************
182 template< typename Type // Data type of the vector
183  , size_t N // Number of elements
184  , bool TF = defaultTransposeFlag > // Transpose flag
185 class StaticVector
186  : public DenseVector< StaticVector<Type,N,TF>, TF >
187 {
188  public:
189  //**Type definitions****************************************************************************
192  using ResultType = This;
194  using ElementType = Type;
196  using ReturnType = const Type&;
197  using CompositeType = const StaticVector&;
198 
199  using Reference = Type&;
200  using ConstReference = const Type&;
201  using Pointer = Type*;
202  using ConstPointer = const Type*;
203 
206  //**********************************************************************************************
207 
208  //**Rebind struct definition********************************************************************
211  template< typename NewType > // Data type of the other vector
212  struct Rebind {
214  };
215  //**********************************************************************************************
216 
217  //**Resize struct definition********************************************************************
220  template< size_t NewN > // Number of elements of the other vector
221  struct Resize {
223  };
224  //**********************************************************************************************
225 
226  //**Compilation flags***************************************************************************
228 
232  enum : bool { simdEnabled = IsVectorizable<Type>::value };
233 
235 
238  enum : bool { smpAssignable = false };
239  //**********************************************************************************************
240 
241  //**Constructors********************************************************************************
244  explicit inline StaticVector();
245  explicit inline StaticVector( const Type& init );
246  explicit inline StaticVector( initializer_list<Type> list );
247 
248  template< typename Other >
249  explicit inline StaticVector( size_t n, const Other* array );
250 
251  template< typename Other, size_t Dim >
252  explicit inline StaticVector( const Other (&array)[Dim] );
253 
254  inline StaticVector( const StaticVector& v );
255  template< typename Other > inline StaticVector( const StaticVector<Other,N,TF>& v );
256  template< typename VT > inline StaticVector( const Vector<VT,TF>& v );
258  //**********************************************************************************************
259 
260  //**Destructor**********************************************************************************
261  // No explicitly declared destructor.
262  //**********************************************************************************************
263 
264  //**Data access functions***********************************************************************
267  inline Reference operator[]( size_t index ) noexcept;
268  inline ConstReference operator[]( size_t index ) const noexcept;
269  inline Reference at( size_t index );
270  inline ConstReference at( size_t index ) const;
271  inline Pointer data () noexcept;
272  inline ConstPointer data () const noexcept;
273  inline Iterator begin () noexcept;
274  inline ConstIterator begin () const noexcept;
275  inline ConstIterator cbegin() const noexcept;
276  inline Iterator end () noexcept;
277  inline ConstIterator end () const noexcept;
278  inline ConstIterator cend () const noexcept;
280  //**********************************************************************************************
281 
282  //**Assignment operators************************************************************************
285  inline StaticVector& operator=( const Type& rhs );
286  inline StaticVector& operator=( initializer_list<Type> list );
287 
288  template< typename Other, size_t Dim >
289  inline StaticVector& operator=( const Other (&array)[Dim] );
290 
291  inline StaticVector& operator=( const StaticVector& rhs );
292  template< typename Other > inline StaticVector& operator=( const StaticVector<Other,N,TF>& rhs );
293 
294  template< typename VT > inline StaticVector& operator= ( const Vector<VT,TF>& rhs );
295  template< typename VT > inline StaticVector& operator+=( const Vector<VT,TF>& rhs );
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 DenseVector<VT,TF>& rhs );
299  template< typename VT > inline StaticVector& operator%=( const Vector<VT,TF>& rhs );
300 
301  template< typename Other >
302  inline EnableIf_<IsNumeric<Other>, StaticVector >& operator*=( Other rhs );
303 
304  template< typename Other >
305  inline EnableIf_<IsNumeric<Other>, StaticVector >& operator/=( Other rhs );
307  //**********************************************************************************************
308 
309  //**Utility functions***************************************************************************
312  inline constexpr size_t size() const noexcept;
313  inline constexpr size_t spacing() const noexcept;
314  inline constexpr size_t capacity() const noexcept;
315  inline size_t nonZeros() const;
316  inline void reset();
317  inline void swap( StaticVector& v ) noexcept;
319  //**********************************************************************************************
320 
321  //**Numeric functions***************************************************************************
324  template< typename Other > inline StaticVector& scale( const Other& scalar );
326  //**********************************************************************************************
327 
328  //**Memory functions****************************************************************************
331  static inline void* operator new ( std::size_t size );
332  static inline void* operator new[]( std::size_t size );
333  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
334  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
335 
336  static inline void operator delete ( void* ptr );
337  static inline void operator delete[]( void* ptr );
338  static inline void operator delete ( void* ptr, const std::nothrow_t& );
339  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
341  //**********************************************************************************************
342 
343  private:
344  //**********************************************************************************************
346  template< typename VT >
348  struct VectorizedAssign {
349  enum : bool { value = useOptimizedKernels &&
350  simdEnabled && VT::simdEnabled &&
352  };
354  //**********************************************************************************************
355 
356  //**********************************************************************************************
358  template< typename VT >
360  struct VectorizedAddAssign {
361  enum : bool { value = useOptimizedKernels &&
362  simdEnabled && VT::simdEnabled &&
365  };
367  //**********************************************************************************************
368 
369  //**********************************************************************************************
371  template< typename VT >
373  struct VectorizedSubAssign {
374  enum : bool { value = useOptimizedKernels &&
375  simdEnabled && VT::simdEnabled &&
378  };
380  //**********************************************************************************************
381 
382  //**********************************************************************************************
384  template< typename VT >
386  struct VectorizedMultAssign {
387  enum : bool { value = useOptimizedKernels &&
388  simdEnabled && VT::simdEnabled &&
391  };
393  //**********************************************************************************************
394 
395  //**********************************************************************************************
397  template< typename VT >
399  struct VectorizedDivAssign {
400  enum : bool { value = useOptimizedKernels &&
401  simdEnabled && VT::simdEnabled &&
404  };
406  //**********************************************************************************************
407 
408  //**********************************************************************************************
410  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
411  //**********************************************************************************************
412 
413  public:
414  //**Debugging functions*************************************************************************
417  inline bool isIntact() const noexcept;
419  //**********************************************************************************************
420 
421  //**Expression template evaluation functions****************************************************
424  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
425  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
426 
427  inline bool isAligned() const noexcept;
428 
429  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
430  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
431  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
432 
433  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
434  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
435  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
436  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
437 
438  template< typename VT >
439  inline DisableIf_< VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
440 
441  template< typename VT >
442  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
443 
444  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
445 
446  template< typename VT >
447  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
448 
449  template< typename VT >
450  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
451 
452  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
453 
454  template< typename VT >
455  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
456 
457  template< typename VT >
458  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
459 
460  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
461 
462  template< typename VT >
463  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
464 
465  template< typename VT >
466  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
467 
468  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
469 
470  template< typename VT >
471  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
472 
473  template< typename VT >
474  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
476  //**********************************************************************************************
477 
478  private:
479  //**********************************************************************************************
481  enum : size_t { NN = ( usePadding )?( nextMultiple( N, SIMDSIZE ) ):( N ) };
482  //**********************************************************************************************
483 
484  //**Member variables****************************************************************************
488 
494  //**********************************************************************************************
495 
496  //**Compile time checks*************************************************************************
502  BLAZE_STATIC_ASSERT( !usePadding || ( NN % SIMDSIZE == 0UL ) );
503  BLAZE_STATIC_ASSERT( NN >= N );
505  //**********************************************************************************************
506 };
507 //*************************************************************************************************
508 
509 
510 
511 
512 //=================================================================================================
513 //
514 // CONSTRUCTORS
515 //
516 //=================================================================================================
517 
518 //*************************************************************************************************
523 template< typename Type // Data type of the vector
524  , size_t N // Number of elements
525  , bool TF > // Transpose flag
527  : v_() // The statically allocated vector elements
528 {
530 
531  if( IsNumeric<Type>::value ) {
532  for( size_t i=0UL; i<NN; ++i )
533  v_[i] = Type();
534  }
535 
536  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
537 }
538 //*************************************************************************************************
539 
540 
541 //*************************************************************************************************
546 template< typename Type // Data type of the vector
547  , size_t N // Number of elements
548  , bool TF > // Transpose flag
549 inline StaticVector<Type,N,TF>::StaticVector( const Type& init )
550  : v_() // The statically allocated vector elements
551 {
553 
554  for( size_t i=0UL; i<N; ++i )
555  v_[i] = init;
556 
557  for( size_t i=N; i<NN; ++i )
558  v_[i] = Type();
559 
560  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
561 }
562 //*************************************************************************************************
563 
564 
565 //*************************************************************************************************
582 template< typename Type // Data type of the vector
583  , size_t N // Number of elements
584  , bool TF > // Transpose flag
586  : v_() // The statically allocated vector elements
587 {
589 
590  if( list.size() > N ) {
591  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
592  }
593 
594  std::fill( std::copy( list.begin(), list.end(), v_.data() ), v_.data()+NN, Type() );
595 
596  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
597 }
598 //*************************************************************************************************
599 
600 
601 //*************************************************************************************************
623 template< typename Type // Data type of the vector
624  , size_t N // Number of elements
625  , bool TF > // Transpose flag
626 template< typename Other > // Data type of the initialization array
627 inline StaticVector<Type,N,TF>::StaticVector( size_t n, const Other* array )
628  : v_() // The statically allocated vector elements
629 {
631 
632  if( n > N ) {
633  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
634  }
635 
636  for( size_t i=0UL; i<n; ++i )
637  v_[i] = array[i];
638 
639  if( IsNumeric<Type>::value ) {
640  for( size_t i=n; i<NN; ++i )
641  v_[i] = Type();
642  }
643 
644  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
645 }
646 //*************************************************************************************************
647 
648 
649 //*************************************************************************************************
665 template< typename Type // Data type of the vector
666  , size_t N // Number of elements
667  , bool TF > // Transpose flag
668 template< typename Other // Data type of the initialization array
669  , size_t Dim > // Dimension of the initialization array
670 inline StaticVector<Type,N,TF>::StaticVector( const Other (&array)[Dim] )
671  : v_() // The statically allocated vector elements
672 {
674  BLAZE_STATIC_ASSERT( Dim == N );
675 
676  for( size_t i=0UL; i<N; ++i )
677  v_[i] = array[i];
678 
679  for( size_t i=N; i<NN; ++i )
680  v_[i] = Type();
681 
682  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
683 }
684 //*************************************************************************************************
685 
686 
687 //*************************************************************************************************
694 template< typename Type // Data type of the vector
695  , size_t N // Number of elements
696  , bool TF > // Transpose flag
697 inline StaticVector<Type,N,TF>::StaticVector( const StaticVector& v )
698  : v_() // The statically allocated vector elements
699 {
701 
702  for( size_t i=0UL; i<NN; ++i )
703  v_[i] = v.v_[i];
704 
705  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
706 }
707 //*************************************************************************************************
708 
709 
710 //*************************************************************************************************
715 template< typename Type // Data type of the vector
716  , size_t N // Number of elements
717  , bool TF > // Transpose flag
718 template< typename Other > // Data type of the foreign vector
720  : v_() // The statically allocated vector elements
721 {
723 
724  for( size_t i=0UL; i<N; ++i )
725  v_[i] = v[i];
726 
727  for( size_t i=N; i<NN; ++i )
728  v_[i] = Type();
729 
730  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
731 }
732 //*************************************************************************************************
733 
734 
735 //*************************************************************************************************
745 template< typename Type // Data type of the vector
746  , size_t N // Number of elements
747  , bool TF > // Transpose flag
748 template< typename VT > // Type of the foreign vector
750  : v_() // The statically allocated vector elements
751 {
752  using blaze::assign;
753 
755 
756  if( (~v).size() != N ) {
757  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
758  }
759 
760  for( size_t i=( IsSparseVector<VT>::value ? 0UL : N ); i<NN; ++i ) {
761  v_[i] = Type();
762  }
763 
764  assign( *this, ~v );
765 
766  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
767 }
768 //*************************************************************************************************
769 
770 
771 
772 
773 //=================================================================================================
774 //
775 // DATA ACCESS FUNCTIONS
776 //
777 //=================================================================================================
778 
779 //*************************************************************************************************
788 template< typename Type // Data type of the vector
789  , size_t N // Number of elements
790  , bool TF > // Transpose flag
792  StaticVector<Type,N,TF>::operator[]( size_t index ) noexcept
793 {
794  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
795  return v_[index];
796 }
797 //*************************************************************************************************
798 
799 
800 //*************************************************************************************************
809 template< typename Type // Data type of the vector
810  , size_t N // Number of elements
811  , bool TF > // Transpose flag
813  StaticVector<Type,N,TF>::operator[]( size_t index ) const noexcept
814 {
815  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
816  return v_[index];
817 }
818 //*************************************************************************************************
819 
820 
821 //*************************************************************************************************
831 template< typename Type // Data type of the vector
832  , size_t N // Number of elements
833  , bool TF > // Transpose flag
836 {
837  if( index >= N ) {
838  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
839  }
840  return (*this)[index];
841 }
842 //*************************************************************************************************
843 
844 
845 //*************************************************************************************************
855 template< typename Type // Data type of the vector
856  , size_t N // Number of elements
857  , bool TF > // Transpose flag
859  StaticVector<Type,N,TF>::at( size_t index ) const
860 {
861  if( index >= N ) {
862  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
863  }
864  return (*this)[index];
865 }
866 //*************************************************************************************************
867 
868 
869 //*************************************************************************************************
876 template< typename Type // Data type of the vector
877  , size_t N // Number of elements
878  , bool TF > // Transpose flag
880 {
881  return v_;
882 }
883 //*************************************************************************************************
884 
885 
886 //*************************************************************************************************
893 template< typename Type // Data type of the vector
894  , size_t N // Number of elements
895  , bool TF > // Transpose flag
897 {
898  return v_;
899 }
900 //*************************************************************************************************
901 
902 
903 //*************************************************************************************************
908 template< typename Type // Data type of the vector
909  , size_t N // Number of elements
910  , bool TF > // Transpose flag
912 {
913  return Iterator( v_ );
914 }
915 //*************************************************************************************************
916 
917 
918 //*************************************************************************************************
923 template< typename Type // Data type of the vector
924  , size_t N // Number of elements
925  , bool TF > // Transpose flag
927 {
928  return ConstIterator( v_ );
929 }
930 //*************************************************************************************************
931 
932 
933 //*************************************************************************************************
938 template< typename Type // Data type of the vector
939  , size_t N // Number of elements
940  , bool TF > // Transpose flag
942 {
943  return ConstIterator( v_ );
944 }
945 //*************************************************************************************************
946 
947 
948 //*************************************************************************************************
953 template< typename Type // Data type of the vector
954  , size_t N // Number of elements
955  , bool TF > // Transpose flag
957 {
958  return Iterator( v_ + N );
959 }
960 //*************************************************************************************************
961 
962 
963 //*************************************************************************************************
968 template< typename Type // Data type of the vector
969  , size_t N // Number of elements
970  , bool TF > // Transpose flag
972 {
973  return ConstIterator( v_ + N );
974 }
975 //*************************************************************************************************
976 
977 
978 //*************************************************************************************************
983 template< typename Type // Data type of the vector
984  , size_t N // Number of elements
985  , bool TF > // Transpose flag
987 {
988  return ConstIterator( v_ + N );
989 }
990 //*************************************************************************************************
991 
992 
993 
994 
995 //=================================================================================================
996 //
997 // ASSIGNMENT OPERATORS
998 //
999 //=================================================================================================
1000 
1001 //*************************************************************************************************
1007 template< typename Type // Data type of the vector
1008  , size_t N // Number of elements
1009  , bool TF > // Transpose flag
1011 {
1012  for( size_t i=0UL; i<N; ++i )
1013  v_[i] = rhs;
1014  return *this;
1015 }
1016 //*************************************************************************************************
1017 
1018 
1019 //*************************************************************************************************
1037 template< typename Type // Data type of the vector
1038  , size_t N // Number of elements
1039  , bool TF > // Transpose flag
1041 {
1042  if( list.size() > N ) {
1043  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to static vector" );
1044  }
1045 
1046  std::fill( std::copy( list.begin(), list.end(), v_.data() ), v_.data()+N, Type() );
1047 
1048  return *this;
1049 }
1050 //*************************************************************************************************
1051 
1052 
1053 //*************************************************************************************************
1070 template< typename Type // Data type of the vector
1071  , size_t N // Number of elements
1072  , bool TF > // Transpose flag
1073 template< typename Other // Data type of the initialization array
1074  , size_t Dim > // Dimension of the initialization array
1076 {
1077  BLAZE_STATIC_ASSERT( Dim == N );
1078 
1079  for( size_t i=0UL; i<N; ++i )
1080  v_[i] = array[i];
1081  return *this;
1082 }
1083 //*************************************************************************************************
1084 
1085 
1086 //*************************************************************************************************
1094 template< typename Type // Data type of the vector
1095  , size_t N // Number of elements
1096  , bool TF > // Transpose flag
1098 {
1099  using blaze::assign;
1100 
1101  assign( *this, ~rhs );
1102 
1103  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1104 
1105  return *this;
1106 }
1107 //*************************************************************************************************
1108 
1109 
1110 //*************************************************************************************************
1116 template< typename Type // Data type of the vector
1117  , size_t N // Number of elements
1118  , bool TF > // Transpose flag
1119 template< typename Other > // Data type of the foreign vector
1121 {
1122  using blaze::assign;
1123 
1124  assign( *this, ~rhs );
1125 
1126  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1127 
1128  return *this;
1129 }
1130 //*************************************************************************************************
1131 
1132 
1133 //*************************************************************************************************
1143 template< typename Type // Data type of the vector
1144  , size_t N // Number of elements
1145  , bool TF > // Transpose flag
1146 template< typename VT > // Type of the right-hand side vector
1148 {
1149  using blaze::assign;
1150 
1151  if( (~rhs).size() != N ) {
1152  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to static vector" );
1153  }
1154 
1155  if( (~rhs).canAlias( this ) ) {
1156  StaticVector tmp( ~rhs );
1157  swap( tmp );
1158  }
1159  else {
1161  reset();
1162  assign( *this, ~rhs );
1163  }
1164 
1165  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1166 
1167  return *this;
1168 }
1169 //*************************************************************************************************
1170 
1171 
1172 //*************************************************************************************************
1182 template< typename Type // Data type of the vector
1183  , size_t N // Number of elements
1184  , bool TF > // Transpose flag
1185 template< typename VT > // Type of the right-hand side vector
1187 {
1188  using blaze::addAssign;
1189 
1190  if( (~rhs).size() != N ) {
1191  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1192  }
1193 
1194  if( (~rhs).canAlias( this ) ) {
1195  StaticVector tmp( ~rhs );
1196  addAssign( *this, tmp );
1197  }
1198  else {
1199  addAssign( *this, ~rhs );
1200  }
1201 
1202  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1203 
1204  return *this;
1205 }
1206 //*************************************************************************************************
1207 
1208 
1209 //*************************************************************************************************
1219 template< typename Type // Data type of the vector
1220  , size_t N // Number of elements
1221  , bool TF > // Transpose flag
1222 template< typename VT > // Type of the right-hand side vector
1224 {
1225  using blaze::subAssign;
1226 
1227  if( (~rhs).size() != N ) {
1228  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1229  }
1230 
1231  if( (~rhs).canAlias( this ) ) {
1232  StaticVector tmp( ~rhs );
1233  subAssign( *this, tmp );
1234  }
1235  else {
1236  subAssign( *this, ~rhs );
1237  }
1238 
1239  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1240 
1241  return *this;
1242 }
1243 //*************************************************************************************************
1244 
1245 
1246 //*************************************************************************************************
1257 template< typename Type // Data type of the vector
1258  , size_t N // Number of elements
1259  , bool TF > // Transpose flag
1260 template< typename VT > // Type of the right-hand side vector
1262 {
1263  using blaze::assign;
1264  using blaze::multAssign;
1265 
1266  if( (~rhs).size() != N ) {
1267  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1268  }
1269 
1270  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1271  const StaticVector tmp( *this * (~rhs) );
1272  assign( *this, tmp );
1273  }
1274  else {
1275  multAssign( *this, ~rhs );
1276  }
1277 
1278  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1279 
1280  return *this;
1281 }
1282 //*************************************************************************************************
1283 
1284 
1285 //*************************************************************************************************
1295 template< typename Type // Data type of the vector
1296  , size_t N // Number of elements
1297  , bool TF > // Transpose flag
1298 template< typename VT > // Type of the right-hand side vector
1300 {
1301  using blaze::assign;
1302  using blaze::divAssign;
1303 
1304  if( (~rhs).size() != N ) {
1305  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1306  }
1307 
1308  if( (~rhs).canAlias( this ) ) {
1309  const StaticVector tmp( *this / (~rhs) );
1310  assign( *this, tmp );
1311  }
1312  else {
1313  divAssign( *this, ~rhs );
1314  }
1315 
1316  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1317 
1318  return *this;
1319 }
1320 //*************************************************************************************************
1321 
1322 
1323 //*************************************************************************************************
1334 template< typename Type // Data type of the vector
1335  , size_t N // Number of elements
1336  , bool TF > // Transpose flag
1337 template< typename VT > // Type of the right-hand side vector
1339 {
1340  using blaze::assign;
1341 
1344 
1345  using CrossType = CrossTrait_< This, ResultType_<VT> >;
1346 
1350 
1351  if( N != 3UL || (~rhs).size() != 3UL ) {
1352  BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1353  }
1354 
1355  const CrossType tmp( *this % (~rhs) );
1356  assign( *this, tmp );
1357 
1358  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1359 
1360  return *this;
1361 }
1362 //*************************************************************************************************
1363 
1364 
1365 //*************************************************************************************************
1372 template< typename Type // Data type of the vector
1373  , size_t N // Number of elements
1374  , bool TF > // Transpose flag
1375 template< typename Other > // Data type of the right-hand side scalar
1378 {
1379  using blaze::assign;
1380 
1381  assign( *this, (*this) * rhs );
1382 
1383  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1384 
1385  return *this;
1386 }
1387 //*************************************************************************************************
1388 
1389 
1390 //*************************************************************************************************
1399 template< typename Type // Data type of the vector
1400  , size_t N // Number of elements
1401  , bool TF > // Transpose flag
1402 template< typename Other > // Data type of the right-hand side scalar
1403 inline EnableIf_<IsNumeric<Other>, StaticVector<Type,N,TF> >&
1405 {
1406  using blaze::assign;
1407 
1408  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1409 
1410  assign( *this, (*this) / rhs );
1411 
1412  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1413 
1414  return *this;
1415 }
1416 //*************************************************************************************************
1417 
1418 
1419 
1420 
1421 //=================================================================================================
1422 //
1423 // UTILITY FUNCTIONS
1424 //
1425 //=================================================================================================
1426 
1427 //*************************************************************************************************
1432 template< typename Type // Data type of the vector
1433  , size_t N // Number of elements
1434  , bool TF > // Transpose flag
1435 inline constexpr size_t StaticVector<Type,N,TF>::size() const noexcept
1436 {
1437  return N;
1438 }
1439 //*************************************************************************************************
1440 
1441 
1442 //*************************************************************************************************
1450 template< typename Type // Data type of the vector
1451  , size_t N // Number of elements
1452  , bool TF > // Transpose flag
1453 inline constexpr size_t StaticVector<Type,N,TF>::spacing() const noexcept
1454 {
1455  return NN;
1456 }
1457 //*************************************************************************************************
1458 
1459 
1460 //*************************************************************************************************
1465 template< typename Type // Data type of the vector
1466  , size_t N // Number of elements
1467  , bool TF > // Transpose flag
1468 inline constexpr size_t StaticVector<Type,N,TF>::capacity() const noexcept
1469 {
1470  return NN;
1471 }
1472 //*************************************************************************************************
1473 
1474 
1475 //*************************************************************************************************
1483 template< typename Type // Data type of the vector
1484  , size_t N // Number of elements
1485  , bool TF > // Transpose flag
1487 {
1488  size_t nonzeros( 0 );
1489 
1490  for( size_t i=0UL; i<N; ++i ) {
1491  if( !isDefault( v_[i] ) )
1492  ++nonzeros;
1493  }
1494 
1495  return nonzeros;
1496 }
1497 //*************************************************************************************************
1498 
1499 
1500 //*************************************************************************************************
1505 template< typename Type // Data type of the vector
1506  , size_t N // Number of elements
1507  , bool TF > // Transpose flag
1509 {
1510  using blaze::clear;
1511  for( size_t i=0UL; i<N; ++i )
1512  clear( v_[i] );
1513 }
1514 //*************************************************************************************************
1515 
1516 
1517 //*************************************************************************************************
1523 template< typename Type // Data type of the vector
1524  , size_t N // Number of elements
1525  , bool TF > // Transpose flag
1526 inline void StaticVector<Type,N,TF>::swap( StaticVector& v ) noexcept
1527 {
1528  using std::swap;
1529 
1530  for( size_t i=0UL; i<N; ++i )
1531  swap( v_[i], v.v_[i] );
1532 }
1533 //*************************************************************************************************
1534 
1535 
1536 
1537 
1538 //=================================================================================================
1539 //
1540 // NUMERIC FUNCTIONS
1541 //
1542 //=================================================================================================
1543 
1544 //*************************************************************************************************
1561 template< typename Type // Data type of the vector
1562  , size_t N // Number of elements
1563  , bool TF > // Transpose flag
1564 template< typename Other > // Data type of the scalar value
1566 {
1567  for( size_t i=0; i<N; ++i )
1568  v_[i] *= scalar;
1569  return *this;
1570 }
1571 //*************************************************************************************************
1572 
1573 
1574 
1575 
1576 //=================================================================================================
1577 //
1578 // MEMORY FUNCTIONS
1579 //
1580 //=================================================================================================
1581 
1582 //*************************************************************************************************
1592 template< typename Type // Data type of the vector
1593  , size_t N // Number of elements
1594  , bool TF > // Transpose flag
1595 inline void* StaticVector<Type,N,TF>::operator new( std::size_t size )
1596 {
1597  UNUSED_PARAMETER( size );
1598 
1599  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1600 
1601  return allocate<StaticVector>( 1UL );
1602 }
1603 //*************************************************************************************************
1604 
1605 
1606 //*************************************************************************************************
1616 template< typename Type // Data type of the vector
1617  , size_t N // Number of elements
1618  , bool TF > // Transpose flag
1619 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size )
1620 {
1621  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1622  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1623 
1624  return allocate<StaticVector>( size/sizeof(StaticVector) );
1625 }
1626 //*************************************************************************************************
1627 
1628 
1629 //*************************************************************************************************
1639 template< typename Type // Data type of the vector
1640  , size_t N // Number of elements
1641  , bool TF > // Transpose flag
1642 inline void* StaticVector<Type,N,TF>::operator new( std::size_t size, const std::nothrow_t& )
1643 {
1644  UNUSED_PARAMETER( size );
1645 
1646  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1647 
1648  return allocate<StaticVector>( 1UL );
1649 }
1650 //*************************************************************************************************
1651 
1652 
1653 //*************************************************************************************************
1663 template< typename Type // Data type of the vector
1664  , size_t N // Number of elements
1665  , bool TF > // Transpose flag
1666 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size, const std::nothrow_t& )
1667 {
1668  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1669  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1670 
1671  return allocate<StaticVector>( size/sizeof(StaticVector) );
1672 }
1673 //*************************************************************************************************
1674 
1675 
1676 //*************************************************************************************************
1682 template< typename Type // Data type of the vector
1683  , size_t N // Number of elements
1684  , bool TF > // Transpose flag
1685 inline void StaticVector<Type,N,TF>::operator delete( void* ptr )
1686 {
1687  deallocate( static_cast<StaticVector*>( ptr ) );
1688 }
1689 //*************************************************************************************************
1690 
1691 
1692 //*************************************************************************************************
1698 template< typename Type // Data type of the vector
1699  , size_t N // Number of elements
1700  , bool TF > // Transpose flag
1701 inline void StaticVector<Type,N,TF>::operator delete[]( void* ptr )
1702 {
1703  deallocate( static_cast<StaticVector*>( ptr ) );
1704 }
1705 //*************************************************************************************************
1706 
1707 
1708 //*************************************************************************************************
1714 template< typename Type // Data type of the vector
1715  , size_t N // Number of elements
1716  , bool TF > // Transpose flag
1717 inline void StaticVector<Type,N,TF>::operator delete( void* ptr, const std::nothrow_t& )
1718 {
1719  deallocate( static_cast<StaticVector*>( ptr ) );
1720 }
1721 //*************************************************************************************************
1722 
1723 
1724 //*************************************************************************************************
1730 template< typename Type // Data type of the vector
1731  , size_t N // Number of elements
1732  , bool TF > // Transpose flag
1733 inline void StaticVector<Type,N,TF>::operator delete[]( void* ptr, const std::nothrow_t& )
1734 {
1735  deallocate( static_cast<StaticVector*>( ptr ) );
1736 }
1737 //*************************************************************************************************
1738 
1739 
1740 
1741 
1742 //=================================================================================================
1743 //
1744 // DEBUGGING FUNCTIONS
1745 //
1746 //=================================================================================================
1747 
1748 //*************************************************************************************************
1757 template< typename Type // Data type of the vector
1758  , size_t N // Number of elements
1759  , bool TF > // Transpose flag
1760 inline bool StaticVector<Type,N,TF>::isIntact() const noexcept
1761 {
1762  if( IsNumeric<Type>::value ) {
1763  for( size_t i=N; i<NN; ++i ) {
1764  if( v_[i] != Type() )
1765  return false;
1766  }
1767  }
1768 
1769  return true;
1770 }
1771 //*************************************************************************************************
1772 
1773 
1774 
1775 
1776 //=================================================================================================
1777 //
1778 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1779 //
1780 //=================================================================================================
1781 
1782 //*************************************************************************************************
1792 template< typename Type // Data type of the vector
1793  , size_t N // Number of elements
1794  , bool TF > // Transpose flag
1795 template< typename Other > // Data type of the foreign expression
1796 inline bool StaticVector<Type,N,TF>::canAlias( const Other* alias ) const noexcept
1797 {
1798  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1799 }
1800 //*************************************************************************************************
1801 
1802 
1803 //*************************************************************************************************
1813 template< typename Type // Data type of the vector
1814  , size_t N // Number of elements
1815  , bool TF > // Transpose flag
1816 template< typename Other > // Data type of the foreign expression
1817 inline bool StaticVector<Type,N,TF>::isAliased( const Other* alias ) const noexcept
1818 {
1819  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1820 }
1821 //*************************************************************************************************
1822 
1823 
1824 //*************************************************************************************************
1833 template< typename Type // Data type of the vector
1834  , size_t N // Number of elements
1835  , bool TF > // Transpose flag
1836 inline bool StaticVector<Type,N,TF>::isAligned() const noexcept
1837 {
1838  return true;
1839 }
1840 //*************************************************************************************************
1841 
1842 
1843 //*************************************************************************************************
1855 template< typename Type // Data type of the vector
1856  , size_t N // Number of elements
1857  , bool TF > // Transpose flag
1859  StaticVector<Type,N,TF>::load( size_t index ) const noexcept
1860 {
1861  return loada( index );
1862 }
1863 //*************************************************************************************************
1864 
1865 
1866 //*************************************************************************************************
1879 template< typename Type // Data type of the vector
1880  , size_t N // Number of elements
1881  , bool TF > // Transpose flag
1883  StaticVector<Type,N,TF>::loada( size_t index ) const noexcept
1884 {
1885  using blaze::loada;
1886 
1888 
1889  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1890  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1891  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1892  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1893 
1894  return loada( &v_[index] );
1895 }
1896 //*************************************************************************************************
1897 
1898 
1899 //*************************************************************************************************
1912 template< typename Type // Data type of the vector
1913  , size_t N // Number of elements
1914  , bool TF > // Transpose flag
1916  StaticVector<Type,N,TF>::loadu( size_t index ) const noexcept
1917 {
1918  using blaze::loadu;
1919 
1921 
1922  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1923  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1924 
1925  return loadu( &v_[index] );
1926 }
1927 //*************************************************************************************************
1928 
1929 
1930 //*************************************************************************************************
1943 template< typename Type // Data type of the vector
1944  , size_t N // Number of elements
1945  , bool TF > // Transpose flag
1947  StaticVector<Type,N,TF>::store( size_t index, const SIMDType& value ) noexcept
1948 {
1949  storea( index, value );
1950 }
1951 //*************************************************************************************************
1952 
1953 
1954 //*************************************************************************************************
1967 template< typename Type // Data type of the vector
1968  , size_t N // Number of elements
1969  , bool TF > // Transpose flag
1971  StaticVector<Type,N,TF>::storea( size_t index, const SIMDType& value ) noexcept
1972 {
1973  using blaze::storea;
1974 
1976 
1977  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1978  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN , "Invalid vector access index" );
1979  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1980  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1981 
1982  storea( &v_[index], value );
1983 }
1984 //*************************************************************************************************
1985 
1986 
1987 //*************************************************************************************************
2000 template< typename Type // Data type of the vector
2001  , size_t N // Number of elements
2002  , bool TF > // Transpose flag
2004  StaticVector<Type,N,TF>::storeu( size_t index, const SIMDType& value ) noexcept
2005 {
2006  using blaze::storeu;
2007 
2009 
2010  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
2011  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2012 
2013  storeu( &v_[index], value );
2014 }
2015 //*************************************************************************************************
2016 
2017 
2018 //*************************************************************************************************
2032 template< typename Type // Data type of the vector
2033  , size_t N // Number of elements
2034  , bool TF > // Transpose flag
2036  StaticVector<Type,N,TF>::stream( size_t index, const SIMDType& value ) noexcept
2037 {
2038  using blaze::stream;
2039 
2041 
2042  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
2043  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2044  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2045  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2046 
2047  stream( &v_[index], value );
2048 }
2049 //*************************************************************************************************
2050 
2051 
2052 //*************************************************************************************************
2063 template< typename Type // Data type of the vector
2064  , size_t N // Number of elements
2065  , bool TF > // Transpose flag
2066 template< typename VT > // Type of the right-hand side dense vector
2069 {
2070  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2071 
2072  for( size_t i=0UL; i<N; ++i )
2073  v_[i] = (~rhs)[i];
2074 }
2075 //*************************************************************************************************
2076 
2077 
2078 //*************************************************************************************************
2089 template< typename Type // Data type of the vector
2090  , size_t N // Number of elements
2091  , bool TF > // Transpose flag
2092 template< typename VT > // Type of the right-hand side dense vector
2095 {
2097 
2098  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2099 
2100  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2101 
2102  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2103  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2104 
2105  size_t i( 0UL );
2106 
2107  for( ; i<ipos; i+=SIMDSIZE ) {
2108  store( i, (~rhs).load(i) );
2109  }
2110  for( ; remainder && i<N; ++i ) {
2111  v_[i] = (~rhs)[i];
2112  }
2113 }
2114 //*************************************************************************************************
2115 
2116 
2117 //*************************************************************************************************
2128 template< typename Type // Data type of the vector
2129  , size_t N // Number of elements
2130  , bool TF > // Transpose flag
2131 template< typename VT > // Type of the right-hand side sparse vector
2133 {
2134  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2135 
2136  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2137  v_[element->index()] = element->value();
2138 }
2139 //*************************************************************************************************
2140 
2141 
2142 //*************************************************************************************************
2153 template< typename Type // Data type of the vector
2154  , size_t N // Number of elements
2155  , bool TF > // Transpose flag
2156 template< typename VT > // Type of the right-hand side dense vector
2157 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2159 {
2160  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2161 
2162  for( size_t i=0UL; i<N; ++i )
2163  v_[i] += (~rhs)[i];
2164 }
2165 //*************************************************************************************************
2166 
2167 
2168 //*************************************************************************************************
2179 template< typename Type // Data type of the vector
2180  , size_t N // Number of elements
2181  , bool TF > // Transpose flag
2182 template< typename VT > // Type of the right-hand side dense vector
2183 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
2185 {
2187 
2188  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2189 
2190  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2191 
2192  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2193  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2194 
2195  size_t i( 0UL );
2196 
2197  for( ; i<ipos; i+=SIMDSIZE ) {
2198  store( i, load(i) + (~rhs).load(i) );
2199  }
2200  for( ; remainder && i<N; ++i ) {
2201  v_[i] += (~rhs)[i];
2202  }
2203 }
2204 //*************************************************************************************************
2205 
2206 
2207 //*************************************************************************************************
2218 template< typename Type // Data type of the vector
2219  , size_t N // Number of elements
2220  , bool TF > // Transpose flag
2221 template< typename VT > // Type of the right-hand side sparse vector
2223 {
2224  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2225 
2226  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2227  v_[element->index()] += element->value();
2228 }
2229 //*************************************************************************************************
2230 
2231 
2232 //*************************************************************************************************
2243 template< typename Type // Data type of the vector
2244  , size_t N // Number of elements
2245  , bool TF > // Transpose flag
2246 template< typename VT > // Type of the right-hand side dense vector
2247 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2249 {
2250  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2251 
2252  for( size_t i=0UL; i<N; ++i )
2253  v_[i] -= (~rhs)[i];
2254 }
2255 //*************************************************************************************************
2256 
2257 
2258 //*************************************************************************************************
2269 template< typename Type // Data type of the vector
2270  , size_t N // Number of elements
2271  , bool TF > // Transpose flag
2272 template< typename VT > // Type of the right-hand side dense vector
2273 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
2275 {
2277 
2278  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2279 
2280  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2281 
2282  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2283  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2284 
2285  size_t i( 0UL );
2286 
2287  for( ; i<ipos; i+=SIMDSIZE ) {
2288  store( i, load(i) - (~rhs).load(i) );
2289  }
2290  for( ; remainder && i<N; ++i ) {
2291  v_[i] -= (~rhs)[i];
2292  }
2293 }
2294 //*************************************************************************************************
2295 
2296 
2297 //*************************************************************************************************
2308 template< typename Type // Data type of the vector
2309  , size_t N // Number of elements
2310  , bool TF > // Transpose flag
2311 template< typename VT > // Type of the right-hand side sparse vector
2313 {
2314  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2315 
2316  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2317  v_[element->index()] -= element->value();
2318 }
2319 //*************************************************************************************************
2320 
2321 
2322 //*************************************************************************************************
2333 template< typename Type // Data type of the vector
2334  , size_t N // Number of elements
2335  , bool TF > // Transpose flag
2336 template< typename VT > // Type of the right-hand side dense vector
2337 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2339 {
2340  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2341 
2342  for( size_t i=0UL; i<N; ++i )
2343  v_[i] *= (~rhs)[i];
2344 }
2345 //*************************************************************************************************
2346 
2347 
2348 //*************************************************************************************************
2359 template< typename Type // Data type of the vector
2360  , size_t N // Number of elements
2361  , bool TF > // Transpose flag
2362 template< typename VT > // Type of the right-hand side dense vector
2363 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2365 {
2367 
2368  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2369 
2370  constexpr bool remainder( !usePadding || !IsPadded<VT>::value );
2371 
2372  const size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2373  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2374 
2375  size_t i( 0UL );
2376 
2377  for( ; i<ipos; i+=SIMDSIZE ) {
2378  store( i, load(i) * (~rhs).load(i) );
2379  }
2380  for( ; remainder && i<N; ++i ) {
2381  v_[i] *= (~rhs)[i];
2382  }
2383 }
2384 //*************************************************************************************************
2385 
2386 
2387 //*************************************************************************************************
2398 template< typename Type // Data type of the vector
2399  , size_t N // Number of elements
2400  , bool TF > // Transpose flag
2401 template< typename VT > // Type of the right-hand side sparse vector
2403 {
2404  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2405 
2406  const StaticVector tmp( serial( *this ) );
2407 
2408  reset();
2409 
2410  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2411  v_[element->index()] = tmp[element->index()] * element->value();
2412 }
2413 //*************************************************************************************************
2414 
2415 
2416 //*************************************************************************************************
2427 template< typename Type // Data type of the vector
2428  , size_t N // Number of elements
2429  , bool TF > // Transpose flag
2430 template< typename VT > // Type of the right-hand side dense vector
2431 inline DisableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2433 {
2434  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2435 
2436  for( size_t i=0UL; i<N; ++i )
2437  v_[i] /= (~rhs)[i];
2438 }
2439 //*************************************************************************************************
2440 
2441 
2442 //*************************************************************************************************
2453 template< typename Type // Data type of the vector
2454  , size_t N // Number of elements
2455  , bool TF > // Transpose flag
2456 template< typename VT > // Type of the right-hand side dense vector
2457 inline EnableIf_<typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2459 {
2461 
2462  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2463 
2464  const size_t ipos( N & size_t(-SIMDSIZE) );
2465  BLAZE_INTERNAL_ASSERT( ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2466 
2467  size_t i( 0UL );
2468 
2469  for( ; i<ipos; i+=SIMDSIZE ) {
2470  store( i, load(i) / (~rhs).load(i) );
2471  }
2472  for( ; i<N; ++i ) {
2473  v_[i] /= (~rhs)[i];
2474  }
2475 }
2476 //*************************************************************************************************
2477 
2478 
2479 
2480 
2481 
2482 
2483 
2484 
2485 //=================================================================================================
2486 //
2487 // STATICVECTOR OPERATORS
2488 //
2489 //=================================================================================================
2490 
2491 //*************************************************************************************************
2494 template< typename Type, size_t N, bool TF >
2495 inline void reset( StaticVector<Type,N,TF>& v );
2496 
2497 template< typename Type, size_t N, bool TF >
2498 inline void clear( StaticVector<Type,N,TF>& v );
2499 
2500 template< bool RF, typename Type, size_t N, bool TF >
2501 inline bool isDefault( const StaticVector<Type,N,TF>& v );
2502 
2503 template< typename Type, size_t N, bool TF >
2504 inline bool isIntact( const StaticVector<Type,N,TF>& v ) noexcept;
2505 
2506 template< typename Type, bool TF >
2508 
2509 template< typename Type, bool TF >
2511 
2512 template< typename Type, size_t N, bool TF >
2513 inline void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) noexcept;
2515 //*************************************************************************************************
2516 
2517 
2518 //*************************************************************************************************
2525 template< typename Type // Data type of the vector
2526  , size_t N // Number of elements
2527  , bool TF > // Transpose flag
2529 {
2530  v.reset();
2531 }
2532 //*************************************************************************************************
2533 
2534 
2535 //*************************************************************************************************
2544 template< typename Type // Data type of the vector
2545  , size_t N // Number of elements
2546  , bool TF > // Transpose flag
2548 {
2549  v.reset();
2550 }
2551 //*************************************************************************************************
2552 
2553 
2554 //*************************************************************************************************
2579 template< bool RF // Relaxation flag
2580  , typename Type // Data type of the vector
2581  , size_t N // Number of elements
2582  , bool TF > // Transpose flag
2583 inline bool isDefault( const StaticVector<Type,N,TF>& v )
2584 {
2585  for( size_t i=0UL; i<N; ++i )
2586  if( !isDefault<RF>( v[i] ) ) return false;
2587  return true;
2588 }
2589 //*************************************************************************************************
2590 
2591 
2592 //*************************************************************************************************
2610 template< typename Type // Data type of the vector
2611  , size_t N // Number of elements
2612  , bool TF > // Transpose flag
2613 inline bool isIntact( const StaticVector<Type,N,TF>& v ) noexcept
2614 {
2615  return v.isIntact();
2616 }
2617 //*************************************************************************************************
2618 
2619 
2620 //*************************************************************************************************
2631 template< typename Type // Data type of the vector
2632  , bool TF > // Transpose flag
2634 {
2635  return StaticVector<Type,2UL,TF>( -v[1UL], v[0UL] );
2636 }
2637 //*************************************************************************************************
2638 
2639 
2640 //*************************************************************************************************
2648 template< typename Type // Data type of the vector
2649  , bool TF > // Transpose flag
2651 {
2652  if( v[0] != Type() || v[1] != Type() )
2653  return StaticVector<Type,3UL,TF>( v[1UL], -v[0UL], Type() );
2654  else
2655  return StaticVector<Type,3UL,TF>( Type(), v[2UL], -v[1UL] );
2656 }
2657 //*************************************************************************************************
2658 
2659 
2660 //*************************************************************************************************
2668 template< typename Type // Data type of the vector
2669  , size_t N // Number of elements
2670  , bool TF > // Transpose flag
2672 {
2673  a.swap( b );
2674 }
2675 //*************************************************************************************************
2676 
2677 
2678 
2679 
2680 //=================================================================================================
2681 //
2682 // SIZE SPECIALIZATIONS
2683 //
2684 //=================================================================================================
2685 
2686 //*************************************************************************************************
2688 template< typename T, size_t N, bool TF >
2689 struct Size< StaticVector<T,N,TF> >
2690  : public PtrdiffT<N>
2691 {};
2693 //*************************************************************************************************
2694 
2695 
2696 
2697 
2698 //=================================================================================================
2699 //
2700 // HASCONSTDATAACCESS SPECIALIZATIONS
2701 //
2702 //=================================================================================================
2703 
2704 //*************************************************************************************************
2706 template< typename T, size_t N, bool TF >
2707 struct HasConstDataAccess< StaticVector<T,N,TF> >
2708  : public TrueType
2709 {};
2711 //*************************************************************************************************
2712 
2713 
2714 
2715 
2716 //=================================================================================================
2717 //
2718 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2719 //
2720 //=================================================================================================
2721 
2722 //*************************************************************************************************
2724 template< typename T, size_t N, bool TF >
2725 struct HasMutableDataAccess< StaticVector<T,N,TF> >
2726  : public TrueType
2727 {};
2729 //*************************************************************************************************
2730 
2731 
2732 
2733 
2734 //=================================================================================================
2735 //
2736 // ISSTATIC SPECIALIZATIONS
2737 //
2738 //=================================================================================================
2739 
2740 //*************************************************************************************************
2742 template< typename T, size_t N, bool TF >
2743 struct IsStatic< StaticVector<T,N,TF> >
2744  : public TrueType
2745 {};
2747 //*************************************************************************************************
2748 
2749 
2750 
2751 
2752 //=================================================================================================
2753 //
2754 // ISALIGNED SPECIALIZATIONS
2755 //
2756 //=================================================================================================
2757 
2758 //*************************************************************************************************
2760 template< typename T, size_t N, bool TF >
2761 struct IsAligned< StaticVector<T,N,TF> >
2762  : public TrueType
2763 {};
2765 //*************************************************************************************************
2766 
2767 
2768 
2769 
2770 //=================================================================================================
2771 //
2772 // ISPADDED SPECIALIZATIONS
2773 //
2774 //=================================================================================================
2775 
2776 //*************************************************************************************************
2778 template< typename T, size_t N, bool TF >
2779 struct IsPadded< StaticVector<T,N,TF> >
2780  : public BoolConstant<usePadding>
2781 {};
2783 //*************************************************************************************************
2784 
2785 
2786 
2787 
2788 //=================================================================================================
2789 //
2790 // ADDTRAIT SPECIALIZATIONS
2791 //
2792 //=================================================================================================
2793 
2794 //*************************************************************************************************
2796 template< typename T1, size_t N, bool TF, typename T2 >
2797 struct AddTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2798 {
2799  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2800 };
2802 //*************************************************************************************************
2803 
2804 
2805 
2806 
2807 //=================================================================================================
2808 //
2809 // SUBTRAIT SPECIALIZATIONS
2810 //
2811 //=================================================================================================
2812 
2813 //*************************************************************************************************
2815 template< typename T1, size_t N, bool TF, typename T2 >
2816 struct SubTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2817 {
2818  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2819 };
2821 //*************************************************************************************************
2822 
2823 
2824 
2825 
2826 //=================================================================================================
2827 //
2828 // MULTTRAIT SPECIALIZATIONS
2829 //
2830 //=================================================================================================
2831 
2832 //*************************************************************************************************
2834 template< typename T1, size_t N, bool TF, typename T2 >
2835 struct MultTrait< StaticVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2836 {
2837  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2838 };
2839 
2840 template< typename T1, typename T2, size_t N, bool TF >
2841 struct MultTrait< T1, StaticVector<T2,N,TF>, EnableIf_<IsNumeric<T1> > >
2842 {
2843  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2844 };
2845 
2846 template< typename T1, size_t N, bool TF, typename T2 >
2847 struct MultTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2848 {
2849  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
2850 };
2851 
2852 template< typename T1, size_t M, typename T2, size_t N >
2853 struct MultTrait< StaticVector<T1,M,false>, StaticVector<T2,N,true> >
2854 {
2855  using Type = StaticMatrix< MultTrait_<T1,T2>, M, N, false >;
2856 };
2857 
2858 template< typename T1, size_t N, typename T2 >
2859 struct MultTrait< StaticVector<T1,N,true>, StaticVector<T2,N,false> >
2860 {
2861  using Type = MultTrait_<T1,T2>;
2862 };
2864 //*************************************************************************************************
2865 
2866 
2867 
2868 
2869 //=================================================================================================
2870 //
2871 // DIVTRAIT SPECIALIZATIONS
2872 //
2873 //=================================================================================================
2874 
2875 //*************************************************************************************************
2877 template< typename T1, size_t N, bool TF, typename T2 >
2878 struct DivTrait< StaticVector<T1,N,TF>, T2, EnableIf_<IsNumeric<T2> > >
2879 {
2880  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2881 };
2882 
2883 template< typename T1, size_t N, bool TF, typename T2 >
2884 struct DivTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2885 {
2886  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
2887 };
2889 //*************************************************************************************************
2890 
2891 
2892 
2893 
2894 //=================================================================================================
2895 //
2896 // CROSSTRAIT SPECIALIZATIONS
2897 //
2898 //=================================================================================================
2899 
2900 //*************************************************************************************************
2902 template< typename T1, typename T2, bool TF >
2903 struct CrossTrait< StaticVector<T1,3UL,TF>, StaticVector<T2,3UL,TF> >
2904 {
2905  private:
2906  using T = MultTrait_<T1,T2>;
2907 
2908  public:
2909  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2910 };
2912 //*************************************************************************************************
2913 
2914 
2915 
2916 
2917 //=================================================================================================
2918 //
2919 // UNARYMAPTRAIT SPECIALIZATIONS
2920 //
2921 //=================================================================================================
2922 
2923 //*************************************************************************************************
2925 template< typename T, size_t N, bool TF, typename OP >
2926 struct UnaryMapTrait< StaticVector<T,N,TF>, OP >
2927 {
2928  using Type = StaticVector< UnaryMapTrait_<T,OP>, N, TF >;
2929 };
2931 //*************************************************************************************************
2932 
2933 
2934 
2935 
2936 //=================================================================================================
2937 //
2938 // BINARYMAPTRAIT SPECIALIZATIONS
2939 //
2940 //=================================================================================================
2941 
2942 //*************************************************************************************************
2944 template< typename T1, size_t N, bool TF, typename T2, typename OP >
2945 struct BinaryMapTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF>, OP >
2946 {
2947  using Type = StaticVector< BinaryMapTrait_<T1,T2,OP>, N, TF >;
2948 };
2950 //*************************************************************************************************
2951 
2952 
2953 
2954 
2955 //=================================================================================================
2956 //
2957 // HIGHTYPE SPECIALIZATIONS
2958 //
2959 //=================================================================================================
2960 
2961 //*************************************************************************************************
2963 template< typename T1, size_t N, bool TF, typename T2 >
2964 struct HighType< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2965 {
2966  using Type = StaticVector< typename HighType<T1,T2>::Type, N, TF >;
2967 };
2969 //*************************************************************************************************
2970 
2971 
2972 
2973 
2974 //=================================================================================================
2975 //
2976 // LOWTYPE SPECIALIZATIONS
2977 //
2978 //=================================================================================================
2979 
2980 //*************************************************************************************************
2982 template< typename T1, size_t N, bool TF, typename T2 >
2983 struct LowType< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2984 {
2985  using Type = StaticVector< typename LowType<T1,T2>::Type, N, TF >;
2986 };
2988 //*************************************************************************************************
2989 
2990 
2991 
2992 
2993 //=================================================================================================
2994 //
2995 // SUBVECTORTRAIT SPECIALIZATIONS
2996 //
2997 //=================================================================================================
2998 
2999 //*************************************************************************************************
3001 template< typename T, size_t N, bool TF >
3002 struct SubvectorTrait< StaticVector<T,N,TF> >
3003 {
3004  using Type = HybridVector<T,N,TF>;
3005 };
3007 //*************************************************************************************************
3008 
3009 } // namespace blaze
3010 
3011 #endif
constexpr size_t spacing() const noexcept
Returns the minimum capacity of the vector.
Definition: StaticVector.h:1453
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:1817
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:941
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:204
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:79
Header file for the serial shim.
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1411
Availability of a SIMD multiplication for the given data types.Depending on the available instruction...
Definition: HasSIMDMult.h:172
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:316
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:250
Iterator end() noexcept
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:956
Header file for memory allocation and deallocation functionality.
System settings for performance optimizations.
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1393
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
Constraint on the data type.
Base template for the CrossTrait class.
Definition: CrossTrait.h:116
Type ElementType
Type of the vector elements.
Definition: StaticVector.h:194
Efficient implementation of a fixed-sized vector.The StaticVector class template is the representatio...
Definition: Forward.h:61
Header file for the std::initializer_list aliases.
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:120
Efficient implementation of a dynamically sized vector with static memory.The HybridVector class temp...
Definition: Forward.h:59
Compile time check for low-level access to mutable data.This type trait tests whether the given data ...
Definition: HasMutableDataAccess.h:75
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
void swap(StaticVector &v) noexcept
Swapping the contents of two static vectors.
Definition: StaticVector.h:1526
Header file for the DisableIf class template.
Header file for the LowType type trait.
Base template for the HighType type trait.
Definition: HighType.h:133
Header file for the multiplication trait.
Header file for the unary map trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5924
Resize mechanism to obtain a StaticVector with a different fixed number of elements.
Definition: StaticVector.h:221
Compile time assertion.
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: StaticVector.h:1836
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:2036
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:835
Type & Reference
Reference to a non-constant vector value.
Definition: StaticVector.h:199
StaticVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: StaticVector.h:1010
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the HasSIMDAdd type trait.
Efficient implementation of a fixed-sized matrix.The StaticMatrix class template is the representatio...
Definition: Forward.h:60
constexpr size_t capacity() const noexcept
Returns the maximum capacity of the vector.
Definition: StaticVector.h:1468
Header file for the DenseIterator class template.
const Type * ConstPointer
Pointer to a constant vector value.
Definition: StaticVector.h:202
Header file for the subvector trait.
Header file for all SIMD functionality.
Constraint on the data type.
Availability of a SIMD division for the given data types.Depending on the available instruction set (...
Definition: HasSIMDDiv.h:150
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:103
SIMDTrait_< ElementType > SIMDType
SIMD type of the vector elements.
Definition: StaticVector.h:195
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:190
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: StaticVector.h:1883
void reset()
Reset to the default initial values.
Definition: StaticVector.h:1508
#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:879
Constraint on the data type.
Header file for the exception macros of the math module.
typename CrossTrait< T1, T2 >::Type CrossTrait_
Auxiliary alias declaration for the CrossTrait class template.The CrossTrait_ alias declaration provi...
Definition: CrossTrait.h:159
Iterator begin() noexcept
Returns an iterator to the first element of the static vector.
Definition: StaticVector.h:911
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:2633
constexpr size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: StaticVector.h:1435
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:580
Header file for the IsPadded type trait.
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
Base template for the LowType type trait.
Definition: LowType.h:133
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: StaticVector.h:487
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:526
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:139
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:986
Base template for the MultTrait class.
Definition: MultTrait.h:139
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:1796
Header file for the division trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticVector.h:196
Constraint on the data type.
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:1916
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:792
DenseIterator< const Type, aligned > ConstIterator
Iterator over constant elements.
Definition: StaticVector.h:205
Constraint on the data type.
Header file for the HasSIMDSub type trait.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:819
Type * Pointer
Pointer to a non-constant vector value.
Definition: StaticVector.h:201
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:1760
EnableIf_< IsBuiltin< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:230
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
Base template for the DivTrait class.
Definition: DivTrait.h:139
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
Header file for the HasSIMDDiv type trait.
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: StaticVector.h:1486
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:177
Header file for the default transpose flag for all vectors of the Blaze library.
Initializer list type of the Blaze library.
Header file for the alignment check function.
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: StaticVector.h:1971
Compile time evaluation of the size of a vector.The Size type trait evaluates the size of the given v...
Definition: Size.h:74
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:2004
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
Base template for the SubTrait class.
Definition: SubTrait.h:139
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
Base template for the BinaryMapTrait class.
Definition: BinaryMapTrait.h:119
Base template for the UnaryMapTrait class.
Definition: UnaryMapTrait.h:117
System settings for the inline keywords.
const Type & ConstReference
Reference to a constant vector value.
Definition: StaticVector.h:200
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:1859
Rebind mechanism to obtain a StaticVector with different data/element type.
Definition: StaticVector.h:212
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:1947