StaticVector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_DENSE_STATICVECTOR_H_
36 #define _BLAZE_MATH_DENSE_STATICVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <stdexcept>
48 #include <blaze/math/Forward.h>
49 #include <blaze/math/Intrinsics.h>
50 #include <blaze/math/shims/Clear.h>
64 #include <blaze/system/Inline.h>
67 #include <blaze/util/Assert.h>
74 #include <blaze/util/DisableIf.h>
75 #include <blaze/util/EnableIf.h>
76 #include <blaze/util/Memory.h>
78 #include <blaze/util/Template.h>
79 #include <blaze/util/Types.h>
83 #include <blaze/util/Unused.h>
84 
85 
86 namespace blaze {
87 
88 //=================================================================================================
89 //
90 // CLASS DEFINITION
91 //
92 //=================================================================================================
93 
94 //*************************************************************************************************
160 template< typename Type // Data type of the vector
161  , size_t N // Number of elements
162  , bool TF = defaultTransposeFlag > // Transpose flag
163 class StaticVector : public DenseVector< StaticVector<Type,N,TF>, TF >
164 {
165  private:
166  //**Type definitions****************************************************************************
168  //**********************************************************************************************
169 
170  //**********************************************************************************************
172  enum { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size };
173  //**********************************************************************************************
174 
175  public:
176  //**Type definitions****************************************************************************
178  typedef This ResultType;
180  typedef Type ElementType;
181  typedef typename IT::Type IntrinsicType;
182  typedef const Type& ReturnType;
183  typedef const StaticVector& CompositeType;
184  typedef Type& Reference;
185  typedef const Type& ConstReference;
186  typedef Type* Pointer;
187  typedef const Type* ConstPointer;
190  //**********************************************************************************************
191 
192  //**Rebind struct definition********************************************************************
195  template< typename ET > // Data type of the other vector
196  struct Rebind {
198  };
199  //**********************************************************************************************
200 
201  //**Compilation flags***************************************************************************
203 
207  enum { vectorizable = IsVectorizable<Type>::value };
208 
210 
213  enum { smpAssignable = 0 };
214  //**********************************************************************************************
215 
216  //**Constructors********************************************************************************
219  explicit inline StaticVector();
220  explicit inline StaticVector( const Type& init );
221  template< typename Other > explicit inline StaticVector( size_t n, const Other* array );
222 
223  template< typename Other >
224  explicit inline StaticVector( const Other (&array)[N] );
225 
226  inline StaticVector( const StaticVector& v );
227  template< typename Other > inline StaticVector( const StaticVector<Other,N,TF>& v );
228  template< typename VT > inline StaticVector( const Vector<VT,TF>& v );
229 
230  inline StaticVector( const Type& v1, const Type& v2 );
231  inline StaticVector( const Type& v1, const Type& v2, const Type& v3 );
232  inline StaticVector( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
233  inline StaticVector( const Type& v1, const Type& v2, const Type& v3,
234  const Type& v4, const Type& v5 );
235  inline StaticVector( const Type& v1, const Type& v2, const Type& v3,
236  const Type& v4, const Type& v5, const Type& v6 );
238  //**********************************************************************************************
239 
240  //**Destructor**********************************************************************************
241  // No explicitly declared destructor.
242  //**********************************************************************************************
243 
244  //**Data access functions***********************************************************************
247  inline Reference operator[]( size_t index );
248  inline ConstReference operator[]( size_t index ) const;
249  inline Pointer data ();
250  inline ConstPointer data () const;
251  inline Iterator begin ();
252  inline ConstIterator begin () const;
253  inline ConstIterator cbegin() const;
254  inline Iterator end ();
255  inline ConstIterator end () const;
256  inline ConstIterator cend () const;
258  //**********************************************************************************************
259 
260  //**Assignment operators************************************************************************
263  template< typename Other >
264  inline StaticVector& operator=( const Other (&array)[N] );
265 
266  inline StaticVector& operator= ( const Type& rhs );
267  inline StaticVector& operator= ( const StaticVector& rhs );
268  template< typename Other > inline StaticVector& operator= ( const StaticVector<Other,N,TF>& rhs );
269  template< typename VT > inline StaticVector& operator= ( const Vector<VT,TF>& rhs );
270  template< typename VT > inline StaticVector& operator+=( const Vector<VT,TF>& rhs );
271  template< typename VT > inline StaticVector& operator-=( const Vector<VT,TF>& rhs );
272  template< typename VT > inline StaticVector& operator*=( const Vector<VT,TF>& rhs );
273 
274  template< typename Other >
275  inline typename EnableIf< IsNumeric<Other>, StaticVector >::Type&
276  operator*=( Other rhs );
277 
278  template< typename Other >
279  inline typename EnableIf< IsNumeric<Other>, StaticVector >::Type&
280  operator/=( Other rhs );
282  //**********************************************************************************************
283 
284  //**Utility functions***************************************************************************
287  inline size_t size() const;
288  inline size_t capacity() const;
289  inline size_t nonZeros() const;
290  inline void reset();
291  template< typename Other > inline StaticVector& scale( const Other& scalar );
292  inline void swap( StaticVector& v ) /* throw() */;
294  //**********************************************************************************************
295 
296  //**Memory functions****************************************************************************
299  static inline void* operator new ( std::size_t size );
300  static inline void* operator new[]( std::size_t size );
301  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
302  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
303 
304  static inline void operator delete ( void* ptr );
305  static inline void operator delete[]( void* ptr );
306  static inline void operator delete ( void* ptr, const std::nothrow_t& );
307  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
309  //**********************************************************************************************
310 
311  private:
312  //**********************************************************************************************
314  template< typename VT >
316  struct VectorizedAssign {
317  enum { value = vectorizable && VT::vectorizable &&
318  IsSame<Type,typename VT::ElementType>::value };
319  };
321  //**********************************************************************************************
322 
323  //**********************************************************************************************
325  template< typename VT >
327  struct VectorizedAddAssign {
328  enum { value = vectorizable && VT::vectorizable &&
329  IsSame<Type,typename VT::ElementType>::value &&
330  IntrinsicTrait<Type>::addition };
331  };
333  //**********************************************************************************************
334 
335  //**********************************************************************************************
337  template< typename VT >
339  struct VectorizedSubAssign {
340  enum { value = vectorizable && VT::vectorizable &&
341  IsSame<Type,typename VT::ElementType>::value &&
342  IntrinsicTrait<Type>::subtraction };
343  };
345  //**********************************************************************************************
346 
347  //**********************************************************************************************
349  template< typename VT >
351  struct VectorizedMultAssign {
352  enum { value = vectorizable && VT::vectorizable &&
353  IsSame<Type,typename VT::ElementType>::value &&
354  IntrinsicTrait<Type>::multiplication };
355  };
357  //**********************************************************************************************
358 
359  public:
360  //**Expression template evaluation functions****************************************************
363  template< typename Other > inline bool canAlias ( const Other* alias ) const;
364  template< typename Other > inline bool isAliased( const Other* alias ) const;
365 
366  inline bool isAligned() const;
367 
368  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t index ) const;
369  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t index ) const;
370 
371  BLAZE_ALWAYS_INLINE void store ( size_t index, const IntrinsicType& value );
372  BLAZE_ALWAYS_INLINE void storeu( size_t index, const IntrinsicType& value );
373  BLAZE_ALWAYS_INLINE void stream( size_t index, const IntrinsicType& value );
374 
375  template< typename VT >
376  inline typename DisableIf< VectorizedAssign<VT> >::Type
377  assign( const DenseVector<VT,TF>& rhs );
378 
379  template< typename VT >
380  inline typename EnableIf< VectorizedAssign<VT> >::Type
381  assign( const DenseVector<VT,TF>& rhs );
382 
383  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
384 
385  template< typename VT >
386  inline typename DisableIf< VectorizedAddAssign<VT> >::Type
387  addAssign( const DenseVector<VT,TF>& rhs );
388 
389  template< typename VT >
390  inline typename EnableIf< VectorizedAddAssign<VT> >::Type
391  addAssign( const DenseVector<VT,TF>& rhs );
392 
393  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
394 
395  template< typename VT >
396  inline typename DisableIf< VectorizedSubAssign<VT> >::Type
397  subAssign( const DenseVector<VT,TF>& rhs );
398 
399  template< typename VT >
400  inline typename EnableIf< VectorizedSubAssign<VT> >::Type
401  subAssign( const DenseVector<VT,TF>& rhs );
402 
403  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
404 
405  template< typename VT >
406  inline typename DisableIf< VectorizedMultAssign<VT> >::Type
407  multAssign( const DenseVector<VT,TF>& rhs );
408 
409  template< typename VT >
410  inline typename EnableIf< VectorizedMultAssign<VT> >::Type
411  multAssign( const DenseVector<VT,TF>& rhs );
412 
413  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
415  //**********************************************************************************************
416 
417  private:
418  //**Member variables****************************************************************************
422 
428  //**********************************************************************************************
429 
430  //**Compile time checks*************************************************************************
436  BLAZE_STATIC_ASSERT( NN % IT::size == 0UL );
437  BLAZE_STATIC_ASSERT( NN >= N );
439  //**********************************************************************************************
440 };
441 //*************************************************************************************************
442 
443 
444 
445 
446 //=================================================================================================
447 //
448 // CONSTRUCTORS
449 //
450 //=================================================================================================
451 
452 //*************************************************************************************************
457 template< typename Type // Data type of the vector
458  , size_t N // Number of elements
459  , bool TF > // Transpose flag
461  : v_() // The statically allocated vector elements
462 {
464 
465  if( IsNumeric<Type>::value ) {
466  for( size_t i=0UL; i<NN; ++i )
467  v_[i] = Type();
468  }
469 }
470 //*************************************************************************************************
471 
472 
473 //*************************************************************************************************
478 template< typename Type // Data type of the vector
479  , size_t N // Number of elements
480  , bool TF > // Transpose flag
481 inline StaticVector<Type,N,TF>::StaticVector( const Type& init )
482  : v_() // The statically allocated vector elements
483 {
485 
486  for( size_t i=0UL; i<N; ++i )
487  v_[i] = init;
488 
489  for( size_t i=N; i<NN; ++i )
490  v_[i] = Type();
491 }
492 //*************************************************************************************************
493 
494 
495 //*************************************************************************************************
517 template< typename Type // Data type of the vector
518  , size_t N // Number of elements
519  , bool TF > // Transpose flag
520 template< typename Other > // Data type of the initialization array
521 inline StaticVector<Type,N,TF>::StaticVector( size_t n, const Other* array )
522  : v_() // The statically allocated vector elements
523 {
525 
526  if( n > N )
527  throw std::invalid_argument( "Invalid setup of static vector" );
528 
529  for( size_t i=0UL; i<n; ++i )
530  v_[i] = array[i];
531 
532  if( IsNumeric<Type>::value ) {
533  for( size_t i=n; i<NN; ++i )
534  v_[i] = Type();
535  }
536 }
537 //*************************************************************************************************
538 
539 
540 //*************************************************************************************************
556 template< typename Type // Data type of the vector
557  , size_t N // Number of elements
558  , bool TF > // Transpose flag
559 template< typename Other > // Data type of the initialization array
560 inline StaticVector<Type,N,TF>::StaticVector( const Other (&array)[N] )
561  : v_() // The statically allocated vector elements
562 {
564 
565  for( size_t i=0UL; i<N; ++i )
566  v_[i] = array[i];
567 
568  for( size_t i=N; i<NN; ++i )
569  v_[i] = Type();
570 }
571 //*************************************************************************************************
572 
573 
574 //*************************************************************************************************
581 template< typename Type // Data type of the vector
582  , size_t N // Number of elements
583  , bool TF > // Transpose flag
585  : v_() // The statically allocated vector elements
586 {
588 
589  for( size_t i=0UL; i<NN; ++i )
590  v_[i] = v.v_[i];
591 }
592 //*************************************************************************************************
593 
594 
595 //*************************************************************************************************
600 template< typename Type // Data type of the vector
601  , size_t N // Number of elements
602  , bool TF > // Transpose flag
603 template< typename Other > // Data type of the foreign vector
605  : v_() // The statically allocated vector elements
606 {
608 
609  for( size_t i=0UL; i<N; ++i )
610  v_[i] = v[i];
611 
612  for( size_t i=N; i<NN; ++i )
613  v_[i] = Type();
614 }
615 //*************************************************************************************************
616 
617 
618 //*************************************************************************************************
628 template< typename Type // Data type of the vector
629  , size_t N // Number of elements
630  , bool TF > // Transpose flag
631 template< typename VT > // Type of the foreign vector
633  : v_() // The statically allocated vector elements
634 {
635  using blaze::assign;
636 
638 
639  if( (~v).size() != N )
640  throw std::invalid_argument( "Invalid setup of static vector" );
641 
642  for( size_t i=( IsSparseVector<VT>::value ? 0UL : N ); i<NN; ++i ) {
643  v_[i] = Type();
644  }
645 
646  assign( *this, ~v );
647 }
648 //*************************************************************************************************
649 
650 
651 //*************************************************************************************************
663 template< typename Type // Data type of the vector
664  , size_t N // Number of elements
665  , bool TF > // Transpose flag
666 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2 )
667  : v_() // The statically allocated vector elements
668 {
669  BLAZE_STATIC_ASSERT( N == 2UL );
671 
672  v_[0UL] = v1;
673  v_[1UL] = v2;
674 
675  for( size_t i=N; i<NN; ++i )
676  v_[i] = Type();
677 }
678 //*************************************************************************************************
679 
680 
681 //*************************************************************************************************
694 template< typename Type // Data type of the vector
695  , size_t N // Number of elements
696  , bool TF > // Transpose flag
697 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2, const Type& v3 )
698  : v_() // The statically allocated vector elements
699 {
700  BLAZE_STATIC_ASSERT( N == 3UL );
702 
703  v_[0UL] = v1;
704  v_[1UL] = v2;
705  v_[2UL] = v3;
706 
707  for( size_t i=N; i<NN; ++i )
708  v_[i] = Type();
709 }
710 //*************************************************************************************************
711 
712 
713 //*************************************************************************************************
727 template< typename Type // Data type of the vector
728  , size_t N // Number of elements
729  , bool TF > // Transpose flag
730 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2,
731  const Type& v3, const Type& v4 )
732  : v_() // The statically allocated vector elements
733 {
734  BLAZE_STATIC_ASSERT( N == 4UL );
736 
737  v_[0UL] = v1;
738  v_[1UL] = v2;
739  v_[2UL] = v3;
740  v_[3UL] = v4;
741 
742  for( size_t i=N; i<NN; ++i )
743  v_[i] = Type();
744 }
745 //*************************************************************************************************
746 
747 
748 //*************************************************************************************************
763 template< typename Type // Data type of the vector
764  , size_t N // Number of elements
765  , bool TF > // Transpose flag
766 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2, const Type& v3,
767  const Type& v4, const Type& v5 )
768  : v_() // The statically allocated vector elements
769 {
770  BLAZE_STATIC_ASSERT( N == 5UL );
772 
773  v_[0UL] = v1;
774  v_[1UL] = v2;
775  v_[2UL] = v3;
776  v_[3UL] = v4;
777  v_[4UL] = v5;
778 
779  for( size_t i=N; i<NN; ++i )
780  v_[i] = Type();
781 }
782 //*************************************************************************************************
783 
784 
785 //*************************************************************************************************
801 template< typename Type // Data type of the vector
802  , size_t N // Number of elements
803  , bool TF > // Transpose flag
804 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2, const Type& v3,
805  const Type& v4, const Type& v5, const Type& v6 )
806  : v_() // The statically allocated vector elements
807 {
808  BLAZE_STATIC_ASSERT( N == 6UL );
810 
811  v_[0UL] = v1;
812  v_[1UL] = v2;
813  v_[2UL] = v3;
814  v_[3UL] = v4;
815  v_[4UL] = v5;
816  v_[5UL] = v6;
817 
818  for( size_t i=N; i<NN; ++i )
819  v_[i] = Type();
820 }
821 //*************************************************************************************************
822 
823 
824 
825 
826 //=================================================================================================
827 //
828 // DATA ACCESS FUNCTIONS
829 //
830 //=================================================================================================
831 
832 //*************************************************************************************************
840 template< typename Type // Data type of the vector
841  , size_t N // Number of elements
842  , bool TF > // Transpose flag
845 {
846  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
847  return v_[index];
848 }
849 //*************************************************************************************************
850 
851 
852 //*************************************************************************************************
860 template< typename Type // Data type of the vector
861  , size_t N // Number of elements
862  , bool TF > // Transpose flag
865 {
866  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
867  return v_[index];
868 }
869 //*************************************************************************************************
870 
871 
872 //*************************************************************************************************
879 template< typename Type // Data type of the vector
880  , size_t N // Number of elements
881  , bool TF > // Transpose flag
883 {
884  return v_;
885 }
886 //*************************************************************************************************
887 
888 
889 //*************************************************************************************************
896 template< typename Type // Data type of the vector
897  , size_t N // Number of elements
898  , bool TF > // Transpose flag
900 {
901  return v_;
902 }
903 //*************************************************************************************************
904 
905 
906 //*************************************************************************************************
911 template< typename Type // Data type of the vector
912  , size_t N // Number of elements
913  , bool TF > // Transpose flag
915 {
916  return Iterator( v_ );
917 }
918 //*************************************************************************************************
919 
920 
921 //*************************************************************************************************
926 template< typename Type // Data type of the vector
927  , size_t N // Number of elements
928  , bool TF > // Transpose flag
930 {
931  return ConstIterator( v_ );
932 }
933 //*************************************************************************************************
934 
935 
936 //*************************************************************************************************
941 template< typename Type // Data type of the vector
942  , size_t N // Number of elements
943  , bool TF > // Transpose flag
945 {
946  return ConstIterator( v_ );
947 }
948 //*************************************************************************************************
949 
950 
951 //*************************************************************************************************
956 template< typename Type // Data type of the vector
957  , size_t N // Number of elements
958  , bool TF > // Transpose flag
960 {
961  return Iterator( v_ + N );
962 }
963 //*************************************************************************************************
964 
965 
966 //*************************************************************************************************
971 template< typename Type // Data type of the vector
972  , size_t N // Number of elements
973  , bool TF > // Transpose flag
975 {
976  return ConstIterator( v_ + N );
977 }
978 //*************************************************************************************************
979 
980 
981 //*************************************************************************************************
986 template< typename Type // Data type of the vector
987  , size_t N // Number of elements
988  , bool TF > // Transpose flag
990 {
991  return ConstIterator( v_ + N );
992 }
993 //*************************************************************************************************
994 
995 
996 
997 
998 //=================================================================================================
999 //
1000 // ASSIGNMENT OPERATORS
1001 //
1002 //=================================================================================================
1003 
1004 //*************************************************************************************************
1021 template< typename Type // Data type of the vector
1022  , size_t N // Number of elements
1023  , bool TF > // Transpose flag
1024 template< typename Other > // Data type of the initialization array
1026 {
1027  for( size_t i=0UL; i<N; ++i )
1028  v_[i] = array[i];
1029  return *this;
1030 }
1031 //*************************************************************************************************
1032 
1033 
1034 //*************************************************************************************************
1040 template< typename Type // Data type of the vector
1041  , size_t N // Number of elements
1042  , bool TF > // Transpose flag
1044 {
1045  for( size_t i=0UL; i<N; ++i )
1046  v_[i] = rhs;
1047  return *this;
1048 }
1049 //*************************************************************************************************
1050 
1051 
1052 //*************************************************************************************************
1060 template< typename Type // Data type of the vector
1061  , size_t N // Number of elements
1062  , bool TF > // Transpose flag
1064 {
1065  using blaze::assign;
1066 
1067  assign( *this, ~rhs );
1068  return *this;
1069 }
1070 //*************************************************************************************************
1071 
1072 
1073 //*************************************************************************************************
1079 template< typename Type // Data type of the vector
1080  , size_t N // Number of elements
1081  , bool TF > // Transpose flag
1082 template< typename Other > // Data type of the foreign vector
1084 {
1085  using blaze::assign;
1086 
1087  assign( *this, ~rhs );
1088  return *this;
1089 }
1090 //*************************************************************************************************
1091 
1092 
1093 //*************************************************************************************************
1103 template< typename Type // Data type of the vector
1104  , size_t N // Number of elements
1105  , bool TF > // Transpose flag
1106 template< typename VT > // Type of the right-hand side vector
1108 {
1109  using blaze::assign;
1110 
1111  if( (~rhs).size() != N )
1112  throw std::invalid_argument( "Invalid assignment to static vector" );
1113 
1114  if( (~rhs).canAlias( this ) ) {
1115  StaticVector tmp( ~rhs );
1116  swap( tmp );
1117  }
1118  else {
1120  reset();
1121  assign( *this, ~rhs );
1122  }
1123 
1124  return *this;
1125 }
1126 //*************************************************************************************************
1127 
1128 
1129 //*************************************************************************************************
1139 template< typename Type // Data type of the vector
1140  , size_t N // Number of elements
1141  , bool TF > // Transpose flag
1142 template< typename VT > // Type of the right-hand side vector
1144 {
1145  using blaze::addAssign;
1146 
1147  if( (~rhs).size() != N )
1148  throw std::invalid_argument( "Vector sizes do not match" );
1149 
1150  if( (~rhs).canAlias( this ) ) {
1151  StaticVector tmp( ~rhs );
1152  addAssign( *this, tmp );
1153  }
1154  else {
1155  addAssign( *this, ~rhs );
1156  }
1157 
1158  return *this;
1159 }
1160 //*************************************************************************************************
1161 
1162 
1163 //*************************************************************************************************
1173 template< typename Type // Data type of the vector
1174  , size_t N // Number of elements
1175  , bool TF > // Transpose flag
1176 template< typename VT > // Type of the right-hand side vector
1178 {
1179  using blaze::subAssign;
1180 
1181  if( (~rhs).size() != N )
1182  throw std::invalid_argument( "Vector sizes do not match" );
1183 
1184  if( (~rhs).canAlias( this ) ) {
1185  StaticVector tmp( ~rhs );
1186  subAssign( *this, tmp );
1187  }
1188  else {
1189  subAssign( *this, ~rhs );
1190  }
1191 
1192  return *this;
1193 }
1194 //*************************************************************************************************
1195 
1196 
1197 //*************************************************************************************************
1208 template< typename Type // Data type of the vector
1209  , size_t N // Number of elements
1210  , bool TF > // Transpose flag
1211 template< typename VT > // Type of the right-hand side vector
1213 {
1214  using blaze::multAssign;
1215 
1216  if( (~rhs).size() != N )
1217  throw std::invalid_argument( "Vector sizes do not match" );
1218 
1219  if( (~rhs).canAlias( this ) || IsSparseVector<VT>::value ) {
1220  StaticVector tmp( *this * (~rhs) );
1221  this->operator=( tmp );
1222  }
1223  else {
1224  multAssign( *this, ~rhs );
1225  }
1226 
1227  return *this;
1228 }
1229 //*************************************************************************************************
1230 
1231 
1232 //*************************************************************************************************
1239 template< typename Type // Data type of the vector
1240  , size_t N // Number of elements
1241  , bool TF > // Transpose flag
1242 template< typename Other > // Data type of the right-hand side scalar
1243 inline typename EnableIf< IsNumeric<Other>, StaticVector<Type,N,TF> >::Type&
1245 {
1246  using blaze::assign;
1247 
1248  assign( *this, (*this) * rhs );
1249  return *this;
1250 }
1251 //*************************************************************************************************
1252 
1253 
1254 //*************************************************************************************************
1263 template< typename Type // Data type of the vector
1264  , size_t N // Number of elements
1265  , bool TF > // Transpose flag
1266 template< typename Other > // Data type of the right-hand side scalar
1267 inline typename EnableIf< IsNumeric<Other>, StaticVector<Type,N,TF> >::Type&
1269 {
1270  using blaze::assign;
1271 
1272  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1273 
1274  assign( *this, (*this) / rhs );
1275  return *this;
1276 }
1277 //*************************************************************************************************
1278 
1279 
1280 
1281 
1282 //=================================================================================================
1283 //
1284 // UTILITY FUNCTIONS
1285 //
1286 //=================================================================================================
1287 
1288 //*************************************************************************************************
1293 template< typename Type // Data type of the vector
1294  , size_t N // Number of elements
1295  , bool TF > // Transpose flag
1296 inline size_t StaticVector<Type,N,TF>::size() const
1297 {
1298  return N;
1299 }
1300 //*************************************************************************************************
1301 
1302 
1303 //*************************************************************************************************
1308 template< typename Type // Data type of the vector
1309  , size_t N // Number of elements
1310  , bool TF > // Transpose flag
1312 {
1313  return NN;
1314 }
1315 //*************************************************************************************************
1316 
1317 
1318 //*************************************************************************************************
1326 template< typename Type // Data type of the vector
1327  , size_t N // Number of elements
1328  , bool TF > // Transpose flag
1330 {
1331  size_t nonzeros( 0 );
1332 
1333  for( size_t i=0UL; i<N; ++i ) {
1334  if( !isDefault( v_[i] ) )
1335  ++nonzeros;
1336  }
1337 
1338  return nonzeros;
1339 }
1340 //*************************************************************************************************
1341 
1342 
1343 //*************************************************************************************************
1348 template< typename Type // Data type of the vector
1349  , size_t N // Number of elements
1350  , bool TF > // Transpose flag
1352 {
1353  using blaze::clear;
1354  for( size_t i=0UL; i<N; ++i )
1355  clear( v_[i] );
1356 }
1357 //*************************************************************************************************
1358 
1359 
1360 //*************************************************************************************************
1366 template< typename Type // Data type of the vector
1367  , size_t N // Number of elements
1368  , bool TF > // Transpose flag
1369 template< typename Other > // Data type of the scalar value
1371 {
1372  for( size_t i=0; i<N; ++i )
1373  v_[i] *= scalar;
1374  return *this;
1375 }
1376 //*************************************************************************************************
1377 
1378 
1379 //*************************************************************************************************
1386 template< typename Type // Data type of the vector
1387  , size_t N // Number of elements
1388  , bool TF > // Transpose flag
1389 inline void StaticVector<Type,N,TF>::swap( StaticVector& v ) /* throw() */
1390 {
1391  using std::swap;
1392 
1393  for( size_t i=0UL; i<N; ++i )
1394  swap( v_[i], v.v_[i] );
1395 }
1396 //*************************************************************************************************
1397 
1398 
1399 
1400 
1401 //=================================================================================================
1402 //
1403 // MEMORY FUNCTIONS
1404 //
1405 //=================================================================================================
1406 
1407 //*************************************************************************************************
1417 template< typename Type // Data type of the vector
1418  , size_t N // Number of elements
1419  , bool TF > // Transpose flag
1420 inline void* StaticVector<Type,N,TF>::operator new( std::size_t size )
1421 {
1423 
1424  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1425 
1426  return allocate<StaticVector>( 1UL );
1427 }
1428 //*************************************************************************************************
1429 
1430 
1431 //*************************************************************************************************
1441 template< typename Type // Data type of the vector
1442  , size_t N // Number of elements
1443  , bool TF > // Transpose flag
1444 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size )
1445 {
1446  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1447  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1448 
1449  return allocate<StaticVector>( size/sizeof(StaticVector) );
1450 }
1451 //*************************************************************************************************
1452 
1453 
1454 //*************************************************************************************************
1464 template< typename Type // Data type of the vector
1465  , size_t N // Number of elements
1466  , bool TF > // Transpose flag
1467 inline void* StaticVector<Type,N,TF>::operator new( std::size_t size, const std::nothrow_t& )
1468 {
1469  UNUSED_PARAMETER( size );
1470 
1471  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1472 
1473  return allocate<StaticVector>( 1UL );
1474 }
1475 //*************************************************************************************************
1476 
1477 
1478 //*************************************************************************************************
1488 template< typename Type // Data type of the vector
1489  , size_t N // Number of elements
1490  , bool TF > // Transpose flag
1491 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size, const std::nothrow_t& )
1492 {
1493  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1494  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1495 
1496  return allocate<StaticVector>( size/sizeof(StaticVector) );
1497 }
1498 //*************************************************************************************************
1499 
1500 
1501 //*************************************************************************************************
1507 template< typename Type // Data type of the vector
1508  , size_t N // Number of elements
1509  , bool TF > // Transpose flag
1510 inline void StaticVector<Type,N,TF>::operator delete( void* ptr )
1511 {
1512  deallocate( static_cast<StaticVector*>( ptr ) );
1513 }
1514 //*************************************************************************************************
1515 
1516 
1517 //*************************************************************************************************
1523 template< typename Type // Data type of the vector
1524  , size_t N // Number of elements
1525  , bool TF > // Transpose flag
1526 inline void StaticVector<Type,N,TF>::operator delete[]( void* ptr )
1527 {
1528  deallocate( static_cast<StaticVector*>( ptr ) );
1529 }
1530 //*************************************************************************************************
1531 
1532 
1533 //*************************************************************************************************
1539 template< typename Type // Data type of the vector
1540  , size_t N // Number of elements
1541  , bool TF > // Transpose flag
1542 inline void StaticVector<Type,N,TF>::operator delete( void* ptr, const std::nothrow_t& )
1543 {
1544  deallocate( static_cast<StaticVector*>( ptr ) );
1545 }
1546 //*************************************************************************************************
1547 
1548 
1549 //*************************************************************************************************
1555 template< typename Type // Data type of the vector
1556  , size_t N // Number of elements
1557  , bool TF > // Transpose flag
1558 inline void StaticVector<Type,N,TF>::operator delete[]( void* ptr, const std::nothrow_t& )
1559 {
1560  deallocate( static_cast<StaticVector*>( ptr ) );
1561 }
1562 //*************************************************************************************************
1563 
1564 
1565 
1566 
1567 //=================================================================================================
1568 //
1569 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1570 //
1571 //=================================================================================================
1572 
1573 //*************************************************************************************************
1583 template< typename Type // Data type of the vector
1584  , size_t N // Number of elements
1585  , bool TF > // Transpose flag
1586 template< typename Other > // Data type of the foreign expression
1587 inline bool StaticVector<Type,N,TF>::canAlias( const Other* alias ) const
1588 {
1589  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1590 }
1591 //*************************************************************************************************
1592 
1593 
1594 //*************************************************************************************************
1604 template< typename Type // Data type of the vector
1605  , size_t N // Number of elements
1606  , bool TF > // Transpose flag
1607 template< typename Other > // Data type of the foreign expression
1608 inline bool StaticVector<Type,N,TF>::isAliased( const Other* alias ) const
1609 {
1610  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1611 }
1612 //*************************************************************************************************
1613 
1614 
1615 //*************************************************************************************************
1624 template< typename Type // Data type of the vector
1625  , size_t N // Number of elements
1626  , bool TF > // Transpose flag
1628 {
1629  return true;
1630 }
1631 //*************************************************************************************************
1632 
1633 
1634 //*************************************************************************************************
1647 template< typename Type // Data type of the vector
1648  , size_t N // Number of elements
1649  , bool TF > // Transpose flag
1651  StaticVector<Type,N,TF>::load( size_t index ) const
1652 {
1653  using blaze::load;
1654 
1656 
1657  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1658  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1659  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
1660 
1661  return load( &v_[index] );
1662 }
1663 //*************************************************************************************************
1664 
1665 
1666 //*************************************************************************************************
1679 template< typename Type // Data type of the vector
1680  , size_t N // Number of elements
1681  , bool TF > // Transpose flag
1683  StaticVector<Type,N,TF>::loadu( size_t index ) const
1684 {
1685  using blaze::loadu;
1686 
1688 
1689  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1690  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1691 
1692  return loadu( &v_[index] );
1693 }
1694 //*************************************************************************************************
1695 
1696 
1697 //*************************************************************************************************
1711 template< typename Type // Data type of the vector
1712  , size_t N // Number of elements
1713  , bool TF > // Transpose flag
1715  StaticVector<Type,N,TF>::store( size_t index, const IntrinsicType& value )
1716 {
1717  using blaze::store;
1718 
1720 
1721  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1722  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1723  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
1724 
1725  store( &v_[index], value );
1726 }
1727 //*************************************************************************************************
1728 
1729 
1730 //*************************************************************************************************
1744 template< typename Type // Data type of the vector
1745  , size_t N // Number of elements
1746  , bool TF > // Transpose flag
1748  StaticVector<Type,N,TF>::storeu( size_t index, const IntrinsicType& value )
1749 {
1750  using blaze::storeu;
1751 
1753 
1754  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1755  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN, "Invalid vector access index" );
1756 
1757  storeu( &v_[index], value );
1758 }
1759 //*************************************************************************************************
1760 
1761 
1762 //*************************************************************************************************
1776 template< typename Type // Data type of the vector
1777  , size_t N // Number of elements
1778  , bool TF > // Transpose flag
1780  StaticVector<Type,N,TF>::stream( size_t index, const IntrinsicType& value )
1781 {
1782  using blaze::stream;
1783 
1785 
1786  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1787  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1788  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
1789 
1790  stream( &v_[index], value );
1791 }
1792 //*************************************************************************************************
1793 
1794 
1795 //*************************************************************************************************
1806 template< typename Type // Data type of the vector
1807  , size_t N // Number of elements
1808  , bool TF > // Transpose flag
1809 template< typename VT > // Type of the right-hand side dense vector
1810 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1812 {
1813  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1814 
1815  for( size_t i=0UL; i<N; ++i )
1816  v_[i] = (~rhs)[i];
1817 }
1818 //*************************************************************************************************
1819 
1820 
1821 //*************************************************************************************************
1832 template< typename Type // Data type of the vector
1833  , size_t N // Number of elements
1834  , bool TF > // Transpose flag
1835 template< typename VT > // Type of the right-hand side dense vector
1836 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1838 {
1839  using blaze::store;
1840 
1841  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1842 
1844 
1845  for( size_t i=0UL; i<N; i+=IT::size ) {
1846  store( v_+i, (~rhs).load(i) );
1847  }
1848 }
1849 //*************************************************************************************************
1850 
1851 
1852 //*************************************************************************************************
1863 template< typename Type // Data type of the vector
1864  , size_t N // Number of elements
1865  , bool TF > // Transpose flag
1866 template< typename VT > // Type of the right-hand side sparse vector
1868 {
1869  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1870 
1871  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1872  v_[element->index()] = element->value();
1873 }
1874 //*************************************************************************************************
1875 
1876 
1877 //*************************************************************************************************
1888 template< typename Type // Data type of the vector
1889  , size_t N // Number of elements
1890  , bool TF > // Transpose flag
1891 template< typename VT > // Type of the right-hand side dense vector
1892 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1894 {
1895  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1896 
1897  for( size_t i=0UL; i<N; ++i )
1898  v_[i] += (~rhs)[i];
1899 }
1900 //*************************************************************************************************
1901 
1902 
1903 //*************************************************************************************************
1914 template< typename Type // Data type of the vector
1915  , size_t N // Number of elements
1916  , bool TF > // Transpose flag
1917 template< typename VT > // Type of the right-hand side dense vector
1918 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1920 {
1921  using blaze::load;
1922  using blaze::store;
1923 
1924  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1925 
1927 
1928  for( size_t i=0UL; i<N; i+=IT::size ) {
1929  store( v_+i, load( v_+i ) + (~rhs).load(i) );
1930  }
1931 }
1932 //*************************************************************************************************
1933 
1934 
1935 //*************************************************************************************************
1946 template< typename Type // Data type of the vector
1947  , size_t N // Number of elements
1948  , bool TF > // Transpose flag
1949 template< typename VT > // Type of the right-hand side sparse vector
1951 {
1952  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1953 
1954  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1955  v_[element->index()] += element->value();
1956 }
1957 //*************************************************************************************************
1958 
1959 
1960 //*************************************************************************************************
1971 template< typename Type // Data type of the vector
1972  , size_t N // Number of elements
1973  , bool TF > // Transpose flag
1974 template< typename VT > // Type of the right-hand side dense vector
1975 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1977 {
1978  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1979 
1980  for( size_t i=0UL; i<N; ++i )
1981  v_[i] -= (~rhs)[i];
1982 }
1983 //*************************************************************************************************
1984 
1985 
1986 //*************************************************************************************************
1997 template< typename Type // Data type of the vector
1998  , size_t N // Number of elements
1999  , bool TF > // Transpose flag
2000 template< typename VT > // Type of the right-hand side dense vector
2001 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
2003 {
2004  using blaze::load;
2005  using blaze::store;
2006 
2007  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2008 
2010 
2011  for( size_t i=0UL; i<N; i+=IT::size ) {
2012  store( v_+i, load( v_+i ) - (~rhs).load(i) );
2013  }
2014 }
2015 //*************************************************************************************************
2016 
2017 
2018 //*************************************************************************************************
2029 template< typename Type // Data type of the vector
2030  , size_t N // Number of elements
2031  , bool TF > // Transpose flag
2032 template< typename VT > // Type of the right-hand side sparse vector
2034 {
2035  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2036 
2037  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2038  v_[element->index()] -= element->value();
2039 }
2040 //*************************************************************************************************
2041 
2042 
2043 //*************************************************************************************************
2054 template< typename Type // Data type of the vector
2055  , size_t N // Number of elements
2056  , bool TF > // Transpose flag
2057 template< typename VT > // Type of the right-hand side dense vector
2058 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
2060 {
2061  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2062 
2063  for( size_t i=0UL; i<N; ++i )
2064  v_[i] *= (~rhs)[i];
2065 }
2066 //*************************************************************************************************
2067 
2068 
2069 //*************************************************************************************************
2080 template< typename Type // Data type of the vector
2081  , size_t N // Number of elements
2082  , bool TF > // Transpose flag
2083 template< typename VT > // Type of the right-hand side dense vector
2084 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
2086 {
2087  using blaze::load;
2088  using blaze::store;
2089 
2090  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2091 
2093 
2094  for( size_t i=0UL; i<N; i+=IT::size ) {
2095  store( v_+i, load( v_+i ) * (~rhs).load(i) );
2096  }
2097 }
2098 //*************************************************************************************************
2099 
2100 
2101 //*************************************************************************************************
2112 template< typename Type // Data type of the vector
2113  , size_t N // Number of elements
2114  , bool TF > // Transpose flag
2115 template< typename VT > // Type of the right-hand side sparse vector
2117 {
2118  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2119 
2120  const StaticVector tmp( serial( *this ) );
2121 
2122  reset();
2123 
2124  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2125  v_[element->index()] = tmp[element->index()] * element->value();
2126 }
2127 //*************************************************************************************************
2128 
2129 
2130 
2131 
2132 
2133 
2134 
2135 
2136 //=================================================================================================
2137 //
2138 // UNDEFINED CLASS TEMPLATE SPECIALIZATION
2139 //
2140 //=================================================================================================
2141 
2142 //*************************************************************************************************
2150 template< typename Type // Data type of the vector
2151  , bool TF > // Transpose flag
2152 class StaticVector<Type,0UL,TF>;
2154 //*************************************************************************************************
2155 
2156 
2157 
2158 
2159 
2160 
2161 
2162 
2163 //=================================================================================================
2164 //
2165 // STATICVECTOR OPERATORS
2166 //
2167 //=================================================================================================
2168 
2169 //*************************************************************************************************
2172 template< typename Type, size_t N, bool TF >
2173 inline void reset( StaticVector<Type,N,TF>& v );
2174 
2175 template< typename Type, size_t N, bool TF >
2176 inline void clear( StaticVector<Type,N,TF>& v );
2177 
2178 template< typename Type, size_t N, bool TF >
2179 inline bool isDefault( const StaticVector<Type,N,TF>& v );
2180 
2181 template< typename Type, bool TF >
2183 
2184 template< typename Type, bool TF >
2186 
2187 template< typename Type, size_t N, bool TF >
2188 inline void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) /* throw() */;
2189 
2190 template< typename Type, size_t N, bool TF >
2191 inline void move( StaticVector<Type,N,TF>& dst, StaticVector<Type,N,TF>& src ) /* throw() */;
2193 //*************************************************************************************************
2194 
2195 
2196 //*************************************************************************************************
2203 template< typename Type // Data type of the vector
2204  , size_t N // Number of elements
2205  , bool TF > // Transpose flag
2207 {
2208  v.reset();
2209 }
2210 //*************************************************************************************************
2211 
2212 
2213 //*************************************************************************************************
2222 template< typename Type // Data type of the vector
2223  , size_t N // Number of elements
2224  , bool TF > // Transpose flag
2226 {
2227  v.reset();
2228 }
2229 //*************************************************************************************************
2230 
2231 
2232 //*************************************************************************************************
2250 template< typename Type // Data type of the vector
2251  , size_t N // Number of elements
2252  , bool TF > // Transpose flag
2253 inline bool isDefault( const StaticVector<Type,N,TF>& v )
2254 {
2255  for( size_t i=0UL; i<N; ++i )
2256  if( !isDefault( v[i] ) ) return false;
2257  return true;
2258 }
2259 //*************************************************************************************************
2260 
2261 
2262 //*************************************************************************************************
2273 template< typename Type // Data type of the vector
2274  , bool TF > // Transpose flag
2276 {
2277  return StaticVector<Type,2UL,TF>( -v[1UL], v[0UL] );
2278 }
2279 //*************************************************************************************************
2280 
2281 
2282 //*************************************************************************************************
2290 template< typename Type // Data type of the vector
2291  , bool TF > // Transpose flag
2293 {
2294  if( v[0] != Type() || v[1] != Type() )
2295  return StaticVector<Type,3UL,TF>( v[1UL], -v[0UL], Type() );
2296  else
2297  return StaticVector<Type,3UL,TF>( Type(), v[2UL], -v[1UL] );
2298 }
2299 //*************************************************************************************************
2300 
2301 
2302 //*************************************************************************************************
2311 template< typename Type // Data type of the vector
2312  , size_t N // Number of elements
2313  , bool TF > // Transpose flag
2314 inline void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) /* throw() */
2315 {
2316  a.swap( b );
2317 }
2318 //*************************************************************************************************
2319 
2320 
2321 //*************************************************************************************************
2330 template< typename Type // Data type of the vector
2331  , size_t N // Number of elements
2332  , bool TF > // Transpose flag
2333 inline void move( StaticVector<Type,N,TF>& dst, StaticVector<Type,N,TF>& src ) /* throw() */
2334 {
2335  dst = src;
2336 }
2337 //*************************************************************************************************
2338 
2339 
2340 
2341 
2342 //=================================================================================================
2343 //
2344 // SIZE SPECIALIZATIONS
2345 //
2346 //=================================================================================================
2347 
2348 //*************************************************************************************************
2350 template< typename T, size_t N, bool TF >
2351 struct Size< StaticVector<T,N,TF> >
2352 {
2353  static const size_t value = N;
2354 };
2356 //*************************************************************************************************
2357 
2358 
2359 
2360 
2361 //=================================================================================================
2362 //
2363 // HASCONSTDATAACCESS SPECIALIZATIONS
2364 //
2365 //=================================================================================================
2366 
2367 //*************************************************************************************************
2369 template< typename T, size_t N, bool TF >
2370 struct HasConstDataAccess< StaticVector<T,N,TF> > : public TrueType
2371 {
2372  enum { value = 1 };
2373  typedef TrueType Type;
2374 };
2376 //*************************************************************************************************
2377 
2378 
2379 
2380 
2381 //=================================================================================================
2382 //
2383 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2384 //
2385 //=================================================================================================
2386 
2387 //*************************************************************************************************
2389 template< typename T, size_t N, bool TF >
2390 struct HasMutableDataAccess< StaticVector<T,N,TF> > : public TrueType
2391 {
2392  enum { value = 1 };
2393  typedef TrueType Type;
2394 };
2396 //*************************************************************************************************
2397 
2398 
2399 
2400 
2401 //=================================================================================================
2402 //
2403 // ADDTRAIT SPECIALIZATIONS
2404 //
2405 //=================================================================================================
2406 
2407 //*************************************************************************************************
2409 template< typename T1, size_t N, bool TF, typename T2 >
2410 struct AddTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2411 {
2412  typedef StaticVector< typename AddTrait<T1,T2>::Type, N, TF > Type;
2413 };
2415 //*************************************************************************************************
2416 
2417 
2418 
2419 
2420 //=================================================================================================
2421 //
2422 // SUBTRAIT SPECIALIZATIONS
2423 //
2424 //=================================================================================================
2425 
2426 //*************************************************************************************************
2428 template< typename T1, size_t N, bool TF, typename T2 >
2429 struct SubTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2430 {
2431  typedef StaticVector< typename SubTrait<T1,T2>::Type, N, TF > Type;
2432 };
2434 //*************************************************************************************************
2435 
2436 
2437 
2438 
2439 //=================================================================================================
2440 //
2441 // MULTTRAIT SPECIALIZATIONS
2442 //
2443 //=================================================================================================
2444 
2445 //*************************************************************************************************
2447 template< typename T1, size_t N, bool TF, typename T2 >
2448 struct MultTrait< StaticVector<T1,N,TF>, T2 >
2449 {
2450  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2452 };
2453 
2454 template< typename T1, typename T2, size_t N, bool TF >
2455 struct MultTrait< T1, StaticVector<T2,N,TF> >
2456 {
2457  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2459 };
2460 
2461 template< typename T1, size_t N, bool TF, typename T2 >
2462 struct MultTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2463 {
2464  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2465 };
2466 
2467 template< typename T1, size_t M, typename T2, size_t N >
2468 struct MultTrait< StaticVector<T1,M,false>, StaticVector<T2,N,true> >
2469 {
2470  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, false > Type;
2471 };
2472 
2473 template< typename T1, size_t N, typename T2 >
2474 struct MultTrait< StaticVector<T1,N,true>, StaticVector<T2,N,false> >
2475 {
2476  typedef typename MultTrait<T1,T2>::Type Type;
2477 };
2479 //*************************************************************************************************
2480 
2481 
2482 
2483 
2484 //=================================================================================================
2485 //
2486 // CROSSTRAIT SPECIALIZATIONS
2487 //
2488 //=================================================================================================
2489 
2490 //*************************************************************************************************
2492 template< typename T1, typename T2 >
2493 struct CrossTrait< StaticVector<T1,3UL,false>, StaticVector<T2,3UL,false> >
2494 {
2495  private:
2496  typedef typename MultTrait<T1,T2>::Type T;
2497 
2498  public:
2499  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2500 };
2502 //*************************************************************************************************
2503 
2504 
2505 
2506 
2507 //=================================================================================================
2508 //
2509 // DIVTRAIT SPECIALIZATIONS
2510 //
2511 //=================================================================================================
2512 
2513 //*************************************************************************************************
2515 template< typename T1, size_t N, bool TF, typename T2 >
2516 struct DivTrait< StaticVector<T1,N,TF>, T2 >
2517 {
2518  typedef StaticVector< typename DivTrait<T1,T2>::Type, N, TF > Type;
2520 };
2522 //*************************************************************************************************
2523 
2524 
2525 
2526 
2527 //=================================================================================================
2528 //
2529 // MATHTRAIT SPECIALIZATIONS
2530 //
2531 //=================================================================================================
2532 
2533 //*************************************************************************************************
2535 template< typename T1, size_t N, bool TF, typename T2 >
2536 struct MathTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2537 {
2538  typedef StaticVector< typename MathTrait<T1,T2>::HighType, N, TF > HighType;
2539  typedef StaticVector< typename MathTrait<T1,T2>::LowType , N, TF > LowType;
2540 };
2542 //*************************************************************************************************
2543 
2544 
2545 
2546 
2547 //=================================================================================================
2548 //
2549 // SUBVECTORTRAIT SPECIALIZATIONS
2550 //
2551 //=================================================================================================
2552 
2553 //*************************************************************************************************
2555 template< typename T1, size_t N, bool TF >
2556 struct SubvectorTrait< StaticVector<T1,N,TF> >
2557 {
2558  typedef HybridVector<T1,N,TF> Type;
2559 };
2561 //*************************************************************************************************
2562 
2563 } // namespace blaze
2564 
2565 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:108
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:116
const bool defaultTransposeFlag
The default transpose flag for all vectors of the Blaze library.This value specifies the default tran...
Definition: TransposeFlag.h:56
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
Constraint on the data type.
BLAZE_ALWAYS_INLINE void multAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the multiplication assignment of a matrix to a matrix.
Definition: Matrix.h:879
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
Header file for basic type definitions.
Header file for the SparseVector base class.
Type * Pointer
Pointer to a non-constant vector value.
Definition: StaticVector.h:186
Iterator end()
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:959
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:264
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type stream(T *address, const sse_int16_t &value)
Aligned, non-temporal store of a vector of 2-byte integral values.
Definition: Stream.h:76
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:258
BLAZE_ALWAYS_INLINE void store(size_t index, const IntrinsicType &value)
Aligned store of an intrinsic element of the vector.
Definition: StaticVector.h:1715
Header file for the IsSame and IsStrictlySame type traits.
IT::Type IntrinsicType
Intrinsic type of the vector elements.
Definition: StaticVector.h:181
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:821
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the DenseVector base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:116
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:699
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: StaticVector.h:1329
Header file for memory allocation and deallocation functionality.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Constraint on the data type.
Efficient implementation of a fixed-sized vector.The StaticVector class template is the representatio...
Definition: Forward.h:59
bool isAligned() const
Returns whether the vector is properly aligned in memory.
Definition: StaticVector.h:1627
Header file for the DisableIf class template.
size_t capacity() const
Returns the maximum capacity of the vector.
Definition: StaticVector.h:1311
bool canAlias(const Other *alias) const
Returns whether the vector can alias with the given address alias.
Definition: StaticVector.h:1587
void swap(StaticVector &v)
Swapping the contents of two static vectors.
Definition: StaticVector.h:1389
Header file for the multiplication trait.
const StaticVector & CompositeType
Data type for composite expression templates.
Definition: StaticVector.h:183
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type loadu(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loadu.h:76
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: StaticVector.h:189
Header file for nested template disabiguation.
Compile time assertion.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4807
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
#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:116
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type store(T *address, const sse_int16_t &value)
Aligned store of a vector of 2-byte integral values.
Definition: Store.h:80
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
EnableIf< IsBuiltin< T > >::Type deallocate(T *address)
Deallocation of memory for built-in data types.
Definition: Memory.h:226
Header file for the DenseIterator class template.
const Type * ConstPointer
Pointer to a constant vector value.
Definition: StaticVector.h:187
Header file for the subvector trait.
Constraint on the data type.
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:103
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticVector.h:182
void reset()
Reset to the default initial values.
Definition: StaticVector.h:1351
#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:79
ConstIterator cbegin() const
Returns an iterator to the first element of the static vector.
Definition: StaticVector.h:944
Reference operator[](size_t index)
Subscript operator for the direct access to the vector elements.
Definition: StaticVector.h:844
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:195
This ResultType
Result type for expression template evaluations.
Definition: StaticVector.h:178
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:2275
BLAZE_ALWAYS_INLINE IntrinsicType load(size_t index) const
Aligned load of an intrinsic element of the vector.
Definition: StaticVector.h:1651
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:841
Header file for the serial shim.
BLAZE_ALWAYS_INLINE void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the vector.
Definition: StaticVector.h:1780
Header file for the IsVectorizable type trait.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type load(const T *address)
Loads a vector of 2-byte integral values.
Definition: Load.h:79
Header file for the IsNumeric type trait.
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: StaticVector.h:421
Header file for the HasConstDataAccess type trait.
BLAZE_ALWAYS_INLINE void storeu(size_t index, const IntrinsicType &value)
Unaligned store of an intrinsic element of the vector.
Definition: StaticVector.h:1748
Header file for the IsSparseVector type trait.
Type ElementType
Type of the vector elements.
Definition: StaticVector.h:180
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:749
StaticVector()
The default constructor for StaticVector.
Definition: StaticVector.h:460
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the cross product trait.
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
Header file for the division trait.
Constraint on the data type.
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
Iterator begin()
Returns an iterator to the first element of the static vector.
Definition: StaticVector.h:914
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type storeu(T *address, const sse_int16_t &value)
Unaligned store of a vector of 2-byte integral values.
Definition: Storeu.h:77
void move(DynamicMatrix< Type, SO > &dst, DynamicMatrix< Type, SO > &src)
Moving the contents of one dynamic matrix to another.
Definition: DynamicMatrix.h:4934
Header file for the AlignedArray implementation.
BLAZE_ALWAYS_INLINE IntrinsicType loadu(size_t index) const
Unaligned load of an intrinsic element of the vector.
Definition: StaticVector.h:1683
#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:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2510
Header file for the isDefault shim.
StaticVector< Type, N, TF > This
Type of this StaticVector instance.
Definition: StaticVector.h:177
Constraint on the data type.
Header file for the HasMutableDataAccess type trait.
bool isAliased(const Other *alias) const
Returns whether the vector is aliased with the given address alias.
Definition: StaticVector.h:1608
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:200
IntrinsicTrait< Type > IT
Intrinsic trait for the vector element type.
Definition: StaticVector.h:167
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
Header file for all intrinsic functionality.
Header file for the mathematical trait.
StaticVector< ET, N, TF > Other
The type of the other StaticVector.
Definition: StaticVector.h:197
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:151
Header file for the default transpose flag for all vectors of the Blaze library.
StaticVector< Type, N,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: StaticVector.h:179
size_t size() const
Returns the current size/dimension of the vector.
Definition: StaticVector.h:1296
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
ConstIterator cend() const
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:989
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: StaticVector.h:188
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
#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:143
Pointer data()
Low-level data access to the vector elements.
Definition: StaticVector.h:882
System settings for the inline keywords.
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Rebind mechanism to obtain a StaticVector with different data/element type.
Definition: StaticVector.h:196
const Type & ConstReference
Reference to a constant vector value.
Definition: StaticVector.h:185
Type & Reference
Reference to a non-constant vector value.
Definition: StaticVector.h:184
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849