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 //*************************************************************************************************
175 template< typename Type // Data type of the vector
176  , size_t N // Number of elements
177  , bool TF = defaultTransposeFlag > // Transpose flag
178 class StaticVector : public DenseVector< StaticVector<Type,N,TF>, TF >
179 {
180  private:
181  //**Type definitions****************************************************************************
183  //**********************************************************************************************
184 
185  //**********************************************************************************************
187  enum { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size };
188  //**********************************************************************************************
189 
190  public:
191  //**Type definitions****************************************************************************
193  typedef This ResultType;
195  typedef Type ElementType;
196  typedef typename IT::Type IntrinsicType;
197  typedef const Type& ReturnType;
198  typedef const StaticVector& CompositeType;
199  typedef Type& Reference;
200  typedef const Type& ConstReference;
203  //**********************************************************************************************
204 
205  //**Compilation flags***************************************************************************
207 
211  enum { vectorizable = IsVectorizable<Type>::value };
212 
214 
217  enum { smpAssignable = 0 };
218  //**********************************************************************************************
219 
220  //**Constructors********************************************************************************
223  explicit inline StaticVector();
224  explicit inline StaticVector( const Type& init );
225  template< typename Other > explicit inline StaticVector( size_t n, const Other* array );
226 
227  template< typename Other >
228  explicit inline StaticVector( const Other (&array)[N] );
229 
230  inline StaticVector( const StaticVector& v );
231  template< typename Other > inline StaticVector( const StaticVector<Other,N,TF>& v );
232  template< typename VT > inline StaticVector( const Vector<VT,TF>& v );
233 
234  inline StaticVector( const Type& v1, const Type& v2 );
235  inline StaticVector( const Type& v1, const Type& v2, const Type& v3 );
236  inline StaticVector( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
237  inline StaticVector( const Type& v1, const Type& v2, const Type& v3,
238  const Type& v4, const Type& v5 );
239  inline StaticVector( const Type& v1, const Type& v2, const Type& v3,
240  const Type& v4, const Type& v5, const Type& v6 );
242  //**********************************************************************************************
243 
244  //**Destructor**********************************************************************************
245  // No explicitly declared destructor.
246  //**********************************************************************************************
247 
248  //**Data access functions***********************************************************************
251  inline Reference operator[]( size_t index );
252  inline ConstReference operator[]( size_t index ) const;
253  inline Type* data ();
254  inline const Type* data () const;
255  inline Iterator begin ();
256  inline ConstIterator begin () const;
257  inline ConstIterator cbegin() const;
258  inline Iterator end ();
259  inline ConstIterator end () const;
260  inline ConstIterator cend () const;
262  //**********************************************************************************************
263 
264  //**Assignment operators************************************************************************
267  template< typename Other >
268  inline StaticVector& operator=( const Other (&array)[N] );
269 
270  inline StaticVector& operator= ( const Type& rhs );
271  inline StaticVector& operator= ( const StaticVector& rhs );
272  template< typename Other > inline StaticVector& operator= ( const StaticVector<Other,N,TF>& rhs );
273  template< typename VT > inline StaticVector& operator= ( const Vector<VT,TF>& rhs );
274  template< typename VT > inline StaticVector& operator+=( const Vector<VT,TF>& rhs );
275  template< typename VT > inline StaticVector& operator-=( const Vector<VT,TF>& rhs );
276  template< typename VT > inline StaticVector& operator*=( const Vector<VT,TF>& rhs );
277 
278  template< typename Other >
279  inline typename EnableIf< IsNumeric<Other>, StaticVector >::Type&
280  operator*=( Other rhs );
281 
282  template< typename Other >
283  inline typename EnableIf< IsNumeric<Other>, StaticVector >::Type&
284  operator/=( Other rhs );
286  //**********************************************************************************************
287 
288  //**Utility functions***************************************************************************
291  inline size_t size() const;
292  inline size_t capacity() const;
293  inline size_t nonZeros() const;
294  inline void reset();
295  template< typename Other > inline StaticVector& scale( Other scalar );
296  inline void swap( StaticVector& v ) /* throw() */;
298  //**********************************************************************************************
299 
300  private:
301  //**********************************************************************************************
303  template< typename VT >
305  struct VectorizedAssign {
306  enum { value = vectorizable && VT::vectorizable &&
307  IsSame<Type,typename VT::ElementType>::value };
308  };
310  //**********************************************************************************************
311 
312  //**********************************************************************************************
314  template< typename VT >
316  struct VectorizedAddAssign {
317  enum { value = vectorizable && VT::vectorizable &&
318  IsSame<Type,typename VT::ElementType>::value &&
319  IntrinsicTrait<Type>::addition };
320  };
322  //**********************************************************************************************
323 
324  //**********************************************************************************************
326  template< typename VT >
328  struct VectorizedSubAssign {
329  enum { value = vectorizable && VT::vectorizable &&
330  IsSame<Type,typename VT::ElementType>::value &&
331  IntrinsicTrait<Type>::subtraction };
332  };
334  //**********************************************************************************************
335 
336  //**********************************************************************************************
338  template< typename VT >
340  struct VectorizedMultAssign {
341  enum { value = vectorizable && VT::vectorizable &&
342  IsSame<Type,typename VT::ElementType>::value &&
343  IntrinsicTrait<Type>::multiplication };
344  };
346  //**********************************************************************************************
347 
348  public:
349  //**Expression template evaluation functions****************************************************
352  template< typename Other > inline bool canAlias ( const Other* alias ) const;
353  template< typename Other > inline bool isAliased( const Other* alias ) const;
354 
355  inline bool isAligned() const;
356 
357  inline IntrinsicType load ( size_t index ) const;
358  inline IntrinsicType loadu ( size_t index ) const;
359  inline void store ( size_t index, const IntrinsicType& value );
360  inline void storeu( size_t index, const IntrinsicType& value );
361  inline void stream( size_t index, const IntrinsicType& value );
362 
363  template< typename VT >
364  inline typename DisableIf< VectorizedAssign<VT> >::Type
365  assign( const DenseVector<VT,TF>& rhs );
366 
367  template< typename VT >
368  inline typename EnableIf< VectorizedAssign<VT> >::Type
369  assign( const DenseVector<VT,TF>& rhs );
370 
371  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
372 
373  template< typename VT >
374  inline typename DisableIf< VectorizedAddAssign<VT> >::Type
375  addAssign( const DenseVector<VT,TF>& rhs );
376 
377  template< typename VT >
378  inline typename EnableIf< VectorizedAddAssign<VT> >::Type
379  addAssign( const DenseVector<VT,TF>& rhs );
380 
381  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
382 
383  template< typename VT >
384  inline typename DisableIf< VectorizedSubAssign<VT> >::Type
385  subAssign( const DenseVector<VT,TF>& rhs );
386 
387  template< typename VT >
388  inline typename EnableIf< VectorizedSubAssign<VT> >::Type
389  subAssign( const DenseVector<VT,TF>& rhs );
390 
391  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
392 
393  template< typename VT >
394  inline typename DisableIf< VectorizedMultAssign<VT> >::Type
395  multAssign( const DenseVector<VT,TF>& rhs );
396 
397  template< typename VT >
398  inline typename EnableIf< VectorizedMultAssign<VT> >::Type
399  multAssign( const DenseVector<VT,TF>& rhs );
400 
401  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
403  //**********************************************************************************************
404 
405  private:
406  //**Member variables****************************************************************************
410 
416  //**********************************************************************************************
417 
418  //**Compile time checks*************************************************************************
424  BLAZE_STATIC_ASSERT( NN % IT::size == 0UL );
425  BLAZE_STATIC_ASSERT( NN >= N );
427  //**********************************************************************************************
428 };
429 //*************************************************************************************************
430 
431 
432 
433 
434 //=================================================================================================
435 //
436 // CONSTRUCTORS
437 //
438 //=================================================================================================
439 
440 //*************************************************************************************************
445 template< typename Type // Data type of the vector
446  , size_t N // Number of elements
447  , bool TF > // Transpose flag
449 {
450  if( IsNumeric<Type>::value ) {
451  for( size_t i=0UL; i<NN; ++i )
452  v_[i] = Type();
453  }
454 }
455 //*************************************************************************************************
456 
457 
458 //*************************************************************************************************
463 template< typename Type // Data type of the vector
464  , size_t N // Number of elements
465  , bool TF > // Transpose flag
466 inline StaticVector<Type,N,TF>::StaticVector( const Type& init )
467 {
468  for( size_t i=0UL; i<N; ++i )
469  v_[i] = init;
470 
471  if( IsNumeric<Type>::value ) {
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 {
507  if( n > N )
508  throw std::invalid_argument( "Invalid setup of static vector" );
509 
510  for( size_t i=0UL; i<n; ++i )
511  v_[i] = array[i];
512 
513  if( IsNumeric<Type>::value ) {
514  for( size_t i=n; i<NN; ++i )
515  v_[i] = Type();
516  }
517 }
518 //*************************************************************************************************
519 
520 
521 //*************************************************************************************************
537 template< typename Type // Data type of the vector
538  , size_t N // Number of elements
539  , bool TF > // Transpose flag
540 template< typename Other > // Data type of the initialization array
541 inline StaticVector<Type,N,TF>::StaticVector( const Other (&array)[N] )
542 {
543  for( size_t i=0UL; i<N; ++i )
544  v_[i] = array[i];
545 
546  if( IsNumeric<Type>::value ) {
547  for( size_t i=N; i<NN; ++i )
548  v_[i] = Type();
549  }
550 }
551 //*************************************************************************************************
552 
553 
554 //*************************************************************************************************
561 template< typename Type // Data type of the vector
562  , size_t N // Number of elements
563  , bool TF > // Transpose flag
565 {
566  for( size_t i=0UL; i<NN; ++i )
567  v_[i] = v.v_[i];
568 }
569 //*************************************************************************************************
570 
571 
572 //*************************************************************************************************
577 template< typename Type // Data type of the vector
578  , size_t N // Number of elements
579  , bool TF > // Transpose flag
580 template< typename Other > // Data type of the foreign vector
582 {
583  for( size_t i=0UL; i<N; ++i )
584  v_[i] = v[i];
585 
586  if( IsNumeric<Type>::value ) {
587  for( size_t i=N; i<NN; ++i )
588  v_[i] = Type();
589  }
590 }
591 //*************************************************************************************************
592 
593 
594 //*************************************************************************************************
604 template< typename Type // Data type of the vector
605  , size_t N // Number of elements
606  , bool TF > // Transpose flag
607 template< typename VT > // Type of the foreign vector
609 {
610  using blaze::assign;
611 
612  if( (~v).size() != N )
613  throw std::invalid_argument( "Invalid setup of static vector" );
614 
615  if( IsNumeric<Type>::value ) {
616  for( size_t i=( IsSparseVector<VT>::value )?( 0UL ):( N ); i<NN; ++i )
617  v_[i] = Type();
618  }
619 
620  assign( *this, ~v );
621 }
622 //*************************************************************************************************
623 
624 
625 //*************************************************************************************************
637 template< typename Type // Data type of the vector
638  , size_t N // Number of elements
639  , bool TF > // Transpose flag
640 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2 )
641 {
642  BLAZE_STATIC_ASSERT( N == 2UL );
643 
644  v_[0] = v1;
645  v_[1] = v2;
646 
647  if( IsNumeric<Type>::value ) {
648  for( size_t i=N; i<NN; ++i )
649  v_[i] = Type();
650  }
651 }
652 //*************************************************************************************************
653 
654 
655 //*************************************************************************************************
668 template< typename Type // Data type of the vector
669  , size_t N // Number of elements
670  , bool TF > // Transpose flag
671 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2, const Type& v3 )
672 {
673  BLAZE_STATIC_ASSERT( N == 3UL );
674 
675  v_[0] = v1;
676  v_[1] = v2;
677  v_[2] = v3;
678 
679  if( IsNumeric<Type>::value ) {
680  for( size_t i=N; i<NN; ++i )
681  v_[i] = Type();
682  }
683 }
684 //*************************************************************************************************
685 
686 
687 //*************************************************************************************************
701 template< typename Type // Data type of the vector
702  , size_t N // Number of elements
703  , bool TF > // Transpose flag
704 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2,
705  const Type& v3, const Type& v4 )
706 {
707  BLAZE_STATIC_ASSERT( N == 4UL );
708 
709  v_[0] = v1;
710  v_[1] = v2;
711  v_[2] = v3;
712  v_[3] = v4;
713 
714  if( IsNumeric<Type>::value ) {
715  for( size_t i=N; i<NN; ++i )
716  v_[i] = Type();
717  }
718 }
719 //*************************************************************************************************
720 
721 
722 //*************************************************************************************************
737 template< typename Type // Data type of the vector
738  , size_t N // Number of elements
739  , bool TF > // Transpose flag
740 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2, const Type& v3,
741  const Type& v4, const Type& v5 )
742 {
743  BLAZE_STATIC_ASSERT( N == 5UL );
744 
745  v_[0] = v1;
746  v_[1] = v2;
747  v_[2] = v3;
748  v_[3] = v4;
749  v_[4] = v5;
750 
751  if( IsNumeric<Type>::value ) {
752  for( size_t i=N; i<NN; ++i )
753  v_[i] = Type();
754  }
755 }
756 //*************************************************************************************************
757 
758 
759 //*************************************************************************************************
775 template< typename Type // Data type of the vector
776  , size_t N // Number of elements
777  , bool TF > // Transpose flag
778 inline StaticVector<Type,N,TF>::StaticVector( const Type& v1, const Type& v2, const Type& v3,
779  const Type& v4, const Type& v5, const Type& v6 )
780 {
781  BLAZE_STATIC_ASSERT( N == 6UL );
782 
783  v_[0] = v1;
784  v_[1] = v2;
785  v_[2] = v3;
786  v_[3] = v4;
787  v_[4] = v5;
788  v_[5] = v6;
789 
790  if( IsNumeric<Type>::value ) {
791  for( size_t i=N; i<NN; ++i )
792  v_[i] = Type();
793  }
794 }
795 //*************************************************************************************************
796 
797 
798 
799 
800 //=================================================================================================
801 //
802 // DATA ACCESS FUNCTIONS
803 //
804 //=================================================================================================
805 
806 //*************************************************************************************************
814 template< typename Type // Data type of the vector
815  , size_t N // Number of elements
816  , bool TF > // Transpose flag
819 {
820  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
821  return v_[index];
822 }
823 //*************************************************************************************************
824 
825 
826 //*************************************************************************************************
834 template< typename Type // Data type of the vector
835  , size_t N // Number of elements
836  , bool TF > // Transpose flag
839 {
840  BLAZE_USER_ASSERT( index < N, "Invalid vector access index" );
841  return v_[index];
842 }
843 //*************************************************************************************************
844 
845 
846 //*************************************************************************************************
853 template< typename Type // Data type of the vector
854  , size_t N // Number of elements
855  , bool TF > // Transpose flag
857 {
858  return v_;
859 }
860 //*************************************************************************************************
861 
862 
863 //*************************************************************************************************
870 template< typename Type // Data type of the vector
871  , size_t N // Number of elements
872  , bool TF > // Transpose flag
873 inline const Type* StaticVector<Type,N,TF>::data() const
874 {
875  return v_;
876 }
877 //*************************************************************************************************
878 
879 
880 //*************************************************************************************************
885 template< typename Type // Data type of the vector
886  , size_t N // Number of elements
887  , bool TF > // Transpose flag
889 {
890  return Iterator( v_ );
891 }
892 //*************************************************************************************************
893 
894 
895 //*************************************************************************************************
900 template< typename Type // Data type of the vector
901  , size_t N // Number of elements
902  , bool TF > // Transpose flag
904 {
905  return ConstIterator( v_ );
906 }
907 //*************************************************************************************************
908 
909 
910 //*************************************************************************************************
915 template< typename Type // Data type of the vector
916  , size_t N // Number of elements
917  , bool TF > // Transpose flag
919 {
920  return ConstIterator( v_ );
921 }
922 //*************************************************************************************************
923 
924 
925 //*************************************************************************************************
930 template< typename Type // Data type of the vector
931  , size_t N // Number of elements
932  , bool TF > // Transpose flag
934 {
935  return Iterator( v_ + N );
936 }
937 //*************************************************************************************************
938 
939 
940 //*************************************************************************************************
945 template< typename Type // Data type of the vector
946  , size_t N // Number of elements
947  , bool TF > // Transpose flag
949 {
950  return ConstIterator( v_ + N );
951 }
952 //*************************************************************************************************
953 
954 
955 //*************************************************************************************************
960 template< typename Type // Data type of the vector
961  , size_t N // Number of elements
962  , bool TF > // Transpose flag
964 {
965  return ConstIterator( v_ + N );
966 }
967 //*************************************************************************************************
968 
969 
970 
971 
972 //=================================================================================================
973 //
974 // ASSIGNMENT OPERATORS
975 //
976 //=================================================================================================
977 
978 //*************************************************************************************************
995 template< typename Type // Data type of the vector
996  , size_t N // Number of elements
997  , bool TF > // Transpose flag
998 template< typename Other > // Data type of the initialization array
1000 {
1001  for( size_t i=0UL; i<N; ++i )
1002  v_[i] = array[i];
1003  return *this;
1004 }
1005 //*************************************************************************************************
1006 
1007 
1008 //*************************************************************************************************
1014 template< typename Type // Data type of the vector
1015  , size_t N // Number of elements
1016  , bool TF > // Transpose flag
1018 {
1019  for( size_t i=0UL; i<N; ++i )
1020  v_[i] = rhs;
1021  return *this;
1022 }
1023 //*************************************************************************************************
1024 
1025 
1026 //*************************************************************************************************
1034 template< typename Type // Data type of the vector
1035  , size_t N // Number of elements
1036  , bool TF > // Transpose flag
1038 {
1039  using blaze::assign;
1040 
1041  assign( *this, ~rhs );
1042  return *this;
1043 }
1044 //*************************************************************************************************
1045 
1046 
1047 //*************************************************************************************************
1053 template< typename Type // Data type of the vector
1054  , size_t N // Number of elements
1055  , bool TF > // Transpose flag
1056 template< typename Other > // Data type of the foreign vector
1058 {
1059  using blaze::assign;
1060 
1061  assign( *this, ~rhs );
1062  return *this;
1063 }
1064 //*************************************************************************************************
1065 
1066 
1067 //*************************************************************************************************
1077 template< typename Type // Data type of the vector
1078  , size_t N // Number of elements
1079  , bool TF > // Transpose flag
1080 template< typename VT > // Type of the right-hand side vector
1082 {
1083  using blaze::assign;
1084 
1085  if( (~rhs).size() != N )
1086  throw std::invalid_argument( "Invalid assignment to static vector" );
1087 
1088  if( (~rhs).canAlias( this ) ) {
1089  StaticVector tmp( ~rhs );
1090  swap( tmp );
1091  }
1092  else {
1094  reset();
1095  assign( *this, ~rhs );
1096  }
1097 
1098  return *this;
1099 }
1100 //*************************************************************************************************
1101 
1102 
1103 //*************************************************************************************************
1113 template< typename Type // Data type of the vector
1114  , size_t N // Number of elements
1115  , bool TF > // Transpose flag
1116 template< typename VT > // Type of the right-hand side vector
1118 {
1119  using blaze::addAssign;
1120 
1121  if( (~rhs).size() != N )
1122  throw std::invalid_argument( "Vector sizes do not match" );
1123 
1124  if( (~rhs).canAlias( this ) ) {
1125  StaticVector tmp( ~rhs );
1126  addAssign( *this, tmp );
1127  }
1128  else {
1129  addAssign( *this, ~rhs );
1130  }
1131 
1132  return *this;
1133 }
1134 //*************************************************************************************************
1135 
1136 
1137 //*************************************************************************************************
1147 template< typename Type // Data type of the vector
1148  , size_t N // Number of elements
1149  , bool TF > // Transpose flag
1150 template< typename VT > // Type of the right-hand side vector
1152 {
1153  using blaze::subAssign;
1154 
1155  if( (~rhs).size() != N )
1156  throw std::invalid_argument( "Vector sizes do not match" );
1157 
1158  if( (~rhs).canAlias( this ) ) {
1159  StaticVector tmp( ~rhs );
1160  subAssign( *this, tmp );
1161  }
1162  else {
1163  subAssign( *this, ~rhs );
1164  }
1165 
1166  return *this;
1167 }
1168 //*************************************************************************************************
1169 
1170 
1171 //*************************************************************************************************
1182 template< typename Type // Data type of the vector
1183  , size_t N // Number of elements
1184  , bool TF > // Transpose flag
1185 template< typename VT > // Type of the right-hand side vector
1187 {
1188  using blaze::assign;
1189 
1190  if( (~rhs).size() != N )
1191  throw std::invalid_argument( "Vector sizes do not match" );
1192 
1193  if( (~rhs).canAlias( this ) || IsSparseVector<VT>::value ) {
1194  StaticVector tmp( *this * (~rhs) );
1195  this->operator=( tmp );
1196  }
1197  else {
1198  assign( *this, *this * (~rhs) );
1199  }
1200 
1201  return *this;
1202 }
1203 //*************************************************************************************************
1204 
1205 
1206 //*************************************************************************************************
1213 template< typename Type // Data type of the vector
1214  , size_t N // Number of elements
1215  , bool TF > // Transpose flag
1216 template< typename Other > // Data type of the right-hand side scalar
1217 inline typename EnableIf< IsNumeric<Other>, StaticVector<Type,N,TF> >::Type&
1219 {
1220  using blaze::assign;
1221 
1222  assign( *this, (*this) * rhs );
1223  return *this;
1224 }
1225 //*************************************************************************************************
1226 
1227 
1228 //*************************************************************************************************
1237 template< typename Type // Data type of the vector
1238  , size_t N // Number of elements
1239  , bool TF > // Transpose flag
1240 template< typename Other > // Data type of the right-hand side scalar
1241 inline typename EnableIf< IsNumeric<Other>, StaticVector<Type,N,TF> >::Type&
1243 {
1244  using blaze::assign;
1245 
1246  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1247 
1248  assign( *this, (*this) / rhs );
1249  return *this;
1250 }
1251 //*************************************************************************************************
1252 
1253 
1254 
1255 
1256 //=================================================================================================
1257 //
1258 // UTILITY FUNCTIONS
1259 //
1260 //=================================================================================================
1261 
1262 //*************************************************************************************************
1267 template< typename Type // Data type of the vector
1268  , size_t N // Number of elements
1269  , bool TF > // Transpose flag
1270 inline size_t StaticVector<Type,N,TF>::size() const
1271 {
1272  return N;
1273 }
1274 //*************************************************************************************************
1275 
1276 
1277 //*************************************************************************************************
1282 template< typename Type // Data type of the vector
1283  , size_t N // Number of elements
1284  , bool TF > // Transpose flag
1286 {
1287  return NN;
1288 }
1289 //*************************************************************************************************
1290 
1291 
1292 //*************************************************************************************************
1300 template< typename Type // Data type of the vector
1301  , size_t N // Number of elements
1302  , bool TF > // Transpose flag
1304 {
1305  size_t nonzeros( 0 );
1306 
1307  for( size_t i=0UL; i<N; ++i ) {
1308  if( !isDefault( v_[i] ) )
1309  ++nonzeros;
1310  }
1311 
1312  return nonzeros;
1313 }
1314 //*************************************************************************************************
1315 
1316 
1317 //*************************************************************************************************
1322 template< typename Type // Data type of the vector
1323  , size_t N // Number of elements
1324  , bool TF > // Transpose flag
1326 {
1327  using blaze::reset;
1328  for( size_t i=0UL; i<N; ++i )
1329  reset( v_[i] );
1330 }
1331 //*************************************************************************************************
1332 
1333 
1334 //*************************************************************************************************
1340 template< typename Type // Data type of the vector
1341  , size_t N // Number of elements
1342  , bool TF > // Transpose flag
1343 template< typename Other > // Data type of the scalar value
1345 {
1346  for( size_t i=0; i<N; ++i )
1347  v_[i] *= scalar;
1348  return *this;
1349 }
1350 //*************************************************************************************************
1351 
1352 
1353 //*************************************************************************************************
1360 template< typename Type // Data type of the vector
1361  , size_t N // Number of elements
1362  , bool TF > // Transpose flag
1363 inline void StaticVector<Type,N,TF>::swap( StaticVector& v ) /* throw() */
1364 {
1365  using std::swap;
1366 
1367  for( size_t i=0UL; i<N; ++i )
1368  swap( v_[i], v.v_[i] );
1369 }
1370 //*************************************************************************************************
1371 
1372 
1373 
1374 
1375 //=================================================================================================
1376 //
1377 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1378 //
1379 //=================================================================================================
1380 
1381 //*************************************************************************************************
1391 template< typename Type // Data type of the vector
1392  , size_t N // Number of elements
1393  , bool TF > // Transpose flag
1394 template< typename Other > // Data type of the foreign expression
1395 inline bool StaticVector<Type,N,TF>::canAlias( const Other* alias ) const
1396 {
1397  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1398 }
1399 //*************************************************************************************************
1400 
1401 
1402 //*************************************************************************************************
1412 template< typename Type // Data type of the vector
1413  , size_t N // Number of elements
1414  , bool TF > // Transpose flag
1415 template< typename Other > // Data type of the foreign expression
1416 inline bool StaticVector<Type,N,TF>::isAliased( const Other* alias ) const
1417 {
1418  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1419 }
1420 //*************************************************************************************************
1421 
1422 
1423 //*************************************************************************************************
1432 template< typename Type // Data type of the vector
1433  , size_t N // Number of elements
1434  , bool TF > // Transpose flag
1436 {
1437  return true;
1438 }
1439 //*************************************************************************************************
1440 
1441 
1442 //*************************************************************************************************
1455 template< typename Type // Data type of the vector
1456  , size_t N // Number of elements
1457  , bool TF > // Transpose flag
1459  StaticVector<Type,N,TF>::load( size_t index ) const
1460 {
1461  using blaze::load;
1462 
1464 
1465  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1466  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1467  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
1468 
1469  return load( &v_[index] );
1470 }
1471 //*************************************************************************************************
1472 
1473 
1474 //*************************************************************************************************
1487 template< typename Type // Data type of the vector
1488  , size_t N // Number of elements
1489  , bool TF > // Transpose flag
1491  StaticVector<Type,N,TF>::loadu( size_t index ) const
1492 {
1493  using blaze::loadu;
1494 
1496 
1497  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1498  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1499 
1500  return loadu( &v_[index] );
1501 }
1502 //*************************************************************************************************
1503 
1504 
1505 //*************************************************************************************************
1519 template< typename Type // Data type of the vector
1520  , size_t N // Number of elements
1521  , bool TF > // Transpose flag
1522 inline void StaticVector<Type,N,TF>::store( size_t index, const IntrinsicType& value )
1523 {
1524  using blaze::store;
1525 
1527 
1528  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1529  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1530  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
1531 
1532  store( &v_[index], value );
1533 }
1534 //*************************************************************************************************
1535 
1536 
1537 //*************************************************************************************************
1551 template< typename Type // Data type of the vector
1552  , size_t N // Number of elements
1553  , bool TF > // Transpose flag
1554 inline void StaticVector<Type,N,TF>::storeu( size_t index, const IntrinsicType& value )
1555 {
1556  using blaze::storeu;
1557 
1559 
1560  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1561  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN, "Invalid vector access index" );
1562 
1563  storeu( &v_[index], value );
1564 }
1565 //*************************************************************************************************
1566 
1567 
1568 //*************************************************************************************************
1582 template< typename Type // Data type of the vector
1583  , size_t N // Number of elements
1584  , bool TF > // Transpose flag
1585 inline void StaticVector<Type,N,TF>::stream( size_t index, const IntrinsicType& value )
1586 {
1587  using blaze::stream;
1588 
1590 
1591  BLAZE_INTERNAL_ASSERT( index < N , "Invalid vector access index" );
1592  BLAZE_INTERNAL_ASSERT( index + IT::size <= NN , "Invalid vector access index" );
1593  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
1594 
1595  stream( &v_[index], value );
1596 }
1597 //*************************************************************************************************
1598 
1599 
1600 //*************************************************************************************************
1611 template< typename Type // Data type of the vector
1612  , size_t N // Number of elements
1613  , bool TF > // Transpose flag
1614 template< typename VT > // Type of the right-hand side dense vector
1615 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1617 {
1618  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1619 
1620  for( size_t i=0UL; i<N; ++i )
1621  v_[i] = (~rhs)[i];
1622 }
1623 //*************************************************************************************************
1624 
1625 
1626 //*************************************************************************************************
1637 template< typename Type // Data type of the vector
1638  , size_t N // Number of elements
1639  , bool TF > // Transpose flag
1640 template< typename VT > // Type of the right-hand side dense vector
1641 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1643 {
1644  using blaze::store;
1645 
1646  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1647 
1649 
1650  for( size_t i=0UL; i<N; i+=IT::size ) {
1651  store( v_+i, (~rhs).load(i) );
1652  }
1653 }
1654 //*************************************************************************************************
1655 
1656 
1657 //*************************************************************************************************
1668 template< typename Type // Data type of the vector
1669  , size_t N // Number of elements
1670  , bool TF > // Transpose flag
1671 template< typename VT > // Type of the right-hand side sparse vector
1673 {
1674  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1675 
1676  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1677  v_[element->index()] = element->value();
1678 }
1679 //*************************************************************************************************
1680 
1681 
1682 //*************************************************************************************************
1693 template< typename Type // Data type of the vector
1694  , size_t N // Number of elements
1695  , bool TF > // Transpose flag
1696 template< typename VT > // Type of the right-hand side dense vector
1697 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1699 {
1700  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1701 
1702  for( size_t i=0UL; i<N; ++i )
1703  v_[i] += (~rhs)[i];
1704 }
1705 //*************************************************************************************************
1706 
1707 
1708 //*************************************************************************************************
1719 template< typename Type // Data type of the vector
1720  , size_t N // Number of elements
1721  , bool TF > // Transpose flag
1722 template< typename VT > // Type of the right-hand side dense vector
1723 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1725 {
1726  using blaze::load;
1727  using blaze::store;
1728 
1729  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1730 
1732 
1733  for( size_t i=0UL; i<N; i+=IT::size ) {
1734  store( v_+i, load( v_+i ) + (~rhs).load(i) );
1735  }
1736 }
1737 //*************************************************************************************************
1738 
1739 
1740 //*************************************************************************************************
1751 template< typename Type // Data type of the vector
1752  , size_t N // Number of elements
1753  , bool TF > // Transpose flag
1754 template< typename VT > // Type of the right-hand side sparse vector
1756 {
1757  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1758 
1759  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1760  v_[element->index()] += element->value();
1761 }
1762 //*************************************************************************************************
1763 
1764 
1765 //*************************************************************************************************
1776 template< typename Type // Data type of the vector
1777  , size_t N // Number of elements
1778  , bool TF > // Transpose flag
1779 template< typename VT > // Type of the right-hand side dense vector
1780 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1782 {
1783  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1784 
1785  for( size_t i=0UL; i<N; ++i )
1786  v_[i] -= (~rhs)[i];
1787 }
1788 //*************************************************************************************************
1789 
1790 
1791 //*************************************************************************************************
1802 template< typename Type // Data type of the vector
1803  , size_t N // Number of elements
1804  , bool TF > // Transpose flag
1805 template< typename VT > // Type of the right-hand side dense vector
1806 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1808 {
1809  using blaze::load;
1810  using blaze::store;
1811 
1812  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1813 
1815 
1816  for( size_t i=0UL; i<N; i+=IT::size ) {
1817  store( v_+i, load( v_+i ) - (~rhs).load(i) );
1818  }
1819 }
1820 //*************************************************************************************************
1821 
1822 
1823 //*************************************************************************************************
1834 template< typename Type // Data type of the vector
1835  , size_t N // Number of elements
1836  , bool TF > // Transpose flag
1837 template< typename VT > // Type of the right-hand side sparse vector
1839 {
1840  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1841 
1842  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1843  v_[element->index()] -= element->value();
1844 }
1845 //*************************************************************************************************
1846 
1847 
1848 //*************************************************************************************************
1859 template< typename Type // Data type of the vector
1860  , size_t N // Number of elements
1861  , bool TF > // Transpose flag
1862 template< typename VT > // Type of the right-hand side dense vector
1863 inline typename DisableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1865 {
1866  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1867 
1868  for( size_t i=0UL; i<N; ++i )
1869  v_[i] *= (~rhs)[i];
1870 }
1871 //*************************************************************************************************
1872 
1873 
1874 //*************************************************************************************************
1885 template< typename Type // Data type of the vector
1886  , size_t N // Number of elements
1887  , bool TF > // Transpose flag
1888 template< typename VT > // Type of the right-hand side dense vector
1889 inline typename EnableIf< typename StaticVector<Type,N,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1891 {
1892  using blaze::load;
1893  using blaze::store;
1894 
1895  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1896 
1898 
1899  for( size_t i=0UL; i<N; i+=IT::size ) {
1900  store( v_+i, load( v_+i ) * (~rhs).load(i) );
1901  }
1902 }
1903 //*************************************************************************************************
1904 
1905 
1906 //*************************************************************************************************
1917 template< typename Type // Data type of the vector
1918  , size_t N // Number of elements
1919  , bool TF > // Transpose flag
1920 template< typename VT > // Type of the right-hand side sparse vector
1922 {
1923  BLAZE_INTERNAL_ASSERT( (~rhs).size() == N, "Invalid vector sizes" );
1924 
1925  const StaticVector tmp( *this );
1926 
1927  reset();
1928 
1929  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1930  v_[element->index()] = tmp[element->index()] * element->value();
1931 }
1932 //*************************************************************************************************
1933 
1934 
1935 
1936 
1937 
1938 
1939 
1940 
1941 //=================================================================================================
1942 //
1943 // UNDEFINED CLASS TEMPLATE SPECIALIZATION
1944 //
1945 //=================================================================================================
1946 
1947 //*************************************************************************************************
1955 template< typename Type // Data type of the vector
1956  , bool TF > // Transpose flag
1957 class StaticVector<Type,0UL,TF>;
1959 //*************************************************************************************************
1960 
1961 
1962 
1963 
1964 
1965 
1966 
1967 
1968 //=================================================================================================
1969 //
1970 // STATICVECTOR OPERATORS
1971 //
1972 //=================================================================================================
1973 
1974 //*************************************************************************************************
1977 template< typename Type, size_t N, bool TF >
1978 inline void reset( StaticVector<Type,N,TF>& v );
1979 
1980 template< typename Type, size_t N, bool TF >
1981 inline void clear( StaticVector<Type,N,TF>& v );
1982 
1983 template< typename Type, size_t N, bool TF >
1984 inline bool isDefault( const StaticVector<Type,N,TF>& v );
1985 
1986 template< typename Type, bool TF >
1988 
1989 template< typename Type, bool TF >
1991 
1992 template< typename Type, size_t N, bool TF >
1993 inline void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) /* throw() */;
1995 //*************************************************************************************************
1996 
1997 
1998 //*************************************************************************************************
2005 template< typename Type // Data type of the vector
2006  , size_t N // Number of elements
2007  , bool TF > // Transpose flag
2009 {
2010  v.reset();
2011 }
2012 //*************************************************************************************************
2013 
2014 
2015 //*************************************************************************************************
2024 template< typename Type // Data type of the vector
2025  , size_t N // Number of elements
2026  , bool TF > // Transpose flag
2028 {
2029  v.reset();
2030 }
2031 //*************************************************************************************************
2032 
2033 
2034 //*************************************************************************************************
2052 template< typename Type // Data type of the vector
2053  , size_t N // Number of elements
2054  , bool TF > // Transpose flag
2055 inline bool isDefault( const StaticVector<Type,N,TF>& v )
2056 {
2057  for( size_t i=0UL; i<N; ++i )
2058  if( !isDefault( v[i] ) ) return false;
2059  return true;
2060 }
2061 //*************************************************************************************************
2062 
2063 
2064 //*************************************************************************************************
2075 template< typename Type // Data type of the vector
2076  , bool TF > // Transpose flag
2078 {
2079  return StaticVector<Type,2UL,TF>( -v[1UL], v[0UL] );
2080 }
2081 //*************************************************************************************************
2082 
2083 
2084 //*************************************************************************************************
2092 template< typename Type // Data type of the vector
2093  , bool TF > // Transpose flag
2095 {
2096  if( v[0] != Type() || v[1] != Type() )
2097  return StaticVector<Type,3UL,TF>( v[1UL], -v[0UL], Type() );
2098  else
2099  return StaticVector<Type,3UL,TF>( Type(), v[2UL], -v[1UL] );
2100 }
2101 //*************************************************************************************************
2102 
2103 
2104 //*************************************************************************************************
2113 template< typename Type // Data type of the vector
2114  , size_t N // Number of elements
2115  , bool TF > // Transpose flag
2116 inline void swap( StaticVector<Type,N,TF>& a, StaticVector<Type,N,TF>& b ) /* throw() */
2117 {
2118  a.swap( b );
2119 }
2120 //*************************************************************************************************
2121 
2122 
2123 
2124 
2125 //=================================================================================================
2126 //
2127 // ADDTRAIT SPECIALIZATIONS
2128 //
2129 //=================================================================================================
2130 
2131 //*************************************************************************************************
2133 template< typename T1, size_t N, bool TF, typename T2 >
2134 struct AddTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2135 {
2136  typedef StaticVector< typename AddTrait<T1,T2>::Type, N, TF > Type;
2137 };
2139 //*************************************************************************************************
2140 
2141 
2142 
2143 
2144 //=================================================================================================
2145 //
2146 // SUBTRAIT SPECIALIZATIONS
2147 //
2148 //=================================================================================================
2149 
2150 //*************************************************************************************************
2152 template< typename T1, size_t N, bool TF, typename T2 >
2153 struct SubTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2154 {
2155  typedef StaticVector< typename SubTrait<T1,T2>::Type, N, TF > Type;
2156 };
2158 //*************************************************************************************************
2159 
2160 
2161 
2162 
2163 //=================================================================================================
2164 //
2165 // MULTTRAIT SPECIALIZATIONS
2166 //
2167 //=================================================================================================
2168 
2169 //*************************************************************************************************
2171 template< typename T1, size_t N, bool TF, typename T2 >
2172 struct MultTrait< StaticVector<T1,N,TF>, T2 >
2173 {
2174  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2176 };
2177 
2178 template< typename T1, typename T2, size_t N, bool TF >
2179 struct MultTrait< T1, StaticVector<T2,N,TF> >
2180 {
2181  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2183 };
2184 
2185 template< typename T1, size_t N, bool TF, typename T2 >
2186 struct MultTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2187 {
2188  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, TF > Type;
2189 };
2190 
2191 template< typename T1, size_t M, typename T2, size_t N >
2192 struct MultTrait< StaticVector<T1,M,false>, StaticVector<T2,N,true> >
2193 {
2194  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, false > Type;
2195 };
2196 
2197 template< typename T1, size_t N, typename T2 >
2198 struct MultTrait< StaticVector<T1,N,true>, StaticVector<T2,N,false> >
2199 {
2200  typedef typename MultTrait<T1,T2>::Type Type;
2201 };
2203 //*************************************************************************************************
2204 
2205 
2206 
2207 
2208 //=================================================================================================
2209 //
2210 // CROSSTRAIT SPECIALIZATIONS
2211 //
2212 //=================================================================================================
2213 
2214 //*************************************************************************************************
2216 template< typename T1, typename T2 >
2217 struct CrossTrait< StaticVector<T1,3UL,false>, StaticVector<T2,3UL,false> >
2218 {
2219  private:
2220  typedef typename MultTrait<T1,T2>::Type T;
2221 
2222  public:
2223  typedef StaticVector< typename SubTrait<T,T>::Type, 3UL, false > Type;
2224 };
2226 //*************************************************************************************************
2227 
2228 
2229 
2230 
2231 //=================================================================================================
2232 //
2233 // DIVTRAIT SPECIALIZATIONS
2234 //
2235 //=================================================================================================
2236 
2237 //*************************************************************************************************
2239 template< typename T1, size_t N, bool TF, typename T2 >
2240 struct DivTrait< StaticVector<T1,N,TF>, T2 >
2241 {
2242  typedef StaticVector< typename DivTrait<T1,T2>::Type, N, TF > Type;
2244 };
2246 //*************************************************************************************************
2247 
2248 
2249 
2250 
2251 //=================================================================================================
2252 //
2253 // MATHTRAIT SPECIALIZATIONS
2254 //
2255 //=================================================================================================
2256 
2257 //*************************************************************************************************
2259 template< typename T1, size_t N, bool TF, typename T2 >
2260 struct MathTrait< StaticVector<T1,N,TF>, StaticVector<T2,N,TF> >
2261 {
2262  typedef StaticVector< typename MathTrait<T1,T2>::HighType, N, TF > HighType;
2263  typedef StaticVector< typename MathTrait<T1,T2>::LowType , N, TF > LowType;
2264 };
2266 //*************************************************************************************************
2267 
2268 
2269 
2270 
2271 //=================================================================================================
2272 //
2273 // SUBVECTORTRAIT SPECIALIZATIONS
2274 //
2275 //=================================================================================================
2276 
2277 //*************************************************************************************************
2279 template< typename T1, size_t N, bool TF >
2280 struct SubvectorTrait< StaticVector<T1,N,TF> >
2281 {
2282  typedef HybridVector<T1,N,TF> Type;
2283 };
2285 //*************************************************************************************************
2286 
2287 } // namespace blaze
2288 
2289 #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:1459
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:4579
#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:933
AlignedArray< Type, NN > v_
The statically allocated vector elements.
Definition: StaticVector.h:409
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4622
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:194
#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:199
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: StaticVector.h:1303
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4595
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
bool isAligned() const
Returns whether the vector is properly aligned in memory.
Definition: StaticVector.h:1435
Header file for the DisableIf class template.
size_t capacity() const
Returns the maximum capacity of the vector.
Definition: StaticVector.h:1285
bool canAlias(const Other *alias) const
Returns whether the vector can alias with the given address alias.
Definition: StaticVector.h:1395
void swap(StaticVector &v)
Swapping the contents of two static vectors.
Definition: StaticVector.h:1363
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:4558
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2388
#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:193
void reset()
Reset to the default initial values.
Definition: StaticVector.h:1325
#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:918
Reference operator[](size_t index)
Subscript operator for the direct access to the vector elements.
Definition: StaticVector.h:818
IT::Type IntrinsicType
Intrinsic type of the vector elements.
Definition: StaticVector.h:196
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:2077
void store(size_t index, const IntrinsicType &value)
Aligned store of an intrinsic element of the vector.
Definition: StaticVector.h:1522
Header file for the EnableIf class template.
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:201
Header file for the IsSparseVector type trait.
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:448
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:4651
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:197
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:200
#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:888
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:2387
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:1416
const StaticVector & CompositeType
Data type for composite expression templates.
Definition: StaticVector.h:198
StaticVector< Type, N, TF > This
Type of this StaticVector instance.
Definition: StaticVector.h:192
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:1585
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:202
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:1270
IntrinsicTrait< Type > IT
Intrinsic trait for the vector element type.
Definition: StaticVector.h:182
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:963
IntrinsicType loadu(size_t index) const
Unaligned load of an intrinsic element of the vector.
Definition: StaticVector.h:1491
#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:856
Type ElementType
Type of the vector elements.
Definition: StaticVector.h:195
#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:1554