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 <utility>
44 #include <blaze/math/Aliases.h>
49 #include <blaze/math/Exception.h>
52 #include <blaze/math/Forward.h>
54 #include <blaze/math/shims/Clear.h>
58 #include <blaze/math/SIMD.h>
94 #include <blaze/system/Inline.h>
100 #include <blaze/util/Assert.h>
106 #include <blaze/util/DisableIf.h>
107 #include <blaze/util/EnableIf.h>
109 #include <blaze/util/Memory.h>
110 #include <blaze/util/mpl/PtrdiffT.h>
111 #include <blaze/util/StaticAssert.h>
112 #include <blaze/util/TrueType.h>
113 #include <blaze/util/Types.h>
118 #include <blaze/util/Unused.h>
119 
120 
121 namespace blaze {
122 
123 //=================================================================================================
124 //
125 // CLASS DEFINITION
126 //
127 //=================================================================================================
128 
129 //*************************************************************************************************
195 template< typename Type // Data type of the vector
196  , size_t N // Number of elements
197  , bool TF = defaultTransposeFlag > // Transpose flag
198 class StaticVector
199  : public DenseVector< StaticVector<Type,N,TF>, TF >
200 {
201  private:
202  //**********************************************************************************************
204  static constexpr size_t SIMDSIZE = SIMDTrait<Type>::size;
205 
207  static constexpr size_t NN = ( usePadding ? nextMultiple( N, SIMDSIZE ) : N );
208 
210  static constexpr bool align = ( NN >= SIMDSIZE );
211  //**********************************************************************************************
212 
213  public:
214  //**Type definitions****************************************************************************
217  using ResultType = This;
219  using ElementType = Type;
221  using ReturnType = const Type&;
222  using CompositeType = const StaticVector&;
223 
224  using Reference = Type&;
225  using ConstReference = const Type&;
226  using Pointer = Type*;
227  using ConstPointer = const Type*;
228 
231  //**********************************************************************************************
232 
233  //**Rebind struct definition********************************************************************
236  template< typename NewType > // Data type of the other vector
237  struct Rebind {
239  };
240  //**********************************************************************************************
241 
242  //**Resize struct definition********************************************************************
245  template< size_t NewN > // Number of elements of the other vector
246  struct Resize {
248  };
249  //**********************************************************************************************
250 
251  //**Compilation flags***************************************************************************
253 
257  static constexpr bool simdEnabled = IsVectorizable_v<Type>;
258 
260 
263  static constexpr bool smpAssignable = false;
264  //**********************************************************************************************
265 
266  //**Constructors********************************************************************************
269  explicit inline StaticVector();
270  explicit inline StaticVector( const Type& init );
271  explicit inline constexpr StaticVector( initializer_list<Type> list );
272 
273  template< typename Other >
274  explicit inline StaticVector( size_t n, const Other* array );
275 
276  template< typename Other, size_t Dim >
277  explicit inline StaticVector( const Other (&array)[Dim] );
278 
279  inline constexpr StaticVector( const StaticVector& v );
280 
281  template< typename Other >
282  inline StaticVector( const StaticVector<Other,N,TF>& v );
283 
284  template< typename VT >
285  inline StaticVector( const Vector<VT,TF>& v );
287  //**********************************************************************************************
288 
289  //**Destructor**********************************************************************************
292  ~StaticVector() = default;
294  //**********************************************************************************************
295 
296  //**Data access functions***********************************************************************
299  inline constexpr Reference operator[]( size_t index ) noexcept;
300  inline constexpr ConstReference operator[]( size_t index ) const noexcept;
301  inline Reference at( size_t index );
302  inline ConstReference at( size_t index ) const;
303  inline constexpr Pointer data () noexcept;
304  inline constexpr ConstPointer data () const noexcept;
305  inline constexpr Iterator begin () noexcept;
306  inline constexpr ConstIterator begin () const noexcept;
307  inline constexpr ConstIterator cbegin() const noexcept;
308  inline constexpr Iterator end () noexcept;
309  inline constexpr ConstIterator end () const noexcept;
310  inline constexpr ConstIterator cend () const noexcept;
312  //**********************************************************************************************
313 
314  //**Assignment operators************************************************************************
317  inline constexpr StaticVector& operator=( const Type& rhs );
318  inline constexpr StaticVector& operator=( initializer_list<Type> list );
319 
320  template< typename Other, size_t Dim >
321  inline StaticVector& operator=( const Other (&array)[Dim] );
322 
323  inline constexpr StaticVector& operator=( const StaticVector& rhs );
324 
325  template< typename Other >
326  inline StaticVector& operator=( const StaticVector<Other,N,TF>& rhs );
327 
328  template< typename VT > inline StaticVector& operator= ( const Vector<VT,TF>& rhs );
329  template< typename VT > inline StaticVector& operator+=( const Vector<VT,TF>& rhs );
330  template< typename VT > inline StaticVector& operator-=( const Vector<VT,TF>& rhs );
331  template< typename VT > inline StaticVector& operator*=( const Vector<VT,TF>& rhs );
332  template< typename VT > inline StaticVector& operator/=( const DenseVector<VT,TF>& rhs );
333  template< typename VT > inline StaticVector& operator%=( const Vector<VT,TF>& rhs );
335  //**********************************************************************************************
336 
337  //**Utility functions***************************************************************************
340  static inline constexpr size_t size() noexcept;
341  static inline constexpr size_t spacing() noexcept;
342  static inline constexpr size_t capacity() noexcept;
343  inline size_t nonZeros() const;
344  inline constexpr void reset();
345  inline void swap( StaticVector& v ) noexcept;
347  //**********************************************************************************************
348 
349  //**Numeric functions***************************************************************************
352  template< typename Other > inline StaticVector& scale( const Other& scalar );
354  //**********************************************************************************************
355 
356  //**Memory functions****************************************************************************
359  static inline void* operator new ( std::size_t size );
360  static inline void* operator new[]( std::size_t size );
361  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
362  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
363 
364  static inline void operator delete ( void* ptr );
365  static inline void operator delete[]( void* ptr );
366  static inline void operator delete ( void* ptr, const std::nothrow_t& );
367  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
369  //**********************************************************************************************
370 
371  private:
372  //**********************************************************************************************
374  template< typename VT >
376  static constexpr bool VectorizedAssign_v =
377  ( useOptimizedKernels &&
378  simdEnabled && VT::simdEnabled &&
379  IsSIMDCombinable_v< Type, ElementType_t<VT> > );
381  //**********************************************************************************************
382 
383  //**********************************************************************************************
385  template< typename VT >
387  static constexpr bool VectorizedAddAssign_v =
388  ( useOptimizedKernels &&
389  simdEnabled && VT::simdEnabled &&
390  IsSIMDCombinable_v< Type, ElementType_t<VT> > &&
391  HasSIMDAdd_v< Type, ElementType_t<VT> > );
393  //**********************************************************************************************
394 
395  //**********************************************************************************************
397  template< typename VT >
399  static constexpr bool VectorizedSubAssign_v =
400  ( useOptimizedKernels &&
401  simdEnabled && VT::simdEnabled &&
402  IsSIMDCombinable_v< Type, ElementType_t<VT> > &&
403  HasSIMDSub_v< Type, ElementType_t<VT> > );
405  //**********************************************************************************************
406 
407  //**********************************************************************************************
409  template< typename VT >
411  static constexpr bool VectorizedMultAssign_v =
412  ( useOptimizedKernels &&
413  simdEnabled && VT::simdEnabled &&
414  IsSIMDCombinable_v< Type, ElementType_t<VT> > &&
415  HasSIMDMult_v< Type, ElementType_t<VT> > );
417  //**********************************************************************************************
418 
419  //**********************************************************************************************
421  template< typename VT >
423  static constexpr bool VectorizedDivAssign_v =
424  ( useOptimizedKernels &&
425  simdEnabled && VT::simdEnabled &&
426  IsSIMDCombinable_v< Type, ElementType_t<VT> > &&
427  HasSIMDDiv_v< Type, ElementType_t<VT> > );
429  //**********************************************************************************************
430 
431  public:
432  //**Debugging functions*************************************************************************
435  inline constexpr bool isIntact() const noexcept;
437  //**********************************************************************************************
438 
439  //**Expression template evaluation functions****************************************************
442  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
443  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
444 
445  static inline constexpr bool isAligned() noexcept;
446 
447  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
448  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
449  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
450 
451  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
452  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
453  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
454  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
455 
456  template< typename VT >
457  inline auto assign( const DenseVector<VT,TF>& rhs ) -> DisableIf_t< VectorizedAssign_v<VT> >;
458 
459  template< typename VT >
460  inline auto assign( const DenseVector<VT,TF>& rhs ) -> EnableIf_t< VectorizedAssign_v<VT> >;
461 
462  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
463 
464  template< typename VT >
465  inline auto addAssign( const DenseVector<VT,TF>& rhs ) -> DisableIf_t< VectorizedAddAssign_v<VT> >;
466 
467  template< typename VT >
468  inline auto addAssign( const DenseVector<VT,TF>& rhs ) -> EnableIf_t< VectorizedAddAssign_v<VT> >;
469 
470  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
471 
472  template< typename VT >
473  inline auto subAssign( const DenseVector<VT,TF>& rhs ) -> DisableIf_t< VectorizedSubAssign_v<VT> >;
474 
475  template< typename VT >
476  inline auto subAssign( const DenseVector<VT,TF>& rhs ) -> EnableIf_t< VectorizedSubAssign_v<VT> >;
477 
478  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
479 
480  template< typename VT >
481  inline auto multAssign( const DenseVector<VT,TF>& rhs ) -> DisableIf_t< VectorizedMultAssign_v<VT> >;
482 
483  template< typename VT >
484  inline auto multAssign( const DenseVector<VT,TF>& rhs ) -> EnableIf_t< VectorizedMultAssign_v<VT> >;
485 
486  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
487 
488  template< typename VT >
489  inline auto divAssign( const DenseVector<VT,TF>& rhs ) -> DisableIf_t< VectorizedDivAssign_v<VT> >;
490 
491  template< typename VT >
492  inline auto divAssign( const DenseVector<VT,TF>& rhs ) -> EnableIf_t< VectorizedDivAssign_v<VT> >;
494  //**********************************************************************************************
495 
496  private:
497  //**********************************************************************************************
499  static constexpr size_t Alignment =
500  ( align ? AlignmentOf_v<Type> : std::alignment_of<Type>::value );
501 
504  //**********************************************************************************************
505 
506  //**Member variables****************************************************************************
510 
516  //**********************************************************************************************
517 
518  //**Compile time checks*************************************************************************
524  BLAZE_STATIC_ASSERT( !usePadding || ( NN % SIMDSIZE == 0UL ) );
525  BLAZE_STATIC_ASSERT( NN >= N );
527  //**********************************************************************************************
528 };
529 //*************************************************************************************************
530 
531 
532 
533 
534 //=================================================================================================
535 //
536 // CONSTRUCTORS
537 //
538 //=================================================================================================
539 
540 //*************************************************************************************************
545 template< typename Type // Data type of the vector
546  , size_t N // Number of elements
547  , bool TF > // Transpose flag
548 inline StaticVector<Type,N,TF>::StaticVector()
549  : v_() // The statically allocated vector elements
550 {
551  BLAZE_STATIC_ASSERT( IsVectorizable_v<Type> || NN == N );
552 
553  if( IsNumeric_v<Type> ) {
554  for( size_t i=0UL; i<NN; ++i )
555  v_[i] = Type();
556  }
557 
558  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
559 }
560 //*************************************************************************************************
561 
562 
563 //*************************************************************************************************
568 template< typename Type // Data type of the vector
569  , size_t N // Number of elements
570  , bool TF > // Transpose flag
571 inline StaticVector<Type,N,TF>::StaticVector( const Type& init )
572  : v_() // The statically allocated vector elements
573 {
574  BLAZE_STATIC_ASSERT( IsVectorizable_v<Type> || NN == N );
575 
576  for( size_t i=0UL; i<N; ++i )
577  v_[i] = init;
578 
579  for( size_t i=N; i<NN; ++i )
580  v_[i] = Type();
581 
582  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
583 }
584 //*************************************************************************************************
585 
586 
587 //*************************************************************************************************
604 template< typename Type // Data type of the vector
605  , size_t N // Number of elements
606  , bool TF > // Transpose flag
608  : v_( Type() ) // The statically allocated vector elements
609 {
610  BLAZE_STATIC_ASSERT( IsVectorizable_v<Type> || NN == N );
611 
612  if( list.size() > N ) {
613  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
614  }
615 
616  size_t i( 0UL );
617 
618  for( const auto& element : list ) {
619  v_[i] = element;
620  ++i;
621  }
622 
623  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
624 }
625 //*************************************************************************************************
626 
627 
628 //*************************************************************************************************
650 template< typename Type // Data type of the vector
651  , size_t N // Number of elements
652  , bool TF > // Transpose flag
653 template< typename Other > // Data type of the initialization array
654 inline StaticVector<Type,N,TF>::StaticVector( size_t n, const Other* array )
655  : v_() // The statically allocated vector elements
656 {
657  BLAZE_STATIC_ASSERT( IsVectorizable_v<Type> || NN == N );
658 
659  if( n > N ) {
660  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
661  }
662 
663  for( size_t i=0UL; i<n; ++i )
664  v_[i] = array[i];
665 
666  if( IsNumeric_v<Type> ) {
667  for( size_t i=n; i<NN; ++i )
668  v_[i] = Type();
669  }
670 
671  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
672 }
673 //*************************************************************************************************
674 
675 
676 //*************************************************************************************************
692 template< typename Type // Data type of the vector
693  , size_t N // Number of elements
694  , bool TF > // Transpose flag
695 template< typename Other // Data type of the initialization array
696  , size_t Dim > // Dimension of the initialization array
697 inline StaticVector<Type,N,TF>::StaticVector( const Other (&array)[Dim] )
698  : v_() // The statically allocated vector elements
699 {
700  BLAZE_STATIC_ASSERT( IsVectorizable_v<Type> || NN == N );
701  BLAZE_STATIC_ASSERT( Dim == N );
702 
703  for( size_t i=0UL; i<N; ++i )
704  v_[i] = array[i];
705 
706  for( size_t i=N; i<NN; ++i )
707  v_[i] = Type();
708 
709  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
710 }
711 //*************************************************************************************************
712 
713 
714 //*************************************************************************************************
721 template< typename Type // Data type of the vector
722  , size_t N // Number of elements
723  , bool TF > // Transpose flag
725  : v_( v.v_ ) // The statically allocated vector elements
726 {
727  BLAZE_STATIC_ASSERT( IsVectorizable_v<Type> || NN == N );
728 
729  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
730 }
731 //*************************************************************************************************
732 
733 
734 //*************************************************************************************************
739 template< typename Type // Data type of the vector
740  , size_t N // Number of elements
741  , bool TF > // Transpose flag
742 template< typename Other > // Data type of the foreign vector
744  : v_() // The statically allocated vector elements
745 {
746  BLAZE_STATIC_ASSERT( IsVectorizable_v<Type> || NN == N );
747 
748  for( size_t i=0UL; i<N; ++i )
749  v_[i] = v[i];
750 
751  for( size_t i=N; i<NN; ++i )
752  v_[i] = Type();
753 
754  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
755 }
756 //*************************************************************************************************
757 
758 
759 //*************************************************************************************************
769 template< typename Type // Data type of the vector
770  , size_t N // Number of elements
771  , bool TF > // Transpose flag
772 template< typename VT > // Type of the foreign vector
774  : v_() // The statically allocated vector elements
775 {
776  using blaze::assign;
777 
778  BLAZE_STATIC_ASSERT( IsVectorizable_v<Type> || NN == N );
779 
780  if( (~v).size() != N ) {
781  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static vector" );
782  }
783 
784  for( size_t i=( IsSparseVector_v<VT> ? 0UL : N ); i<NN; ++i ) {
785  v_[i] = Type();
786  }
787 
788  assign( *this, ~v );
789 
790  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
791 }
792 //*************************************************************************************************
793 
794 
795 
796 
797 //=================================================================================================
798 //
799 // DATA ACCESS FUNCTIONS
800 //
801 //=================================================================================================
802 
803 //*************************************************************************************************
812 template< typename Type // Data type of the vector
813  , size_t N // Number of elements
814  , bool TF > // Transpose flag
815 inline constexpr typename StaticVector<Type,N,TF>::Reference
816  StaticVector<Type,N,TF>::operator[]( size_t index ) noexcept
817 {
818  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
819  return v_[index];
820 }
821 //*************************************************************************************************
822 
823 
824 //*************************************************************************************************
833 template< typename Type // Data type of the vector
834  , size_t N // Number of elements
835  , bool TF > // Transpose flag
836 inline constexpr typename StaticVector<Type,N,TF>::ConstReference
837  StaticVector<Type,N,TF>::operator[]( size_t index ) const noexcept
838 {
839  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
840  return v_[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
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 //*************************************************************************************************
879 template< typename Type // Data type of the vector
880  , size_t N // Number of elements
881  , bool TF > // Transpose flag
883  StaticVector<Type,N,TF>::at( size_t index ) const
884 {
885  if( index >= N ) {
886  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
887  }
888  return (*this)[index];
889 }
890 //*************************************************************************************************
891 
892 
893 //*************************************************************************************************
900 template< typename Type // Data type of the vector
901  , size_t N // Number of elements
902  , bool TF > // Transpose flag
903 inline constexpr typename StaticVector<Type,N,TF>::Pointer
905 {
906  return v_;
907 }
908 //*************************************************************************************************
909 
910 
911 //*************************************************************************************************
918 template< typename Type // Data type of the vector
919  , size_t N // Number of elements
920  , bool TF > // Transpose flag
921 inline constexpr typename StaticVector<Type,N,TF>::ConstPointer
923 {
924  return v_;
925 }
926 //*************************************************************************************************
927 
928 
929 //*************************************************************************************************
934 template< typename Type // Data type of the vector
935  , size_t N // Number of elements
936  , bool TF > // Transpose flag
937 inline constexpr typename StaticVector<Type,N,TF>::Iterator
939 {
940  return Iterator( v_ );
941 }
942 //*************************************************************************************************
943 
944 
945 //*************************************************************************************************
950 template< typename Type // Data type of the vector
951  , size_t N // Number of elements
952  , bool TF > // Transpose flag
953 inline constexpr typename StaticVector<Type,N,TF>::ConstIterator
955 {
956  return ConstIterator( v_ );
957 }
958 //*************************************************************************************************
959 
960 
961 //*************************************************************************************************
966 template< typename Type // Data type of the vector
967  , size_t N // Number of elements
968  , bool TF > // Transpose flag
969 inline constexpr typename StaticVector<Type,N,TF>::ConstIterator
971 {
972  return ConstIterator( v_ );
973 }
974 //*************************************************************************************************
975 
976 
977 //*************************************************************************************************
982 template< typename Type // Data type of the vector
983  , size_t N // Number of elements
984  , bool TF > // Transpose flag
985 inline constexpr typename StaticVector<Type,N,TF>::Iterator
987 {
988  return Iterator( v_ + N );
989 }
990 //*************************************************************************************************
991 
992 
993 //*************************************************************************************************
998 template< typename Type // Data type of the vector
999  , size_t N // Number of elements
1000  , bool TF > // Transpose flag
1001 inline constexpr typename StaticVector<Type,N,TF>::ConstIterator
1003 {
1004  return ConstIterator( v_ + N );
1005 }
1006 //*************************************************************************************************
1007 
1008 
1009 //*************************************************************************************************
1014 template< typename Type // Data type of the vector
1015  , size_t N // Number of elements
1016  , bool TF > // Transpose flag
1017 inline constexpr typename StaticVector<Type,N,TF>::ConstIterator
1019 {
1020  return ConstIterator( v_ + N );
1021 }
1022 //*************************************************************************************************
1023 
1024 
1025 
1026 
1027 //=================================================================================================
1028 //
1029 // ASSIGNMENT OPERATORS
1030 //
1031 //=================================================================================================
1032 
1033 //*************************************************************************************************
1039 template< typename Type // Data type of the vector
1040  , size_t N // Number of elements
1041  , bool TF > // Transpose flag
1042 inline constexpr StaticVector<Type,N,TF>&
1044 {
1045  for( size_t i=0UL; i<N; ++i )
1046  v_[i] = rhs;
1047  return *this;
1048 }
1049 //*************************************************************************************************
1050 
1051 
1052 //*************************************************************************************************
1070 template< typename Type // Data type of the vector
1071  , size_t N // Number of elements
1072  , bool TF > // Transpose flag
1073 inline constexpr StaticVector<Type,N,TF>&
1075 {
1076  if( list.size() > N ) {
1077  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to static vector" );
1078  }
1079 
1080  size_t i( 0UL );
1081 
1082  for( const auto& element : list ) {
1083  v_[i] = element;
1084  ++i;
1085  }
1086 
1087  for( ; i<N; ++i ) {
1088  v_[i] = Type();
1089  }
1090 
1091  return *this;
1092 }
1093 //*************************************************************************************************
1094 
1095 
1096 //*************************************************************************************************
1113 template< typename Type // Data type of the vector
1114  , size_t N // Number of elements
1115  , bool TF > // Transpose flag
1116 template< typename Other // Data type of the initialization array
1117  , size_t Dim > // Dimension of the initialization array
1119 {
1120  BLAZE_STATIC_ASSERT( Dim == N );
1121 
1122  for( size_t i=0UL; i<N; ++i )
1123  v_[i] = array[i];
1124  return *this;
1125 }
1126 //*************************************************************************************************
1127 
1128 
1129 //*************************************************************************************************
1137 template< typename Type // Data type of the vector
1138  , size_t N // Number of elements
1139  , bool TF > // Transpose flag
1141 {
1142  v_ = rhs.v_;
1143 
1144  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1145 
1146  return *this;
1147 }
1148 //*************************************************************************************************
1149 
1150 
1151 //*************************************************************************************************
1157 template< typename Type // Data type of the vector
1158  , size_t N // Number of elements
1159  , bool TF > // Transpose flag
1160 template< typename Other > // Data type of the foreign vector
1162 {
1163  using blaze::assign;
1164 
1165  assign( *this, ~rhs );
1166 
1167  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1168 
1169  return *this;
1170 }
1171 //*************************************************************************************************
1172 
1173 
1174 //*************************************************************************************************
1184 template< typename Type // Data type of the vector
1185  , size_t N // Number of elements
1186  , bool TF > // Transpose flag
1187 template< typename VT > // Type of the right-hand side vector
1189 {
1190  using blaze::assign;
1191 
1192  if( (~rhs).size() != N ) {
1193  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to static vector" );
1194  }
1195 
1196  if( (~rhs).canAlias( this ) ) {
1197  StaticVector tmp( ~rhs );
1198  swap( tmp );
1199  }
1200  else {
1201  if( IsSparseVector_v<VT> )
1202  reset();
1203  assign( *this, ~rhs );
1204  }
1205 
1206  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1207 
1208  return *this;
1209 }
1210 //*************************************************************************************************
1211 
1212 
1213 //*************************************************************************************************
1223 template< typename Type // Data type of the vector
1224  , size_t N // Number of elements
1225  , bool TF > // Transpose flag
1226 template< typename VT > // Type of the right-hand side vector
1228 {
1229  using blaze::addAssign;
1230 
1231  if( (~rhs).size() != N ) {
1232  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1233  }
1234 
1235  if( (~rhs).canAlias( this ) ) {
1236  StaticVector tmp( ~rhs );
1237  addAssign( *this, tmp );
1238  }
1239  else {
1240  addAssign( *this, ~rhs );
1241  }
1242 
1243  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1244 
1245  return *this;
1246 }
1247 //*************************************************************************************************
1248 
1249 
1250 //*************************************************************************************************
1260 template< typename Type // Data type of the vector
1261  , size_t N // Number of elements
1262  , bool TF > // Transpose flag
1263 template< typename VT > // Type of the right-hand side vector
1265 {
1266  using blaze::subAssign;
1267 
1268  if( (~rhs).size() != N ) {
1269  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1270  }
1271 
1272  if( (~rhs).canAlias( this ) ) {
1273  StaticVector tmp( ~rhs );
1274  subAssign( *this, tmp );
1275  }
1276  else {
1277  subAssign( *this, ~rhs );
1278  }
1279 
1280  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1281 
1282  return *this;
1283 }
1284 //*************************************************************************************************
1285 
1286 
1287 //*************************************************************************************************
1298 template< typename Type // Data type of the vector
1299  , size_t N // Number of elements
1300  , bool TF > // Transpose flag
1301 template< typename VT > // Type of the right-hand side vector
1303 {
1304  using blaze::assign;
1305  using blaze::multAssign;
1306 
1307  if( (~rhs).size() != N ) {
1308  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1309  }
1310 
1311  if( IsSparseVector_v<VT> || (~rhs).canAlias( this ) ) {
1312  const StaticVector tmp( *this * (~rhs) );
1313  assign( *this, tmp );
1314  }
1315  else {
1316  multAssign( *this, ~rhs );
1317  }
1318 
1319  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1320 
1321  return *this;
1322 }
1323 //*************************************************************************************************
1324 
1325 
1326 //*************************************************************************************************
1336 template< typename Type // Data type of the vector
1337  , size_t N // Number of elements
1338  , bool TF > // Transpose flag
1339 template< typename VT > // Type of the right-hand side vector
1341 {
1342  using blaze::assign;
1343  using blaze::divAssign;
1344 
1345  if( (~rhs).size() != N ) {
1346  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1347  }
1348 
1349  if( (~rhs).canAlias( this ) ) {
1350  const StaticVector tmp( *this / (~rhs) );
1351  assign( *this, tmp );
1352  }
1353  else {
1354  divAssign( *this, ~rhs );
1355  }
1356 
1357  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1358 
1359  return *this;
1360 }
1361 //*************************************************************************************************
1362 
1363 
1364 //*************************************************************************************************
1375 template< typename Type // Data type of the vector
1376  , size_t N // Number of elements
1377  , bool TF > // Transpose flag
1378 template< typename VT > // Type of the right-hand side vector
1380 {
1381  using blaze::assign;
1382 
1385 
1386  using CrossType = CrossTrait_t< This, ResultType_t<VT> >;
1387 
1391 
1392  if( N != 3UL || (~rhs).size() != 3UL ) {
1393  BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1394  }
1395 
1396  const CrossType tmp( *this % (~rhs) );
1397  assign( *this, tmp );
1398 
1399  BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1400 
1401  return *this;
1402 }
1403 //*************************************************************************************************
1404 
1405 
1406 
1407 
1408 //=================================================================================================
1409 //
1410 // UTILITY FUNCTIONS
1411 //
1412 //=================================================================================================
1413 
1414 //*************************************************************************************************
1419 template< typename Type // Data type of the vector
1420  , size_t N // Number of elements
1421  , bool TF > // Transpose flag
1422 inline constexpr size_t StaticVector<Type,N,TF>::size() noexcept
1423 {
1424  return N;
1425 }
1426 //*************************************************************************************************
1427 
1428 
1429 //*************************************************************************************************
1437 template< typename Type // Data type of the vector
1438  , size_t N // Number of elements
1439  , bool TF > // Transpose flag
1440 inline constexpr size_t StaticVector<Type,N,TF>::spacing() noexcept
1441 {
1442  return NN;
1443 }
1444 //*************************************************************************************************
1445 
1446 
1447 //*************************************************************************************************
1452 template< typename Type // Data type of the vector
1453  , size_t N // Number of elements
1454  , bool TF > // Transpose flag
1455 inline constexpr size_t StaticVector<Type,N,TF>::capacity() noexcept
1456 {
1457  return NN;
1458 }
1459 //*************************************************************************************************
1460 
1461 
1462 //*************************************************************************************************
1470 template< typename Type // Data type of the vector
1471  , size_t N // Number of elements
1472  , bool TF > // Transpose flag
1474 {
1475  size_t nonzeros( 0 );
1476 
1477  for( size_t i=0UL; i<N; ++i ) {
1478  if( !isDefault( v_[i] ) )
1479  ++nonzeros;
1480  }
1481 
1482  return nonzeros;
1483 }
1484 //*************************************************************************************************
1485 
1486 
1487 //*************************************************************************************************
1492 template< typename Type // Data type of the vector
1493  , size_t N // Number of elements
1494  , bool TF > // Transpose flag
1495 inline constexpr void StaticVector<Type,N,TF>::reset()
1496 {
1497  using blaze::clear;
1498  for( size_t i=0UL; i<N; ++i )
1499  clear( v_[i] );
1500 }
1501 //*************************************************************************************************
1502 
1503 
1504 //*************************************************************************************************
1510 template< typename Type // Data type of the vector
1511  , size_t N // Number of elements
1512  , bool TF > // Transpose flag
1514 {
1515  using std::swap;
1516 
1517  for( size_t i=0UL; i<N; ++i )
1518  swap( v_[i], v.v_[i] );
1519 }
1520 //*************************************************************************************************
1521 
1522 
1523 
1524 
1525 //=================================================================================================
1526 //
1527 // NUMERIC FUNCTIONS
1528 //
1529 //=================================================================================================
1530 
1531 //*************************************************************************************************
1548 template< typename Type // Data type of the vector
1549  , size_t N // Number of elements
1550  , bool TF > // Transpose flag
1551 template< typename Other > // Data type of the scalar value
1553 {
1554  for( size_t i=0; i<N; ++i )
1555  v_[i] *= scalar;
1556  return *this;
1557 }
1558 //*************************************************************************************************
1559 
1560 
1561 
1562 
1563 //=================================================================================================
1564 //
1565 // MEMORY FUNCTIONS
1566 //
1567 //=================================================================================================
1568 
1569 //*************************************************************************************************
1579 template< typename Type // Data type of the vector
1580  , size_t N // Number of elements
1581  , bool TF > // Transpose flag
1582 inline void* StaticVector<Type,N,TF>::operator new( std::size_t size )
1583 {
1585 
1586  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1587 
1588  return allocate<StaticVector>( 1UL );
1589 }
1590 //*************************************************************************************************
1591 
1592 
1593 //*************************************************************************************************
1603 template< typename Type // Data type of the vector
1604  , size_t N // Number of elements
1605  , bool TF > // Transpose flag
1606 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size )
1607 {
1608  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1609  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1610 
1611  return allocate<StaticVector>( size/sizeof(StaticVector) );
1612 }
1613 //*************************************************************************************************
1614 
1615 
1616 //*************************************************************************************************
1626 template< typename Type // Data type of the vector
1627  , size_t N // Number of elements
1628  , bool TF > // Transpose flag
1629 inline void* StaticVector<Type,N,TF>::operator new( std::size_t size, const std::nothrow_t& )
1630 {
1632 
1633  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1634 
1635  return allocate<StaticVector>( 1UL );
1636 }
1637 //*************************************************************************************************
1638 
1639 
1640 //*************************************************************************************************
1650 template< typename Type // Data type of the vector
1651  , size_t N // Number of elements
1652  , bool TF > // Transpose flag
1653 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size, const std::nothrow_t& )
1654 {
1655  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1656  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1657 
1658  return allocate<StaticVector>( size/sizeof(StaticVector) );
1659 }
1660 //*************************************************************************************************
1661 
1662 
1663 //*************************************************************************************************
1669 template< typename Type // Data type of the vector
1670  , size_t N // Number of elements
1671  , bool TF > // Transpose flag
1672 inline void StaticVector<Type,N,TF>::operator delete( void* ptr )
1673 {
1674  deallocate( static_cast<StaticVector*>( ptr ) );
1675 }
1676 //*************************************************************************************************
1677 
1678 
1679 //*************************************************************************************************
1685 template< typename Type // Data type of the vector
1686  , size_t N // Number of elements
1687  , bool TF > // Transpose flag
1688 inline void StaticVector<Type,N,TF>::operator delete[]( void* ptr )
1689 {
1690  deallocate( static_cast<StaticVector*>( ptr ) );
1691 }
1692 //*************************************************************************************************
1693 
1694 
1695 //*************************************************************************************************
1701 template< typename Type // Data type of the vector
1702  , size_t N // Number of elements
1703  , bool TF > // Transpose flag
1704 inline void StaticVector<Type,N,TF>::operator delete( void* ptr, const std::nothrow_t& )
1705 {
1706  deallocate( static_cast<StaticVector*>( ptr ) );
1707 }
1708 //*************************************************************************************************
1709 
1710 
1711 //*************************************************************************************************
1717 template< typename Type // Data type of the vector
1718  , size_t N // Number of elements
1719  , bool TF > // Transpose flag
1720 inline void StaticVector<Type,N,TF>::operator delete[]( void* ptr, const std::nothrow_t& )
1721 {
1722  deallocate( static_cast<StaticVector*>( ptr ) );
1723 }
1724 //*************************************************************************************************
1725 
1726 
1727 
1728 
1729 //=================================================================================================
1730 //
1731 // DEBUGGING FUNCTIONS
1732 //
1733 //=================================================================================================
1734 
1735 //*************************************************************************************************
1744 template< typename Type // Data type of the vector
1745  , size_t N // Number of elements
1746  , bool TF > // Transpose flag
1747 inline constexpr bool StaticVector<Type,N,TF>::isIntact() const noexcept
1748 {
1749  if( IsNumeric_v<Type> ) {
1750  for( size_t i=N; i<NN; ++i ) {
1751  if( v_[i] != Type() )
1752  return false;
1753  }
1754  }
1755 
1756  return true;
1757 }
1758 //*************************************************************************************************
1759 
1760 
1761 
1762 
1763 //=================================================================================================
1764 //
1765 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1766 //
1767 //=================================================================================================
1768 
1769 //*************************************************************************************************
1779 template< typename Type // Data type of the vector
1780  , size_t N // Number of elements
1781  , bool TF > // Transpose flag
1782 template< typename Other > // Data type of the foreign expression
1783 inline bool StaticVector<Type,N,TF>::canAlias( const Other* alias ) const noexcept
1784 {
1785  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1786 }
1787 //*************************************************************************************************
1788 
1789 
1790 //*************************************************************************************************
1800 template< typename Type // Data type of the vector
1801  , size_t N // Number of elements
1802  , bool TF > // Transpose flag
1803 template< typename Other > // Data type of the foreign expression
1804 inline bool StaticVector<Type,N,TF>::isAliased( const Other* alias ) const noexcept
1805 {
1806  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1807 }
1808 //*************************************************************************************************
1809 
1810 
1811 //*************************************************************************************************
1820 template< typename Type // Data type of the vector
1821  , size_t N // Number of elements
1822  , bool TF > // Transpose flag
1823 inline constexpr bool StaticVector<Type,N,TF>::isAligned() noexcept
1824 {
1825  return align;
1826 }
1827 //*************************************************************************************************
1828 
1829 
1830 //*************************************************************************************************
1842 template< typename Type // Data type of the vector
1843  , size_t N // Number of elements
1844  , bool TF > // Transpose flag
1846  StaticVector<Type,N,TF>::load( size_t index ) const noexcept
1847 {
1848  return loada( index );
1849 }
1850 //*************************************************************************************************
1851 
1852 
1853 //*************************************************************************************************
1866 template< typename Type // Data type of the vector
1867  , size_t N // Number of elements
1868  , bool TF > // Transpose flag
1870  StaticVector<Type,N,TF>::loada( size_t index ) const noexcept
1871 {
1872  using blaze::loada;
1873 
1875 
1876  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1877  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1878  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1879  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1880 
1881  return loada( &v_[index] );
1882 }
1883 //*************************************************************************************************
1884 
1885 
1886 //*************************************************************************************************
1899 template< typename Type // Data type of the vector
1900  , size_t N // Number of elements
1901  , bool TF > // Transpose flag
1903  StaticVector<Type,N,TF>::loadu( size_t index ) const noexcept
1904 {
1905  using blaze::loadu;
1906 
1908 
1909  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1910  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1911 
1912  return loadu( &v_[index] );
1913 }
1914 //*************************************************************************************************
1915 
1916 
1917 //*************************************************************************************************
1930 template< typename Type // Data type of the vector
1931  , size_t N // Number of elements
1932  , bool TF > // Transpose flag
1934  StaticVector<Type,N,TF>::store( size_t index, const SIMDType& value ) noexcept
1935 {
1936  storea( index, value );
1937 }
1938 //*************************************************************************************************
1939 
1940 
1941 //*************************************************************************************************
1954 template< typename Type // Data type of the vector
1955  , size_t N // Number of elements
1956  , bool TF > // Transpose flag
1958  StaticVector<Type,N,TF>::storea( size_t index, const SIMDType& value ) noexcept
1959 {
1960  using blaze::storea;
1961 
1963 
1964  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1965  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN , "Invalid vector access index" );
1966  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1967  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
1968 
1969  storea( &v_[index], value );
1970 }
1971 //*************************************************************************************************
1972 
1973 
1974 //*************************************************************************************************
1987 template< typename Type // Data type of the vector
1988  , size_t N // Number of elements
1989  , bool TF > // Transpose flag
1991  StaticVector<Type,N,TF>::storeu( size_t index, const SIMDType& value ) noexcept
1992 {
1993  using blaze::storeu;
1994 
1996 
1997  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
1998  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
1999 
2000  storeu( &v_[index], value );
2001 }
2002 //*************************************************************************************************
2003 
2004 
2005 //*************************************************************************************************
2019 template< typename Type // Data type of the vector
2020  , size_t N // Number of elements
2021  , bool TF > // Transpose flag
2023  StaticVector<Type,N,TF>::stream( size_t index, const SIMDType& value ) noexcept
2024 {
2025  using blaze::stream;
2026 
2028 
2029  BLAZE_INTERNAL_ASSERT( index < N, "Invalid vector access index" );
2030  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2031  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2032  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2033 
2034  stream( &v_[index], value );
2035 }
2036 //*************************************************************************************************
2037 
2038 
2039 //*************************************************************************************************
2050 template< typename Type // Data type of the vector
2051  , size_t N // Number of elements
2052  , bool TF > // Transpose flag
2053 template< typename VT > // Type of the right-hand side dense vector
2056 {
2057  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2058 
2059  for( size_t i=0UL; i<N; ++i )
2060  v_[i] = (~rhs)[i];
2061 }
2062 //*************************************************************************************************
2063 
2064 
2065 //*************************************************************************************************
2076 template< typename Type // Data type of the vector
2077  , size_t N // Number of elements
2078  , bool TF > // Transpose flag
2079 template< typename VT > // Type of the right-hand side dense vector
2080 inline auto StaticVector<Type,N,TF>::assign( const DenseVector<VT,TF>& rhs )
2082 {
2084 
2085  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2086 
2087  constexpr bool remainder( !usePadding || !IsPadded_v<VT> );
2088 
2089  constexpr size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2090  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2091 
2092  size_t i( 0UL );
2093 
2094  for( ; i<ipos; i+=SIMDSIZE ) {
2095  store( i, (~rhs).load(i) );
2096  }
2097  for( ; remainder && i<N; ++i ) {
2098  v_[i] = (~rhs)[i];
2099  }
2100 }
2101 //*************************************************************************************************
2102 
2103 
2104 //*************************************************************************************************
2115 template< typename Type // Data type of the vector
2116  , size_t N // Number of elements
2117  , bool TF > // Transpose flag
2118 template< typename VT > // Type of the right-hand side sparse vector
2120 {
2121  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2122 
2123  for( auto element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2124  v_[element->index()] = element->value();
2125 }
2126 //*************************************************************************************************
2127 
2128 
2129 //*************************************************************************************************
2140 template< typename Type // Data type of the vector
2141  , size_t N // Number of elements
2142  , bool TF > // Transpose flag
2143 template< typename VT > // Type of the right-hand side dense vector
2146 {
2147  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2148 
2149  for( size_t i=0UL; i<N; ++i )
2150  v_[i] += (~rhs)[i];
2151 }
2152 //*************************************************************************************************
2153 
2154 
2155 //*************************************************************************************************
2166 template< typename Type // Data type of the vector
2167  , size_t N // Number of elements
2168  , bool TF > // Transpose flag
2169 template< typename VT > // Type of the right-hand side dense vector
2172 {
2174 
2175  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2176 
2177  constexpr bool remainder( !usePadding || !IsPadded_v<VT> );
2178 
2179  constexpr size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2180  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2181 
2182  size_t i( 0UL );
2183 
2184  for( ; i<ipos; i+=SIMDSIZE ) {
2185  store( i, load(i) + (~rhs).load(i) );
2186  }
2187  for( ; remainder && i<N; ++i ) {
2188  v_[i] += (~rhs)[i];
2189  }
2190 }
2191 //*************************************************************************************************
2192 
2193 
2194 //*************************************************************************************************
2205 template< typename Type // Data type of the vector
2206  , size_t N // Number of elements
2207  , bool TF > // Transpose flag
2208 template< typename VT > // Type of the right-hand side sparse vector
2210 {
2211  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2212 
2213  for( auto element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2214  v_[element->index()] += element->value();
2215 }
2216 //*************************************************************************************************
2217 
2218 
2219 //*************************************************************************************************
2230 template< typename Type // Data type of the vector
2231  , size_t N // Number of elements
2232  , bool TF > // Transpose flag
2233 template< typename VT > // Type of the right-hand side dense vector
2236 {
2237  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2238 
2239  for( size_t i=0UL; i<N; ++i )
2240  v_[i] -= (~rhs)[i];
2241 }
2242 //*************************************************************************************************
2243 
2244 
2245 //*************************************************************************************************
2256 template< typename Type // Data type of the vector
2257  , size_t N // Number of elements
2258  , bool TF > // Transpose flag
2259 template< typename VT > // Type of the right-hand side dense vector
2262 {
2264 
2265  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2266 
2267  constexpr bool remainder( !usePadding || !IsPadded_v<VT> );
2268 
2269  constexpr size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2270  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2271 
2272  size_t i( 0UL );
2273 
2274  for( ; i<ipos; i+=SIMDSIZE ) {
2275  store( i, load(i) - (~rhs).load(i) );
2276  }
2277  for( ; remainder && i<N; ++i ) {
2278  v_[i] -= (~rhs)[i];
2279  }
2280 }
2281 //*************************************************************************************************
2282 
2283 
2284 //*************************************************************************************************
2295 template< typename Type // Data type of the vector
2296  , size_t N // Number of elements
2297  , bool TF > // Transpose flag
2298 template< typename VT > // Type of the right-hand side sparse vector
2300 {
2301  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2302 
2303  for( auto element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2304  v_[element->index()] -= element->value();
2305 }
2306 //*************************************************************************************************
2307 
2308 
2309 //*************************************************************************************************
2320 template< typename Type // Data type of the vector
2321  , size_t N // Number of elements
2322  , bool TF > // Transpose flag
2323 template< typename VT > // Type of the right-hand side dense vector
2326 {
2327  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2328 
2329  for( size_t i=0UL; i<N; ++i )
2330  v_[i] *= (~rhs)[i];
2331 }
2332 //*************************************************************************************************
2333 
2334 
2335 //*************************************************************************************************
2346 template< typename Type // Data type of the vector
2347  , size_t N // Number of elements
2348  , bool TF > // Transpose flag
2349 template< typename VT > // Type of the right-hand side dense vector
2352 {
2354 
2355  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2356 
2357  constexpr bool remainder( !usePadding || !IsPadded_v<VT> );
2358 
2359  constexpr size_t ipos( ( remainder )?( N & size_t(-SIMDSIZE) ):( N ) );
2360  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2361 
2362  size_t i( 0UL );
2363 
2364  for( ; i<ipos; i+=SIMDSIZE ) {
2365  store( i, load(i) * (~rhs).load(i) );
2366  }
2367  for( ; remainder && i<N; ++i ) {
2368  v_[i] *= (~rhs)[i];
2369  }
2370 }
2371 //*************************************************************************************************
2372 
2373 
2374 //*************************************************************************************************
2385 template< typename Type // Data type of the vector
2386  , size_t N // Number of elements
2387  , bool TF > // Transpose flag
2388 template< typename VT > // Type of the right-hand side sparse vector
2390 {
2391  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2392 
2393  const StaticVector tmp( serial( *this ) );
2394 
2395  reset();
2396 
2397  for( auto element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2398  v_[element->index()] = tmp[element->index()] * element->value();
2399 }
2400 //*************************************************************************************************
2401 
2402 
2403 //*************************************************************************************************
2414 template< typename Type // Data type of the vector
2415  , size_t N // Number of elements
2416  , bool TF > // Transpose flag
2417 template< typename VT > // Type of the right-hand side dense vector
2420 {
2421  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2422 
2423  for( size_t i=0UL; i<N; ++i )
2424  v_[i] /= (~rhs)[i];
2425 }
2426 //*************************************************************************************************
2427 
2428 
2429 //*************************************************************************************************
2440 template< typename Type // Data type of the vector
2441  , size_t N // Number of elements
2442  , bool TF > // Transpose flag
2443 template< typename VT > // Type of the right-hand side dense vector
2446 {
2448 
2449  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2450 
2451  constexpr size_t ipos( N & size_t(-SIMDSIZE) );
2452  BLAZE_INTERNAL_ASSERT( ( N - ( N % (SIMDSIZE) ) ) == ipos, "Invalid end calculation" );
2453 
2454  size_t i( 0UL );
2455 
2456  for( ; i<ipos; i+=SIMDSIZE ) {
2457  store( i, load(i) / (~rhs).load(i) );
2458  }
2459  for( ; i<N; ++i ) {
2460  v_[i] /= (~rhs)[i];
2461  }
2462 }
2463 //*************************************************************************************************
2464 
2465 
2466 
2467 
2468 
2469 
2470 
2471 
2472 //=================================================================================================
2473 //
2474 // STATICVECTOR OPERATORS
2475 //
2476 //=================================================================================================
2477 
2478 //*************************************************************************************************
2481 template< typename Type, size_t N, bool TF >
2482 constexpr void reset( StaticVector<Type,N,TF>& v );
2483 
2484 template< typename Type, size_t N, bool TF >
2485 constexpr void clear( StaticVector<Type,N,TF>& v );
2486 
2487 template< bool RF, typename Type, size_t N, bool TF >
2488 bool isDefault( const StaticVector<Type,N,TF>& v );
2489 
2490 template< typename Type, size_t N, bool TF >
2491 constexpr bool isIntact( const StaticVector<Type,N,TF>& v ) noexcept;
2492 
2493 template< typename Type, bool TF >
2494 const StaticVector<Type,2UL,TF> perp( const StaticVector<Type,2UL,TF>& v );
2495 
2496 template< typename Type, bool TF >
2497 const StaticVector<Type,3UL,TF> perp( const StaticVector<Type,3UL,TF>& v );
2498 
2499 template< typename Type, size_t N, bool TF >
2500 void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) noexcept;
2502 //*************************************************************************************************
2503 
2504 
2505 //*************************************************************************************************
2512 template< typename Type // Data type of the vector
2513  , size_t N // Number of elements
2514  , bool TF > // Transpose flag
2515 inline constexpr void reset( StaticVector<Type,N,TF>& v )
2516 {
2517  v.reset();
2518 }
2519 //*************************************************************************************************
2520 
2521 
2522 //*************************************************************************************************
2531 template< typename Type // Data type of the vector
2532  , size_t N // Number of elements
2533  , bool TF > // Transpose flag
2534 inline constexpr void clear( StaticVector<Type,N,TF>& v )
2535 {
2536  v.reset();
2537 }
2538 //*************************************************************************************************
2539 
2540 
2541 //*************************************************************************************************
2566 template< bool RF // Relaxation flag
2567  , typename Type // Data type of the vector
2568  , size_t N // Number of elements
2569  , bool TF > // Transpose flag
2570 inline bool isDefault( const StaticVector<Type,N,TF>& v )
2571 {
2572  for( size_t i=0UL; i<N; ++i )
2573  if( !isDefault<RF>( v[i] ) ) return false;
2574  return true;
2575 }
2576 //*************************************************************************************************
2577 
2578 
2579 //*************************************************************************************************
2597 template< typename Type // Data type of the vector
2598  , size_t N // Number of elements
2599  , bool TF > // Transpose flag
2600 inline constexpr bool isIntact( const StaticVector<Type,N,TF>& v ) noexcept
2601 {
2602  return v.isIntact();
2603 }
2604 //*************************************************************************************************
2605 
2606 
2607 //*************************************************************************************************
2618 template< typename Type // Data type of the vector
2619  , bool TF > // Transpose flag
2621 {
2622  return StaticVector<Type,2UL,TF>( -v[1UL], v[0UL] );
2623 }
2624 //*************************************************************************************************
2625 
2626 
2627 //*************************************************************************************************
2635 template< typename Type // Data type of the vector
2636  , bool TF > // Transpose flag
2638 {
2639  if( v[0] != Type() || v[1] != Type() )
2640  return StaticVector<Type,3UL,TF>( v[1UL], -v[0UL], Type() );
2641  else
2642  return StaticVector<Type,3UL,TF>( Type(), v[2UL], -v[1UL] );
2643 }
2644 //*************************************************************************************************
2645 
2646 
2647 //*************************************************************************************************
2655 template< typename Type // Data type of the vector
2656  , size_t N // Number of elements
2657  , bool TF > // Transpose flag
2659 {
2660  a.swap( b );
2661 }
2662 //*************************************************************************************************
2663 
2664 
2665 
2666 
2667 //=================================================================================================
2668 //
2669 // SIZE SPECIALIZATIONS
2670 //
2671 //=================================================================================================
2672 
2673 //*************************************************************************************************
2675 template< typename T, size_t N, bool TF >
2676 struct Size< StaticVector<T,N,TF>, 0UL >
2677  : public PtrdiffT<N>
2678 {};
2680 //*************************************************************************************************
2681 
2682 
2683 
2684 
2685 //=================================================================================================
2686 //
2687 // MAXSIZE SPECIALIZATIONS
2688 //
2689 //=================================================================================================
2690 
2691 //*************************************************************************************************
2693 template< typename T, size_t N, bool TF >
2694 struct MaxSize< StaticVector<T,N,TF>, 0UL >
2695  : public PtrdiffT<N>
2696 {};
2698 //*************************************************************************************************
2699 
2700 
2701 
2702 
2703 //=================================================================================================
2704 //
2705 // HASCONSTDATAACCESS SPECIALIZATIONS
2706 //
2707 //=================================================================================================
2708 
2709 //*************************************************************************************************
2711 template< typename T, size_t N, bool TF >
2712 struct HasConstDataAccess< StaticVector<T,N,TF> >
2713  : public TrueType
2714 {};
2716 //*************************************************************************************************
2717 
2718 
2719 
2720 
2721 //=================================================================================================
2722 //
2723 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2724 //
2725 //=================================================================================================
2726 
2727 //*************************************************************************************************
2729 template< typename T, size_t N, bool TF >
2730 struct HasMutableDataAccess< StaticVector<T,N,TF> >
2731  : public TrueType
2732 {};
2734 //*************************************************************************************************
2735 
2736 
2737 
2738 
2739 //=================================================================================================
2740 //
2741 // ISSTATIC SPECIALIZATIONS
2742 //
2743 //=================================================================================================
2744 
2745 //*************************************************************************************************
2747 template< typename T, size_t N, bool TF >
2748 struct IsStatic< StaticVector<T,N,TF> >
2749  : public TrueType
2750 {};
2752 //*************************************************************************************************
2753 
2754 
2755 
2756 
2757 //=================================================================================================
2758 //
2759 // ISALIGNED SPECIALIZATIONS
2760 //
2761 //=================================================================================================
2762 
2763 //*************************************************************************************************
2765 template< typename T, size_t N, bool TF >
2766 struct IsAligned< StaticVector<T,N,TF> >
2767  : public BoolConstant< StaticVector<T,N,TF>::isAligned() >
2768 {};
2770 //*************************************************************************************************
2771 
2772 
2773 
2774 
2775 //=================================================================================================
2776 //
2777 // ISCONTIGUOUS SPECIALIZATIONS
2778 //
2779 //=================================================================================================
2780 
2781 //*************************************************************************************************
2783 template< typename T, size_t N, bool TF >
2784 struct IsContiguous< StaticVector<T,N,TF> >
2785  : public TrueType
2786 {};
2788 //*************************************************************************************************
2789 
2790 
2791 
2792 
2793 //=================================================================================================
2794 //
2795 // ISPADDED SPECIALIZATIONS
2796 //
2797 //=================================================================================================
2798 
2799 //*************************************************************************************************
2801 template< typename T, size_t N, bool TF >
2802 struct IsPadded< StaticVector<T,N,TF> >
2803  : public BoolConstant<usePadding>
2804 {};
2806 //*************************************************************************************************
2807 
2808 
2809 
2810 
2811 //=================================================================================================
2812 //
2813 // ADDTRAIT SPECIALIZATIONS
2814 //
2815 //=================================================================================================
2816 
2817 //*************************************************************************************************
2819 template< typename T1, typename T2 >
2820 struct AddTraitEval2< T1, T2
2821  , EnableIf_t< IsVector_v<T1> &&
2822  IsVector_v<T2> &&
2823  ( Size_v<T1,0UL> != DefaultSize_v ||
2824  Size_v<T2,0UL> != DefaultSize_v ) > >
2825 {
2826  using ET1 = ElementType_t<T1>;
2827  using ET2 = ElementType_t<T2>;
2828 
2829  static constexpr size_t N = max( Size_v<T1,0UL>, Size_v<T2,0UL> );
2830 
2831  using Type = StaticVector< AddTrait_t<ET1,ET2>, N, TransposeFlag_v<T1> >;
2832 };
2834 //*************************************************************************************************
2835 
2836 
2837 
2838 
2839 //=================================================================================================
2840 //
2841 // SUBTRAIT SPECIALIZATIONS
2842 //
2843 //=================================================================================================
2844 
2845 //*************************************************************************************************
2847 template< typename T1, typename T2 >
2848 struct SubTraitEval2< T1, T2
2849  , EnableIf_t< IsVector_v<T1> &&
2850  IsVector_v<T2> &&
2851  ( Size_v<T1,0UL> != DefaultSize_v ||
2852  Size_v<T2,0UL> != DefaultSize_v ) > >
2853 {
2854  using ET1 = ElementType_t<T1>;
2855  using ET2 = ElementType_t<T2>;
2856 
2857  static constexpr size_t N = max( Size_v<T1,0UL>, Size_v<T2,0UL> );
2858 
2859  using Type = StaticVector< SubTrait_t<ET1,ET2>, N, TransposeFlag_v<T1> >;
2860 };
2862 //*************************************************************************************************
2863 
2864 
2865 
2866 
2867 //=================================================================================================
2868 //
2869 // MULTTRAIT SPECIALIZATIONS
2870 //
2871 //=================================================================================================
2872 
2873 //*************************************************************************************************
2875 template< typename T1, typename T2 >
2876 struct MultTraitEval2< T1, T2
2877  , EnableIf_t< IsVector_v<T1> &&
2878  IsNumeric_v<T2> &&
2879  ( Size_v<T1,0UL> != DefaultSize_v ) > >
2880 {
2881  using ET1 = ElementType_t<T1>;
2882 
2883  static constexpr size_t N = Size_v<T1,0UL>;
2884 
2885  using Type = StaticVector< MultTrait_t<ET1,T2>, N, TransposeFlag_v<T1> >;
2886 };
2887 
2888 template< typename T1, typename T2 >
2889 struct MultTraitEval2< T1, T2
2890  , EnableIf_t< IsNumeric_v<T1> &&
2891  IsVector_v<T2> &&
2892  ( Size_v<T2,0UL> != DefaultSize_v ) > >
2893 {
2894  using ET2 = ElementType_t<T2>;
2895 
2896  static constexpr size_t N = Size_v<T2,0UL>;
2897 
2898  using Type = StaticVector< MultTrait_t<T1,ET2>, N, TransposeFlag_v<T2> >;
2899 };
2900 
2901 template< typename T1, typename T2 >
2902 struct MultTraitEval2< T1, T2
2903  , EnableIf_t< ( ( IsRowVector_v<T1> && IsRowVector_v<T2> ) ||
2904  ( IsColumnVector_v<T1> && IsColumnVector_v<T2> ) ) &&
2905  IsDenseVector_v<T1> &&
2906  IsDenseVector_v<T2> &&
2907  ( Size_v<T1,0UL> != DefaultSize_v || Size_v<T2,0UL> != DefaultSize_v ) > >
2908 {
2909  using ET1 = ElementType_t<T1>;
2910  using ET2 = ElementType_t<T2>;
2911 
2912  static constexpr size_t N = max( Size_v<T1,0UL>, Size_v<T2,0UL> );
2913 
2914  using Type = StaticVector< MultTrait_t<ET1,ET2>, N, TransposeFlag_v<T1> >;
2915 };
2916 
2917 template< typename T1, typename T2 >
2918 struct MultTraitEval2< T1, T2
2919  , EnableIf_t< IsMatrix_v<T1> &&
2920  IsColumnVector_v<T2> &&
2921  ( Size_v<T1,0UL> != DefaultSize_v ||
2922  ( IsSquare_v<T1> && Size_v<T2,0UL> != DefaultSize_v ) ) > >
2923 {
2924  using ET1 = ElementType_t<T1>;
2925  using ET2 = ElementType_t<T2>;
2926 
2927  static constexpr size_t N = ( Size_v<T1,0UL> != DefaultSize_v ? Size_v<T1,0UL> : Size_v<T2,0UL> );
2928 
2929  using Type = StaticVector< MultTrait_t<ET1,ET2>, N, false >;
2930 };
2931 
2932 template< typename T1, typename T2 >
2933 struct MultTraitEval2< T1, T2
2934  , EnableIf_t< IsRowVector_v<T1> &&
2935  IsMatrix_v<T2> &&
2936  ( Size_v<T2,1UL> != DefaultSize_v ||
2937  ( IsSquare_v<T2> && Size_v<T1,0UL> != DefaultSize_v ) ) > >
2938 {
2939  using ET1 = ElementType_t<T1>;
2940  using ET2 = ElementType_t<T2>;
2941 
2942  static constexpr size_t N = ( Size_v<T2,1UL> != DefaultSize_v ? Size_v<T2,1UL> : Size_v<T1,0UL> );
2943 
2944  using Type = StaticVector< MultTrait_t<ET1,ET2>, N, true >;
2945 };
2947 //*************************************************************************************************
2948 
2949 
2950 
2951 
2952 //=================================================================================================
2953 //
2954 // DIVTRAIT SPECIALIZATIONS
2955 //
2956 //=================================================================================================
2957 
2958 //*************************************************************************************************
2960 template< typename T1, typename T2 >
2961 struct DivTraitEval2< T1, T2
2962  , EnableIf_t< IsVector_v<T1> &&
2963  IsNumeric_v<T2> &&
2964  ( Size_v<T1,0UL> != DefaultSize_v ) > >
2965 {
2966  using ET1 = ElementType_t<T1>;
2967 
2968  static constexpr size_t N = Size_v<T1,0UL>;
2969 
2970  using Type = StaticVector< DivTrait_t<ET1,T2>, N, TransposeFlag_v<T1> >;
2971 };
2972 
2973 template< typename T1, typename T2 >
2974 struct DivTraitEval2< T1, T2
2975  , EnableIf_t< IsDenseVector_v<T1> &&
2976  IsDenseVector_v<T2> &&
2977  ( Size_v<T1,0UL> != DefaultSize_v ||
2978  Size_v<T2,0UL> != DefaultSize_v ) > >
2979 {
2980  using ET1 = ElementType_t<T1>;
2981  using ET2 = ElementType_t<T2>;
2982 
2983  static constexpr size_t N = max( Size_v<T1,0UL>, Size_v<T2,0UL> );
2984 
2985  using Type = StaticVector< DivTrait_t<ET1,ET2>, N, TransposeFlag_v<T1> >;
2986 };
2988 //*************************************************************************************************
2989 
2990 
2991 
2992 
2993 //=================================================================================================
2994 //
2995 // CROSSTRAIT SPECIALIZATIONS
2996 //
2997 //=================================================================================================
2998 
2999 //*************************************************************************************************
3001 template< typename T1, typename T2 >
3002 struct CrossTraitEval2< T1, T2
3003  , EnableIf_t< IsVector_v<T1> && IsVector_v<T2> > >
3004 {
3005  using Tmp = MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >;
3006 
3007  using Type = StaticVector< SubTrait_t<Tmp,Tmp>, 3UL, TransposeFlag_v<T1> >;
3008 };
3010 //*************************************************************************************************
3011 
3012 
3013 
3014 
3015 //=================================================================================================
3016 //
3017 // MAPTRAIT SPECIALIZATIONS
3018 //
3019 //=================================================================================================
3020 
3021 //*************************************************************************************************
3023 template< typename T, typename OP >
3024 struct UnaryMapTraitEval2< T, OP
3025  , EnableIf_t< IsVector_v<T> &&
3026  Size_v<T,0UL> != DefaultSize_v > >
3027 {
3028  using ET = ElementType_t<T>;
3029 
3030  using Type = StaticVector< MapTrait_t<ET,OP>, Size_v<T,0UL>, TransposeFlag_v<T> >;
3031 };
3033 //*************************************************************************************************
3034 
3035 
3036 //*************************************************************************************************
3038 template< typename T1, typename T2, typename OP >
3039 struct BinaryMapTraitEval2< T1, T2, OP
3040  , EnableIf_t< IsVector_v<T1> &&
3041  IsVector_v<T2> &&
3042  ( Size_v<T1,0UL> != DefaultSize_v ||
3043  Size_v<T2,0UL> != DefaultSize_v ) > >
3044 {
3045  using ET1 = ElementType_t<T1>;
3046  using ET2 = ElementType_t<T2>;
3047 
3048  static constexpr size_t N = max( Size_v<T1,0UL>, Size_v<T2,0UL> );
3049 
3050  using Type = StaticVector< MapTrait_t<ET1,ET2,OP>, N, TransposeFlag_v<T1> >;
3051 };
3053 //*************************************************************************************************
3054 
3055 
3056 
3057 
3058 //=================================================================================================
3059 //
3060 // REDUCETRAIT SPECIALIZATIONS
3061 //
3062 //=================================================================================================
3063 
3064 //*************************************************************************************************
3066 template< typename T, typename OP, size_t RF >
3067 struct PartialReduceTraitEval2< T, OP, RF
3068  , EnableIf_t< IsMatrix_v<T> &&
3069  Size_v<T,0UL> != DefaultSize_v &&
3070  Size_v<T,1UL> != DefaultSize_v > >
3071 {
3072  static constexpr bool TF = ( RF == 0UL );
3073 
3074  static constexpr size_t N = Size_v< T, TF ? 1UL : 0UL >;
3075 
3076  using Type = StaticVector< ElementType_t<T>, N, TF >;
3077 };
3079 //*************************************************************************************************
3080 
3081 
3082 
3083 
3084 //=================================================================================================
3085 //
3086 // HIGHTYPE SPECIALIZATIONS
3087 //
3088 //=================================================================================================
3089 
3090 //*************************************************************************************************
3092 template< typename T1, size_t N, bool TF, typename T2 >
3093 struct HighType< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
3094 {
3095  using Type = StaticVector< typename HighType<T1,T2>::Type, N, TF >;
3096 };
3098 //*************************************************************************************************
3099 
3100 
3101 
3102 
3103 //=================================================================================================
3104 //
3105 // LOWTYPE SPECIALIZATIONS
3106 //
3107 //=================================================================================================
3108 
3109 //*************************************************************************************************
3111 template< typename T1, size_t N, bool TF, typename T2 >
3112 struct LowType< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
3113 {
3114  using Type = StaticVector< typename LowType<T1,T2>::Type, N, TF >;
3115 };
3117 //*************************************************************************************************
3118 
3119 
3120 
3121 
3122 //=================================================================================================
3123 //
3124 // SUBVECTORTRAIT SPECIALIZATIONS
3125 //
3126 //=================================================================================================
3127 
3128 //*************************************************************************************************
3130 template< typename VT, size_t I, size_t N >
3131 struct SubvectorTraitEval2< VT, I, N
3132  , EnableIf_t< I != inf && N != inf &&
3133  IsDenseVector_v<VT> > >
3134 {
3135  using Type = StaticVector< RemoveConst_t< ElementType_t<VT> >, N, TransposeFlag_v<VT> >;
3136 };
3138 //*************************************************************************************************
3139 
3140 
3141 
3142 
3143 //=================================================================================================
3144 //
3145 // ELEMENTSTRAIT SPECIALIZATIONS
3146 //
3147 //=================================================================================================
3148 
3149 //*************************************************************************************************
3151 template< typename VT, size_t N >
3152 struct ElementsTraitEval2< VT, N
3153  , EnableIf_t< N != 0UL &&
3154  IsDenseVector_v<VT> > >
3155 {
3156  using Type = StaticVector< RemoveConst_t< ElementType_t<VT> >, N, TransposeFlag_v<VT> >;
3157 };
3159 //*************************************************************************************************
3160 
3161 
3162 
3163 
3164 //=================================================================================================
3165 //
3166 // ROWTRAIT SPECIALIZATIONS
3167 //
3168 //=================================================================================================
3169 
3170 //*************************************************************************************************
3172 template< typename MT, size_t I >
3173 struct RowTraitEval2< MT, I
3174  , EnableIf_t< IsDenseMatrix_v<MT> &&
3175  Size_v<MT,1UL> != DefaultSize_v > >
3176 {
3177  using Type = StaticVector< RemoveConst_t< ElementType_t<MT> >, Size_v<MT,1UL>, true >;
3178 };
3180 //*************************************************************************************************
3181 
3182 
3183 
3184 
3185 //=================================================================================================
3186 //
3187 // COLUMNTRAIT SPECIALIZATIONS
3188 //
3189 //=================================================================================================
3190 
3191 //*************************************************************************************************
3193 template< typename MT, size_t I >
3194 struct ColumnTraitEval2< MT, I
3195  , EnableIf_t< IsDenseMatrix_v<MT> &&
3196  Size_v<MT,0UL> != DefaultSize_v > >
3197 {
3198  using Type = StaticVector< RemoveConst_t< ElementType_t<MT> >, Size_v<MT,0UL>, false >;
3199 };
3201 //*************************************************************************************************
3202 
3203 
3204 
3205 
3206 //=================================================================================================
3207 //
3208 // BANDTRAIT SPECIALIZATIONS
3209 //
3210 //=================================================================================================
3211 
3212 //*************************************************************************************************
3214 template< typename MT, ptrdiff_t I >
3215 struct BandTraitEval2< MT, I
3216  , EnableIf_t< IsDenseMatrix_v<MT> &&
3217  Size_v<MT,0UL> != DefaultSize_v &&
3218  Size_v<MT,1UL> != DefaultSize_v > >
3219 {
3220  static constexpr size_t M = Size_v<MT,0UL>;
3221  static constexpr size_t N = Size_v<MT,1UL>;
3222  static constexpr size_t Min = min( M - ( I >= 0L ? 0UL : -I ), N - ( I >= 0L ? I : 0UL ) );
3223 
3224  using Type = StaticVector< RemoveConst_t< ElementType_t<MT> >, Min, defaultTransposeFlag >;
3225 };
3227 //*************************************************************************************************
3228 
3229 } // namespace blaze
3230 
3231 #endif
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.
Header file for the nextMultiple shim.
#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:1804
Header file for the AlignmentOf type trait.
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.
static constexpr size_t spacing() noexcept
Returns the minimum capacity of the vector.
Definition: StaticVector.h:1440
constexpr Iterator begin() noexcept
Returns an iterator to the first element of the static vector.
Definition: StaticVector.h:938
constexpr bool HasSIMDSub_v
Auxiliary variable template for the HasSIMDSub type trait.The HasSIMDSub_v variable template provides...
Definition: HasSIMDSub.h:188
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:139
Header file for the row trait.
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
Header file for the serial shim.
static constexpr bool align
Compilation switch for the choice of alignment.
Definition: StaticVector.h:210
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:76
static constexpr bool simdEnabled
Compilation flag for SIMD optimization.
Definition: StaticVector.h:257
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
Header file for the IsRowVector type trait.
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_t alias declaration provid...
Definition: SIMDTrait.h:315
Header file for the DenseVector base class.
constexpr ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the static vector.
Definition: StaticVector.h:970
#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
SIMDTrait_t< ElementType > SIMDType
SIMD type of the vector elements.
Definition: StaticVector.h:220
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
Header file for memory allocation and deallocation functionality.
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition: Storeu.h:75
auto addAssign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedAddAssign_v< VT > >
Default implementation of the addition assignment of a dense vector.
Definition: StaticVector.h:2144
Header file for the extended initializer_list functionality.
System settings for performance optimizations.
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
STL namespace.
Header file for the reduce trait.
Header file for the MaxSize type trait.
Header file for the elements trait.
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Header file for the band trait.
Constraint on the data type.
Type ElementType
Type of the vector elements.
Definition: StaticVector.h:219
Efficient implementation of a fixed-sized vector.The StaticVector class template is the representatio...
Definition: Forward.h:61
Header file for the IsMatrix type trait.
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: StaticVector.h:263
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
void swap(StaticVector &v) noexcept
Swapping the contents of two static vectors.
Definition: StaticVector.h:1513
Headerfile for the generic max algorithm.
Header file for the DisableIf class template.
Header file for the LowType type trait.
Header file for the multiplication trait.
constexpr bool IsSIMDCombinable_v
Auxiliary variable template for the IsSIMDCombinable type trait.The IsSIMDCombinable_v variable templ...
Definition: IsSIMDCombinable.h:137
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5907
Resize mechanism to obtain a StaticVector with a different fixed number of elements.
Definition: StaticVector.h:246
Compile time assertion.
constexpr bool HasSIMDMult_v
Auxiliary variable template for the HasSIMDMult type trait.The HasSIMDMult_v variable template provid...
Definition: HasSIMDMult.h:189
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:2023
Reference at(size_t index)
Checked access to the vector elements.
Definition: StaticVector.h:859
Type & Reference
Reference to a non-constant vector value.
Definition: StaticVector.h:224
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the HasSIMDAdd type trait.
static constexpr size_t capacity() noexcept
Returns the maximum capacity of the vector.
Definition: StaticVector.h:1455
constexpr bool HasSIMDDiv_v
Auxiliary variable template for the HasSIMDDiv type trait.The HasSIMDDiv_v variable template provides...
Definition: HasSIMDDiv.h:172
Header file for the DenseIterator class template.
const Type * ConstPointer
Pointer to a constant vector value.
Definition: StaticVector.h:227
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
Header file for the subvector trait.
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
static constexpr size_t size() noexcept
Returns the current size/dimension of the vector.
Definition: StaticVector.h:1422
Header file for all SIMD functionality.
Constraint on the data type.
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
constexpr ConstIterator cend() const noexcept
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:1018
Header file for the IsAligned type trait.
constexpr bool IsDenseVector_v
Auxiliary variable template for the IsDenseVector type trait.The IsDenseVector_v variable template pr...
Definition: IsDenseVector.h:139
Constraint on the data type.
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:78
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.The IsVector_v variable template provides a c...
Definition: IsVector.h:140
StaticVector< Type, N, TF > This
Type of this StaticVector instance.
Definition: StaticVector.h:215
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: StaticVector.h:1870
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a vectorizable data type...
Definition: Vectorizable.h:61
Header file for the TransposeFlag type trait.
auto divAssign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedDivAssign_v< VT > >
Default implementation of the division assignment of a dense vector.
Definition: StaticVector.h:2418
AlignedStorage v_
The statically allocated vector elements.
Definition: StaticVector.h:509
Constraint on the data type.
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1179
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
Constraint on the data type.
Header file for the IsVector type trait.
Header file for the IsDenseMatrix type trait.
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:2620
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
constexpr void reset()
Reset to the default initial values.
Definition: StaticVector.h:1495
Header file for the IsPadded type trait.
typename CrossTrait< T1, T2 >::Type CrossTrait_t
Auxiliary alias declaration for the CrossTrait class template.The CrossTrait_t alias declaration prov...
Definition: CrossTrait.h:165
constexpr bool isIntact() const noexcept
Returns whether the invariants of the static vector are intact.
Definition: StaticVector.h:1747
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
IntegralConstant< ptrdiff_t, N > PtrdiffT
Compile time integral constant wrapper for ptrdiff_t.The PtrdiffT class template represents an integr...
Definition: PtrdiffT.h:72
Header file for the RemoveConst type trait.
Header file for the IsSIMDCombinable type trait.
Header file for the PtrdiffT class template.
auto assign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedAssign_v< VT > >
Default implementation of the assignment of a dense vector.
Definition: StaticVector.h:2054
Header file for the IsSparseVector type trait.
Header file for the HasSIMDMult type trait.
static constexpr size_t Alignment
Alignment of the data elements.
Definition: StaticVector.h:499
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: NextMultiple.h:68
StaticVector()
The default constructor for StaticVector.
Definition: StaticVector.h:548
Header file for run time assertion macros.
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:1783
Header file for the division trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticVector.h:221
Constraint on the data type.
Header file for the IsContiguous type trait.
static constexpr size_t NN
Alignment adjustment.
Definition: StaticVector.h:207
Header file for the AlignedArray implementation.
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:295
Header file for the IsStatic type trait.
constexpr StaticVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: StaticVector.h:1043
#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:1903
Header file for the column trait.
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:281
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
static constexpr bool isAligned() noexcept
Returns whether the vector is properly aligned in memory.
Definition: StaticVector.h:1823
Constraint on the data type.
Header file for the HasSIMDSub type trait.
constexpr bool IsDenseMatrix_v
Auxiliary variable template for the IsDenseMatrix type trait.The IsDenseMatrix_v variable template pr...
Definition: IsDenseMatrix.h:139
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
Type * Pointer
Pointer to a non-constant vector value.
Definition: StaticVector.h:226
Header file for the HasMutableDataAccess type trait.
#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
constexpr ptrdiff_t DefaultSize_v
Default size of the Size type trait.
Definition: Size.h:72
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:101
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:79
constexpr Iterator end() noexcept
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:986
constexpr Pointer data() noexcept
Low-level data access to the vector elements.
Definition: StaticVector.h:904
Header file for the IsDenseVector type trait.
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< 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:74
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
#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
constexpr size_t AlignmentOf_v
Auxiliary variable template for the AlignmentOf type trait.The AlignmentOf_v variable template provid...
Definition: AlignmentOf.h:238
Header file for the HasSIMDDiv type trait.
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: StaticVector.h:1473
constexpr bool IsRowVector_v
Auxiliary variable template for the IsRowVector type trait.The IsRowVector_v variable template provid...
Definition: IsRowVector.h:143
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:186
EnableIf_t< IsBuiltin_v< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:224
Header file for the default transpose flag for all vectors of the Blaze library.
constexpr Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: StaticVector.h:816
Header file for the alignment check function.
constexpr bool HasSIMDAdd_v
Auxiliary variable template for the HasSIMDAdd type trait.The HasSIMDAdd_v variable template provides...
Definition: HasSIMDAdd.h:188
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: StaticVector.h:1958
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:138
Header file for the IntegralConstant class template.
constexpr Infinity inf
Global Infinity instance.The blaze::inf instance can be used wherever a built-in data type is expecte...
Definition: Infinity.h:1080
Header file for the map trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
auto multAssign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedMultAssign_v< VT > >
Default implementation of the multiplication assignment of a dense vector.
Definition: StaticVector.h:2324
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: StaticVector.h:1991
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
Header file for the IsColumnVector type trait.
#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
auto subAssign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedSubAssign_v< VT > >
Default implementation of the subtraction assignment of a dense vector.
Definition: StaticVector.h:2234
System settings for the inline keywords.
const Type & ConstReference
Reference to a constant vector value.
Definition: StaticVector.h:225
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
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD vector.
Definition: StaticVector.h:204
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: StaticVector.h:1846
Rebind mechanism to obtain a StaticVector with different data/element type.
Definition: StaticVector.h:237
Header file for the HighType type trait.
Header file for the TrueType type/value trait base class.
Header file for the clear shim.
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: StaticVector.h:1934