All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
51 #include <blaze/math/shims/Reset.h>
63 #include <blaze/util/Assert.h>
70 #include <blaze/util/DisableIf.h>
71 #include <blaze/util/EnableIf.h>
72 #include <blaze/util/Memory.h>
74 #include <blaze/util/Template.h>
75 #include <blaze/util/Types.h>
79 #include <blaze/util/Unused.h>
80 
81 
82 namespace blaze {
83 
84 //=================================================================================================
85 //
86 // CLASS DEFINITION
87 //
88 //=================================================================================================
89 
90 //*************************************************************************************************
156 template< typename Type // Data type of the vector
157  , size_t N // Number of elements
158  , bool TF = defaultTransposeFlag > // Transpose flag
159 class StaticVector : public DenseVector< StaticVector<Type,N,TF>, TF >
160 {
161  private:
162  //**Type definitions****************************************************************************
164  //**********************************************************************************************
165 
166  //**********************************************************************************************
168  enum { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size };
169  //**********************************************************************************************
170 
171  public:
172  //**Type definitions****************************************************************************
174  typedef This ResultType;
176  typedef Type ElementType;
177  typedef typename IT::Type IntrinsicType;
178  typedef const Type& ReturnType;
179  typedef const StaticVector& CompositeType;
180  typedef Type& Reference;
181  typedef const Type& ConstReference;
182  typedef Type* Pointer;
183  typedef const Type* ConstPointer;
186  //**********************************************************************************************
187 
188  //**Compilation flags***************************************************************************
190 
194  enum { vectorizable = IsVectorizable<Type>::value };
195 
197 
200  enum { smpAssignable = 0 };
201  //**********************************************************************************************
202 
203  //**Constructors********************************************************************************
206  explicit inline StaticVector();
207  explicit inline StaticVector( const Type& init );
208  template< typename Other > explicit inline StaticVector( size_t n, const Other* array );
209 
210  template< typename Other >
211  explicit inline StaticVector( const Other (&array)[N] );
212 
213  inline StaticVector( const StaticVector& v );
214  template< typename Other > inline StaticVector( const StaticVector<Other,N,TF>& v );
215  template< typename VT > inline StaticVector( const Vector<VT,TF>& v );
216 
217  inline StaticVector( const Type& v1, const Type& v2 );
218  inline StaticVector( const Type& v1, const Type& v2, const Type& v3 );
219  inline StaticVector( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
220  inline StaticVector( const Type& v1, const Type& v2, const Type& v3,
221  const Type& v4, const Type& v5 );
222  inline StaticVector( const Type& v1, const Type& v2, const Type& v3,
223  const Type& v4, const Type& v5, const Type& v6 );
225  //**********************************************************************************************
226 
227  //**Destructor**********************************************************************************
228  // No explicitly declared destructor.
229  //**********************************************************************************************
230 
231  //**Data access functions***********************************************************************
234  inline Reference operator[]( size_t index );
235  inline ConstReference operator[]( size_t index ) const;
236  inline Pointer data ();
237  inline ConstPointer data () const;
238  inline Iterator begin ();
239  inline ConstIterator begin () const;
240  inline ConstIterator cbegin() const;
241  inline Iterator end ();
242  inline ConstIterator end () const;
243  inline ConstIterator cend () const;
245  //**********************************************************************************************
246 
247  //**Assignment operators************************************************************************
250  template< typename Other >
251  inline StaticVector& operator=( const Other (&array)[N] );
252 
253  inline StaticVector& operator= ( const Type& rhs );
254  inline StaticVector& operator= ( const StaticVector& rhs );
255  template< typename Other > inline StaticVector& operator= ( const StaticVector<Other,N,TF>& rhs );
256  template< typename VT > inline StaticVector& operator= ( const Vector<VT,TF>& rhs );
257  template< typename VT > inline StaticVector& operator+=( const Vector<VT,TF>& rhs );
258  template< typename VT > inline StaticVector& operator-=( const Vector<VT,TF>& rhs );
259  template< typename VT > inline StaticVector& operator*=( const Vector<VT,TF>& rhs );
260 
261  template< typename Other >
262  inline typename EnableIf< IsNumeric<Other>, StaticVector >::Type&
263  operator*=( Other rhs );
264 
265  template< typename Other >
266  inline typename EnableIf< IsNumeric<Other>, StaticVector >::Type&
267  operator/=( Other rhs );
269  //**********************************************************************************************
270 
271  //**Utility functions***************************************************************************
274  inline size_t size() const;
275  inline size_t capacity() const;
276  inline size_t nonZeros() const;
277  inline void reset();
278  template< typename Other > inline StaticVector& scale( Other scalar );
279  inline void swap( StaticVector& v ) /* throw() */;
281  //**********************************************************************************************
282 
283  //**Memory functions****************************************************************************
286  static inline void* operator new ( std::size_t size );
287  static inline void* operator new[]( std::size_t size );
288  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
289  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
290 
291  static inline void operator delete ( void* ptr );
292  static inline void operator delete[]( void* ptr );
293  static inline void operator delete ( void* ptr, const std::nothrow_t& );
294  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
296  //**********************************************************************************************
297 
298  private:
299  //**********************************************************************************************
301  template< typename VT >
303  struct VectorizedAssign {
304  enum { value = vectorizable && VT::vectorizable &&
305  IsSame<Type,typename VT::ElementType>::value };
306  };
308  //**********************************************************************************************
309 
310  //**********************************************************************************************
312  template< typename VT >
314  struct VectorizedAddAssign {
315  enum { value = vectorizable && VT::vectorizable &&
316  IsSame<Type,typename VT::ElementType>::value &&
317  IntrinsicTrait<Type>::addition };
318  };
320  //**********************************************************************************************
321 
322  //**********************************************************************************************
324  template< typename VT >
326  struct VectorizedSubAssign {
327  enum { value = vectorizable && VT::vectorizable &&
328  IsSame<Type,typename VT::ElementType>::value &&
329  IntrinsicTrait<Type>::subtraction };
330  };
332  //**********************************************************************************************
333 
334  //**********************************************************************************************
336  template< typename VT >
338  struct VectorizedMultAssign {
339  enum { value = vectorizable && VT::vectorizable &&
340  IsSame<Type,typename VT::ElementType>::value &&
341  IntrinsicTrait<Type>::multiplication };
342  };
344  //**********************************************************************************************
345 
346  public:
347  //**Expression template evaluation functions****************************************************
350  template< typename Other > inline bool canAlias ( const Other* alias ) const;
351  template< typename Other > inline bool isAliased( const Other* alias ) const;
352 
353  inline bool isAligned() const;
354 
355  inline IntrinsicType load ( size_t index ) const;
356  inline IntrinsicType loadu ( size_t index ) const;
357  inline void store ( size_t index, const IntrinsicType& value );
358  inline void storeu( size_t index, const IntrinsicType& value );
359  inline void stream( size_t index, const IntrinsicType& value );
360 
361  template< typename VT >
362  inline typename DisableIf< VectorizedAssign<VT> >::Type
363  assign( const DenseVector<VT,TF>& rhs );
364 
365  template< typename VT >
366  inline typename EnableIf< VectorizedAssign<VT> >::Type
367  assign( const DenseVector<VT,TF>& rhs );
368 
369  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
370 
371  template< typename VT >
372  inline typename DisableIf< VectorizedAddAssign<VT> >::Type
373  addAssign( const DenseVector<VT,TF>& rhs );
374 
375  template< typename VT >
376  inline typename EnableIf< VectorizedAddAssign<VT> >::Type
377  addAssign( const DenseVector<VT,TF>& rhs );
378 
379  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
380 
381  template< typename VT >
382  inline typename DisableIf< VectorizedSubAssign<VT> >::Type
383  subAssign( const DenseVector<VT,TF>& rhs );
384 
385  template< typename VT >
386  inline typename EnableIf< VectorizedSubAssign<VT> >::Type
387  subAssign( const DenseVector<VT,TF>& rhs );
388 
389  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
390 
391  template< typename VT >
392  inline typename DisableIf< VectorizedMultAssign<VT> >::Type
393  multAssign( const DenseVector<VT,TF>& rhs );
394 
395  template< typename VT >
396  inline typename EnableIf< VectorizedMultAssign<VT> >::Type
397  multAssign( const DenseVector<VT,TF>& rhs );
398 
399  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
401  //**********************************************************************************************
402 
403  private:
404  //**Member variables****************************************************************************
408 
414  //**********************************************************************************************
415 
416  //**Compile time checks*************************************************************************
422  BLAZE_STATIC_ASSERT( NN % IT::size == 0UL );
423  BLAZE_STATIC_ASSERT( NN >= N );
425  //**********************************************************************************************
426 };
427 //*************************************************************************************************
428 
429 
430 
431 
432 //=================================================================================================
433 //
434 // CONSTRUCTORS
435 //
436 //=================================================================================================
437 
438 //*************************************************************************************************
443 template< typename Type // Data type of the vector
444  , size_t N // Number of elements
445  , bool TF > // Transpose flag
447  : v_() // The statically allocated vector elements
448 {
450  for( size_t i=0UL; i<NN; ++i )
451  v_[i] = Type();
452  }
453 }
454 //*************************************************************************************************
455 
456 
457 //*************************************************************************************************
462 template< typename Type // Data type of the vector
463  , size_t N // Number of elements
464  , bool TF > // Transpose flag
465 inline StaticVector<Type,N,TF>::StaticVector( const Type& init )
466  : v_() // The statically allocated vector elements
467 {
468  for( size_t i=0UL; i<N; ++i )
469  v_[i] = init;
470 
472  for( size_t i=N; i<NN; ++i )
473  v_[i] = Type();
474  }
475 }
476 //*************************************************************************************************
477 
478 
479 //*************************************************************************************************
501 template< typename Type // Data type of the vector
502  , size_t N // Number of elements
503  , bool TF > // Transpose flag
504 template< typename Other > // Data type of the initialization array
505 inline StaticVector<Type,N,TF>::StaticVector( size_t n, const Other* array )
506  : v_() // The statically allocated vector elements
507 {
508  if( n > N )
509  throw std::invalid_argument( "Invalid setup of static vector" );
510 
511  for( size_t i=0UL; i<n; ++i )
512  v_[i] = array[i];
513 
515  for( size_t i=n; i<NN; ++i )
516  v_[i] = Type();
517  }
518 }
519 //*************************************************************************************************
520 
521 
522 //*************************************************************************************************
538 template< typename Type // Data type of the vector
539  , size_t N // Number of elements
540  , bool TF > // Transpose flag
541 template< typename Other > // Data type of the initialization array
542 inline StaticVector<Type,N,TF>::StaticVector( const Other (&array)[N] )
543  : v_() // The statically allocated vector elements
544 {
545  for( size_t i=0UL; i<N; ++i )
546  v_[i] = array[i];
547 
549  for( size_t i=N; i<NN; ++i )
550  v_[i] = Type();
551  }
552 }
553 //*************************************************************************************************
554 
555 
556 //*************************************************************************************************
563 template< typename Type // Data type of the vector
564  , size_t N // Number of elements
565  , bool TF > // Transpose flag
567  : v_() // The statically allocated vector elements
568 {
569  for( size_t i=0UL; i<NN; ++i )
570  v_[i] = v.v_[i];
571 }
572 //*************************************************************************************************
573 
574 
575 //*************************************************************************************************
580 template< typename Type // Data type of the vector
581  , size_t N // Number of elements
582  , bool TF > // Transpose flag
583 template< typename Other > // Data type of the foreign vector
585  : v_() // The statically allocated vector elements
586 {
587  for( size_t i=0UL; i<N; ++i )
588  v_[i] = v[i];
589 
591  for( size_t i=N; i<NN; ++i )
592  v_[i] = Type();
593  }
594 }
595 //*************************************************************************************************
596 
597 
598 //*************************************************************************************************
608 template< typename Type // Data type of the vector
609  , size_t N // Number of elements
610  , bool TF > // Transpose flag
611 template< typename VT > // Type of the foreign vector
613  : v_() // The statically allocated vector elements
614 {
615  using blaze::assign;
616 
617  if( (~v).size() != N )
618  throw std::invalid_argument( "Invalid setup of static vector" );
619 
620  for( size_t i=( IsSparseVector<VT>::value ? 0UL : N );
621  i<( IsVectorizable<Type>::value ? NN : N ); ++i ) {
622  v_[i] = Type();
623  }
624 
625  assign( *this, ~v );
626 }
627 //*************************************************************************************************
628 
629 
630 //*************************************************************************************************
642 template< typename Type // Data type of the vector
643  , size_t N // Number of elements
644  , bool TF > // Transpose flag
645 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2 )
646  : v_() // The statically allocated vector elements
647 {
648  BLAZE_STATIC_ASSERT( N == 2UL );
649 
650  v_[0] = v1;
651  v_[1] = v2;
652 
654  for( size_t i=N; i<NN; ++i )
655  v_[i] = Type();
656  }
657 }
658 //*************************************************************************************************
659 
660 
661 //*************************************************************************************************
674 template< typename Type // Data type of the vector
675  , size_t N // Number of elements
676  , bool TF > // Transpose flag
677 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2, const Type& v3 )
678  : v_() // The statically allocated vector elements
679 {
680  BLAZE_STATIC_ASSERT( N == 3UL );
681 
682  v_[0] = v1;
683  v_[1] = v2;
684  v_[2] = v3;
685 
687  for( size_t i=N; i<NN; ++i )
688  v_[i] = Type();
689  }
690 }
691 //*************************************************************************************************
692 
693 
694 //*************************************************************************************************
708 template< typename Type // Data type of the vector
709  , size_t N // Number of elements
710  , bool TF > // Transpose flag
711 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2,
712  const Type& v3, const Type& v4 )
713  : v_() // The statically allocated vector elements
714 {
715  BLAZE_STATIC_ASSERT( N == 4UL );
716 
717  v_[0] = v1;
718  v_[1] = v2;
719  v_[2] = v3;
720  v_[3] = v4;
721 
723  for( size_t i=N; i<NN; ++i )
724  v_[i] = Type();
725  }
726 }
727 //*************************************************************************************************
728 
729 
730 //*************************************************************************************************
745 template< typename Type // Data type of the vector
746  , size_t N // Number of elements
747  , bool TF > // Transpose flag
748 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2, const Type& v3,
749  const Type& v4, const Type& v5 )
750  : v_() // The statically allocated vector elements
751 {
752  BLAZE_STATIC_ASSERT( N == 5UL );
753 
754  v_[0] = v1;
755  v_[1] = v2;
756  v_[2] = v3;
757  v_[3] = v4;
758  v_[4] = v5;
759 
761  for( size_t i=N; i<NN; ++i )
762  v_[i] = Type();
763  }
764 }
765 //*************************************************************************************************
766 
767 
768 //*************************************************************************************************
784 template< typename Type // Data type of the vector
785  , size_t N // Number of elements
786  , bool TF > // Transpose flag
787 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2, const Type& v3,
788  const Type& v4, const Type& v5, const Type& v6 )
789  : v_() // The statically allocated vector elements
790 {
791  BLAZE_STATIC_ASSERT( N == 6UL );
792 
793  v_[0] = v1;
794  v_[1] = v2;
795  v_[2] = v3;
796  v_[3] = v4;
797  v_[4] = v5;
798  v_[5] = v6;
799 
801  for( size_t i=N; i<NN; ++i )
802  v_[i] = Type();
803  }
804 }
805 //*************************************************************************************************
806 
807 
808 
809 
810 //=================================================================================================
811 //
812 // DATA ACCESS FUNCTIONS
813 //
814 //=================================================================================================
815 
816 //*************************************************************************************************
824 template< typename Type // Data type of the vector
825  , size_t N // Number of elements
826  , bool TF > // Transpose flag
829 {
830  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
831  return v_[index];
832 }
833 //*************************************************************************************************
834 
835 
836 //*************************************************************************************************
844 template< typename Type // Data type of the vector
845  , size_t N // Number of elements
846  , bool TF > // Transpose flag
849 {
850  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
851  return v_[index];
852 }
853 //*************************************************************************************************
854 
855 
856 //*************************************************************************************************
863 template< typename Type // Data type of the vector
864  , size_t N // Number of elements
865  , bool TF > // Transpose flag
867 {
868  return v_;
869 }
870 //*************************************************************************************************
871 
872 
873 //*************************************************************************************************
880 template< typename Type // Data type of the vector
881  , size_t N // Number of elements
882  , bool TF > // Transpose flag
884 {
885  return v_;
886 }
887 //*************************************************************************************************
888 
889 
890 //*************************************************************************************************
895 template< typename Type // Data type of the vector
896  , size_t N // Number of elements
897  , bool TF > // Transpose flag
899 {
900  return Iterator( v_ );
901 }
902 //*************************************************************************************************
903 
904 
905 //*************************************************************************************************
910 template< typename Type // Data type of the vector
911  , size_t N // Number of elements
912  , bool TF > // Transpose flag
914 {
915  return ConstIterator( v_ );
916 }
917 //*************************************************************************************************
918 
919 
920 //*************************************************************************************************
925 template< typename Type // Data type of the vector
926  , size_t N // Number of elements
927  , bool TF > // Transpose flag
929 {
930  return ConstIterator( v_ );
931 }
932 //*************************************************************************************************
933 
934 
935 //*************************************************************************************************
940 template< typename Type // Data type of the vector
941  , size_t N // Number of elements
942  , bool TF > // Transpose flag
944 {
945  return Iterator( v_ + N );
946 }
947 //*************************************************************************************************
948 
949 
950 //*************************************************************************************************
955 template< typename Type // Data type of the vector
956  , size_t N // Number of elements
957  , bool TF > // Transpose flag
959 {
960  return ConstIterator( v_ + N );
961 }
962 //*************************************************************************************************
963 
964 
965 //*************************************************************************************************
970 template< typename Type // Data type of the vector
971  , size_t N // Number of elements
972  , bool TF > // Transpose flag
974 {
975  return ConstIterator( v_ + N );
976 }
977 //*************************************************************************************************
978 
979 
980 
981 
982 //=================================================================================================
983 //
984 // ASSIGNMENT OPERATORS
985 //
986 //=================================================================================================
987 
988 //*************************************************************************************************
1005 template< typename Type // Data type of the vector
1006  , size_t N // Number of elements
1007  , bool TF > // Transpose flag
1008 template< typename Other > // Data type of the initialization array
1010 {
1011  for( size_t i=0UL; i<N; ++i )
1012  v_[i] = array[i];
1013  return *this;
1014 }
1015 //*************************************************************************************************
1016 
1017 
1018 //*************************************************************************************************
1024 template< typename Type // Data type of the vector
1025  , size_t N // Number of elements
1026  , bool TF > // Transpose flag
1028 {
1029  for( size_t i=0UL; i<N; ++i )
1030  v_[i] = rhs;
1031  return *this;
1032 }
1033 //*************************************************************************************************
1034 
1035 
1036 //*************************************************************************************************
1044 template< typename Type // Data type of the vector
1045  , size_t N // Number of elements
1046  , bool TF > // Transpose flag
1048 {
1049  using blaze::assign;
1050 
1051  assign( *this, ~rhs );
1052  return *this;
1053 }
1054 //*************************************************************************************************
1055 
1056 
1057 //*************************************************************************************************
1063 template< typename Type // Data type of the vector
1064  , size_t N // Number of elements
1065  , bool TF > // Transpose flag
1066 template< typename Other > // Data type of the foreign vector
1068 {
1069  using blaze::assign;
1070 
1071  assign( *this, ~rhs );
1072  return *this;
1073 }
1074 //*************************************************************************************************
1075 
1076 
1077 //*************************************************************************************************
1087 template< typename Type // Data type of the vector
1088  , size_t N // Number of elements
1089  , bool TF > // Transpose flag
1090 template< typename VT > // Type of the right-hand side vector
1092 {
1093  using blaze::assign;
1094 
1095  if( (~rhs).size() != N )
1096  throw std::invalid_argument( "Invalid assignment to static vector" );
1097 
1098  if( (~rhs).canAlias( this ) ) {
1099  StaticVector tmp( ~rhs );
1100  swap( tmp );
1101  }
1102  else {
1104  reset();
1105  assign( *this, ~rhs );
1106  }
1107 
1108  return *this;
1109 }
1110 //*************************************************************************************************
1111 
1112 
1113 //*************************************************************************************************
1123 template< typename Type // Data type of the vector
1124  , size_t N // Number of elements
1125  , bool TF > // Transpose flag
1126 template< typename VT > // Type of the right-hand side vector
1128 {
1129  using blaze::addAssign;
1130 
1131  if( (~rhs).size() != N )
1132  throw std::invalid_argument( "Vector sizes do not match" );
1133 
1134  if( (~rhs).canAlias( this ) ) {
1135  StaticVector tmp( ~rhs );
1136  addAssign( *this, tmp );
1137  }
1138  else {
1139  addAssign( *this, ~rhs );
1140  }
1141 
1142  return *this;
1143 }
1144 //*************************************************************************************************
1145 
1146 
1147 //*************************************************************************************************
1157 template< typename Type // Data type of the vector
1158  , size_t N // Number of elements
1159  , bool TF > // Transpose flag
1160 template< typename VT > // Type of the right-hand side vector
1162 {
1163  using blaze::subAssign;
1164 
1165  if( (~rhs).size() != N )
1166  throw std::invalid_argument( "Vector sizes do not match" );
1167 
1168  if( (~rhs).canAlias( this ) ) {
1169  StaticVector tmp( ~rhs );
1170  subAssign( *this, tmp );
1171  }
1172  else {
1173  subAssign( *this, ~rhs );
1174  }
1175 
1176  return *this;
1177 }
1178 //*************************************************************************************************
1179 
1180 
1181 //*************************************************************************************************
1192 template< typename Type // Data type of the vector
1193  , size_t N // Number of elements
1194  , bool TF > // Transpose flag
1195 template< typename VT > // Type of the right-hand side vector
1197 {
1198  using blaze::multAssign;
1199 
1200  if( (~rhs).size() != N )
1201  throw std::invalid_argument( "Vector sizes do not match" );
1202 
1203  if( (~rhs).canAlias( this ) || IsSparseVector<VT>::value ) {
1204  StaticVector tmp( *this * (~rhs) );
1205  this->operator=( tmp );
1206  }
1207  else {
1208  multAssign( *this, ~rhs );
1209  }
1210 
1211  return *this;
1212 }
1213 //*************************************************************************************************
1214 
1215 
1216 //*************************************************************************************************
1223 template< typename Type // Data type of the vector
1224  , size_t N // Number of elements
1225  , bool TF > // Transpose flag
1226 template< typename Other > // Data type of the right-hand side scalar
1227 inline typename EnableIf< IsNumeric<Other>, StaticVector<Type,N,TF> >::Type&
1229 {
1230  using blaze::assign;
1231 
1232  assign( *this, (*this) * rhs );
1233  return *this;
1234 }
1235 //*************************************************************************************************
1236 
1237 
1238 //*************************************************************************************************
1247 template< typename Type // Data type of the vector
1248  , size_t N // Number of elements
1249  , bool TF > // Transpose flag
1250 template< typename Other > // Data type of the right-hand side scalar
1251 inline typename EnableIf< IsNumeric<Other>, StaticVector<Type,N,TF> >::Type&
1253 {
1254  using blaze::assign;
1255 
1256  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1257 
1258  assign( *this, (*this) / rhs );
1259  return *this;
1260 }
1261 //*************************************************************************************************
1262 
1263 
1264 
1265 
1266 //=================================================================================================
1267 //
1268 // UTILITY FUNCTIONS
1269 //
1270 //=================================================================================================
1271 
1272 //*************************************************************************************************
1277 template< typename Type // Data type of the vector
1278  , size_t N // Number of elements
1279  , bool TF > // Transpose flag
1280 inline size_t StaticVector<Type,N,TF>::size() const
1281 {
1282  return N;
1283 }
1284 //*************************************************************************************************
1285 
1286 
1287 //*************************************************************************************************
1292 template< typename Type // Data type of the vector
1293  , size_t N // Number of elements
1294  , bool TF > // Transpose flag
1296 {
1297  return NN;
1298 }
1299 //*************************************************************************************************
1300 
1301 
1302 //*************************************************************************************************
1310 template< typename Type // Data type of the vector
1311  , size_t N // Number of elements
1312  , bool TF > // Transpose flag
1314 {
1315  size_t nonzeros( 0 );
1316 
1317  for( size_t i=0UL; i<N; ++i ) {
1318  if( !isDefault( v_[i] ) )
1319  ++nonzeros;
1320  }
1321 
1322  return nonzeros;
1323 }
1324 //*************************************************************************************************
1325 
1326 
1327 //*************************************************************************************************
1332 template< typename Type // Data type of the vector
1333  , size_t N // Number of elements
1334  , bool TF > // Transpose flag
1336 {
1337  using blaze::reset;
1338  for( size_t i=0UL; i<N; ++i )
1339  reset( v_[i] );
1340 }
1341 //*************************************************************************************************
1342 
1343 
1344 //*************************************************************************************************
1350 template< typename Type // Data type of the vector
1351  , size_t N // Number of elements
1352  , bool TF > // Transpose flag
1353 template< typename Other > // Data type of the scalar value
1355 {
1356  for( size_t i=0; i<N; ++i )
1357  v_[i] *= scalar;
1358  return *this;
1359 }
1360 //*************************************************************************************************
1361 
1362 
1363 //*************************************************************************************************
1370 template< typename Type // Data type of the vector
1371  , size_t N // Number of elements
1372  , bool TF > // Transpose flag
1373 inline void StaticVector<Type,N,TF>::swap( StaticVector& v ) /* throw() */
1374 {
1375  using std::swap;
1376 
1377  for( size_t i=0UL; i<N; ++i )
1378  swap( v_[i], v.v_[i] );
1379 }
1380 //*************************************************************************************************
1381 
1382 
1383 
1384 
1385 //=================================================================================================
1386 //
1387 // MEMORY FUNCTIONS
1388 //
1389 //=================================================================================================
1390 
1391 //*************************************************************************************************
1401 template< typename Type // Data type of the vector
1402  , size_t N // Number of elements
1403  , bool TF > // Transpose flag
1404 inline void* StaticVector<Type,N,TF>::operator new( std::size_t size )
1405 {
1406  UNUSED_PARAMETER( size );
1407 
1408  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1409 
1410  return allocate<StaticVector>( 1UL );
1411 }
1412 //*************************************************************************************************
1413 
1414 
1415 //*************************************************************************************************
1425 template< typename Type // Data type of the vector
1426  , size_t N // Number of elements
1427  , bool TF > // Transpose flag
1428 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size )
1429 {
1430  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1431  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1432 
1433  return allocate<StaticVector>( size/sizeof(StaticVector) );
1434 }
1435 //*************************************************************************************************
1436 
1437 
1438 //*************************************************************************************************
1448 template< typename Type // Data type of the vector
1449  , size_t N // Number of elements
1450  , bool TF > // Transpose flag
1451 inline void* StaticVector<Type,N,TF>::operator new( std::size_t size, const std::nothrow_t& )
1452 {
1453  UNUSED_PARAMETER( size );
1454 
1455  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticVector ), "Invalid number of bytes detected" );
1456 
1457  return allocate<StaticVector>( 1UL );
1458 }
1459 //*************************************************************************************************
1460 
1461 
1462 //*************************************************************************************************
1472 template< typename Type // Data type of the vector
1473  , size_t N // Number of elements
1474  , bool TF > // Transpose flag
1475 inline void* StaticVector<Type,N,TF>::operator new[]( std::size_t size, const std::nothrow_t& )
1476 {
1477  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticVector ) , "Invalid number of bytes detected" );
1478  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticVector ) == 0UL, "Invalid number of bytes detected" );
1479 
1480  return allocate<StaticVector>( size/sizeof(StaticVector) );
1481 }
1482 //*************************************************************************************************
1483 
1484 
1485 //*************************************************************************************************
1491 template< typename Type // Data type of the vector
1492  , size_t N // Number of elements
1493  , bool TF > // Transpose flag
1494 inline void StaticVector<Type,N,TF>::operator delete( void* ptr )
1495 {
1496  deallocate( static_cast<StaticVector*>( ptr ) );
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, const std::nothrow_t& )
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 
1550 
1551 //=================================================================================================
1552 //
1553 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1554 //
1555 //=================================================================================================
1556 
1557 //*************************************************************************************************
1567 template< typename Type // Data type of the vector
1568  , size_t N // Number of elements
1569  , bool TF > // Transpose flag
1570 template< typename Other > // Data type of the foreign expression
1571 inline bool StaticVector<Type,N,TF>::canAlias( const Other* alias ) const
1572 {
1573  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1574 }
1575 //*************************************************************************************************
1576 
1577 
1578 //*************************************************************************************************
1588 template< typename Type // Data type of the vector
1589  , size_t N // Number of elements
1590  , bool TF > // Transpose flag
1591 template< typename Other > // Data type of the foreign expression
1592 inline bool StaticVector<Type,N,TF>::isAliased( const Other* alias ) const
1593 {
1594  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1595 }
1596 //*************************************************************************************************
1597 
1598 
1599 //*************************************************************************************************
1608 template< typename Type // Data type of the vector
1609  , size_t N // Number of elements
1610  , bool TF > // Transpose flag
1612 {
1613  return true;
1614 }
1615 //*************************************************************************************************
1616 
1617 
1618 //*************************************************************************************************
1631 template< typename Type // Data type of the vector
1632  , size_t N // Number of elements
1633  , bool TF > // Transpose flag
1635  StaticVector<Type,N,TF>::load( size_t index ) const
1636 {
1637  using blaze::load;
1638 
1640 
1641  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1642  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1643  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
1644 
1645  return load( &v_[index] );
1646 }
1647 //*************************************************************************************************
1648 
1649 
1650 //*************************************************************************************************
1663 template< typename Type // Data type of the vector
1664  , size_t N // Number of elements
1665  , bool TF > // Transpose flag
1667  StaticVector<Type,N,TF>::loadu( size_t index ) const
1668 {
1669  using blaze::loadu;
1670 
1672 
1673  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1674  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1675 
1676  return loadu( &v_[index] );
1677 }
1678 //*************************************************************************************************
1679 
1680 
1681 //*************************************************************************************************
1695 template< typename Type // Data type of the vector
1696  , size_t N // Number of elements
1697  , bool TF > // Transpose flag
1698 inline void StaticVector<Type,N,TF>::store( size_t index, const IntrinsicType& value )
1699 {
1700  using blaze::store;
1701 
1703 
1704  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1705  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1706  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
1707 
1708  store( &v_[index], value );
1709 }
1710 //*************************************************************************************************
1711 
1712 
1713 //*************************************************************************************************
1727 template< typename Type // Data type of the vector
1728  , size_t N // Number of elements
1729  , bool TF > // Transpose flag
1730 inline void StaticVector<Type,N,TF>::storeu( size_t index, const IntrinsicType& value )
1731 {
1732  using blaze::storeu;
1733 
1735 
1736  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1737  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN, "Invalid vector access index" );
1738 
1739  storeu( &v_[index], value );
1740 }
1741 //*************************************************************************************************
1742 
1743 
1744 //*************************************************************************************************
1758 template< typename Type // Data type of the vector
1759  , size_t N // Number of elements
1760  , bool TF > // Transpose flag
1761 inline void StaticVector<Type,N,TF>::stream( size_t index, const IntrinsicType& value )
1762 {
1763  using blaze::stream;
1764 
1766 
1767  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1768  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1769  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
1770 
1771  stream( &v_[index], value );
1772 }
1773 //*************************************************************************************************
1774 
1775 
1776 //*************************************************************************************************
1787 template< typename Type // Data type of the vector
1788  , size_t N // Number of elements
1789  , bool TF > // Transpose flag
1790 template< typename VT > // Type of the right-hand side dense vector
1791 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1793 {
1794  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1795 
1796  for( size_t i=0UL; i<N; ++i )
1797  v_[i] = (~rhs)[i];
1798 }
1799 //*************************************************************************************************
1800 
1801 
1802 //*************************************************************************************************
1813 template< typename Type // Data type of the vector
1814  , size_t N // Number of elements
1815  , bool TF > // Transpose flag
1816 template< typename VT > // Type of the right-hand side dense vector
1817 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1819 {
1820  using blaze::store;
1821 
1822  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1823 
1825 
1826  for( size_t i=0UL; i<N; i+=IT::size ) {
1827  store( v_+i, (~rhs).load(i) );
1828  }
1829 }
1830 //*************************************************************************************************
1831 
1832 
1833 //*************************************************************************************************
1844 template< typename Type // Data type of the vector
1845  , size_t N // Number of elements
1846  , bool TF > // Transpose flag
1847 template< typename VT > // Type of the right-hand side sparse vector
1849 {
1850  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1851 
1852  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1853  v_[element->index()] = element->value();
1854 }
1855 //*************************************************************************************************
1856 
1857 
1858 //*************************************************************************************************
1869 template< typename Type // Data type of the vector
1870  , size_t N // Number of elements
1871  , bool TF > // Transpose flag
1872 template< typename VT > // Type of the right-hand side dense vector
1873 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1875 {
1876  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1877 
1878  for( size_t i=0UL; i<N; ++i )
1879  v_[i] += (~rhs)[i];
1880 }
1881 //*************************************************************************************************
1882 
1883 
1884 //*************************************************************************************************
1895 template< typename Type // Data type of the vector
1896  , size_t N // Number of elements
1897  , bool TF > // Transpose flag
1898 template< typename VT > // Type of the right-hand side dense vector
1899 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1901 {
1902  using blaze::load;
1903  using blaze::store;
1904 
1905  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1906 
1908 
1909  for( size_t i=0UL; i<N; i+=IT::size ) {
1910  store( v_+i, load( v_+i ) + (~rhs).load(i) );
1911  }
1912 }
1913 //*************************************************************************************************
1914 
1915 
1916 //*************************************************************************************************
1927 template< typename Type // Data type of the vector
1928  , size_t N // Number of elements
1929  , bool TF > // Transpose flag
1930 template< typename VT > // Type of the right-hand side sparse vector
1932 {
1933  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1934 
1935  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1936  v_[element->index()] += element->value();
1937 }
1938 //*************************************************************************************************
1939 
1940 
1941 //*************************************************************************************************
1952 template< typename Type // Data type of the vector
1953  , size_t N // Number of elements
1954  , bool TF > // Transpose flag
1955 template< typename VT > // Type of the right-hand side dense vector
1956 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1958 {
1959  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1960 
1961  for( size_t i=0UL; i<N; ++i )
1962  v_[i] -= (~rhs)[i];
1963 }
1964 //*************************************************************************************************
1965 
1966 
1967 //*************************************************************************************************
1978 template< typename Type // Data type of the vector
1979  , size_t N // Number of elements
1980  , bool TF > // Transpose flag
1981 template< typename VT > // Type of the right-hand side dense vector
1982 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1984 {
1985  using blaze::load;
1986  using blaze::store;
1987 
1988  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1989 
1991 
1992  for( size_t i=0UL; i<N; i+=IT::size ) {
1993  store( v_+i, load( v_+i ) - (~rhs).load(i) );
1994  }
1995 }
1996 //*************************************************************************************************
1997 
1998 
1999 //*************************************************************************************************
2010 template< typename Type // Data type of the vector
2011  , size_t N // Number of elements
2012  , bool TF > // Transpose flag
2013 template< typename VT > // Type of the right-hand side sparse vector
2015 {
2016  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2017 
2018  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2019  v_[element->index()] -= element->value();
2020 }
2021 //*************************************************************************************************
2022 
2023 
2024 //*************************************************************************************************
2035 template< typename Type // Data type of the vector
2036  , size_t N // Number of elements
2037  , bool TF > // Transpose flag
2038 template< typename VT > // Type of the right-hand side dense vector
2039 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
2041 {
2042  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2043 
2044  for( size_t i=0UL; i<N; ++i )
2045  v_[i] *= (~rhs)[i];
2046 }
2047 //*************************************************************************************************
2048 
2049 
2050 //*************************************************************************************************
2061 template< typename Type // Data type of the vector
2062  , size_t N // Number of elements
2063  , bool TF > // Transpose flag
2064 template< typename VT > // Type of the right-hand side dense vector
2065 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
2067 {
2068  using blaze::load;
2069  using blaze::store;
2070 
2071  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2072 
2074 
2075  for( size_t i=0UL; i<N; i+=IT::size ) {
2076  store( v_+i, load( v_+i ) * (~rhs).load(i) );
2077  }
2078 }
2079 //*************************************************************************************************
2080 
2081 
2082 //*************************************************************************************************
2093 template< typename Type // Data type of the vector
2094  , size_t N // Number of elements
2095  , bool TF > // Transpose flag
2096 template< typename VT > // Type of the right-hand side sparse vector
2098 {
2099  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
2100 
2101  const StaticVector tmp( serial( *this ) );
2102 
2103  reset();
2104 
2105  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2106  v_[element->index()] = tmp[element->index()] * element->value();
2107 }
2108 //*************************************************************************************************
2109 
2110 
2111 
2112 
2113 
2114 
2115 
2116 
2117 //=================================================================================================
2118 //
2119 // UNDEFINED CLASS TEMPLATE SPECIALIZATION
2120 //
2121 //=================================================================================================
2122 
2123 //*************************************************************************************************
2131 template< typename Type // Data type of the vector
2132  , bool TF > // Transpose flag
2133 class StaticVector<Type,0UL,TF>;
2135 //*************************************************************************************************
2136 
2137 
2138 
2139 
2140 
2141 
2142 
2143 
2144 //=================================================================================================
2145 //
2146 // STATICVECTOR OPERATORS
2147 //
2148 //=================================================================================================
2149 
2150 //*************************************************************************************************
2153 template< typename Type, size_t N, bool TF >
2154 inline void reset( StaticVector<Type,N,TF>& v );
2155 
2156 template< typename Type, size_t N, bool TF >
2157 inline void clear( StaticVector<Type,N,TF>& v );
2158 
2159 template< typename Type, size_t N, bool TF >
2160 inline bool isDefault( const StaticVector<Type,N,TF>& v );
2161 
2162 template< typename Type, bool TF >
2164 
2165 template< typename Type, bool TF >
2167 
2168 template< typename Type, size_t N, bool TF >
2169 inline void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) /* throw() */;
2171 //*************************************************************************************************
2172 
2173 
2174 //*************************************************************************************************
2181 template< typename Type // Data type of the vector
2182  , size_t N // Number of elements
2183  , bool TF > // Transpose flag
2185 {
2186  v.reset();
2187 }
2188 //*************************************************************************************************
2189 
2190 
2191 //*************************************************************************************************
2200 template< typename Type // Data type of the vector
2201  , size_t N // Number of elements
2202  , bool TF > // Transpose flag
2204 {
2205  v.reset();
2206 }
2207 //*************************************************************************************************
2208 
2209 
2210 //*************************************************************************************************
2228 template< typename Type // Data type of the vector
2229  , size_t N // Number of elements
2230  , bool TF > // Transpose flag
2231 inline bool isDefault( const StaticVector<Type,N,TF>& v )
2232 {
2233  for( size_t i=0UL; i<N; ++i )
2234  if( !isDefault( v[i] ) ) return false;
2235  return true;
2236 }
2237 //*************************************************************************************************
2238 
2239 
2240 //*************************************************************************************************
2251 template< typename Type // Data type of the vector
2252  , bool TF > // Transpose flag
2254 {
2255  return StaticVector<Type,2UL,TF>( -v[1UL], v[0UL] );
2256 }
2257 //*************************************************************************************************
2258 
2259 
2260 //*************************************************************************************************
2268 template< typename Type // Data type of the vector
2269  , bool TF > // Transpose flag
2271 {
2272  if( v[0] != Type() || v[1] != Type() )
2273  return StaticVector<Type,3UL,TF>( v[1UL], -v[0UL], Type() );
2274  else
2275  return StaticVector<Type,3UL,TF>( Type(), v[2UL], -v[1UL] );
2276 }
2277 //*************************************************************************************************
2278 
2279 
2280 //*************************************************************************************************
2289 template< typename Type // Data type of the vector
2290  , size_t N // Number of elements
2291  , bool TF > // Transpose flag
2292 inline void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) /* throw() */
2293 {
2294  a.swap( b );
2295 }
2296 //*************************************************************************************************
2297 
2298 
2299 
2300 
2301 //=================================================================================================
2302 //
2303 // ADDTRAIT SPECIALIZATIONS
2304 //
2305 //=================================================================================================
2306 
2307 //*************************************************************************************************
2309 template< typename T1, size_t N, bool TF, typename T2 >
2310 struct AddTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2311 {
2312  typedef StaticVector< typename AddTrait<T1,T2>::Type, N, TF > Type;
2313 };
2315 //*************************************************************************************************
2316 
2317 
2318 
2319 
2320 //=================================================================================================
2321 //
2322 // SUBTRAIT SPECIALIZATIONS
2323 //
2324 //=================================================================================================
2325 
2326 //*************************************************************************************************
2328 template< typename T1, size_t N, bool TF, typename T2 >
2329 struct SubTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2330 {
2331  typedef StaticVector< typename SubTrait<T1,T2>::Type, N, TF > Type;
2332 };
2334 //*************************************************************************************************
2335 
2336 
2337 
2338 
2339 //=================================================================================================
2340 //
2341 // MULTTRAIT SPECIALIZATIONS
2342 //
2343 //=================================================================================================
2344 
2345 //*************************************************************************************************
2347 template< typename T1, size_t N, bool TF, typename T2 >
2348 struct MultTrait< StaticVector<T1,N,TF>, T2 >
2349 {
2350  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2352 };
2353 
2354 template< typename T1, typename T2, size_t N, bool TF >
2355 struct MultTrait< T1, StaticVector<T2,N,TF> >
2356 {
2357  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2359 };
2360 
2361 template< typename T1, size_t N, bool TF, typename T2 >
2362 struct MultTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2363 {
2364  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2365 };
2366 
2367 template< typename T1, size_t M, typename T2, size_t N >
2368 struct MultTrait< StaticVector<T1,M,false>, StaticVector<T2,N,true> >
2369 {
2370  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, false > Type;
2371 };
2372 
2373 template< typename T1, size_t N, typename T2 >
2374 struct MultTrait< StaticVector<T1,N,true>, StaticVector<T2,N,false> >
2375 {
2376  typedef typename MultTrait<T1,T2>::Type Type;
2377 };
2379 //*************************************************************************************************
2380 
2381 
2382 
2383 
2384 //=================================================================================================
2385 //
2386 // CROSSTRAIT SPECIALIZATIONS
2387 //
2388 //=================================================================================================
2389 
2390 //*************************************************************************************************
2392 template< typename T1, typename T2 >
2393 struct CrossTrait< StaticVector<T1,3UL,false>, StaticVector<T2,3UL,false> >
2394 {
2395  private:
2396  typedef typename MultTrait<T1,T2>::Type T;
2397 
2398  public:
2399  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2400 };
2402 //*************************************************************************************************
2403 
2404 
2405 
2406 
2407 //=================================================================================================
2408 //
2409 // DIVTRAIT SPECIALIZATIONS
2410 //
2411 //=================================================================================================
2412 
2413 //*************************************************************************************************
2415 template< typename T1, size_t N, bool TF, typename T2 >
2416 struct DivTrait< StaticVector<T1,N,TF>, T2 >
2417 {
2418  typedef StaticVector< typename DivTrait<T1,T2>::Type, N, TF > Type;
2420 };
2422 //*************************************************************************************************
2423 
2424 
2425 
2426 
2427 //=================================================================================================
2428 //
2429 // MATHTRAIT SPECIALIZATIONS
2430 //
2431 //=================================================================================================
2432 
2433 //*************************************************************************************************
2435 template< typename T1, size_t N, bool TF, typename T2 >
2436 struct MathTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2437 {
2438  typedef StaticVector< typename MathTrait<T1,T2>::HighType, N, TF > HighType;
2439  typedef StaticVector< typename MathTrait<T1,T2>::LowType , N, TF > LowType;
2440 };
2442 //*************************************************************************************************
2443 
2444 
2445 
2446 
2447 //=================================================================================================
2448 //
2449 // SUBVECTORTRAIT SPECIALIZATIONS
2450 //
2451 //=================================================================================================
2452 
2453 //*************************************************************************************************
2455 template< typename T1, size_t N, bool TF >
2456 struct SubvectorTrait< StaticVector<T1,N,TF> >
2457 {
2458  typedef HybridVector<T1,N,TF> Type;
2459 };
2461 //*************************************************************************************************
2462 
2463 } // namespace blaze
2464 
2465 #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
IntrinsicType load(size_t index) const
Aligned load of an intrinsic element of the vector.
Definition: StaticVector.h:1635
const bool defaultTransposeFlag
The default transpose flag for all vectors of the Blaze library.This value specifies the default tran...
Definition: TransposeFlag.h:56
Constraint on the data type.
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4599
#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
EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:223
EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
Header file for the SparseVector base class.
Type * Pointer
Pointer to a non-constant vector value.
Definition: StaticVector.h:182
Iterator end()
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:943
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: StaticVector.h:407
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4642
EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:219
Header file for the IsSame and IsStrictlySame type traits.
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:84
Header file for the DenseVector base class.
StaticVector< Type, N,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: StaticVector.h:175
#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:690
Type & Reference
Reference to a non-constant vector value.
Definition: StaticVector.h:180
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: StaticVector.h:1313
Header file for memory allocation and deallocation functionality.
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4615
Constraint on the data type.
Efficient implementation of a fixed-sized vector.The StaticVector class template is the representatio...
Definition: Forward.h:52
void deallocate(T *address)
Deallocation of memory.
Definition: Memory.h:115
bool isAligned() const
Returns whether the vector is properly aligned in memory.
Definition: StaticVector.h:1611
Header file for the DisableIf class template.
size_t capacity() const
Returns the maximum capacity of the vector.
Definition: StaticVector.h:1295
bool canAlias(const Other *alias) const
Returns whether the vector can alias with the given address alias.
Definition: StaticVector.h:1571
void swap(StaticVector &v)
Swapping the contents of two static vectors.
Definition: StaticVector.h:1373
Header file for the multiplication trait.
Header file for nested template disabiguation.
Compile time assertion.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two sparse matrices.
Definition: CompressedMatrix.h:4605
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2412
#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
Header file for the DenseIterator class template.
Header file for the subvector trait.
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:271
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
This ResultType
Result type for expression template evaluations.
Definition: StaticVector.h:174
void reset()
Reset to the default initial values.
Definition: StaticVector.h:1335
#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:928
Reference operator[](size_t index)
Subscript operator for the direct access to the vector elements.
Definition: StaticVector.h:828
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:361
IT::Type IntrinsicType
Intrinsic type of the vector elements.
Definition: StaticVector.h:177
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:2253
void store(size_t index, const IntrinsicType &value)
Aligned store of an intrinsic element of the vector.
Definition: StaticVector.h:1698
Header file for the EnableIf class template.
EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:216
Header file for the serial shim.
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: StaticVector.h:184
Header file for the IsSparseVector type trait.
EnableIf< IsIntegral< T > >::Type stream(T *address, const typename Stream< T, sizeof(T)>::Type &value)
Aligned, non-temporal store of a vector of integral values.
Definition: Stream.h:218
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:748
StaticVector()
The default constructor for StaticVector.
Definition: StaticVector.h:446
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
void swap(DynamicMatrix< Type, SO > &a, DynamicMatrix< Type, SO > &b)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:4671
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:301
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticVector.h:178
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
const Type & ConstReference
Reference to a constant vector value.
Definition: StaticVector.h:181
#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:898
Header file for the reset shim.
Header file for the AlignedArray implementation.
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:331
#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:2411
Header file for the isDefault shim.
Constraint on the data type.
bool isAliased(const Other *alias) const
Returns whether the vector is aliased with the given address alias.
Definition: StaticVector.h:1592
const StaticVector & CompositeType
Data type for composite expression templates.
Definition: StaticVector.h:179
StaticVector< Type, N, TF > This
Type of this StaticVector instance.
Definition: StaticVector.h:173
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the vector.
Definition: StaticVector.h:1761
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.
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: StaticVector.h:185
const Type * ConstPointer
Pointer to a constant vector value.
Definition: StaticVector.h:183
Header file for the default transpose flag for all vectors of the Blaze library.
size_t size() const
Returns the current size/dimension of the vector.
Definition: StaticVector.h:1280
IntrinsicTrait< Type > IT
Intrinsic trait for the vector element type.
Definition: StaticVector.h:163
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
Header file for basic type definitions.
ConstIterator cend() const
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:973
IntrinsicType loadu(size_t index) const
Unaligned load of an intrinsic element of the vector.
Definition: StaticVector.h:1667
#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
Type ElementType
Type of the vector elements.
Definition: StaticVector.h:176
Pointer data()
Low-level data access to the vector elements.
Definition: StaticVector.h:866
#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
void storeu(size_t index, const IntrinsicType &value)
Unaligned store of an intrinsic element of the vector.
Definition: StaticVector.h:1730