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>
62 #include <blaze/util/Assert.h>
69 #include <blaze/util/DisableIf.h>
70 #include <blaze/util/EnableIf.h>
72 #include <blaze/util/Template.h>
73 #include <blaze/util/Types.h>
77 
78 
79 namespace blaze {
80 
81 //=================================================================================================
82 //
83 // CLASS DEFINITION
84 //
85 //=================================================================================================
86 
87 //*************************************************************************************************
153 template< typename Type // Data type of the vector
154  , size_t N // Number of elements
155  , bool TF = defaultTransposeFlag > // Transpose flag
156 class StaticVector : public DenseVector< StaticVector<Type,N,TF>, TF >
157 {
158  private:
159  //**Type definitions****************************************************************************
161  //**********************************************************************************************
162 
163  //**********************************************************************************************
165  enum { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size };
166  //**********************************************************************************************
167 
168  public:
169  //**Type definitions****************************************************************************
171  typedef This ResultType;
173  typedef Type ElementType;
174  typedef typename IT::Type IntrinsicType;
175  typedef const Type& ReturnType;
176  typedef const StaticVector& CompositeType;
177  typedef Type& Reference;
178  typedef const Type& ConstReference;
181  //**********************************************************************************************
182 
183  //**Compilation flags***************************************************************************
185 
189  enum { vectorizable = IsVectorizable<Type>::value };
190 
192 
195  enum { smpAssignable = 0 };
196  //**********************************************************************************************
197 
198  //**Constructors********************************************************************************
201  explicit inline StaticVector();
202  explicit inline StaticVector( const Type& init );
203  template< typename Other > explicit inline StaticVector( size_t n, const Other* array );
204 
205  template< typename Other >
206  explicit inline StaticVector( const Other (&array)[N] );
207 
208  inline StaticVector( const StaticVector& v );
209  template< typename Other > inline StaticVector( const StaticVector<Other,N,TF>& v );
210  template< typename VT > inline StaticVector( const Vector<VT,TF>& v );
211 
212  inline StaticVector( const Type& v1, const Type& v2 );
213  inline StaticVector( const Type& v1, const Type& v2, const Type& v3 );
214  inline StaticVector( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
215  inline StaticVector( const Type& v1, const Type& v2, const Type& v3,
216  const Type& v4, const Type& v5 );
217  inline StaticVector( const Type& v1, const Type& v2, const Type& v3,
218  const Type& v4, const Type& v5, const Type& v6 );
220  //**********************************************************************************************
221 
222  //**Destructor**********************************************************************************
223  // No explicitly declared destructor.
224  //**********************************************************************************************
225 
226  //**Data access functions***********************************************************************
229  inline Reference operator[]( size_t index );
230  inline ConstReference operator[]( size_t index ) const;
231  inline Type* data ();
232  inline const Type* data () const;
233  inline Iterator begin ();
234  inline ConstIterator begin () const;
235  inline ConstIterator cbegin() const;
236  inline Iterator end ();
237  inline ConstIterator end () const;
238  inline ConstIterator cend () const;
240  //**********************************************************************************************
241 
242  //**Assignment operators************************************************************************
245  template< typename Other >
246  inline StaticVector& operator=( const Other (&array)[N] );
247 
248  inline StaticVector& operator= ( const Type& rhs );
249  inline StaticVector& operator= ( const StaticVector& rhs );
250  template< typename Other > inline StaticVector& operator= ( const StaticVector<Other,N,TF>& rhs );
251  template< typename VT > inline StaticVector& operator= ( const Vector<VT,TF>& rhs );
252  template< typename VT > inline StaticVector& operator+=( const Vector<VT,TF>& rhs );
253  template< typename VT > inline StaticVector& operator-=( const Vector<VT,TF>& rhs );
254  template< typename VT > inline StaticVector& operator*=( const Vector<VT,TF>& rhs );
255 
256  template< typename Other >
257  inline typename EnableIf< IsNumeric<Other>, StaticVector >::Type&
258  operator*=( Other rhs );
259 
260  template< typename Other >
261  inline typename EnableIf< IsNumeric<Other>, StaticVector >::Type&
262  operator/=( Other rhs );
264  //**********************************************************************************************
265 
266  //**Utility functions***************************************************************************
269  inline size_t size() const;
270  inline size_t capacity() const;
271  inline size_t nonZeros() const;
272  inline void reset();
273  template< typename Other > inline StaticVector& scale( Other scalar );
274  inline void swap( StaticVector& v ) /* throw() */;
276  //**********************************************************************************************
277 
278  private:
279  //**********************************************************************************************
281  template< typename VT >
283  struct VectorizedAssign {
284  enum { value = vectorizable && VT::vectorizable &&
285  IsSame<Type,typename VT::ElementType>::value };
286  };
288  //**********************************************************************************************
289 
290  //**********************************************************************************************
292  template< typename VT >
294  struct VectorizedAddAssign {
295  enum { value = vectorizable && VT::vectorizable &&
296  IsSame<Type,typename VT::ElementType>::value &&
297  IntrinsicTrait<Type>::addition };
298  };
300  //**********************************************************************************************
301 
302  //**********************************************************************************************
304  template< typename VT >
306  struct VectorizedSubAssign {
307  enum { value = vectorizable && VT::vectorizable &&
308  IsSame<Type,typename VT::ElementType>::value &&
309  IntrinsicTrait<Type>::subtraction };
310  };
312  //**********************************************************************************************
313 
314  //**********************************************************************************************
316  template< typename VT >
318  struct VectorizedMultAssign {
319  enum { value = vectorizable && VT::vectorizable &&
320  IsSame<Type,typename VT::ElementType>::value &&
321  IntrinsicTrait<Type>::multiplication };
322  };
324  //**********************************************************************************************
325 
326  public:
327  //**Expression template evaluation functions****************************************************
330  template< typename Other > inline bool canAlias ( const Other* alias ) const;
331  template< typename Other > inline bool isAliased( const Other* alias ) const;
332 
333  inline IntrinsicType load ( size_t index ) const;
334  inline IntrinsicType loadu ( size_t index ) const;
335  inline void store ( size_t index, const IntrinsicType& value );
336  inline void storeu( size_t index, const IntrinsicType& value );
337  inline void stream( size_t index, const IntrinsicType& value );
338 
339  template< typename VT >
340  inline typename DisableIf< VectorizedAssign<VT> >::Type
341  assign( const DenseVector<VT,TF>& rhs );
342 
343  template< typename VT >
344  inline typename EnableIf< VectorizedAssign<VT> >::Type
345  assign( const DenseVector<VT,TF>& rhs );
346 
347  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
348 
349  template< typename VT >
350  inline typename DisableIf< VectorizedAddAssign<VT> >::Type
351  addAssign( const DenseVector<VT,TF>& rhs );
352 
353  template< typename VT >
354  inline typename EnableIf< VectorizedAddAssign<VT> >::Type
355  addAssign( const DenseVector<VT,TF>& rhs );
356 
357  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
358 
359  template< typename VT >
360  inline typename DisableIf< VectorizedSubAssign<VT> >::Type
361  subAssign( const DenseVector<VT,TF>& rhs );
362 
363  template< typename VT >
364  inline typename EnableIf< VectorizedSubAssign<VT> >::Type
365  subAssign( const DenseVector<VT,TF>& rhs );
366 
367  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
368 
369  template< typename VT >
370  inline typename DisableIf< VectorizedMultAssign<VT> >::Type
371  multAssign( const DenseVector<VT,TF>& rhs );
372 
373  template< typename VT >
374  inline typename EnableIf< VectorizedMultAssign<VT> >::Type
375  multAssign( const DenseVector<VT,TF>& rhs );
376 
377  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
379  //**********************************************************************************************
380 
381  private:
382  //**Member variables****************************************************************************
386 
392  //**********************************************************************************************
393 
394  //**Compile time checks*************************************************************************
400  BLAZE_STATIC_ASSERT( NN % IT::size == 0UL );
401  BLAZE_STATIC_ASSERT( NN >= N );
403  //**********************************************************************************************
404 };
405 //*************************************************************************************************
406 
407 
408 
409 
410 //=================================================================================================
411 //
412 // CONSTRUCTORS
413 //
414 //=================================================================================================
415 
416 //*************************************************************************************************
421 template< typename Type // Data type of the vector
422  , size_t N // Number of elements
423  , bool TF > // Transpose flag
425 {
426  if( IsNumeric<Type>::value ) {
427  for( size_t i=0UL; i<NN; ++i )
428  v_[i] = Type();
429  }
430 }
431 //*************************************************************************************************
432 
433 
434 //*************************************************************************************************
439 template< typename Type // Data type of the vector
440  , size_t N // Number of elements
441  , bool TF > // Transpose flag
442 inline StaticVector<Type,N,TF>::StaticVector( const Type& init )
443 {
444  for( size_t i=0UL; i<N; ++i )
445  v_[i] = init;
446 
447  if( IsNumeric<Type>::value ) {
448  for( size_t i=N; i<NN; ++i )
449  v_[i] = Type();
450  }
451 }
452 //*************************************************************************************************
453 
454 
455 //*************************************************************************************************
477 template< typename Type // Data type of the vector
478  , size_t N // Number of elements
479  , bool TF > // Transpose flag
480 template< typename Other > // Data type of the initialization array
481 inline StaticVector<Type,N,TF>::StaticVector( size_t n, const Other* array )
482 {
483  if( n > N )
484  throw std::invalid_argument( "Invalid setup of static vector" );
485 
486  for( size_t i=0UL; i<n; ++i )
487  v_[i] = array[i];
488 
489  if( IsNumeric<Type>::value ) {
490  for( size_t i=n; i<NN; ++i )
491  v_[i] = Type();
492  }
493 }
494 //*************************************************************************************************
495 
496 
497 //*************************************************************************************************
513 template< typename Type // Data type of the vector
514  , size_t N // Number of elements
515  , bool TF > // Transpose flag
516 template< typename Other > // Data type of the initialization array
517 inline StaticVector<Type,N,TF>::StaticVector( const Other (&array)[N] )
518 {
519  for( size_t i=0UL; i<N; ++i )
520  v_[i] = array[i];
521 
522  if( IsNumeric<Type>::value ) {
523  for( size_t i=N; i<NN; ++i )
524  v_[i] = Type();
525  }
526 }
527 //*************************************************************************************************
528 
529 
530 //*************************************************************************************************
537 template< typename Type // Data type of the vector
538  , size_t N // Number of elements
539  , bool TF > // Transpose flag
541 {
542  for( size_t i=0UL; i<NN; ++i )
543  v_[i] = v.v_[i];
544 }
545 //*************************************************************************************************
546 
547 
548 //*************************************************************************************************
553 template< typename Type // Data type of the vector
554  , size_t N // Number of elements
555  , bool TF > // Transpose flag
556 template< typename Other > // Data type of the foreign vector
558 {
559  for( size_t i=0UL; i<N; ++i )
560  v_[i] = v[i];
561 
562  if( IsNumeric<Type>::value ) {
563  for( size_t i=N; i<NN; ++i )
564  v_[i] = Type();
565  }
566 }
567 //*************************************************************************************************
568 
569 
570 //*************************************************************************************************
580 template< typename Type // Data type of the vector
581  , size_t N // Number of elements
582  , bool TF > // Transpose flag
583 template< typename VT > // Type of the foreign vector
585 {
586  using blaze::assign;
587 
588  if( (~v).size() != N )
589  throw std::invalid_argument( "Invalid setup of static vector" );
590 
591  if( IsNumeric<Type>::value ) {
592  for( size_t i=( IsSparseVector<VT>::value )?( 0UL ):( N ); i<NN; ++i )
593  v_[i] = Type();
594  }
595 
596  assign( *this, ~v );
597 }
598 //*************************************************************************************************
599 
600 
601 //*************************************************************************************************
613 template< typename Type // Data type of the vector
614  , size_t N // Number of elements
615  , bool TF > // Transpose flag
616 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2 )
617 {
618  BLAZE_STATIC_ASSERT( N == 2UL );
619 
620  v_[0] = v1;
621  v_[1] = v2;
622 
623  if( IsNumeric<Type>::value ) {
624  for( size_t i=N; i<NN; ++i )
625  v_[i] = Type();
626  }
627 }
628 //*************************************************************************************************
629 
630 
631 //*************************************************************************************************
644 template< typename Type // Data type of the vector
645  , size_t N // Number of elements
646  , bool TF > // Transpose flag
647 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2, const Type& v3 )
648 {
649  BLAZE_STATIC_ASSERT( N == 3UL );
650 
651  v_[0] = v1;
652  v_[1] = v2;
653  v_[2] = v3;
654 
655  if( IsNumeric<Type>::value ) {
656  for( size_t i=N; i<NN; ++i )
657  v_[i] = Type();
658  }
659 }
660 //*************************************************************************************************
661 
662 
663 //*************************************************************************************************
677 template< typename Type // Data type of the vector
678  , size_t N // Number of elements
679  , bool TF > // Transpose flag
680 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2,
681  const Type& v3, const Type& v4 )
682 {
683  BLAZE_STATIC_ASSERT( N == 4UL );
684 
685  v_[0] = v1;
686  v_[1] = v2;
687  v_[2] = v3;
688  v_[3] = v4;
689 
690  if( IsNumeric<Type>::value ) {
691  for( size_t i=N; i<NN; ++i )
692  v_[i] = Type();
693  }
694 }
695 //*************************************************************************************************
696 
697 
698 //*************************************************************************************************
713 template< typename Type // Data type of the vector
714  , size_t N // Number of elements
715  , bool TF > // Transpose flag
716 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2, const Type& v3,
717  const Type& v4, const Type& v5 )
718 {
719  BLAZE_STATIC_ASSERT( N == 5UL );
720 
721  v_[0] = v1;
722  v_[1] = v2;
723  v_[2] = v3;
724  v_[3] = v4;
725  v_[4] = v5;
726 
727  if( IsNumeric<Type>::value ) {
728  for( size_t i=N; i<NN; ++i )
729  v_[i] = Type();
730  }
731 }
732 //*************************************************************************************************
733 
734 
735 //*************************************************************************************************
751 template< typename Type // Data type of the vector
752  , size_t N // Number of elements
753  , bool TF > // Transpose flag
754 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2, const Type& v3,
755  const Type& v4, const Type& v5, const Type& v6 )
756 {
757  BLAZE_STATIC_ASSERT( N == 6UL );
758 
759  v_[0] = v1;
760  v_[1] = v2;
761  v_[2] = v3;
762  v_[3] = v4;
763  v_[4] = v5;
764  v_[5] = v6;
765 
766  if( IsNumeric<Type>::value ) {
767  for( size_t i=N; i<NN; ++i )
768  v_[i] = Type();
769  }
770 }
771 //*************************************************************************************************
772 
773 
774 
775 
776 //=================================================================================================
777 //
778 // DATA ACCESS FUNCTIONS
779 //
780 //=================================================================================================
781 
782 //*************************************************************************************************
790 template< typename Type // Data type of the vector
791  , size_t N // Number of elements
792  , bool TF > // Transpose flag
795 {
796  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
797  return v_[index];
798 }
799 //*************************************************************************************************
800 
801 
802 //*************************************************************************************************
810 template< typename Type // Data type of the vector
811  , size_t N // Number of elements
812  , bool TF > // Transpose flag
815 {
816  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
817  return v_[index];
818 }
819 //*************************************************************************************************
820 
821 
822 //*************************************************************************************************
829 template< typename Type // Data type of the vector
830  , size_t N // Number of elements
831  , bool TF > // Transpose flag
833 {
834  return v_;
835 }
836 //*************************************************************************************************
837 
838 
839 //*************************************************************************************************
846 template< typename Type // Data type of the vector
847  , size_t N // Number of elements
848  , bool TF > // Transpose flag
849 inline const Type* StaticVector<Type,N,TF>::data() const
850 {
851  return v_;
852 }
853 //*************************************************************************************************
854 
855 
856 //*************************************************************************************************
861 template< typename Type // Data type of the vector
862  , size_t N // Number of elements
863  , bool TF > // Transpose flag
865 {
866  return Iterator( v_ );
867 }
868 //*************************************************************************************************
869 
870 
871 //*************************************************************************************************
876 template< typename Type // Data type of the vector
877  , size_t N // Number of elements
878  , bool TF > // Transpose flag
880 {
881  return ConstIterator( v_ );
882 }
883 //*************************************************************************************************
884 
885 
886 //*************************************************************************************************
891 template< typename Type // Data type of the vector
892  , size_t N // Number of elements
893  , bool TF > // Transpose flag
895 {
896  return ConstIterator( v_ );
897 }
898 //*************************************************************************************************
899 
900 
901 //*************************************************************************************************
906 template< typename Type // Data type of the vector
907  , size_t N // Number of elements
908  , bool TF > // Transpose flag
910 {
911  return Iterator( v_ + N );
912 }
913 //*************************************************************************************************
914 
915 
916 //*************************************************************************************************
921 template< typename Type // Data type of the vector
922  , size_t N // Number of elements
923  , bool TF > // Transpose flag
925 {
926  return ConstIterator( v_ + N );
927 }
928 //*************************************************************************************************
929 
930 
931 //*************************************************************************************************
936 template< typename Type // Data type of the vector
937  , size_t N // Number of elements
938  , bool TF > // Transpose flag
940 {
941  return ConstIterator( v_ + N );
942 }
943 //*************************************************************************************************
944 
945 
946 
947 
948 //=================================================================================================
949 //
950 // ASSIGNMENT OPERATORS
951 //
952 //=================================================================================================
953 
954 //*************************************************************************************************
971 template< typename Type // Data type of the vector
972  , size_t N // Number of elements
973  , bool TF > // Transpose flag
974 template< typename Other > // Data type of the initialization array
976 {
977  for( size_t i=0UL; i<N; ++i )
978  v_[i] = array[i];
979  return *this;
980 }
981 //*************************************************************************************************
982 
983 
984 //*************************************************************************************************
990 template< typename Type // Data type of the vector
991  , size_t N // Number of elements
992  , bool TF > // Transpose flag
994 {
995  for( size_t i=0UL; i<N; ++i )
996  v_[i] = rhs;
997  return *this;
998 }
999 //*************************************************************************************************
1000 
1001 
1002 //*************************************************************************************************
1010 template< typename Type // Data type of the vector
1011  , size_t N // Number of elements
1012  , bool TF > // Transpose flag
1014 {
1015  // This implementation was chosen for several reasons:
1016  // - it works for all possible element types (even types that could not be copied by 'memcpy')
1017  // - it is faster than the synthesized default copy assignment operator
1018  // - it is faster than an implementation with the C library function 'memcpy' in combination
1019  // with a protection against self-assignment
1020  // - it goes without a protection against self-assignment
1021  for( size_t i=0UL; i<N; ++i )
1022  v_[i] = rhs.v_[i];
1023  return *this;
1024 }
1025 //*************************************************************************************************
1026 
1027 
1028 //*************************************************************************************************
1034 template< typename Type // Data type of the vector
1035  , size_t N // Number of elements
1036  , bool TF > // Transpose flag
1037 template< typename Other > // Data type of the foreign vector
1039 {
1040  // This implementation was chosen for several reasons:
1041  // - it works for all possible element types (even types that could not be copied by 'memcpy')
1042  // - it is faster than the synthesized default copy assignment operator
1043  // - it is faster than an implementation with the C library function 'memcpy' in combination
1044  // with a protection against self-assignment
1045  // - it goes without a protection against self-assignment
1046  for( size_t i=0UL; i<N; ++i )
1047  v_[i] = rhs[i];
1048  return *this;
1049 }
1050 //*************************************************************************************************
1051 
1052 
1053 //*************************************************************************************************
1063 template< typename Type // Data type of the vector
1064  , size_t N // Number of elements
1065  , bool TF > // Transpose flag
1066 template< typename VT > // Type of the right-hand side vector
1068 {
1069  using blaze::assign;
1070 
1071  if( (~rhs).size() != N )
1072  throw std::invalid_argument( "Invalid assignment to static vector" );
1073 
1074  if( (~rhs).canAlias( this ) ) {
1075  StaticVector tmp( ~rhs );
1076  swap( tmp );
1077  }
1078  else {
1080  reset();
1081  assign( *this, ~rhs );
1082  }
1083 
1084  return *this;
1085 }
1086 //*************************************************************************************************
1087 
1088 
1089 //*************************************************************************************************
1099 template< typename Type // Data type of the vector
1100  , size_t N // Number of elements
1101  , bool TF > // Transpose flag
1102 template< typename VT > // Type of the right-hand side vector
1104 {
1105  using blaze::addAssign;
1106 
1107  if( (~rhs).size() != N )
1108  throw std::invalid_argument( "Vector sizes do not match" );
1109 
1110  if( (~rhs).canAlias( this ) ) {
1111  StaticVector tmp( ~rhs );
1112  addAssign( *this, tmp );
1113  }
1114  else {
1115  addAssign( *this, ~rhs );
1116  }
1117 
1118  return *this;
1119 }
1120 //*************************************************************************************************
1121 
1122 
1123 //*************************************************************************************************
1133 template< typename Type // Data type of the vector
1134  , size_t N // Number of elements
1135  , bool TF > // Transpose flag
1136 template< typename VT > // Type of the right-hand side vector
1138 {
1139  using blaze::subAssign;
1140 
1141  if( (~rhs).size() != N )
1142  throw std::invalid_argument( "Vector sizes do not match" );
1143 
1144  if( (~rhs).canAlias( this ) ) {
1145  StaticVector tmp( ~rhs );
1146  subAssign( *this, tmp );
1147  }
1148  else {
1149  subAssign( *this, ~rhs );
1150  }
1151 
1152  return *this;
1153 }
1154 //*************************************************************************************************
1155 
1156 
1157 //*************************************************************************************************
1168 template< typename Type // Data type of the vector
1169  , size_t N // Number of elements
1170  , bool TF > // Transpose flag
1171 template< typename VT > // Type of the right-hand side vector
1173 {
1174  using blaze::assign;
1175 
1176  if( (~rhs).size() != N )
1177  throw std::invalid_argument( "Vector sizes do not match" );
1178 
1179  if( (~rhs).canAlias( this ) || IsSparseVector<VT>::value ) {
1180  StaticVector tmp( *this * (~rhs) );
1181  this->operator=( tmp );
1182  }
1183  else {
1184  assign( *this, *this * (~rhs) );
1185  }
1186 
1187  return *this;
1188 }
1189 //*************************************************************************************************
1190 
1191 
1192 //*************************************************************************************************
1199 template< typename Type // Data type of the vector
1200  , size_t N // Number of elements
1201  , bool TF > // Transpose flag
1202 template< typename Other > // Data type of the right-hand side scalar
1203 inline typename EnableIf< IsNumeric<Other>, StaticVector<Type,N,TF> >::Type&
1205 {
1206  using blaze::assign;
1207 
1208  assign( *this, (*this) * rhs );
1209  return *this;
1210 }
1211 //*************************************************************************************************
1212 
1213 
1214 //*************************************************************************************************
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  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1233 
1234  assign( *this, (*this) / rhs );
1235  return *this;
1236 }
1237 //*************************************************************************************************
1238 
1239 
1240 
1241 
1242 //=================================================================================================
1243 //
1244 // UTILITY FUNCTIONS
1245 //
1246 //=================================================================================================
1247 
1248 //*************************************************************************************************
1253 template< typename Type // Data type of the vector
1254  , size_t N // Number of elements
1255  , bool TF > // Transpose flag
1256 inline size_t StaticVector<Type,N,TF>::size() const
1257 {
1258  return N;
1259 }
1260 //*************************************************************************************************
1261 
1262 
1263 //*************************************************************************************************
1268 template< typename Type // Data type of the vector
1269  , size_t N // Number of elements
1270  , bool TF > // Transpose flag
1272 {
1273  return NN;
1274 }
1275 //*************************************************************************************************
1276 
1277 
1278 //*************************************************************************************************
1286 template< typename Type // Data type of the vector
1287  , size_t N // Number of elements
1288  , bool TF > // Transpose flag
1290 {
1291  size_t nonzeros( 0 );
1292 
1293  for( size_t i=0UL; i<N; ++i ) {
1294  if( !isDefault( v_[i] ) )
1295  ++nonzeros;
1296  }
1297 
1298  return nonzeros;
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  using blaze::reset;
1314  for( size_t i=0UL; i<N; ++i )
1315  reset( v_[i] );
1316 }
1317 //*************************************************************************************************
1318 
1319 
1320 //*************************************************************************************************
1326 template< typename Type // Data type of the vector
1327  , size_t N // Number of elements
1328  , bool TF > // Transpose flag
1329 template< typename Other > // Data type of the scalar value
1331 {
1332  for( size_t i=0; i<N; ++i )
1333  v_[i] *= scalar;
1334  return *this;
1335 }
1336 //*************************************************************************************************
1337 
1338 
1339 //*************************************************************************************************
1346 template< typename Type // Data type of the vector
1347  , size_t N // Number of elements
1348  , bool TF > // Transpose flag
1349 inline void StaticVector<Type,N,TF>::swap( StaticVector& v ) /* throw() */
1350 {
1351  using std::swap;
1352 
1353  for( size_t i=0UL; i<N; ++i )
1354  swap( v_[i], v.v_[i] );
1355 }
1356 //*************************************************************************************************
1357 
1358 
1359 
1360 
1361 //=================================================================================================
1362 //
1363 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1364 //
1365 //=================================================================================================
1366 
1367 //*************************************************************************************************
1377 template< typename Type // Data type of the vector
1378  , size_t N // Number of elements
1379  , bool TF > // Transpose flag
1380 template< typename Other > // Data type of the foreign expression
1381 inline bool StaticVector<Type,N,TF>::canAlias( const Other* alias ) const
1382 {
1383  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1384 }
1385 //*************************************************************************************************
1386 
1387 
1388 //*************************************************************************************************
1398 template< typename Type // Data type of the vector
1399  , size_t N // Number of elements
1400  , bool TF > // Transpose flag
1401 template< typename Other > // Data type of the foreign expression
1402 inline bool StaticVector<Type,N,TF>::isAliased( const Other* alias ) const
1403 {
1404  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1405 }
1406 //*************************************************************************************************
1407 
1408 
1409 //*************************************************************************************************
1422 template< typename Type // Data type of the vector
1423  , size_t N // Number of elements
1424  , bool TF > // Transpose flag
1426  StaticVector<Type,N,TF>::load( size_t index ) const
1427 {
1428  using blaze::load;
1429 
1431 
1432  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1433  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1434  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
1435 
1436  return load( &v_[index] );
1437 }
1438 //*************************************************************************************************
1439 
1440 
1441 //*************************************************************************************************
1454 template< typename Type // Data type of the vector
1455  , size_t N // Number of elements
1456  , bool TF > // Transpose flag
1458  StaticVector<Type,N,TF>::loadu( size_t index ) const
1459 {
1460  using blaze::loadu;
1461 
1463 
1464  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1465  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1466 
1467  return loadu( &v_[index] );
1468 }
1469 //*************************************************************************************************
1470 
1471 
1472 //*************************************************************************************************
1486 template< typename Type // Data type of the vector
1487  , size_t N // Number of elements
1488  , bool TF > // Transpose flag
1489 inline void StaticVector<Type,N,TF>::store( size_t index, const IntrinsicType& value )
1490 {
1491  using blaze::store;
1492 
1494 
1495  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1496  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1497  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
1498 
1499  store( &v_[index], value );
1500 }
1501 //*************************************************************************************************
1502 
1503 
1504 //*************************************************************************************************
1518 template< typename Type // Data type of the vector
1519  , size_t N // Number of elements
1520  , bool TF > // Transpose flag
1521 inline void StaticVector<Type,N,TF>::storeu( size_t index, const IntrinsicType& value )
1522 {
1523  using blaze::storeu;
1524 
1526 
1527  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1528  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN, "Invalid vector access index" );
1529 
1530  storeu( &v_[index], value );
1531 }
1532 //*************************************************************************************************
1533 
1534 
1535 //*************************************************************************************************
1549 template< typename Type // Data type of the vector
1550  , size_t N // Number of elements
1551  , bool TF > // Transpose flag
1552 inline void StaticVector<Type,N,TF>::stream( size_t index, const IntrinsicType& value )
1553 {
1554  using blaze::stream;
1555 
1557 
1558  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1559  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1560  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
1561 
1562  stream( &v_[index], value );
1563 }
1564 //*************************************************************************************************
1565 
1566 
1567 //*************************************************************************************************
1578 template< typename Type // Data type of the vector
1579  , size_t N // Number of elements
1580  , bool TF > // Transpose flag
1581 template< typename VT > // Type of the right-hand side dense vector
1582 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1584 {
1585  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1586 
1587  for( size_t i=0UL; i<N; ++i )
1588  v_[i] = (~rhs)[i];
1589 }
1590 //*************************************************************************************************
1591 
1592 
1593 //*************************************************************************************************
1604 template< typename Type // Data type of the vector
1605  , size_t N // Number of elements
1606  , bool TF > // Transpose flag
1607 template< typename VT > // Type of the right-hand side dense vector
1608 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1610 {
1611  using blaze::store;
1612 
1613  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1614 
1616 
1617  for( size_t i=0UL; i<N; i+=IT::size ) {
1618  store( v_+i, (~rhs).load(i) );
1619  }
1620 }
1621 //*************************************************************************************************
1622 
1623 
1624 //*************************************************************************************************
1635 template< typename Type // Data type of the vector
1636  , size_t N // Number of elements
1637  , bool TF > // Transpose flag
1638 template< typename VT > // Type of the right-hand side sparse vector
1640 {
1641  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1642 
1643  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1644  v_[element->index()] = element->value();
1645 }
1646 //*************************************************************************************************
1647 
1648 
1649 //*************************************************************************************************
1660 template< typename Type // Data type of the vector
1661  , size_t N // Number of elements
1662  , bool TF > // Transpose flag
1663 template< typename VT > // Type of the right-hand side dense vector
1664 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1666 {
1667  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1668 
1669  for( size_t i=0UL; i<N; ++i )
1670  v_[i] += (~rhs)[i];
1671 }
1672 //*************************************************************************************************
1673 
1674 
1675 //*************************************************************************************************
1686 template< typename Type // Data type of the vector
1687  , size_t N // Number of elements
1688  , bool TF > // Transpose flag
1689 template< typename VT > // Type of the right-hand side dense vector
1690 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1692 {
1693  using blaze::load;
1694  using blaze::store;
1695 
1696  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1697 
1699 
1700  for( size_t i=0UL; i<N; i+=IT::size ) {
1701  store( v_+i, load( v_+i ) + (~rhs).load(i) );
1702  }
1703 }
1704 //*************************************************************************************************
1705 
1706 
1707 //*************************************************************************************************
1718 template< typename Type // Data type of the vector
1719  , size_t N // Number of elements
1720  , bool TF > // Transpose flag
1721 template< typename VT > // Type of the right-hand side sparse vector
1723 {
1724  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1725 
1726  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1727  v_[element->index()] += element->value();
1728 }
1729 //*************************************************************************************************
1730 
1731 
1732 //*************************************************************************************************
1743 template< typename Type // Data type of the vector
1744  , size_t N // Number of elements
1745  , bool TF > // Transpose flag
1746 template< typename VT > // Type of the right-hand side dense vector
1747 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1749 {
1750  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1751 
1752  for( size_t i=0UL; i<N; ++i )
1753  v_[i] -= (~rhs)[i];
1754 }
1755 //*************************************************************************************************
1756 
1757 
1758 //*************************************************************************************************
1769 template< typename Type // Data type of the vector
1770  , size_t N // Number of elements
1771  , bool TF > // Transpose flag
1772 template< typename VT > // Type of the right-hand side dense vector
1773 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1775 {
1776  using blaze::load;
1777  using blaze::store;
1778 
1779  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1780 
1782 
1783  for( size_t i=0UL; i<N; i+=IT::size ) {
1784  store( v_+i, load( v_+i ) - (~rhs).load(i) );
1785  }
1786 }
1787 //*************************************************************************************************
1788 
1789 
1790 //*************************************************************************************************
1801 template< typename Type // Data type of the vector
1802  , size_t N // Number of elements
1803  , bool TF > // Transpose flag
1804 template< typename VT > // Type of the right-hand side sparse vector
1806 {
1807  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1808 
1809  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1810  v_[element->index()] -= element->value();
1811 }
1812 //*************************************************************************************************
1813 
1814 
1815 //*************************************************************************************************
1826 template< typename Type // Data type of the vector
1827  , size_t N // Number of elements
1828  , bool TF > // Transpose flag
1829 template< typename VT > // Type of the right-hand side dense vector
1830 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1832 {
1833  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1834 
1835  for( size_t i=0UL; i<N; ++i )
1836  v_[i] *= (~rhs)[i];
1837 }
1838 //*************************************************************************************************
1839 
1840 
1841 //*************************************************************************************************
1852 template< typename Type // Data type of the vector
1853  , size_t N // Number of elements
1854  , bool TF > // Transpose flag
1855 template< typename VT > // Type of the right-hand side dense vector
1856 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1858 {
1859  using blaze::load;
1860  using blaze::store;
1861 
1862  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1863 
1865 
1866  for( size_t i=0UL; i<N; i+=IT::size ) {
1867  store( v_+i, load( v_+i ) * (~rhs).load(i) );
1868  }
1869 }
1870 //*************************************************************************************************
1871 
1872 
1873 //*************************************************************************************************
1884 template< typename Type // Data type of the vector
1885  , size_t N // Number of elements
1886  , bool TF > // Transpose flag
1887 template< typename VT > // Type of the right-hand side sparse vector
1889 {
1890  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1891 
1892  const StaticVector tmp( *this );
1893 
1894  reset();
1895 
1896  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1897  v_[element->index()] = tmp[element->index()] * element->value();
1898 }
1899 //*************************************************************************************************
1900 
1901 
1902 
1903 
1904 
1905 
1906 
1907 
1908 //=================================================================================================
1909 //
1910 // UNDEFINED CLASS TEMPLATE SPECIALIZATION
1911 //
1912 //=================================================================================================
1913 
1914 //*************************************************************************************************
1922 template< typename Type // Data type of the vector
1923  , bool TF > // Transpose flag
1924 class StaticVector<Type,0UL,TF>;
1926 //*************************************************************************************************
1927 
1928 
1929 
1930 
1931 
1932 
1933 
1934 
1935 //=================================================================================================
1936 //
1937 // STATICVECTOR OPERATORS
1938 //
1939 //=================================================================================================
1940 
1941 //*************************************************************************************************
1944 template< typename Type, size_t N, bool TF >
1945 inline void reset( StaticVector<Type,N,TF>& v );
1946 
1947 template< typename Type, size_t N, bool TF >
1948 inline void clear( StaticVector<Type,N,TF>& v );
1949 
1950 template< typename Type, size_t N, bool TF >
1951 inline bool isDefault( const StaticVector<Type,N,TF>& v );
1952 
1953 template< typename Type, bool TF >
1955 
1956 template< typename Type, bool TF >
1958 
1959 template< typename Type, size_t N, bool TF >
1960 inline void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) /* throw() */;
1962 //*************************************************************************************************
1963 
1964 
1965 //*************************************************************************************************
1972 template< typename Type // Data type of the vector
1973  , size_t N // Number of elements
1974  , bool TF > // Transpose flag
1976 {
1977  v.reset();
1978 }
1979 //*************************************************************************************************
1980 
1981 
1982 //*************************************************************************************************
1991 template< typename Type // Data type of the vector
1992  , size_t N // Number of elements
1993  , bool TF > // Transpose flag
1995 {
1996  v.reset();
1997 }
1998 //*************************************************************************************************
1999 
2000 
2001 //*************************************************************************************************
2019 template< typename Type // Data type of the vector
2020  , size_t N // Number of elements
2021  , bool TF > // Transpose flag
2022 inline bool isDefault( const StaticVector<Type,N,TF>& v )
2023 {
2024  for( size_t i=0UL; i<N; ++i )
2025  if( !isDefault( v[i] ) ) return false;
2026  return true;
2027 }
2028 //*************************************************************************************************
2029 
2030 
2031 //*************************************************************************************************
2042 template< typename Type // Data type of the vector
2043  , bool TF > // Transpose flag
2045 {
2046  return StaticVector<Type,2UL,TF>( -v[1UL], v[0UL] );
2047 }
2048 //*************************************************************************************************
2049 
2050 
2051 //*************************************************************************************************
2059 template< typename Type // Data type of the vector
2060  , bool TF > // Transpose flag
2062 {
2063  if( v[0] != Type() || v[1] != Type() )
2064  return StaticVector<Type,3UL,TF>( v[1UL], -v[0UL], Type() );
2065  else
2066  return StaticVector<Type,3UL,TF>( Type(), v[2UL], -v[1UL] );
2067 }
2068 //*************************************************************************************************
2069 
2070 
2071 //*************************************************************************************************
2080 template< typename Type // Data type of the vector
2081  , size_t N // Number of elements
2082  , bool TF > // Transpose flag
2083 inline void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) /* throw() */
2084 {
2085  a.swap( b );
2086 }
2087 //*************************************************************************************************
2088 
2089 
2090 
2091 
2092 //=================================================================================================
2093 //
2094 // ADDTRAIT SPECIALIZATIONS
2095 //
2096 //=================================================================================================
2097 
2098 //*************************************************************************************************
2100 template< typename T1, size_t N, bool TF, typename T2 >
2101 struct AddTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2102 {
2103  typedef StaticVector< typename AddTrait<T1,T2>::Type, N, TF > Type;
2104 };
2106 //*************************************************************************************************
2107 
2108 
2109 
2110 
2111 //=================================================================================================
2112 //
2113 // SUBTRAIT SPECIALIZATIONS
2114 //
2115 //=================================================================================================
2116 
2117 //*************************************************************************************************
2119 template< typename T1, size_t N, bool TF, typename T2 >
2120 struct SubTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2121 {
2122  typedef StaticVector< typename SubTrait<T1,T2>::Type, N, TF > Type;
2123 };
2125 //*************************************************************************************************
2126 
2127 
2128 
2129 
2130 //=================================================================================================
2131 //
2132 // MULTTRAIT SPECIALIZATIONS
2133 //
2134 //=================================================================================================
2135 
2136 //*************************************************************************************************
2138 template< typename T1, size_t N, bool TF, typename T2 >
2139 struct MultTrait< StaticVector<T1,N,TF>, T2 >
2140 {
2141  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2143 };
2144 
2145 template< typename T1, typename T2, size_t N, bool TF >
2146 struct MultTrait< T1, StaticVector<T2,N,TF> >
2147 {
2148  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2150 };
2151 
2152 template< typename T1, size_t N, bool TF, typename T2 >
2153 struct MultTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2154 {
2155  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2156 };
2157 
2158 template< typename T1, size_t M, typename T2, size_t N >
2159 struct MultTrait< StaticVector<T1,M,false>, StaticVector<T2,N,true> >
2160 {
2161  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, false > Type;
2162 };
2163 
2164 template< typename T1, size_t N, typename T2 >
2165 struct MultTrait< StaticVector<T1,N,true>, StaticVector<T2,N,false> >
2166 {
2167  typedef typename MultTrait<T1,T2>::Type Type;
2168 };
2170 //*************************************************************************************************
2171 
2172 
2173 
2174 
2175 //=================================================================================================
2176 //
2177 // CROSSTRAIT SPECIALIZATIONS
2178 //
2179 //=================================================================================================
2180 
2181 //*************************************************************************************************
2183 template< typename T1, typename T2 >
2184 struct CrossTrait< StaticVector<T1,3UL,false>, StaticVector<T2,3UL,false> >
2185 {
2186  private:
2187  typedef typename MultTrait<T1,T2>::Type T;
2188 
2189  public:
2190  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2191 };
2193 //*************************************************************************************************
2194 
2195 
2196 
2197 
2198 //=================================================================================================
2199 //
2200 // DIVTRAIT SPECIALIZATIONS
2201 //
2202 //=================================================================================================
2203 
2204 //*************************************************************************************************
2206 template< typename T1, size_t N, bool TF, typename T2 >
2207 struct DivTrait< StaticVector<T1,N,TF>, T2 >
2208 {
2209  typedef StaticVector< typename DivTrait<T1,T2>::Type, N, TF > Type;
2211 };
2213 //*************************************************************************************************
2214 
2215 
2216 
2217 
2218 //=================================================================================================
2219 //
2220 // MATHTRAIT SPECIALIZATIONS
2221 //
2222 //=================================================================================================
2223 
2224 //*************************************************************************************************
2226 template< typename T1, size_t N, bool TF, typename T2 >
2227 struct MathTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2228 {
2229  typedef StaticVector< typename MathTrait<T1,T2>::HighType, N, TF > HighType;
2230  typedef StaticVector< typename MathTrait<T1,T2>::LowType , N, TF > LowType;
2231 };
2233 //*************************************************************************************************
2234 
2235 
2236 
2237 
2238 //=================================================================================================
2239 //
2240 // SUBVECTORTRAIT SPECIALIZATIONS
2241 //
2242 //=================================================================================================
2243 
2244 //*************************************************************************************************
2246 template< typename T1, size_t N, bool TF >
2247 struct SubvectorTrait< StaticVector<T1,N,TF> >
2248 {
2249  typedef HybridVector<T1,N,TF> Type;
2250 };
2252 //*************************************************************************************************
2253 
2254 } // namespace blaze
2255 
2256 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:107
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:1426
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.
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4512
#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 >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
Header file for the subtraction trait.
Header file for the SparseVector base class.
Iterator end()
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:909
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: StaticVector.h:385
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4555
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 storeu(float *address, const sse_float_t &value)
Unaligned store of a vector of &#39;float&#39; values.
Definition: Storeu.h:234
Header file for the DenseVector base class.
StaticVector< Type, N,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: StaticVector.h:172
#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
Type & Reference
Reference to a non-constant vector value.
Definition: StaticVector.h:177
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: StaticVector.h:1289
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4528
Constraint on the data type.
Efficient implementation of a fixed-sized vector.The StaticVector class template is the representatio...
Definition: Forward.h:51
void stream(float *address, const sse_float_t &value)
Aligned, non-temporal store of a vector of &#39;float&#39; values.
Definition: Stream.h:233
Header file for the DisableIf class template.
size_t capacity() const
Returns the maximum capacity of the vector.
Definition: StaticVector.h:1271
bool canAlias(const Other *alias) const
Returns whether the vector can alias with the given address alias.
Definition: StaticVector.h:1381
void swap(StaticVector &v)
Swapping the contents of two static vectors.
Definition: StaticVector.h:1349
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:4541
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
#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:179
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:171
void reset()
Reset to the default initial values.
Definition: StaticVector.h:1311
#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:894
Reference operator[](size_t index)
Subscript operator for the direct access to the vector elements.
Definition: StaticVector.h:794
IT::Type IntrinsicType
Intrinsic type of the vector elements.
Definition: StaticVector.h:174
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:2044
void store(size_t index, const IntrinsicType &value)
Aligned store of an intrinsic element of the vector.
Definition: StaticVector.h:1489
Header file for the EnableIf class template.
Header file for the IsVectorizable type trait.
ColumnIterator< const MT > ConstIterator
Iterator over constant elements.
Definition: DenseColumn.h:1972
Header file for the IsNumeric type trait.
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: StaticVector.h:179
Header file for the IsSparseVector type trait.
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:648
StaticVector()
The default constructor for StaticVector.
Definition: StaticVector.h:424
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:4584
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:209
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticVector.h:175
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:178
#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:864
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:239
#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:2378
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:1402
const StaticVector & CompositeType
Data type for composite expression templates.
Definition: StaticVector.h:176
StaticVector< Type, N, TF > This
Type of this StaticVector instance.
Definition: StaticVector.h:170
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:1552
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:180
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:1256
IntrinsicTrait< Type > IT
Intrinsic trait for the vector element type.
Definition: StaticVector.h:160
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:105
Header file for basic type definitions.
ConstIterator cend() const
Returns an iterator just past the last element of the static vector.
Definition: StaticVector.h:939
SelectType< useConst, ConstIterator, ColumnIterator< MT > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseColumn.h:1980
IntrinsicType loadu(size_t index) const
Unaligned load of an intrinsic element of the vector.
Definition: StaticVector.h:1458
#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 * data()
Low-level data access to the vector elements.
Definition: StaticVector.h:832
Type ElementType
Type of the vector elements.
Definition: StaticVector.h:173
#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 store(float *address, const sse_float_t &value)
Aligned store of a vector of &#39;float&#39; values.
Definition: Store.h:242
void storeu(size_t index, const IntrinsicType &value)
Unaligned store of an intrinsic element of the vector.
Definition: StaticVector.h:1521