CustomVector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_DENSE_CUSTOMVECTOR_H_
36 #define _BLAZE_MATH_DENSE_CUSTOMVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <utility>
45 #include <boost/smart_ptr/shared_array.hpp>
46 #include <blaze/math/Aliases.h>
52 #include <blaze/math/Exception.h>
55 #include <blaze/math/Forward.h>
57 #include <blaze/math/PaddingFlag.h>
58 #include <blaze/math/shims/Clear.h>
61 #include <blaze/math/SIMD.h>
79 #include <blaze/system/CacheSize.h>
80 #include <blaze/system/Inline.h>
85 #include <blaze/util/Assert.h>
91 #include <blaze/util/DisableIf.h>
92 #include <blaze/util/EnableIf.h>
95 #include <blaze/util/Template.h>
96 #include <blaze/util/TrueType.h>
97 #include <blaze/util/Types.h>
102 #include <blaze/util/Unused.h>
103 
104 
105 namespace blaze {
106 
107 //=================================================================================================
108 //
109 // CLASS DEFINITION
110 //
111 //=================================================================================================
112 
113 //*************************************************************************************************
419 template< typename Type // Data type of the vector
420  , bool AF // Alignment flag
421  , bool PF // Padding flag
422  , bool TF = defaultTransposeFlag > // Transpose flag
423 class CustomVector : public DenseVector< CustomVector<Type,AF,PF,TF>, TF >
424 {
425  public:
426  //**Type definitions****************************************************************************
431  typedef Type ElementType;
433  typedef const Type& ReturnType;
434  typedef const CustomVector& CompositeType;
435 
436  typedef Type& Reference;
437  typedef const Type& ConstReference;
438  typedef Type* Pointer;
439  typedef const Type* ConstPointer;
440 
443  //**********************************************************************************************
444 
445  //**Rebind struct definition********************************************************************
448  template< typename ET > // Data type of the other vector
449  struct Rebind {
451  };
452  //**********************************************************************************************
453 
454  //**Compilation flags***************************************************************************
456 
460  enum : bool { simdEnabled = IsVectorizable<Type>::value };
461 
463 
466  enum : bool { smpAssignable = !IsSMPAssignable<Type>::value };
467  //**********************************************************************************************
468 
469  //**Constructors********************************************************************************
472  explicit inline CustomVector();
473  explicit inline CustomVector( Type* ptr, size_t n );
474  explicit inline CustomVector( Type* ptr, size_t n, size_t nn );
475 
476  template< typename Deleter, typename = EnableIf_<IsClass<Deleter> > >
477  explicit inline CustomVector( Type* ptr, size_t n, Deleter d );
478 
479  template< typename Deleter >
480  explicit inline CustomVector( Type* ptr, size_t n, size_t nn, Deleter d );
481 
482  inline CustomVector( const CustomVector& v );
483  inline CustomVector( CustomVector&& v ) noexcept;
485  //**********************************************************************************************
486 
487  //**Destructor**********************************************************************************
488  // No explicitly declared destructor.
489  //**********************************************************************************************
490 
491  //**Data access functions***********************************************************************
494  inline Reference operator[]( size_t index ) noexcept;
495  inline ConstReference operator[]( size_t index ) const noexcept;
496  inline Reference at( size_t index );
497  inline ConstReference at( size_t index ) const;
498  inline Pointer data () noexcept;
499  inline ConstPointer data () const noexcept;
500  inline Iterator begin () noexcept;
501  inline ConstIterator begin () const noexcept;
502  inline ConstIterator cbegin() const noexcept;
503  inline Iterator end () noexcept;
504  inline ConstIterator end () const noexcept;
505  inline ConstIterator cend () const noexcept;
507  //**********************************************************************************************
508 
509  //**Assignment operators************************************************************************
512  inline CustomVector& operator=( const Type& rhs );
513  inline CustomVector& operator=( initializer_list<Type> list );
514 
515  template< typename Other, size_t N >
516  inline CustomVector& operator=( const Other (&array)[N] );
517 
518  inline CustomVector& operator=( const CustomVector& rhs );
519  inline CustomVector& operator=( CustomVector&& rhs ) noexcept;
520 
521  template< typename VT > inline CustomVector& operator= ( const Vector<VT,TF>& rhs );
522  template< typename VT > inline CustomVector& operator+=( const Vector<VT,TF>& rhs );
523  template< typename VT > inline CustomVector& operator-=( const Vector<VT,TF>& rhs );
524  template< typename VT > inline CustomVector& operator*=( const Vector<VT,TF>& rhs );
525  template< typename VT > inline CustomVector& operator/=( const DenseVector<VT,TF>& rhs );
526 
527  template< typename Other >
528  inline EnableIf_<IsNumeric<Other>, CustomVector >& operator*=( Other rhs );
529 
530  template< typename Other >
531  inline EnableIf_<IsNumeric<Other>, CustomVector >& operator/=( Other rhs );
533  //**********************************************************************************************
534 
535  //**Utility functions***************************************************************************
538  inline size_t size() const noexcept;
539  inline size_t capacity() const noexcept;
540  inline size_t nonZeros() const;
541  inline void reset();
542  inline void clear();
543  template< typename Other > inline CustomVector& scale( const Other& scalar );
544  inline void swap( CustomVector& v ) noexcept;
546  //**********************************************************************************************
547 
548  //**Resource management functions***************************************************************
551  inline void reset( Type* ptr, size_t n );
552  inline void reset( Type* ptr, size_t n, size_t nn );
553 
554  template< typename Deleter, typename = EnableIf_<IsClass<Deleter> > >
555  inline void reset( Type* ptr, size_t n, Deleter d );
556 
557  template< typename Deleter >
558  inline void reset( Type* ptr, size_t n, size_t nn, Deleter d );
560  //**********************************************************************************************
561 
562  private:
563  //**********************************************************************************************
565  template< typename VT >
567  struct VectorizedAssign {
568  enum : bool { value = useOptimizedKernels &&
569  simdEnabled && VT::simdEnabled &&
570  AreSIMDCombinable< Type, ElementType_<VT> >::value };
571  };
573  //**********************************************************************************************
574 
575  //**********************************************************************************************
577  template< typename VT >
579  struct VectorizedAddAssign {
580  enum : bool { value = useOptimizedKernels &&
581  simdEnabled && VT::simdEnabled &&
582  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
583  HasSIMDAdd< Type, ElementType_<VT> >::value };
584  };
586  //**********************************************************************************************
587 
588  //**********************************************************************************************
590  template< typename VT >
592  struct VectorizedSubAssign {
593  enum : bool { value = useOptimizedKernels &&
594  simdEnabled && VT::simdEnabled &&
595  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
596  HasSIMDSub< Type, ElementType_<VT> >::value };
597  };
599  //**********************************************************************************************
600 
601  //**********************************************************************************************
603  template< typename VT >
605  struct VectorizedMultAssign {
606  enum : bool { value = useOptimizedKernels &&
607  simdEnabled && VT::simdEnabled &&
608  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
609  HasSIMDMult< Type, ElementType_<VT> >::value };
610  };
612  //**********************************************************************************************
613 
614  //**********************************************************************************************
616  template< typename VT >
618  struct VectorizedDivAssign {
619  enum : bool { value = useOptimizedKernels &&
620  simdEnabled && VT::simdEnabled &&
621  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
622  HasSIMDDiv< Type, ElementType_<VT> >::value };
623  };
625  //**********************************************************************************************
626 
627  //**SIMD properties*****************************************************************************
629  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
630  //**********************************************************************************************
631 
632  public:
633  //**Expression template evaluation functions****************************************************
636  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
637  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
638 
639  inline bool isAligned () const noexcept;
640  inline bool canSMPAssign() const noexcept;
641 
642  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
643  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
644  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
645 
646  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
647  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
648  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
649  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
650 
651  template< typename VT >
652  inline DisableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
653 
654  template< typename VT >
655  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
656 
657  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
658 
659  template< typename VT >
660  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
661 
662  template< typename VT >
663  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
664 
665  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
666 
667  template< typename VT >
668  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
669 
670  template< typename VT >
671  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
672 
673  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
674 
675  template< typename VT >
676  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
677 
678  template< typename VT >
679  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
680 
681  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
682 
683  template< typename VT >
684  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
685 
686  template< typename VT >
687  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
689  //**********************************************************************************************
690 
691  private:
692  //**Member variables****************************************************************************
695  size_t size_;
696  boost::shared_array<Type> v_;
697 
703  //**********************************************************************************************
704 
705  //**Compile time checks*************************************************************************
712  //**********************************************************************************************
713 };
714 //*************************************************************************************************
715 
716 
717 
718 
719 //=================================================================================================
720 //
721 // CONSTRUCTORS
722 //
723 //=================================================================================================
724 
725 //*************************************************************************************************
728 template< typename Type // Data type of the vector
729  , bool AF // Alignment flag
730  , bool PF // Padding flag
731  , bool TF > // Transpose flag
732 inline CustomVector<Type,AF,PF,TF>::CustomVector()
733  : size_( 0UL ) // The size/dimension of the vector
734  , v_ ( ) // The custom array of elements
735 {}
736 //*************************************************************************************************
737 
738 
739 //*************************************************************************************************
757 template< typename Type // Data type of the vector
758  , bool AF // Alignment flag
759  , bool PF // Padding flag
760  , bool TF > // Transpose flag
761 inline CustomVector<Type,AF,PF,TF>::CustomVector( Type* ptr, size_t n )
762  : size_( n ) // The size/dimension of the vector
763  , v_ ( ) // The custom array of elements
764 {
765  if( ptr == nullptr ) {
766  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array of elements" );
767  }
768 
769  if( AF && !checkAlignment( ptr ) ) {
770  BLAZE_THROW_INVALID_ARGUMENT( "Invalid alignment detected" );
771  }
772 
773  v_.reset( ptr, NoDelete() );
774 }
775 //*************************************************************************************************
776 
777 
778 //*************************************************************************************************
800 template< typename Type // Data type of the vector
801  , bool AF // Alignment flag
802  , bool PF // Padding flag
803  , bool TF > // Transpose flag
804 inline CustomVector<Type,AF,PF,TF>::CustomVector( Type* ptr, size_t n, size_t nn )
805  : size_( 0UL ) // The size/dimension of the vector
806  , v_ ( ) // The custom array of elements
807 {
808  BLAZE_STATIC_ASSERT( PF == padded );
809 
810  UNUSED_PARAMETER( ptr, n, nn );
811 }
812 //*************************************************************************************************
813 
814 
815 //*************************************************************************************************
833 template< typename Type // Data type of the vector
834  , bool AF // Alignment flag
835  , bool PF // Padding flag
836  , bool TF > // Transpose flag
837 template< typename Deleter // Type of the custom deleter
838  , typename > // Type restriction on the custom deleter
839 inline CustomVector<Type,AF,PF,TF>::CustomVector( Type* ptr, size_t n, Deleter d )
840  : size_( n ) // The size/dimension of the vector
841  , v_ ( ) // The custom array of elements
842 {
843  if( ptr == nullptr ) {
844  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array of elements" );
845  }
846 
847  if( AF && !checkAlignment( ptr ) ) {
848  BLAZE_THROW_INVALID_ARGUMENT( "Invalid alignment detected" );
849  }
850 
851  v_.reset( ptr, d );
852 }
853 //*************************************************************************************************
854 
855 
856 //*************************************************************************************************
878 template< typename Type // Data type of the vector
879  , bool AF // Alignment flag
880  , bool PF // Padding flag
881  , bool TF > // Transpose flag
882 template< typename Deleter > // Type of the custom deleter
883 inline CustomVector<Type,AF,PF,TF>::CustomVector( Type* ptr, size_t n, size_t nn, Deleter d )
884  : size_( 0UL ) // The size/dimension of the vector
885  , v_ ( ) // The custom array of elements
886 {
887  BLAZE_STATIC_ASSERT( PF == padded );
888 
889  UNUSED_PARAMETER( ptr, n, nn, d );
890 }
891 //*************************************************************************************************
892 
893 
894 //*************************************************************************************************
901 template< typename Type // Data type of the vector
902  , bool AF // Alignment flag
903  , bool PF // Padding flag
904  , bool TF > // Transpose flag
906  : size_( v.size_ ) // The size/dimension of the vector
907  , v_ ( v.v_ ) // The custom array of elements
908 {}
909 //*************************************************************************************************
910 
911 
912 //*************************************************************************************************
917 template< typename Type // Data type of the vector
918  , bool AF // Alignment flag
919  , bool PF // Padding flag
920  , bool TF > // Transpose flag
922  : size_( v.size_ ) // The size/dimension of the vector
923  , v_ ( std::move( v.v_ ) ) // The custom array of elements
924 {
925  v.size_ = 0UL;
926 
927  BLAZE_INTERNAL_ASSERT( v.data() == nullptr, "Invalid data reference detected" );
928 }
929 //*************************************************************************************************
930 
931 
932 
933 
934 //=================================================================================================
935 //
936 // DATA ACCESS FUNCTIONS
937 //
938 //=================================================================================================
939 
940 //*************************************************************************************************
949 template< typename Type // Data type of the vector
950  , bool AF // Alignment flag
951  , bool PF // Padding flag
952  , bool TF > // Transpose flag
955 {
956  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
957  return v_[index];
958 }
959 //*************************************************************************************************
960 
961 
962 //*************************************************************************************************
971 template< typename Type // Data type of the vector
972  , bool AF // Alignment flag
973  , bool PF // Padding flag
974  , bool TF > // Transpose flag
976  CustomVector<Type,AF,PF,TF>::operator[]( size_t index ) const noexcept
977 {
978  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
979  return v_[index];
980 }
981 //*************************************************************************************************
982 
983 
984 //*************************************************************************************************
994 template< typename Type // Data type of the vector
995  , bool AF // Alignment flag
996  , bool PF // Padding flag
997  , bool TF > // Transpose flag
1000 {
1001  if( index >= size_ ) {
1002  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
1003  }
1004  return (*this)[index];
1005 }
1006 //*************************************************************************************************
1007 
1008 
1009 //*************************************************************************************************
1019 template< typename Type // Data type of the vector
1020  , bool AF // Alignment flag
1021  , bool PF // Padding flag
1022  , bool TF > // Transpose flag
1024  CustomVector<Type,AF,PF,TF>::at( size_t index ) const
1025 {
1026  if( index >= size_ ) {
1027  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
1028  }
1029  return (*this)[index];
1030 }
1031 //*************************************************************************************************
1032 
1033 
1034 //*************************************************************************************************
1041 template< typename Type // Data type of the vector
1042  , bool AF // Alignment flag
1043  , bool PF // Padding flag
1044  , bool TF > // Transpose flag
1047 {
1048  return v_.get();
1049 }
1050 //*************************************************************************************************
1051 
1052 
1053 //*************************************************************************************************
1060 template< typename Type // Data type of the vector
1061  , bool AF // Alignment flag
1062  , bool PF // Padding flag
1063  , bool TF > // Transpose flag
1066 {
1067  return v_.get();
1068 }
1069 //*************************************************************************************************
1070 
1071 
1072 //*************************************************************************************************
1077 template< typename Type // Data type of the vector
1078  , bool AF // Alignment flag
1079  , bool PF // Padding flag
1080  , bool TF > // Transpose flag
1083 {
1084  return Iterator( v_.get() );
1085 }
1086 //*************************************************************************************************
1087 
1088 
1089 //*************************************************************************************************
1094 template< typename Type // Data type of the vector
1095  , bool AF // Alignment flag
1096  , bool PF // Padding flag
1097  , bool TF > // Transpose flag
1100 {
1101  return ConstIterator( v_.get() );
1102 }
1103 //*************************************************************************************************
1104 
1105 
1106 //*************************************************************************************************
1111 template< typename Type // Data type of the vector
1112  , bool AF // Alignment flag
1113  , bool PF // Padding flag
1114  , bool TF > // Transpose flag
1117 {
1118  return ConstIterator( v_.get() );
1119 }
1120 //*************************************************************************************************
1121 
1122 
1123 //*************************************************************************************************
1128 template< typename Type // Data type of the vector
1129  , bool AF // Alignment flag
1130  , bool PF // Padding flag
1131  , bool TF > // Transpose flag
1134 {
1135  return Iterator( v_.get() + size_ );
1136 }
1137 //*************************************************************************************************
1138 
1139 
1140 //*************************************************************************************************
1145 template< typename Type // Data type of the vector
1146  , bool AF // Alignment flag
1147  , bool PF // Padding flag
1148  , bool TF > // Transpose flag
1151 {
1152  return ConstIterator( v_.get() + size_ );
1153 }
1154 //*************************************************************************************************
1155 
1156 
1157 //*************************************************************************************************
1162 template< typename Type // Data type of the vector
1163  , bool AF // Alignment flag
1164  , bool PF // Padding flag
1165  , bool TF > // Transpose flag
1168 {
1169  return ConstIterator( v_.get() + size_ );
1170 }
1171 //*************************************************************************************************
1172 
1173 
1174 
1175 
1176 //=================================================================================================
1177 //
1178 // ASSIGNMENT OPERATORS
1179 //
1180 //=================================================================================================
1181 
1182 //*************************************************************************************************
1188 template< typename Type // Data type of the vector
1189  , bool AF // Alignment flag
1190  , bool PF // Padding flag
1191  , bool TF > // Transpose flag
1193 {
1194  for( size_t i=0UL; i<size_; ++i )
1195  v_[i] = rhs;
1196  return *this;
1197 }
1198 //*************************************************************************************************
1199 
1200 
1201 //*************************************************************************************************
1225 template< typename Type // Data type of the vector
1226  , bool AF // Alignment flag
1227  , bool PF // Padding flag
1228  , bool TF > // Transpose flag
1230 {
1231  if( list.size() > size_ ) {
1232  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to custom vector" );
1233  }
1234 
1235  std::fill( std::copy( list.begin(), list.end(), v_.get() ), v_.get()+size_, Type() );
1236 
1237  return *this;
1238 }
1239 //*************************************************************************************************
1240 
1241 
1242 //*************************************************************************************************
1269 template< typename Type // Data type of the vector
1270  , bool AF // Alignment flag
1271  , bool PF // Padding flag
1272  , bool TF > // Transpose flag
1273 template< typename Other // Data type of the initialization array
1274  , size_t N > // Dimension of the initialization array
1276 {
1277  if( size_ != N ) {
1278  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array size" );
1279  }
1280 
1281  for( size_t i=0UL; i<N; ++i )
1282  v_[i] = array[i];
1283 
1284  return *this;
1285 }
1286 //*************************************************************************************************
1287 
1288 
1289 //*************************************************************************************************
1299 template< typename Type // Data type of the vector
1300  , bool AF // Alignment flag
1301  , bool PF // Padding flag
1302  , bool TF > // Transpose flag
1304 {
1305  if( rhs.size() != size_ ) {
1306  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1307  }
1308 
1309  smpAssign( *this, ~rhs );
1310 
1311  return *this;
1312 }
1313 //*************************************************************************************************
1314 
1315 
1316 //*************************************************************************************************
1322 template< typename Type // Data type of the vector
1323  , bool AF // Alignment flag
1324  , bool PF // Padding flag
1325  , bool TF > // Transpose flag
1328 {
1329  size_ = rhs.size_;
1330  v_ = std::move( rhs.v_ );
1331 
1332  rhs.size_ = 0UL;
1333 
1334  BLAZE_INTERNAL_ASSERT( rhs.data() == nullptr, "Invalid data reference detected" );
1335 
1336  return *this;
1337 }
1338 //*************************************************************************************************
1339 
1340 
1341 //*************************************************************************************************
1351 template< typename Type // Data type of the vector
1352  , bool AF // Alignment flag
1353  , bool PF // Padding flag
1354  , bool TF > // Transpose flag
1355 template< typename VT > // Type of the right-hand side vector
1357 {
1358  if( (~rhs).size() != size_ ) {
1359  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1360  }
1361 
1362  if( (~rhs).canAlias( this ) ) {
1363  const ResultType_<VT> tmp( ~rhs );
1364  smpAssign( *this, tmp );
1365  }
1366  else {
1368  reset();
1369  smpAssign( *this, ~rhs );
1370  }
1371 
1372  return *this;
1373 }
1374 //*************************************************************************************************
1375 
1376 
1377 //*************************************************************************************************
1387 template< typename Type // Data type of the vector
1388  , bool AF // Alignment flag
1389  , bool PF // Padding flag
1390  , bool TF > // Transpose flag
1391 template< typename VT > // Type of the right-hand side vector
1393 {
1394  if( (~rhs).size() != size_ ) {
1395  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1396  }
1397 
1398  if( (~rhs).canAlias( this ) ) {
1399  const ResultType_<VT> tmp( ~rhs );
1400  smpAddAssign( *this, tmp );
1401  }
1402  else {
1403  smpAddAssign( *this, ~rhs );
1404  }
1405 
1406  return *this;
1407 }
1408 //*************************************************************************************************
1409 
1410 
1411 //*************************************************************************************************
1422 template< typename Type // Data type of the vector
1423  , bool AF // Alignment flag
1424  , bool PF // Padding flag
1425  , bool TF > // Transpose flag
1426 template< typename VT > // Type of the right-hand side vector
1428 {
1429  if( (~rhs).size() != size_ ) {
1430  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1431  }
1432 
1433  if( (~rhs).canAlias( this ) ) {
1434  const ResultType_<VT> tmp( ~rhs );
1435  smpSubAssign( *this, tmp );
1436  }
1437  else {
1438  smpSubAssign( *this, ~rhs );
1439  }
1440 
1441  return *this;
1442 }
1443 //*************************************************************************************************
1444 
1445 
1446 //*************************************************************************************************
1457 template< typename Type // Data type of the vector
1458  , bool AF // Alignment flag
1459  , bool PF // Padding flag
1460  , bool TF > // Transpose flag
1461 template< typename VT > // Type of the right-hand side vector
1463 {
1466 
1467  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
1468 
1471 
1472  if( (~rhs).size() != size_ ) {
1473  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1474  }
1475 
1476  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1477  const MultType tmp( *this * (~rhs) );
1478  this->operator=( tmp );
1479  }
1480  else {
1481  smpMultAssign( *this, ~rhs );
1482  }
1483 
1484  return *this;
1485 }
1486 //*************************************************************************************************
1487 
1488 
1489 //*************************************************************************************************
1499 template< typename Type // Data type of the vector
1500  , bool AF // Alignment flag
1501  , bool PF // Padding flag
1502  , bool TF > // Transpose flag
1503 template< typename VT > // Type of the right-hand side vector
1506 {
1509 
1510  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
1511 
1514 
1515  if( (~rhs).size() != size_ ) {
1516  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1517  }
1518 
1519  if( (~rhs).canAlias( this ) ) {
1520  const DivType tmp( *this / (~rhs) );
1521  this->operator=( tmp );
1522  }
1523  else {
1524  smpDivAssign( *this, ~rhs );
1525  }
1526 
1527  return *this;
1528 }
1529 //*************************************************************************************************
1530 
1531 
1532 //*************************************************************************************************
1539 template< typename Type // Data type of the vector
1540  , bool AF // Alignment flag
1541  , bool PF // Padding flag
1542  , bool TF > // Transpose flag
1543 template< typename Other > // Data type of the right-hand side scalar
1546 {
1547  smpAssign( *this, (*this) * rhs );
1548  return *this;
1549 }
1550 //*************************************************************************************************
1551 
1552 
1553 //*************************************************************************************************
1562 template< typename Type // Data type of the vector
1563  , bool AF // Alignment flag
1564  , bool PF // Padding flag
1565  , bool TF > // Transpose flag
1566 template< typename Other > // Data type of the right-hand side scalar
1567 inline EnableIf_<IsNumeric<Other>, CustomVector<Type,AF,PF,TF> >&
1569 {
1570  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1571 
1572  smpAssign( *this, (*this) / rhs );
1573  return *this;
1574 }
1575 //*************************************************************************************************
1576 
1577 
1578 
1579 
1580 //=================================================================================================
1581 //
1582 // UTILITY FUNCTIONS
1583 //
1584 //=================================================================================================
1585 
1586 //*************************************************************************************************
1591 template< typename Type // Data type of the vector
1592  , bool AF // Alignment flag
1593  , bool PF // Padding flag
1594  , bool TF > // Transpose flag
1595 inline size_t CustomVector<Type,AF,PF,TF>::size() const noexcept
1596 {
1597  return size_;
1598 }
1599 //*************************************************************************************************
1600 
1601 
1602 //*************************************************************************************************
1607 template< typename Type // Data type of the vector
1608  , bool AF // Alignment flag
1609  , bool PF // Padding flag
1610  , bool TF > // Transpose flag
1611 inline size_t CustomVector<Type,AF,PF,TF>::capacity() const noexcept
1612 {
1613  return size_;
1614 }
1615 //*************************************************************************************************
1616 
1617 
1618 //*************************************************************************************************
1626 template< typename Type // Data type of the vector
1627  , bool AF // Alignment flag
1628  , bool PF // Padding flag
1629  , bool TF > // Transpose flag
1631 {
1632  size_t nonzeros( 0 );
1633 
1634  for( size_t i=0UL; i<size_; ++i ) {
1635  if( !isDefault( v_[i] ) )
1636  ++nonzeros;
1637  }
1638 
1639  return nonzeros;
1640 }
1641 //*************************************************************************************************
1642 
1643 
1644 //*************************************************************************************************
1649 template< typename Type // Data type of the vector
1650  , bool AF // Alignment flag
1651  , bool PF // Padding flag
1652  , bool TF > // Transpose flag
1654 {
1655  using blaze::clear;
1656  for( size_t i=0UL; i<size_; ++i )
1657  clear( v_[i] );
1658 }
1659 //*************************************************************************************************
1660 
1661 
1662 //*************************************************************************************************
1670 template< typename Type // Data type of the vector
1671  , bool AF // Alignment flag
1672  , bool PF // Padding flag
1673  , bool TF > // Transpose flag
1675 {
1676  size_ = 0UL;
1677  v_.reset();
1678 }
1679 //*************************************************************************************************
1680 
1681 
1682 //*************************************************************************************************
1688 template< typename Type // Data type of the vector
1689  , bool AF // Alignment flag
1690  , bool PF // Padding flag
1691  , bool TF > // Transpose flag
1692 template< typename Other > // Data type of the scalar value
1694 {
1695  for( size_t i=0UL; i<size_; ++i )
1696  v_[i] *= scalar;
1697  return *this;
1698 }
1699 //*************************************************************************************************
1700 
1701 
1702 //*************************************************************************************************
1708 template< typename Type // Data type of the vector
1709  , bool AF // Alignment flag
1710  , bool PF // Padding flag
1711  , bool TF > // Transpose flag
1713 {
1714  using std::swap;
1715 
1716  swap( size_, v.size_ );
1717  swap( v_, v.v_ );
1718 }
1719 //*************************************************************************************************
1720 
1721 
1722 
1723 
1724 //=================================================================================================
1725 //
1726 // RESOURCE MANAGEMENT FUNCTIONS
1727 //
1728 //=================================================================================================
1729 
1730 //*************************************************************************************************
1752 template< typename Type // Data type of the vector
1753  , bool AF // Alignment flag
1754  , bool PF // Padding flag
1755  , bool TF > // Transpose flag
1756 inline void CustomVector<Type,AF,PF,TF>::reset( Type* ptr, size_t n )
1757 {
1758  CustomVector tmp( ptr, n );
1759  swap( tmp );
1760 }
1761 //*************************************************************************************************
1762 
1763 
1764 //*************************************************************************************************
1789 template< typename Type // Data type of the vector
1790  , bool AF // Alignment flag
1791  , bool PF // Padding flag
1792  , bool TF > // Transpose flag
1793 inline void CustomVector<Type,AF,PF,TF>::reset( Type* ptr, size_t n, size_t nn )
1794 {
1795  BLAZE_STATIC_ASSERT( PF == padded );
1796 
1797  UNUSED_PARAMETER( ptr, n, nn );
1798 }
1799 //*************************************************************************************************
1800 
1801 
1802 //*************************************************************************************************
1824 template< typename Type // Data type of the vector
1825  , bool AF // Alignment flag
1826  , bool PF // Padding flag
1827  , bool TF > // Transpose flag
1828 template< typename Deleter // Type of the custom deleter
1829  , typename > // Type restriction on the custom deleter
1830 inline void CustomVector<Type,AF,PF,TF>::reset( Type* ptr, size_t n, Deleter d )
1831 {
1832  CustomVector tmp( ptr, n, d );
1833  swap( tmp );
1834 }
1835 //*************************************************************************************************
1836 
1837 
1838 //*************************************************************************************************
1863 template< typename Type // Data type of the vector
1864  , bool AF // Alignment flag
1865  , bool PF // Padding flag
1866  , bool TF > // Transpose flag
1867 template< typename Deleter > // Type of the custom deleter
1868 inline void CustomVector<Type,AF,PF,TF>::reset( Type* ptr, size_t n, size_t nn, Deleter d )
1869 {
1870  BLAZE_STATIC_ASSERT( PF == padded );
1871 
1872  UNUSED_PARAMETER( ptr, n, nn, d );
1873 }
1874 //*************************************************************************************************
1875 
1876 
1877 
1878 
1879 //=================================================================================================
1880 //
1881 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1882 //
1883 //=================================================================================================
1884 
1885 //*************************************************************************************************
1895 template< typename Type // Data type of the vector
1896  , bool AF // Alignment flag
1897  , bool PF // Padding flag
1898  , bool TF > // Transpose flag
1899 template< typename Other > // Data type of the foreign expression
1900 inline bool CustomVector<Type,AF,PF,TF>::canAlias( const Other* alias ) const noexcept
1901 {
1902  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1903 }
1904 //*************************************************************************************************
1905 
1906 
1907 //*************************************************************************************************
1917 template< typename Type // Data type of the vector
1918  , bool AF // Alignment flag
1919  , bool PF // Padding flag
1920  , bool TF > // Transpose flag
1921 template< typename Other > // Data type of the foreign expression
1922 inline bool CustomVector<Type,AF,PF,TF>::isAliased( const Other* alias ) const noexcept
1923 {
1924  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1925 }
1926 //*************************************************************************************************
1927 
1928 
1929 //*************************************************************************************************
1938 template< typename Type // Data type of the vector
1939  , bool AF // Alignment flag
1940  , bool PF // Padding flag
1941  , bool TF > // Transpose flag
1942 inline bool CustomVector<Type,AF,PF,TF>::isAligned() const noexcept
1943 {
1944  return ( AF || checkAlignment( v_.get() ) );
1945 }
1946 //*************************************************************************************************
1947 
1948 
1949 //*************************************************************************************************
1959 template< typename Type // Data type of the vector
1960  , bool AF // Alignment flag
1961  , bool PF // Padding flag
1962  , bool TF > // Transpose flag
1963 inline bool CustomVector<Type,AF,PF,TF>::canSMPAssign() const noexcept
1964 {
1965  return ( size() > SMP_DVECASSIGN_THRESHOLD );
1966 }
1967 //*************************************************************************************************
1968 
1969 
1970 //*************************************************************************************************
1982 template< typename Type // Data type of the vector
1983  , bool AF // Alignment flag
1984  , bool PF // Padding flag
1985  , bool TF > // Transpose flag
1987  CustomVector<Type,AF,PF,TF>::load( size_t index ) const noexcept
1988 {
1989  if( AF )
1990  return loada( index );
1991  else
1992  return loadu( index );
1993 }
1994 //*************************************************************************************************
1995 
1996 
1997 //*************************************************************************************************
2010 template< typename Type // Data type of the vector
2011  , bool AF // Alignment flag
2012  , bool PF // Padding flag
2013  , bool TF > // Transpose flag
2015  CustomVector<Type,AF,PF,TF>::loada( size_t index ) const noexcept
2016 {
2017  using blaze::loada;
2018 
2020 
2021  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2022  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2023  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
2024  BLAZE_INTERNAL_ASSERT( checkAlignment( v_.get()+index ), "Invalid vector access index" );
2025 
2026  return loada( v_.get()+index );
2027 }
2028 //*************************************************************************************************
2029 
2030 
2031 //*************************************************************************************************
2044 template< typename Type // Data type of the vector
2045  , bool AF // Alignment flag
2046  , bool PF // Padding flag
2047  , bool TF > // Transpose flag
2049  CustomVector<Type,AF,PF,TF>::loadu( size_t index ) const noexcept
2050 {
2051  using blaze::loadu;
2052 
2054 
2055  BLAZE_INTERNAL_ASSERT( index< size_, "Invalid vector access index" );
2056  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2057 
2058  return loadu( v_.get()+index );
2059 }
2060 //*************************************************************************************************
2061 
2062 
2063 //*************************************************************************************************
2076 template< typename Type // Data type of the vector
2077  , bool AF // Alignment flag
2078  , bool PF // Padding flag
2079  , bool TF > // Transpose flag
2080 BLAZE_ALWAYS_INLINE void CustomVector<Type,AF,PF,TF>::store( size_t index, const SIMDType& value ) noexcept
2081 {
2082  if( AF )
2083  storea( index, value );
2084  else
2085  storeu( index, value );
2086 }
2087 //*************************************************************************************************
2088 
2089 
2090 //*************************************************************************************************
2103 template< typename Type // Data type of the vector
2104  , bool AF // Alignment flag
2105  , bool PF // Padding flag
2106  , bool TF > // Transpose flag
2107 BLAZE_ALWAYS_INLINE void CustomVector<Type,AF,PF,TF>::storea( size_t index, const SIMDType& value ) noexcept
2108 {
2109  using blaze::storea;
2110 
2112 
2113  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2114  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2115  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
2116  BLAZE_INTERNAL_ASSERT( checkAlignment( v_.get()+index ), "Invalid vector access index" );
2117 
2118  storea( v_.get()+index, value );
2119 }
2120 //*************************************************************************************************
2121 
2122 
2123 //*************************************************************************************************
2136 template< typename Type // Data type of the vector
2137  , bool AF // Alignment flag
2138  , bool PF // Padding flag
2139  , bool TF > // Transpose flag
2140 BLAZE_ALWAYS_INLINE void CustomVector<Type,AF,PF,TF>::storeu( size_t index, const SIMDType& value ) noexcept
2141 {
2142  using blaze::storeu;
2143 
2145 
2146  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2147  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2148 
2149  storeu( v_.get()+index, value );
2150 }
2151 //*************************************************************************************************
2152 
2153 
2154 //*************************************************************************************************
2168 template< typename Type // Data type of the vector
2169  , bool AF // Alignment flag
2170  , bool PF // Padding flag
2171  , bool TF > // Transpose flag
2172 BLAZE_ALWAYS_INLINE void CustomVector<Type,AF,PF,TF>::stream( size_t index, const SIMDType& value ) noexcept
2173 {
2174  using blaze::stream;
2175 
2177 
2178  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2179  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2180  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
2181  BLAZE_INTERNAL_ASSERT( checkAlignment( v_.get()+index ), "Invalid vector access index" );
2182 
2183  stream( v_.get()+index, value );
2184 }
2185 //*************************************************************************************************
2186 
2187 
2188 //*************************************************************************************************
2199 template< typename Type // Data type of the vector
2200  , bool AF // Alignment flag
2201  , bool PF // Padding flag
2202  , bool TF > // Transpose flag
2203 template< typename VT > // Type of the right-hand side dense vector
2206 {
2207  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2208 
2209  const size_t ipos( size_ & size_t(-2) );
2210  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2211 
2212  for( size_t i=0UL; i<ipos; i+=2UL ) {
2213  v_[i ] = (~rhs)[i ];
2214  v_[i+1UL] = (~rhs)[i+1UL];
2215  }
2216  if( ipos < (~rhs).size() )
2217  v_[ipos] = (~rhs)[ipos];
2218 }
2219 //*************************************************************************************************
2220 
2221 
2222 //*************************************************************************************************
2233 template< typename Type // Data type of the vector
2234  , bool AF // Alignment flag
2235  , bool PF // Padding flag
2236  , bool TF > // Transpose flag
2237 template< typename VT > // Type of the right-hand side dense vector
2240 {
2242 
2243  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2244 
2245  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2246  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2247 
2248  if( AF && useStreaming && size_ > ( cacheSize/( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
2249  {
2250  size_t i( 0UL );
2251 
2252  for( ; i<ipos; i+=SIMDSIZE ) {
2253  stream( i, (~rhs).load(i) );
2254  }
2255  for( ; i<size_; ++i ) {
2256  v_[i] = (~rhs)[i];
2257  }
2258  }
2259  else
2260  {
2261  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2262  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2263  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2264 
2265  size_t i( 0UL );
2266  ConstIterator_<VT> it( (~rhs).begin() );
2267 
2268  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2269  store( i , it.load() ); it += SIMDSIZE;
2270  store( i+SIMDSIZE , it.load() ); it += SIMDSIZE;
2271  store( i+SIMDSIZE*2UL, it.load() ); it += SIMDSIZE;
2272  store( i+SIMDSIZE*3UL, it.load() ); it += SIMDSIZE;
2273  }
2274  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2275  store( i, it.load() );
2276  }
2277  for( ; i<size_; ++i, ++it ) {
2278  v_[i] = *it;
2279  }
2280  }
2281 }
2282 //*************************************************************************************************
2283 
2284 
2285 //*************************************************************************************************
2296 template< typename Type // Data type of the vector
2297  , bool AF // Alignment flag
2298  , bool PF // Padding flag
2299  , bool TF > // Transpose flag
2300 template< typename VT > // Type of the right-hand side sparse vector
2302 {
2303  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2304 
2305  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2306  v_[element->index()] = element->value();
2307 }
2308 //*************************************************************************************************
2309 
2310 
2311 //*************************************************************************************************
2322 template< typename Type // Data type of the vector
2323  , bool AF // Alignment flag
2324  , bool PF // Padding flag
2325  , bool TF > // Transpose flag
2326 template< typename VT > // Type of the right-hand side dense vector
2329 {
2330  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2331 
2332  const size_t ipos( size_ & size_t(-2) );
2333  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2334 
2335  for( size_t i=0UL; i<ipos; i+=2UL ) {
2336  v_[i ] += (~rhs)[i ];
2337  v_[i+1UL] += (~rhs)[i+1UL];
2338  }
2339  if( ipos < (~rhs).size() )
2340  v_[ipos] += (~rhs)[ipos];
2341 }
2342 //*************************************************************************************************
2343 
2344 
2345 //*************************************************************************************************
2356 template< typename Type // Data type of the vector
2357  , bool AF // Alignment flag
2358  , bool PF // Padding flag
2359  , bool TF > // Transpose flag
2360 template< typename VT > // Type of the right-hand side dense vector
2363 {
2365 
2366  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2367 
2368  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2369  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2370 
2371  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2372  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2373  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2374 
2375  size_t i( 0UL );
2376  ConstIterator_<VT> it( (~rhs).begin() );
2377 
2378  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2379  store( i , load(i ) + it.load() ); it += SIMDSIZE;
2380  store( i+SIMDSIZE , load(i+SIMDSIZE ) + it.load() ); it += SIMDSIZE;
2381  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) + it.load() ); it += SIMDSIZE;
2382  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) + it.load() ); it += SIMDSIZE;
2383  }
2384  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2385  store( i, load(i) + it.load() );
2386  }
2387  for( ; i<size_; ++i, ++it ) {
2388  v_[i] += *it;
2389  }
2390 }
2391 //*************************************************************************************************
2392 
2393 
2394 //*************************************************************************************************
2405 template< typename Type // Data type of the vector
2406  , bool AF // Alignment flag
2407  , bool PF // Padding flag
2408  , bool TF > // Transpose flag
2409 template< typename VT > // Type of the right-hand side sparse vector
2411 {
2412  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2413 
2414  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2415  v_[element->index()] += element->value();
2416 }
2417 //*************************************************************************************************
2418 
2419 
2420 //*************************************************************************************************
2431 template< typename Type // Data type of the vector
2432  , bool AF // Alignment flag
2433  , bool PF // Padding flag
2434  , bool TF > // Transpose flag
2435 template< typename VT > // Type of the right-hand side dense vector
2438 {
2439  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2440 
2441  const size_t ipos( size_ & size_t(-2) );
2442  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2443 
2444  for( size_t i=0UL; i<ipos; i+=2UL ) {
2445  v_[i ] -= (~rhs)[i ];
2446  v_[i+1UL] -= (~rhs)[i+1UL];
2447  }
2448  if( ipos < (~rhs).size() )
2449  v_[ipos] -= (~rhs)[ipos];
2450 }
2451 //*************************************************************************************************
2452 
2453 
2454 //*************************************************************************************************
2465 template< typename Type // Data type of the vector
2466  , bool AF // Alignment flag
2467  , bool PF // Padding flag
2468  , bool TF > // Transpose flag
2469 template< typename VT > // Type of the right-hand side dense vector
2472 {
2474 
2475  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2476 
2477  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2478  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2479 
2480  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2481  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2482  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2483 
2484  size_t i( 0UL );
2485  ConstIterator_<VT> it( (~rhs).begin() );
2486 
2487  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2488  store( i , load(i ) - it.load() ); it += SIMDSIZE;
2489  store( i+SIMDSIZE , load(i+SIMDSIZE ) - it.load() ); it += SIMDSIZE;
2490  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) - it.load() ); it += SIMDSIZE;
2491  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) - it.load() ); it += SIMDSIZE;
2492  }
2493  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2494  store( i, load(i) - it.load() );
2495  }
2496  for( ; i<size_; ++i, ++it ) {
2497  v_[i] -= *it;
2498  }
2499 }
2500 //*************************************************************************************************
2501 
2502 
2503 //*************************************************************************************************
2514 template< typename Type // Data type of the vector
2515  , bool AF // Alignment flag
2516  , bool PF // Padding flag
2517  , bool TF > // Transpose flag
2518 template< typename VT > // Type of the right-hand side sparse vector
2520 {
2521  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2522 
2523  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2524  v_[element->index()] -= element->value();
2525 }
2526 //*************************************************************************************************
2527 
2528 
2529 //*************************************************************************************************
2540 template< typename Type // Data type of the vector
2541  , bool AF // Alignment flag
2542  , bool PF // Padding flag
2543  , bool TF > // Transpose flag
2544 template< typename VT > // Type of the right-hand side dense vector
2547 {
2548  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2549 
2550  const size_t ipos( size_ & size_t(-2) );
2551  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2552 
2553  for( size_t i=0UL; i<ipos; i+=2UL ) {
2554  v_[i ] *= (~rhs)[i ];
2555  v_[i+1UL] *= (~rhs)[i+1UL];
2556  }
2557  if( ipos < (~rhs).size() )
2558  v_[ipos] *= (~rhs)[ipos];
2559 }
2560 //*************************************************************************************************
2561 
2562 
2563 //*************************************************************************************************
2574 template< typename Type // Data type of the vector
2575  , bool AF // Alignment flag
2576  , bool PF // Padding flag
2577  , bool TF > // Transpose flag
2578 template< typename VT > // Type of the right-hand side dense vector
2581 {
2583 
2584  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2585 
2586  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2587  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2588 
2589  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2590  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2591  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2592 
2593  size_t i( 0UL );
2594  ConstIterator_<VT> it( (~rhs).begin() );
2595 
2596  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2597  store( i , load(i ) * it.load() ); it += SIMDSIZE;
2598  store( i+SIMDSIZE , load(i+SIMDSIZE ) * it.load() ); it += SIMDSIZE;
2599  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) * it.load() ); it += SIMDSIZE;
2600  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) * it.load() ); it += SIMDSIZE;
2601  }
2602  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2603  store( i, load(i) * it.load() );
2604  }
2605  for( ; i<size_; ++i, ++it ) {
2606  v_[i] *= *it;
2607  }
2608 }
2609 //*************************************************************************************************
2610 
2611 
2612 //*************************************************************************************************
2623 template< typename Type // Data type of the vector
2624  , bool AF // Alignment flag
2625  , bool PF // Padding flag
2626  , bool TF > // Transpose flag
2627 template< typename VT > // Type of the right-hand side sparse vector
2629 {
2630  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2631 
2632  const DynamicVector<Type,TF> tmp( serial( *this ) );
2633 
2634  reset();
2635 
2636  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2637  v_[element->index()] = tmp[element->index()] * element->value();
2638 }
2639 //*************************************************************************************************
2640 
2641 
2642 //*************************************************************************************************
2653 template< typename Type // Data type of the vector
2654  , bool AF // Alignment flag
2655  , bool PF // Padding flag
2656  , bool TF > // Transpose flag
2657 template< typename VT > // Type of the right-hand side dense vector
2660 {
2661  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2662 
2663  const size_t ipos( size_ & size_t(-2) );
2664  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2665 
2666  for( size_t i=0UL; i<ipos; i+=2UL ) {
2667  v_[i ] /= (~rhs)[i ];
2668  v_[i+1UL] /= (~rhs)[i+1UL];
2669  }
2670  if( ipos < (~rhs).size() )
2671  v_[ipos] /= (~rhs)[ipos];
2672 }
2673 //*************************************************************************************************
2674 
2675 
2676 //*************************************************************************************************
2687 template< typename Type // Data type of the vector
2688  , bool AF // Alignment flag
2689  , bool PF // Padding flag
2690  , bool TF > // Transpose flag
2691 template< typename VT > // Type of the right-hand side dense vector
2694 {
2696 
2697  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2698 
2699  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2700  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2701 
2702  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2703  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2704  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2705 
2706  size_t i( 0UL );
2707  ConstIterator_<VT> it( (~rhs).begin() );
2708 
2709  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2710  store( i , load(i ) / it.load() ); it += SIMDSIZE;
2711  store( i+SIMDSIZE , load(i+SIMDSIZE ) / it.load() ); it += SIMDSIZE;
2712  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) / it.load() ); it += SIMDSIZE;
2713  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) / it.load() ); it += SIMDSIZE;
2714  }
2715  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2716  store( i, load(i) / it.load() );
2717  }
2718  for( ; i<size_; ++i, ++it ) {
2719  v_[i] /= *it;
2720  }
2721 }
2722 //*************************************************************************************************
2723 
2724 
2725 
2726 
2727 
2728 
2729 
2730 
2731 //=================================================================================================
2732 //
2733 // CLASS TEMPLATE SPECIALIZATION FOR PADDED VECTORS
2734 //
2735 //=================================================================================================
2736 
2737 //*************************************************************************************************
2745 template< typename Type // Data type of the vector
2746  , bool AF // Alignment flag
2747  , bool TF > // Transpose flag
2748 class CustomVector<Type,AF,padded,TF>
2749  : public DenseVector< CustomVector<Type,AF,padded,TF>, TF >
2750 {
2751  public:
2752  //**Type definitions****************************************************************************
2756  typedef Type ElementType;
2758  typedef const Type& ReturnType;
2759  typedef const CustomVector& CompositeType;
2760 
2761  typedef Type& Reference;
2762  typedef const Type& ConstReference;
2763  typedef Type* Pointer;
2764  typedef const Type* ConstPointer;
2765 
2768  //**********************************************************************************************
2769 
2770  //**Rebind struct definition********************************************************************
2773  template< typename ET > // Data type of the other vector
2774  struct Rebind {
2776  };
2777  //**********************************************************************************************
2778 
2779  //**Compilation flags***************************************************************************
2781 
2785  enum : bool { simdEnabled = IsVectorizable<Type>::value };
2786 
2788 
2791  enum : bool { smpAssignable = !IsSMPAssignable<Type>::value };
2792  //**********************************************************************************************
2793 
2794  //**Constructors********************************************************************************
2797  explicit inline CustomVector();
2798  explicit inline CustomVector( Type* ptr, size_t n, size_t nn );
2799 
2800  template< typename Deleter >
2801  explicit inline CustomVector( Type* ptr, size_t n, size_t nn, Deleter d );
2802 
2803  inline CustomVector( const CustomVector& v );
2804  inline CustomVector( CustomVector&& v ) noexcept;
2806  //**********************************************************************************************
2807 
2808  //**Destructor**********************************************************************************
2809  // No explicitly declared destructor.
2810  //**********************************************************************************************
2811 
2812  //**Data access functions***********************************************************************
2815  inline Reference operator[]( size_t index ) noexcept;
2816  inline ConstReference operator[]( size_t index ) const noexcept;
2817  inline Reference at( size_t index );
2818  inline ConstReference at( size_t index ) const;
2819  inline Pointer data () noexcept;
2820  inline ConstPointer data () const noexcept;
2821  inline Iterator begin () noexcept;
2822  inline ConstIterator begin () const noexcept;
2823  inline ConstIterator cbegin() const noexcept;
2824  inline Iterator end () noexcept;
2825  inline ConstIterator end () const noexcept;
2826  inline ConstIterator cend () const noexcept;
2828  //**********************************************************************************************
2829 
2830  //**Assignment operators************************************************************************
2833  inline CustomVector& operator=( const Type& rhs );
2834  inline CustomVector& operator=( initializer_list<Type> list );
2835 
2836  template< typename Other, size_t N >
2837  inline CustomVector& operator=( const Other (&array)[N] );
2838 
2839  inline CustomVector& operator=( const CustomVector& rhs );
2840  inline CustomVector& operator=( CustomVector&& rhs ) noexcept;
2841 
2842  template< typename VT > inline CustomVector& operator= ( const Vector<VT,TF>& rhs );
2843  template< typename VT > inline CustomVector& operator+=( const Vector<VT,TF>& rhs );
2844  template< typename VT > inline CustomVector& operator-=( const Vector<VT,TF>& rhs );
2845  template< typename VT > inline CustomVector& operator*=( const Vector<VT,TF>& rhs );
2846  template< typename VT > inline CustomVector& operator/=( const DenseVector<VT,TF>& rhs );
2847 
2848  template< typename Other >
2849  inline EnableIf_<IsNumeric<Other>, CustomVector >& operator*=( Other rhs );
2850 
2851  template< typename Other >
2852  inline EnableIf_<IsNumeric<Other>, CustomVector >& operator/=( Other rhs );
2854  //**********************************************************************************************
2855 
2856  //**Utility functions***************************************************************************
2859  inline size_t size() const noexcept;
2860  inline size_t capacity() const noexcept;
2861  inline size_t nonZeros() const;
2862  inline void reset();
2863  inline void clear();
2864  template< typename Other > inline CustomVector& scale( const Other& scalar );
2865  inline void swap( CustomVector& v ) noexcept;
2867  //**********************************************************************************************
2868 
2869  //**Resource management functions***************************************************************
2872  inline void reset( Type* ptr, size_t n, size_t nn );
2873  template< typename Deleter > inline void reset( Type* ptr, size_t n, size_t nn, Deleter d );
2875  //**********************************************************************************************
2876 
2877  private:
2878  //**********************************************************************************************
2880  template< typename VT >
2881  struct VectorizedAssign {
2882  enum : bool { value = useOptimizedKernels &&
2883  simdEnabled && VT::simdEnabled &&
2884  AreSIMDCombinable< Type, ElementType_<VT> >::value };
2885  };
2886  //**********************************************************************************************
2887 
2888  //**********************************************************************************************
2890  template< typename VT >
2891  struct VectorizedAddAssign {
2892  enum : bool { value = useOptimizedKernels &&
2893  simdEnabled && VT::simdEnabled &&
2894  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
2895  HasSIMDAdd< Type, ElementType_<VT> >::value };
2896  };
2897  //**********************************************************************************************
2898 
2899  //**********************************************************************************************
2901  template< typename VT >
2902  struct VectorizedSubAssign {
2903  enum : bool { value = useOptimizedKernels &&
2904  simdEnabled && VT::simdEnabled &&
2905  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
2906  HasSIMDSub< Type, ElementType_<VT> >::value };
2907  };
2908  //**********************************************************************************************
2909 
2910  //**********************************************************************************************
2912  template< typename VT >
2913  struct VectorizedMultAssign {
2914  enum : bool { value = useOptimizedKernels &&
2915  simdEnabled && VT::simdEnabled &&
2916  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
2917  HasSIMDMult< Type, ElementType_<VT> >::value };
2918  };
2919  //**********************************************************************************************
2920 
2921  //**********************************************************************************************
2923  template< typename VT >
2924  struct VectorizedDivAssign {
2925  enum : bool { value = useOptimizedKernels &&
2926  simdEnabled && VT::simdEnabled &&
2927  AreSIMDCombinable< Type, ElementType_<VT> >::value &&
2928  HasSIMDDiv< Type, ElementType_<VT> >::value };
2929  };
2930  //**********************************************************************************************
2931 
2932  //**SIMD properties*****************************************************************************
2934  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
2935  //**********************************************************************************************
2936 
2937  public:
2938  //**Expression template evaluation functions****************************************************
2941  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
2942  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
2943 
2944  inline bool isAligned () const noexcept;
2945  inline bool canSMPAssign() const noexcept;
2946 
2947  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
2948  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
2949  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
2950 
2951  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
2952  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
2953  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
2954  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
2955 
2956  template< typename VT >
2957  inline DisableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
2958 
2959  template< typename VT >
2960  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
2961 
2962  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
2963 
2964  template< typename VT >
2965  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
2966 
2967  template< typename VT >
2968  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
2969 
2970  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
2971 
2972  template< typename VT >
2973  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
2974 
2975  template< typename VT >
2976  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
2977 
2978  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
2979 
2980  template< typename VT >
2981  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
2982 
2983  template< typename VT >
2984  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
2985 
2986  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
2987 
2988  template< typename VT >
2989  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
2990 
2991  template< typename VT >
2992  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
2994  //**********************************************************************************************
2995 
2996  private:
2997  //**Member variables****************************************************************************
3000  size_t size_;
3001  size_t capacity_;
3002  boost::shared_array<Type> v_;
3003 
3009  //**********************************************************************************************
3010 
3011  //**Compile time checks*************************************************************************
3016  //**********************************************************************************************
3017 };
3019 //*************************************************************************************************
3020 
3021 
3022 
3023 
3024 //=================================================================================================
3025 //
3026 // CONSTRUCTORS
3027 //
3028 //=================================================================================================
3029 
3030 //*************************************************************************************************
3034 template< typename Type // Data type of the vector
3035  , bool AF // Alignment flag
3036  , bool TF > // Transpose flag
3037 inline CustomVector<Type,AF,padded,TF>::CustomVector()
3038  : size_ ( 0UL ) // The size/dimension of the vector
3039  , capacity_( 0UL ) // The maximum capacity of the vector
3040  , v_ ( ) // The custom array of elements
3041 {}
3043 //*************************************************************************************************
3044 
3045 
3046 //*************************************************************************************************
3068 template< typename Type // Data type of the vector
3069  , bool AF // Alignment flag
3070  , bool TF > // Transpose flag
3071 inline CustomVector<Type,AF,padded,TF>::CustomVector( Type* ptr, size_t n, size_t nn )
3072  : size_ ( n ) // The size/dimension of the vector
3073  , capacity_( nn ) // The maximum capacity of the vector
3074  , v_ ( ) // The custom array of elements
3075 {
3076  if( ptr == nullptr ) {
3077  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array of elements" );
3078  }
3079 
3080  if( AF && !checkAlignment( ptr ) ) {
3081  BLAZE_THROW_INVALID_ARGUMENT( "Invalid alignment detected" );
3082  }
3083 
3084  if( IsVectorizable<Type>::value && capacity_ < nextMultiple<size_t>( size_, SIMDSIZE ) ) {
3085  BLAZE_THROW_INVALID_ARGUMENT( "Insufficient capacity for padded vector" );
3086  }
3087 
3088  v_.reset( ptr, NoDelete() );
3089 
3090  if( IsVectorizable<Type>::value ) {
3091  for( size_t i=size_; i<capacity_; ++i )
3092  v_[i] = Type();
3093  }
3094 }
3096 //*************************************************************************************************
3097 
3098 
3099 //*************************************************************************************************
3120 template< typename Type // Data type of the vector
3121  , bool AF // Alignment flag
3122  , bool TF > // Transpose flag
3123 template< typename Deleter > // Type of the custom deleter
3124 inline CustomVector<Type,AF,padded,TF>::CustomVector( Type* ptr, size_t n, size_t nn, Deleter d )
3125  : size_ ( n ) // The custom array of elements
3126  , capacity_( nn ) // The maximum capacity of the vector
3127  , v_ ( ) // The custom array of elements
3128 {
3129  if( ptr == nullptr ) {
3130  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array of elements" );
3131  }
3132 
3133  if( AF && !checkAlignment( ptr ) ) {
3134  BLAZE_THROW_INVALID_ARGUMENT( "Invalid alignment detected" );
3135  }
3136 
3137  if( IsVectorizable<Type>::value && capacity_ < nextMultiple<size_t>( size_, SIMDSIZE ) ) {
3138  BLAZE_THROW_INVALID_ARGUMENT( "Insufficient capacity for padded vector" );
3139  }
3140 
3141  v_.reset( ptr, d );
3142 
3143  if( IsVectorizable<Type>::value ) {
3144  for( size_t i=size_; i<capacity_; ++i )
3145  v_[i] = Type();
3146  }
3147 }
3149 //*************************************************************************************************
3150 
3151 
3152 //*************************************************************************************************
3160 template< typename Type // Data type of the vector
3161  , bool AF // Alignment flag
3162  , bool TF > // Transpose flag
3163 inline CustomVector<Type,AF,padded,TF>::CustomVector( const CustomVector& v )
3164  : size_ ( v.size_ ) // The size/dimension of the vector
3165  , capacity_( v.capacity_ ) // The maximum capacity of the vector
3166  , v_ ( v.v_ ) // The custom array of elements
3167 {}
3169 //*************************************************************************************************
3170 
3171 
3172 //*************************************************************************************************
3178 template< typename Type // Data type of the vector
3179  , bool AF // Alignment flag
3180  , bool TF > // Transpose flag
3181 inline CustomVector<Type,AF,padded,TF>::CustomVector( CustomVector&& v ) noexcept
3182  : size_ ( v.size_ ) // The size/dimension of the vector
3183  , capacity_( v.capacity_ ) // The maximum capacity of the vector
3184  , v_ ( std::move( v.v_ ) ) // The custom array of elements
3185 {
3186  v.size_ = 0UL;
3187  v.capacity_ = 0UL;
3188 
3189  BLAZE_INTERNAL_ASSERT( v.data() == nullptr, "Invalid data reference detected" );
3190 }
3192 //*************************************************************************************************
3193 
3194 
3195 
3196 
3197 //=================================================================================================
3198 //
3199 // DATA ACCESS FUNCTIONS
3200 //
3201 //=================================================================================================
3202 
3203 //*************************************************************************************************
3213 template< typename Type // Data type of the vector
3214  , bool AF // Alignment flag
3215  , bool TF > // Transpose flag
3217  CustomVector<Type,AF,padded,TF>::operator[]( size_t index ) noexcept
3218 {
3219  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
3220  return v_[index];
3221 }
3223 //*************************************************************************************************
3224 
3225 
3226 //*************************************************************************************************
3236 template< typename Type // Data type of the vector
3237  , bool AF // Alignment flag
3238  , bool TF > // Transpose flag
3240  CustomVector<Type,AF,padded,TF>::operator[]( size_t index ) const noexcept
3241 {
3242  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
3243  return v_[index];
3244 }
3246 //*************************************************************************************************
3247 
3248 
3249 //*************************************************************************************************
3260 template< typename Type // Data type of the vector
3261  , bool AF // Alignment flag
3262  , bool TF > // Transpose flag
3264  CustomVector<Type,AF,padded,TF>::at( size_t index )
3265 {
3266  if( index >= size_ ) {
3267  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
3268  }
3269  return (*this)[index];
3270 }
3272 //*************************************************************************************************
3273 
3274 
3275 //*************************************************************************************************
3286 template< typename Type // Data type of the vector
3287  , bool AF // Alignment flag
3288  , bool TF > // Transpose flag
3290  CustomVector<Type,AF,padded,TF>::at( size_t index ) const
3291 {
3292  if( index >= size_ ) {
3293  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
3294  }
3295  return (*this)[index];
3296 }
3298 //*************************************************************************************************
3299 
3300 
3301 //*************************************************************************************************
3309 template< typename Type // Data type of the vector
3310  , bool AF // Alignment flag
3311  , bool TF > // Transpose flag
3312 inline typename CustomVector<Type,AF,padded,TF>::Pointer
3314 {
3315  return v_.get();
3316 }
3318 //*************************************************************************************************
3319 
3320 
3321 //*************************************************************************************************
3329 template< typename Type // Data type of the vector
3330  , bool AF // Alignment flag
3331  , bool TF > // Transpose flag
3332 inline typename CustomVector<Type,AF,padded,TF>::ConstPointer
3333  CustomVector<Type,AF,padded,TF>::data() const noexcept
3334 {
3335  return v_.get();
3336 }
3338 //*************************************************************************************************
3339 
3340 
3341 //*************************************************************************************************
3347 template< typename Type // Data type of the vector
3348  , bool AF // Alignment flag
3349  , bool TF > // Transpose flag
3352 {
3353  return Iterator( v_.get() );
3354 }
3356 //*************************************************************************************************
3357 
3358 
3359 //*************************************************************************************************
3365 template< typename Type // Data type of the vector
3366  , bool AF // Alignment flag
3367  , bool TF > // Transpose flag
3370 {
3371  return ConstIterator( v_.get() );
3372 }
3374 //*************************************************************************************************
3375 
3376 
3377 //*************************************************************************************************
3383 template< typename Type // Data type of the vector
3384  , bool AF // Alignment flag
3385  , bool TF > // Transpose flag
3388 {
3389  return ConstIterator( v_.get() );
3390 }
3392 //*************************************************************************************************
3393 
3394 
3395 //*************************************************************************************************
3401 template< typename Type // Data type of the vector
3402  , bool AF // Alignment flag
3403  , bool TF > // Transpose flag
3406 {
3407  return Iterator( v_.get() + size_ );
3408 }
3410 //*************************************************************************************************
3411 
3412 
3413 //*************************************************************************************************
3419 template< typename Type // Data type of the vector
3420  , bool AF // Alignment flag
3421  , bool TF > // Transpose flag
3423  CustomVector<Type,AF,padded,TF>::end() const noexcept
3424 {
3425  return ConstIterator( v_.get() + size_ );
3426 }
3428 //*************************************************************************************************
3429 
3430 
3431 //*************************************************************************************************
3437 template< typename Type // Data type of the vector
3438  , bool AF // Alignment flag
3439  , bool TF > // Transpose flag
3441  CustomVector<Type,AF,padded,TF>::cend() const noexcept
3442 {
3443  return ConstIterator( v_.get() + size_ );
3444 }
3446 //*************************************************************************************************
3447 
3448 
3449 
3450 
3451 //=================================================================================================
3452 //
3453 // ASSIGNMENT OPERATORS
3454 //
3455 //=================================================================================================
3456 
3457 //*************************************************************************************************
3464 template< typename Type // Data type of the vector
3465  , bool AF // Alignment flag
3466  , bool TF > // Transpose flag
3467 inline CustomVector<Type,AF,padded,TF>&
3469 {
3470  for( size_t i=0UL; i<size_; ++i )
3471  v_[i] = rhs;
3472  return *this;
3473 }
3475 //*************************************************************************************************
3476 
3477 
3478 //*************************************************************************************************
3503 template< typename Type // Data type of the vector
3504  , bool AF // Alignment flag
3505  , bool TF > // Transpose flag
3506 inline CustomVector<Type,AF,padded,TF>&
3507  CustomVector<Type,AF,padded,TF>::operator=( initializer_list<Type> list )
3508 {
3509  if( list.size() > size_ ) {
3510  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to custom vector" );
3511  }
3512 
3513  std::fill( std::copy( list.begin(), list.end(), v_.get() ), v_.get()+capacity_, Type() );
3514 
3515  return *this;
3516 }
3518 //*************************************************************************************************
3519 
3520 
3521 //*************************************************************************************************
3549 template< typename Type // Data type of the vector
3550  , bool AF // Alignment flag
3551  , bool TF > // Transpose flag
3552 template< typename Other // Data type of the initialization array
3553  , size_t N > // Dimension of the initialization array
3554 inline CustomVector<Type,AF,padded,TF>&
3555  CustomVector<Type,AF,padded,TF>::operator=( const Other (&array)[N] )
3556 {
3557  if( size_ != N ) {
3558  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array size" );
3559  }
3560 
3561  for( size_t i=0UL; i<N; ++i )
3562  v_[i] = array[i];
3563 
3564  return *this;
3565 }
3567 //*************************************************************************************************
3568 
3569 
3570 //*************************************************************************************************
3581 template< typename Type // Data type of the vector
3582  , bool AF // Alignment flag
3583  , bool TF > // Transpose flag
3584 inline CustomVector<Type,AF,padded,TF>&
3585  CustomVector<Type,AF,padded,TF>::operator=( const CustomVector& rhs )
3586 {
3587  if( rhs.size() != size_ ) {
3588  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3589  }
3590 
3591  smpAssign( *this, ~rhs );
3592 
3593  return *this;
3594 }
3596 //*************************************************************************************************
3597 
3598 
3599 //*************************************************************************************************
3606 template< typename Type // Data type of the vector
3607  , bool AF // Alignment flag
3608  , bool TF > // Transpose flag
3609 inline CustomVector<Type,AF,padded,TF>&
3610  CustomVector<Type,AF,padded,TF>::operator=( CustomVector&& rhs ) noexcept
3611 {
3612  size_ = rhs.size_;
3613  capacity_ = rhs.capacity_;
3614  v_ = std::move( rhs.v_ );
3615 
3616  rhs.size_ = 0UL;
3617  rhs.capacity_ = 0UL;
3618 
3619  BLAZE_INTERNAL_ASSERT( rhs.data() == nullptr, "Invalid data reference detected" );
3620 
3621  return *this;
3622 }
3624 //*************************************************************************************************
3625 
3626 
3627 //*************************************************************************************************
3638 template< typename Type // Data type of the vector
3639  , bool AF // Alignment flag
3640  , bool TF > // Transpose flag
3641 template< typename VT > // Type of the right-hand side vector
3642 inline CustomVector<Type,AF,padded,TF>&
3643  CustomVector<Type,AF,padded,TF>::operator=( const Vector<VT,TF>& rhs )
3644 {
3645  if( (~rhs).size() != size_ ) {
3646  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3647  }
3648 
3649  if( (~rhs).canAlias( this ) ) {
3650  const ResultType_<VT> tmp( ~rhs );
3651  smpAssign( *this, tmp );
3652  }
3653  else {
3654  if( IsSparseVector<VT>::value )
3655  reset();
3656  smpAssign( *this, ~rhs );
3657  }
3658 
3659  return *this;
3660 }
3662 //*************************************************************************************************
3663 
3664 
3665 //*************************************************************************************************
3676 template< typename Type // Data type of the vector
3677  , bool AF // Alignment flag
3678  , bool TF > // Transpose flag
3679 template< typename VT > // Type of the right-hand side vector
3680 inline CustomVector<Type,AF,padded,TF>&
3681  CustomVector<Type,AF,padded,TF>::operator+=( const Vector<VT,TF>& rhs )
3682 {
3683  if( (~rhs).size() != size_ ) {
3684  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3685  }
3686 
3687  if( (~rhs).canAlias( this ) ) {
3688  const ResultType_<VT> tmp( ~rhs );
3689  smpAddAssign( *this, tmp );
3690  }
3691  else {
3692  smpAddAssign( *this, ~rhs );
3693  }
3694 
3695  return *this;
3696 }
3698 //*************************************************************************************************
3699 
3700 
3701 //*************************************************************************************************
3713 template< typename Type // Data type of the vector
3714  , bool AF // Alignment flag
3715  , bool TF > // Transpose flag
3716 template< typename VT > // Type of the right-hand side vector
3717 inline CustomVector<Type,AF,padded,TF>&
3718  CustomVector<Type,AF,padded,TF>::operator-=( const Vector<VT,TF>& rhs )
3719 {
3720  if( (~rhs).size() != size_ ) {
3721  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3722  }
3723 
3724  if( (~rhs).canAlias( this ) ) {
3725  const ResultType_<VT> tmp( ~rhs );
3726  smpSubAssign( *this, tmp );
3727  }
3728  else {
3729  smpSubAssign( *this, ~rhs );
3730  }
3731 
3732  return *this;
3733 }
3735 //*************************************************************************************************
3736 
3737 
3738 //*************************************************************************************************
3750 template< typename Type // Data type of the vector
3751  , bool AF // Alignment flag
3752  , bool TF > // Transpose flag
3753 template< typename VT > // Type of the right-hand side vector
3754 inline CustomVector<Type,AF,padded,TF>&
3755  CustomVector<Type,AF,padded,TF>::operator*=( const Vector<VT,TF>& rhs )
3756 {
3759 
3760  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
3761 
3764 
3765  if( (~rhs).size() != size_ ) {
3766  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3767  }
3768 
3769  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
3770  const MultType tmp( *this * (~rhs) );
3771  this->operator=( tmp );
3772  }
3773  else {
3774  smpMultAssign( *this, ~rhs );
3775  }
3776 
3777  return *this;
3778 }
3780 //*************************************************************************************************
3781 
3782 
3783 //*************************************************************************************************
3794 template< typename Type // Data type of the vector
3795  , bool AF // Alignment flag
3796  , bool TF > // Transpose flag
3797 template< typename VT > // Type of the right-hand side vector
3798 inline CustomVector<Type,AF,padded,TF>&
3799  CustomVector<Type,AF,padded,TF>::operator/=( const DenseVector<VT,TF>& rhs )
3800 {
3803 
3804  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
3805 
3808 
3809  if( (~rhs).size() != size_ ) {
3810  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3811  }
3812 
3813  if( (~rhs).canAlias( this ) ) {
3814  const DivType tmp( *this / (~rhs) );
3815  this->operator=( tmp );
3816  }
3817  else {
3818  smpDivAssign( *this, ~rhs );
3819  }
3820 
3821  return *this;
3822 }
3824 //*************************************************************************************************
3825 
3826 
3827 //*************************************************************************************************
3835 template< typename Type // Data type of the vector
3836  , bool AF // Alignment flag
3837  , bool TF > // Transpose flag
3838 template< typename Other > // Data type of the right-hand side scalar
3839 inline EnableIf_<IsNumeric<Other>, CustomVector<Type,AF,padded,TF> >&
3841 {
3842  smpAssign( *this, (*this) * rhs );
3843  return *this;
3844 }
3846 //*************************************************************************************************
3847 
3848 
3849 //*************************************************************************************************
3859 template< typename Type // Data type of the vector
3860  , bool AF // Alignment flag
3861  , bool TF > // Transpose flag
3862 template< typename Other > // Data type of the right-hand side scalar
3863 inline EnableIf_<IsNumeric<Other>, CustomVector<Type,AF,padded,TF> >&
3865 {
3866  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3867 
3868  smpAssign( *this, (*this) / rhs );
3869  return *this;
3870 }
3872 //*************************************************************************************************
3873 
3874 
3875 
3876 
3877 //=================================================================================================
3878 //
3879 // UTILITY FUNCTIONS
3880 //
3881 //=================================================================================================
3882 
3883 //*************************************************************************************************
3889 template< typename Type // Data type of the vector
3890  , bool AF // Alignment flag
3891  , bool TF > // Transpose flag
3892 inline size_t CustomVector<Type,AF,padded,TF>::size() const noexcept
3893 {
3894  return size_;
3895 }
3897 //*************************************************************************************************
3898 
3899 
3900 //*************************************************************************************************
3906 template< typename Type // Data type of the vector
3907  , bool AF // Alignment flag
3908  , bool TF > // Transpose flag
3909 inline size_t CustomVector<Type,AF,padded,TF>::capacity() const noexcept
3910 {
3911  return capacity_;
3912 }
3914 //*************************************************************************************************
3915 
3916 
3917 //*************************************************************************************************
3926 template< typename Type // Data type of the vector
3927  , bool AF // Alignment flag
3928  , bool TF > // Transpose flag
3929 inline size_t CustomVector<Type,AF,padded,TF>::nonZeros() const
3930 {
3931  size_t nonzeros( 0 );
3932 
3933  for( size_t i=0UL; i<size_; ++i ) {
3934  if( !isDefault( v_[i] ) )
3935  ++nonzeros;
3936  }
3937 
3938  return nonzeros;
3939 }
3941 //*************************************************************************************************
3942 
3943 
3944 //*************************************************************************************************
3950 template< typename Type // Data type of the vector
3951  , bool AF // Alignment flag
3952  , bool TF > // Transpose flag
3954 {
3955  using blaze::clear;
3956  for( size_t i=0UL; i<size_; ++i )
3957  clear( v_[i] );
3958 }
3960 //*************************************************************************************************
3961 
3962 
3963 //*************************************************************************************************
3972 template< typename Type // Data type of the vector
3973  , bool AF // Alignment flag
3974  , bool TF > // Transpose flag
3976 {
3977  size_ = 0UL;
3978  capacity_ = 0UL;
3979  v_.reset();
3980 }
3982 //*************************************************************************************************
3983 
3984 
3985 //*************************************************************************************************
3992 template< typename Type // Data type of the vector
3993  , bool AF // Alignment flag
3994  , bool TF > // Transpose flag
3995 template< typename Other > // Data type of the scalar value
3996 inline CustomVector<Type,AF,padded,TF>&
3997  CustomVector<Type,AF,padded,TF>::scale( const Other& scalar )
3998 {
3999  for( size_t i=0UL; i<size_; ++i )
4000  v_[i] *= scalar;
4001  return *this;
4002 }
4004 //*************************************************************************************************
4005 
4006 
4007 //*************************************************************************************************
4014 template< typename Type // Data type of the vector
4015  , bool AF // Alignment flag
4016  , bool TF > // Transpose flag
4017 inline void CustomVector<Type,AF,padded,TF>::swap( CustomVector& v ) noexcept
4018 {
4019  using std::swap;
4020 
4021  swap( size_, v.size_ );
4022  swap( capacity_, v.capacity_ );
4023  swap( v_, v.v_ );
4024 }
4026 //*************************************************************************************************
4027 
4028 
4029 
4030 
4031 //=================================================================================================
4032 //
4033 // RESOURCE MANAGEMENT FUNCTIONS
4034 //
4035 //=================================================================================================
4036 
4037 //*************************************************************************************************
4060 template< typename Type // Data type of the vector
4061  , bool AF // Alignment flag
4062  , bool TF > // Transpose flag
4063 inline void CustomVector<Type,AF,padded,TF>::reset( Type* ptr, size_t n, size_t nn )
4064 {
4065  CustomVector tmp( ptr, n, nn );
4066  swap( tmp );
4067 }
4069 //*************************************************************************************************
4070 
4071 
4072 //*************************************************************************************************
4095 template< typename Type // Data type of the vector
4096  , bool AF // Alignment flag
4097  , bool TF > // Transpose flag
4098 template< typename Deleter > // Type of the custom deleter
4099 inline void CustomVector<Type,AF,padded,TF>::reset( Type* ptr, size_t n, size_t nn, Deleter d )
4100 {
4101  CustomVector tmp( ptr, n, nn, d );
4102  swap( tmp );
4103 }
4105 //*************************************************************************************************
4106 
4107 
4108 
4109 
4110 //=================================================================================================
4111 //
4112 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
4113 //
4114 //=================================================================================================
4115 
4116 //*************************************************************************************************
4127 template< typename Type // Data type of the vector
4128  , bool AF // Alignment flag
4129  , bool TF > // Transpose flag
4130 template< typename Other > // Data type of the foreign expression
4131 inline bool CustomVector<Type,AF,padded,TF>::canAlias( const Other* alias ) const noexcept
4132 {
4133  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4134 }
4136 //*************************************************************************************************
4137 
4138 
4139 //*************************************************************************************************
4150 template< typename Type // Data type of the vector
4151  , bool AF // Alignment flag
4152  , bool TF > // Transpose flag
4153 template< typename Other > // Data type of the foreign expression
4154 inline bool CustomVector<Type,AF,padded,TF>::isAliased( const Other* alias ) const noexcept
4155 {
4156  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4157 }
4159 //*************************************************************************************************
4160 
4161 
4162 //*************************************************************************************************
4172 template< typename Type // Data type of the vector
4173  , bool AF // Alignment flag
4174  , bool TF > // Transpose flag
4175 inline bool CustomVector<Type,AF,padded,TF>::isAligned() const noexcept
4176 {
4177  return ( AF || checkAlignment( v_.get() ) );
4178 }
4180 //*************************************************************************************************
4181 
4182 
4183 //*************************************************************************************************
4194 template< typename Type // Data type of the vector
4195  , bool AF // Alignment flag
4196  , bool TF > // Transpose flag
4197 inline bool CustomVector<Type,AF,padded,TF>::canSMPAssign() const noexcept
4198 {
4199  return ( size() > SMP_DVECASSIGN_THRESHOLD );
4200 }
4202 //*************************************************************************************************
4203 
4204 
4205 //*************************************************************************************************
4218 template< typename Type // Data type of the vector
4219  , bool AF // Alignment flag
4220  , bool TF > // Transpose flag
4221 BLAZE_ALWAYS_INLINE typename CustomVector<Type,AF,padded,TF>::SIMDType
4222  CustomVector<Type,AF,padded,TF>::load( size_t index ) const noexcept
4223 {
4224  if( AF )
4225  return loada( index );
4226  else
4227  return loadu( index );
4228 }
4230 //*************************************************************************************************
4231 
4232 
4233 //*************************************************************************************************
4247 template< typename Type // Data type of the vector
4248  , bool AF // Alignment flag
4249  , bool TF > // Transpose flag
4250 BLAZE_ALWAYS_INLINE typename CustomVector<Type,AF,padded,TF>::SIMDType
4251  CustomVector<Type,AF,padded,TF>::loada( size_t index ) const noexcept
4252 {
4253  using blaze::loada;
4254 
4256 
4257  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4258  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4259  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
4260  BLAZE_INTERNAL_ASSERT( checkAlignment( v_.get()+index ), "Invalid vector access index" );
4261 
4262  return loada( v_.get()+index );
4263 }
4265 //*************************************************************************************************
4266 
4267 
4268 //*************************************************************************************************
4282 template< typename Type // Data type of the vector
4283  , bool AF // Alignment flag
4284  , bool TF > // Transpose flag
4285 BLAZE_ALWAYS_INLINE typename CustomVector<Type,AF,padded,TF>::SIMDType
4286  CustomVector<Type,AF,padded,TF>::loadu( size_t index ) const noexcept
4287 {
4288  using blaze::loadu;
4289 
4291 
4292  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4293  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4294 
4295  return loadu( v_.get()+index );
4296 }
4298 //*************************************************************************************************
4299 
4300 
4301 //*************************************************************************************************
4315 template< typename Type // Data type of the vector
4316  , bool AF // Alignment flag
4317  , bool TF > // Transpose flag
4319  CustomVector<Type,AF,padded,TF>::store( size_t index, const SIMDType& value ) noexcept
4320 {
4321  if( AF )
4322  storea( index, value );
4323  else
4324  storeu( index, value );
4325 }
4327 //*************************************************************************************************
4328 
4329 
4330 //*************************************************************************************************
4344 template< typename Type // Data type of the vector
4345  , bool AF // Alignment flag
4346  , bool TF > // Transpose flag
4348  CustomVector<Type,AF,padded,TF>::storea( size_t index, const SIMDType& value ) noexcept
4349 {
4350  using blaze::storea;
4351 
4353 
4354  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4355  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4356  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
4357  BLAZE_INTERNAL_ASSERT( checkAlignment( v_.get()+index ), "Invalid vector access index" );
4358 
4359  storea( v_.get()+index, value );
4360 }
4362 //*************************************************************************************************
4363 
4364 
4365 //*************************************************************************************************
4379 template< typename Type // Data type of the vector
4380  , bool AF // Alignment flag
4381  , bool TF > // Transpose flag
4383  CustomVector<Type,AF,padded,TF>::storeu( size_t index, const SIMDType& value ) noexcept
4384 {
4385  using blaze::storeu;
4386 
4388 
4389  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4390  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4391 
4392  storeu( v_.get()+index, value );
4393 }
4395 //*************************************************************************************************
4396 
4397 
4398 //*************************************************************************************************
4413 template< typename Type // Data type of the vector
4414  , bool AF // Alignment flag
4415  , bool TF > // Transpose flag
4417  CustomVector<Type,AF,padded,TF>::stream( size_t index, const SIMDType& value ) noexcept
4418 {
4419  using blaze::stream;
4420 
4422 
4423  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4424  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4425  BLAZE_INTERNAL_ASSERT( checkAlignment( v_.get()+index ), "Invalid vector access index" );
4426 
4427  stream( v_.get()+index, value );
4428 }
4430 //*************************************************************************************************
4431 
4432 
4433 //*************************************************************************************************
4445 template< typename Type // Data type of the vector
4446  , bool AF // Alignment flag
4447  , bool TF > // Transpose flag
4448 template< typename VT > // Type of the right-hand side dense vector
4449 inline DisableIf_<typename CustomVector<Type,AF,padded,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >
4450  CustomVector<Type,AF,padded,TF>::assign( const DenseVector<VT,TF>& rhs )
4451 {
4452  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4453 
4454  const size_t ipos( size_ & size_t(-2) );
4455  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4456 
4457  for( size_t i=0UL; i<ipos; i+=2UL ) {
4458  v_[i ] = (~rhs)[i ];
4459  v_[i+1UL] = (~rhs)[i+1UL];
4460  }
4461  if( ipos < (~rhs).size() )
4462  v_[ipos] = (~rhs)[ipos];
4463 }
4465 //*************************************************************************************************
4466 
4467 
4468 //*************************************************************************************************
4480 template< typename Type // Data type of the vector
4481  , bool AF // Alignment flag
4482  , bool TF > // Transpose flag
4483 template< typename VT > // Type of the right-hand side dense vector
4484 inline EnableIf_<typename CustomVector<Type,AF,padded,TF>::BLAZE_TEMPLATE VectorizedAssign<VT> >
4485  CustomVector<Type,AF,padded,TF>::assign( const DenseVector<VT,TF>& rhs )
4486 {
4488 
4489  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4490 
4491  const bool remainder( !IsPadded<VT>::value );
4492 
4493  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
4494  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4495 
4496  if( AF && useStreaming && size_ > ( cacheSize/( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
4497  {
4498  size_t i( 0UL );
4499 
4500  for( ; i<ipos; i+=SIMDSIZE ) {
4501  stream( i, (~rhs).load(i) );
4502  }
4503  for( ; remainder && i<size_; ++i ) {
4504  v_[i] = (~rhs)[i];
4505  }
4506  }
4507  else
4508  {
4509  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4510  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4511  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4512 
4513  size_t i( 0UL );
4514  ConstIterator_<VT> it( (~rhs).begin() );
4515 
4516  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4517  store( i , it.load() ); it += SIMDSIZE;
4518  store( i+SIMDSIZE , it.load() ); it += SIMDSIZE;
4519  store( i+SIMDSIZE*2UL, it.load() ); it += SIMDSIZE;
4520  store( i+SIMDSIZE*3UL, it.load() ); it += SIMDSIZE;
4521  }
4522  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4523  store( i, it.load() );
4524  }
4525  for( ; remainder && i<size_; ++i, ++it ) {
4526  v_[i] = *it;
4527  }
4528  }
4529 }
4531 //*************************************************************************************************
4532 
4533 
4534 //*************************************************************************************************
4546 template< typename Type // Data type of the vector
4547  , bool AF // Alignment flag
4548  , bool TF > // Transpose flag
4549 template< typename VT > // Type of the right-hand side sparse vector
4550 inline void CustomVector<Type,AF,padded,TF>::assign( const SparseVector<VT,TF>& rhs )
4551 {
4552  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4553 
4554  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
4555  v_[element->index()] = element->value();
4556 }
4558 //*************************************************************************************************
4559 
4560 
4561 //*************************************************************************************************
4573 template< typename Type // Data type of the vector
4574  , bool AF // Alignment flag
4575  , bool TF > // Transpose flag
4576 template< typename VT > // Type of the right-hand side dense vector
4577 inline DisableIf_<typename CustomVector<Type,AF,padded,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
4578  CustomVector<Type,AF,padded,TF>::addAssign( const DenseVector<VT,TF>& rhs )
4579 {
4580  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4581 
4582  const size_t ipos( size_ & size_t(-2) );
4583  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4584 
4585  for( size_t i=0UL; i<ipos; i+=2UL ) {
4586  v_[i ] += (~rhs)[i ];
4587  v_[i+1UL] += (~rhs)[i+1UL];
4588  }
4589  if( ipos < (~rhs).size() )
4590  v_[ipos] += (~rhs)[ipos];
4591 }
4593 //*************************************************************************************************
4594 
4595 
4596 //*************************************************************************************************
4608 template< typename Type // Data type of the vector
4609  , bool AF // Alignment flag
4610  , bool TF > // Transpose flag
4611 template< typename VT > // Type of the right-hand side dense vector
4612 inline EnableIf_<typename CustomVector<Type,AF,padded,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
4613  CustomVector<Type,AF,padded,TF>::addAssign( const DenseVector<VT,TF>& rhs )
4614 {
4616 
4617  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4618 
4619  const bool remainder( !IsPadded<VT>::value );
4620 
4621  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
4622  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4623 
4624  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4625  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4626  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4627 
4628  size_t i( 0UL );
4629  ConstIterator_<VT> it( (~rhs).begin() );
4630 
4631  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4632  store( i , load(i ) + it.load() ); it += SIMDSIZE;
4633  store( i+SIMDSIZE , load(i+SIMDSIZE ) + it.load() ); it += SIMDSIZE;
4634  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) + it.load() ); it += SIMDSIZE;
4635  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) + it.load() ); it += SIMDSIZE;
4636  }
4637  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4638  store( i, load(i) + it.load() );
4639  }
4640  for( ; remainder && i<size_; ++i, ++it ) {
4641  v_[i] += *it;
4642  }
4643 }
4645 //*************************************************************************************************
4646 
4647 
4648 //*************************************************************************************************
4660 template< typename Type // Data type of the vector
4661  , bool AF // Alignment flag
4662  , bool TF > // Transpose flag
4663 template< typename VT > // Type of the right-hand side sparse vector
4664 inline void CustomVector<Type,AF,padded,TF>::addAssign( const SparseVector<VT,TF>& rhs )
4665 {
4666  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4667 
4668  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
4669  v_[element->index()] += element->value();
4670 }
4672 //*************************************************************************************************
4673 
4674 
4675 //*************************************************************************************************
4687 template< typename Type // Data type of the vector
4688  , bool AF // Alignment flag
4689  , bool TF > // Transpose flag
4690 template< typename VT > // Type of the right-hand side dense vector
4691 inline DisableIf_<typename CustomVector<Type,AF,padded,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
4692  CustomVector<Type,AF,padded,TF>::subAssign( const DenseVector<VT,TF>& rhs )
4693 {
4694  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4695 
4696  const size_t ipos( size_ & size_t(-2) );
4697  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4698 
4699  for( size_t i=0UL; i<ipos; i+=2UL ) {
4700  v_[i ] -= (~rhs)[i ];
4701  v_[i+1UL] -= (~rhs)[i+1UL];
4702  }
4703  if( ipos < (~rhs).size() )
4704  v_[ipos] -= (~rhs)[ipos];
4705 }
4707 //*************************************************************************************************
4708 
4709 
4710 //*************************************************************************************************
4722 template< typename Type // Data type of the vector
4723  , bool AF // Alignment flag
4724  , bool TF > // Transpose flag
4725 template< typename VT > // Type of the right-hand side dense vector
4726 inline EnableIf_<typename CustomVector<Type,AF,padded,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
4727  CustomVector<Type,AF,padded,TF>::subAssign( const DenseVector<VT,TF>& rhs )
4728 {
4730 
4731  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4732 
4733  const bool remainder( !IsPadded<VT>::value );
4734 
4735  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
4736  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4737 
4738  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4739  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4740  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4741 
4742  size_t i( 0UL );
4743  ConstIterator_<VT> it( (~rhs).begin() );
4744 
4745  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4746  store( i , load(i ) - it.load() ); it += SIMDSIZE;
4747  store( i+SIMDSIZE , load(i+SIMDSIZE ) - it.load() ); it += SIMDSIZE;
4748  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) - it.load() ); it += SIMDSIZE;
4749  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) - it.load() ); it += SIMDSIZE;
4750  }
4751  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4752  store( i, load(i) - it.load() );
4753  }
4754  for( ; remainder && i<size_; ++i, ++it ) {
4755  v_[i] -= *it;
4756  }
4757 }
4759 //*************************************************************************************************
4760 
4761 
4762 //*************************************************************************************************
4774 template< typename Type // Data type of the vector
4775  , bool AF // Alignment flag
4776  , bool TF > // Transpose flag
4777 template< typename VT > // Type of the right-hand side sparse vector
4778 inline void CustomVector<Type,AF,padded,TF>::subAssign( const SparseVector<VT,TF>& rhs )
4779 {
4780  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4781 
4782  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
4783  v_[element->index()] -= element->value();
4784 }
4786 //*************************************************************************************************
4787 
4788 
4789 //*************************************************************************************************
4801 template< typename Type // Data type of the vector
4802  , bool AF // Alignment flag
4803  , bool TF > // Transpose flag
4804 template< typename VT > // Type of the right-hand side dense vector
4805 inline DisableIf_<typename CustomVector<Type,AF,padded,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
4806  CustomVector<Type,AF,padded,TF>::multAssign( const DenseVector<VT,TF>& rhs )
4807 {
4808  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4809 
4810  const size_t ipos( size_ & size_t(-2) );
4811  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4812 
4813  for( size_t i=0UL; i<ipos; i+=2UL ) {
4814  v_[i ] *= (~rhs)[i ];
4815  v_[i+1UL] *= (~rhs)[i+1UL];
4816  }
4817  if( ipos < (~rhs).size() )
4818  v_[ipos] *= (~rhs)[ipos];
4819 }
4821 //*************************************************************************************************
4822 
4823 
4824 //*************************************************************************************************
4836 template< typename Type // Data type of the vector
4837  , bool AF // Alignment flag
4838  , bool TF > // Transpose flag
4839 template< typename VT > // Type of the right-hand side dense vector
4840 inline EnableIf_<typename CustomVector<Type,AF,padded,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
4841  CustomVector<Type,AF,padded,TF>::multAssign( const DenseVector<VT,TF>& rhs )
4842 {
4844 
4845  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4846 
4847  const bool remainder( !IsPadded<VT>::value );
4848 
4849  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
4850  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4851 
4852  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4853  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4854  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4855 
4856  size_t i( 0UL );
4857  ConstIterator_<VT> it( (~rhs).begin() );
4858 
4859  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4860  store( i , load(i ) * it.load() ); it += SIMDSIZE;
4861  store( i+SIMDSIZE , load(i+SIMDSIZE ) * it.load() ); it += SIMDSIZE;
4862  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) * it.load() ); it += SIMDSIZE;
4863  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) * it.load() ); it += SIMDSIZE;
4864  }
4865  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4866  store( i, load(i) * it.load() );
4867  }
4868  for( ; remainder && i<size_; ++i, ++it ) {
4869  v_[i] *= *it;
4870  }
4871 }
4873 //*************************************************************************************************
4874 
4875 
4876 //*************************************************************************************************
4888 template< typename Type // Data type of the vector
4889  , bool AF // Alignment flag
4890  , bool TF > // Transpose flag
4891 template< typename VT > // Type of the right-hand side sparse vector
4892 inline void CustomVector<Type,AF,padded,TF>::multAssign( const SparseVector<VT,TF>& rhs )
4893 {
4894  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4895 
4896  const DynamicVector<Type,TF> tmp( serial( *this ) );
4897 
4898  reset();
4899 
4900  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
4901  v_[element->index()] = tmp[element->index()] * element->value();
4902 }
4904 //*************************************************************************************************
4905 
4906 
4907 //*************************************************************************************************
4919 template< typename Type // Data type of the vector
4920  , bool AF // Alignment flag
4921  , bool TF > // Transpose flag
4922 template< typename VT > // Type of the right-hand side dense vector
4923 inline DisableIf_<typename CustomVector<Type,AF,padded,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
4924  CustomVector<Type,AF,padded,TF>::divAssign( const DenseVector<VT,TF>& rhs )
4925 {
4926  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4927 
4928  const size_t ipos( size_ & size_t(-2) );
4929  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4930 
4931  for( size_t i=0UL; i<ipos; i+=2UL ) {
4932  v_[i ] /= (~rhs)[i ];
4933  v_[i+1UL] /= (~rhs)[i+1UL];
4934  }
4935  if( ipos < (~rhs).size() )
4936  v_[ipos] /= (~rhs)[ipos];
4937 }
4939 //*************************************************************************************************
4940 
4941 
4942 //*************************************************************************************************
4954 template< typename Type // Data type of the vector
4955  , bool AF // Alignment flag
4956  , bool TF > // Transpose flag
4957 template< typename VT > // Type of the right-hand side dense vector
4958 inline EnableIf_<typename CustomVector<Type,AF,padded,TF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
4959  CustomVector<Type,AF,padded,TF>::divAssign( const DenseVector<VT,TF>& rhs )
4960 {
4962 
4963  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4964 
4965  const size_t ipos( size_ & size_t(-SIMDSIZE) );
4966  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4967 
4968  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4969  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4970  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4971 
4972  size_t i( 0UL );
4973  ConstIterator_<VT> it( (~rhs).begin() );
4974 
4975  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4976  store( i , load(i ) / it.load() ); it += SIMDSIZE;
4977  store( i+SIMDSIZE , load(i+SIMDSIZE ) / it.load() ); it += SIMDSIZE;
4978  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) / it.load() ); it += SIMDSIZE;
4979  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) / it.load() ); it += SIMDSIZE;
4980  }
4981  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4982  store( i, load(i) / it.load() );
4983  }
4984  for( ; i<size_; ++i, ++it ) {
4985  v_[i] /= *it;
4986  }
4987 }
4989 //*************************************************************************************************
4990 
4991 
4992 
4993 
4994 
4995 
4996 
4997 
4998 //=================================================================================================
4999 //
5000 // CUSTOMVECTOR OPERATORS
5001 //
5002 //=================================================================================================
5003 
5004 //*************************************************************************************************
5007 template< typename Type, bool AF, bool PF, bool TF >
5008 inline void reset( CustomVector<Type,AF,PF,TF>& v );
5009 
5010 template< typename Type, bool AF, bool PF, bool TF >
5011 inline void clear( CustomVector<Type,AF,PF,TF>& v );
5012 
5013 template< typename Type, bool AF, bool PF, bool TF >
5014 inline bool isDefault( const CustomVector<Type,AF,PF,TF>& v );
5015 
5016 template< typename Type, bool AF, bool PF, bool TF >
5017 inline bool isIntact( const CustomVector<Type,AF,PF,TF>& v ) noexcept;
5018 
5019 template< typename Type, bool AF, bool PF, bool TF >
5020 inline void swap( CustomVector<Type,AF,PF,TF>& a, CustomVector<Type,AF,PF,TF>& b ) noexcept;
5022 //*************************************************************************************************
5023 
5024 
5025 //*************************************************************************************************
5032 template< typename Type // Data type of the vector
5033  , bool AF // Alignment flag
5034  , bool PF // Padding flag
5035  , bool TF > // Transpose flag
5037 {
5038  v.reset();
5039 }
5040 //*************************************************************************************************
5041 
5042 
5043 //*************************************************************************************************
5050 template< typename Type // Data type of the vector
5051  , bool AF // Alignment flag
5052  , bool PF // Padding flag
5053  , bool TF > // Transpose flag
5055 {
5056  v.clear();
5057 }
5058 //*************************************************************************************************
5059 
5060 
5061 //*************************************************************************************************
5082 template< typename Type // Data type of the vector
5083  , bool AF // Alignment flag
5084  , bool PF // Padding flag
5085  , bool TF > // Transpose flag
5087 {
5088  return ( v.size() == 0UL );
5089 }
5090 //*************************************************************************************************
5091 
5092 
5093 //*************************************************************************************************
5114 template< typename Type // Data type of the vector
5115  , bool AF // Alignment flag
5116  , bool PF // Padding flag
5117  , bool TF > // Transpose flag
5118 inline bool isIntact( const CustomVector<Type,AF,PF,TF>& v ) noexcept
5119 {
5120  return ( v.size() <= v.capacity() );
5121 }
5122 //*************************************************************************************************
5123 
5124 
5125 //*************************************************************************************************
5133 template< typename Type // Data type of the vector
5134  , bool AF // Alignment flag
5135  , bool PF // Padding flag
5136  , bool TF > // Transpose flag
5138 {
5139  a.swap( b );
5140 }
5141 //*************************************************************************************************
5142 
5143 
5144 
5145 
5146 //=================================================================================================
5147 //
5148 // HASCONSTDATAACCESS SPECIALIZATIONS
5149 //
5150 //=================================================================================================
5151 
5152 //*************************************************************************************************
5154 template< typename T, bool AF, bool PF, bool TF >
5155 struct HasConstDataAccess< CustomVector<T,AF,PF,TF> > : public TrueType
5156 {};
5158 //*************************************************************************************************
5159 
5160 
5161 
5162 
5163 //=================================================================================================
5164 //
5165 // HASMUTABLEDATAACCESS SPECIALIZATIONS
5166 //
5167 //=================================================================================================
5168 
5169 //*************************************************************************************************
5171 template< typename T, bool AF, bool PF, bool TF >
5172 struct HasMutableDataAccess< CustomVector<T,AF,PF,TF> > : public TrueType
5173 {};
5175 //*************************************************************************************************
5176 
5177 
5178 
5179 
5180 //=================================================================================================
5181 //
5182 // ISCUSTOM SPECIALIZATIONS
5183 //
5184 //=================================================================================================
5185 
5186 //*************************************************************************************************
5188 template< typename T, bool AF, bool PF, bool TF >
5189 struct IsCustom< CustomVector<T,AF,PF,TF> > : public TrueType
5190 {};
5192 //*************************************************************************************************
5193 
5194 
5195 
5196 
5197 //=================================================================================================
5198 //
5199 // ISALIGNED SPECIALIZATIONS
5200 //
5201 //=================================================================================================
5202 
5203 //*************************************************************************************************
5205 template< typename T, bool PF, bool TF >
5206 struct IsAligned< CustomVector<T,aligned,PF,TF> > : public TrueType
5207 {};
5209 //*************************************************************************************************
5210 
5211 
5212 
5213 
5214 //=================================================================================================
5215 //
5216 // ISPADDED SPECIALIZATIONS
5217 //
5218 //=================================================================================================
5219 
5220 //*************************************************************************************************
5222 template< typename T, bool AF, bool TF >
5223 struct IsPadded< CustomVector<T,AF,padded,TF> > : public TrueType
5224 {};
5226 //*************************************************************************************************
5227 
5228 
5229 
5230 
5231 //=================================================================================================
5232 //
5233 // ADDTRAIT SPECIALIZATIONS
5234 //
5235 //=================================================================================================
5236 
5237 //*************************************************************************************************
5239 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5240 struct AddTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF> >
5241 {
5242  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
5243 };
5244 
5245 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5246 struct AddTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5247 {
5248  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
5249 };
5250 
5251 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5252 struct AddTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5253 {
5254  using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
5255 };
5256 
5257 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5258 struct AddTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5259 {
5260  using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
5261 };
5262 
5263 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5264 struct AddTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5265 {
5266  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
5267 };
5268 
5269 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5270 struct AddTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5271 {
5272  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
5273 };
5274 
5275 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5276 struct AddTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5277 {
5278  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
5279 };
5281 //*************************************************************************************************
5282 
5283 
5284 
5285 
5286 //=================================================================================================
5287 //
5288 // SUBTRAIT SPECIALIZATIONS
5289 //
5290 //=================================================================================================
5291 
5292 //*************************************************************************************************
5294 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5295 struct SubTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF> >
5296 {
5297  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
5298 };
5299 
5300 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5301 struct SubTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5302 {
5303  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
5304 };
5305 
5306 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5307 struct SubTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5308 {
5309  using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
5310 };
5311 
5312 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5313 struct SubTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5314 {
5315  using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
5316 };
5317 
5318 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5319 struct SubTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5320 {
5321  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
5322 };
5323 
5324 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5325 struct SubTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5326 {
5327  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
5328 };
5329 
5330 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5331 struct SubTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5332 {
5333  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
5334 };
5336 //*************************************************************************************************
5337 
5338 
5339 
5340 
5341 //=================================================================================================
5342 //
5343 // MULTTRAIT SPECIALIZATIONS
5344 //
5345 //=================================================================================================
5346 
5347 //*************************************************************************************************
5349 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5350 struct MultTrait< CustomVector<T1,AF,PF,TF>, T2, EnableIf_<IsNumeric<T2> > >
5351 {
5352  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5353 };
5354 
5355 template< typename T1, typename T2, bool AF, bool PF, bool TF >
5356 struct MultTrait< T1, CustomVector<T2,AF,PF,TF>, EnableIf_<IsNumeric<T1> > >
5357 {
5358  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5359 };
5360 
5361 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5362 struct MultTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF> >
5363 {
5364  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
5365 };
5366 
5367 template< typename T1, bool AF, bool PF, typename T2, size_t N >
5368 struct MultTrait< CustomVector<T1,AF,PF,false>, StaticVector<T2,N,true> >
5369 {
5370  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5371 };
5372 
5373 template< typename T1, bool AF, bool PF, typename T2, size_t N >
5374 struct MultTrait< CustomVector<T1,AF,PF,true>, StaticVector<T2,N,false> >
5375 {
5376  using Type = MultTrait_<T1,T2>;
5377 };
5378 
5379 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5380 struct MultTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5381 {
5382  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
5383 };
5384 
5385 template< typename T1, size_t N, typename T2, bool AF, bool PF >
5386 struct MultTrait< StaticVector<T1,N,false>, CustomVector<T2,AF,PF,true> >
5387 {
5388  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5389 };
5390 
5391 template< typename T1, size_t N, typename T2, bool AF, bool PF >
5392 struct MultTrait< StaticVector<T1,N,true>, CustomVector<T2,AF,PF,false> >
5393 {
5394  using Type = MultTrait_<T1,T2>;
5395 };
5396 
5397 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5398 struct MultTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5399 {
5400  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
5401 };
5402 
5403 template< typename T1, bool AF, bool PF, typename T2, size_t N >
5404 struct MultTrait< CustomVector<T1,AF,PF,false>, HybridVector<T2,N,true> >
5405 {
5406  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5407 };
5408 
5409 template< typename T1, bool AF, bool PF, typename T2, size_t N >
5410 struct MultTrait< CustomVector<T1,AF,PF,true>, HybridVector<T2,N,false> >
5411 {
5412  using Type = MultTrait_<T1,T2>;
5413 };
5414 
5415 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5416 struct MultTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5417 {
5418  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
5419 };
5420 
5421 template< typename T1, size_t N, typename T2, bool AF, bool PF >
5422 struct MultTrait< HybridVector<T1,N,false>, CustomVector<T2,AF,PF,true> >
5423 {
5424  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5425 };
5426 
5427 template< typename T1, size_t N, typename T2, bool AF, bool PF >
5428 struct MultTrait< HybridVector<T1,N,true>, CustomVector<T2,AF,PF,false> >
5429 {
5430  using Type = MultTrait_<T1,T2>;
5431 };
5432 
5433 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5434 struct MultTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5435 {
5436  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5437 };
5438 
5439 template< typename T1, bool AF, bool PF, typename T2 >
5440 struct MultTrait< CustomVector<T1,AF,PF,false>, DynamicVector<T2,true> >
5441 {
5442  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5443 };
5444 
5445 template< typename T1, bool AF, bool PF, typename T2 >
5446 struct MultTrait< CustomVector<T1,AF,PF,true>, DynamicVector<T2,false> >
5447 {
5448  using Type = MultTrait_<T1,T2>;
5449 };
5450 
5451 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5452 struct MultTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5453 {
5454  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5455 };
5456 
5457 template< typename T1, typename T2, bool AF, bool PF >
5458 struct MultTrait< DynamicVector<T1,false>, CustomVector<T2,AF,PF,true> >
5459 {
5460  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5461 };
5462 
5463 template< typename T1, typename T2, bool AF, bool PF >
5464 struct MultTrait< DynamicVector<T1,true>, CustomVector<T2,AF,PF,false> >
5465 {
5466  using Type = MultTrait_<T1,T2>;
5467 };
5468 
5469 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5470 struct MultTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5471 {
5472  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5473 };
5474 
5475 template< typename T1, bool AF1, bool PF1, typename T2, bool AF2, bool PF2 >
5476 struct MultTrait< CustomVector<T1,AF1,PF1,false>, CustomVector<T2,AF2,PF2,true> >
5477 {
5478  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5479 };
5480 
5481 template< typename T1, bool AF1, bool PF1, typename T2, bool AF2, bool PF2 >
5482 struct MultTrait< CustomVector<T1,AF1,PF1,true>, CustomVector<T2,AF2,PF2,false> >
5483 {
5484  using Type = MultTrait_<T1,T2>;
5485 };
5487 //*************************************************************************************************
5488 
5489 
5490 
5491 
5492 //=================================================================================================
5493 //
5494 // CROSSTRAIT SPECIALIZATIONS
5495 //
5496 //=================================================================================================
5497 
5498 //*************************************************************************************************
5500 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5501 struct CrossTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,3UL,TF> >
5502 {
5503  private:
5504  using T = MultTrait_<T1,T2>;
5505 
5506  public:
5507  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5508 };
5509 
5510 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5511 struct CrossTrait< StaticVector<T1,3UL,TF>, CustomVector<T2,AF,PF,TF> >
5512 {
5513  private:
5514  using T = MultTrait_<T1,T2>;
5515 
5516  public:
5517  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5518 };
5519 
5520 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5521 struct CrossTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5522 {
5523  private:
5524  using T = MultTrait_<T1,T2>;
5525 
5526  public:
5527  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5528 };
5529 
5530 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5531 struct CrossTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5532 {
5533  private:
5534  using T = MultTrait_<T1,T2>;
5535 
5536  public:
5537  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5538 };
5539 
5540 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5541 struct CrossTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5542 {
5543  private:
5544  using T = MultTrait_<T1,T2>;
5545 
5546  public:
5547  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5548 };
5549 
5550 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5551 struct CrossTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5552 {
5553  private:
5554  using T = MultTrait_<T1,T2>;
5555 
5556  public:
5557  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5558 };
5559 
5560 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5561 struct CrossTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5562 {
5563  private:
5564  using T = MultTrait_<T1,T2>;
5565 
5566  public:
5567  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5568 };
5570 //*************************************************************************************************
5571 
5572 
5573 
5574 
5575 //=================================================================================================
5576 //
5577 // DIVTRAIT SPECIALIZATIONS
5578 //
5579 //=================================================================================================
5580 
5581 //*************************************************************************************************
5583 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5584 struct DivTrait< CustomVector<T1,AF,PF,TF>, T2, EnableIf_<IsNumeric<T2> > >
5585 {
5586  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
5587 };
5588 
5589 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5590 struct DivTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF> >
5591 {
5592  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
5593 };
5594 
5595 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5596 struct DivTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5597 {
5598  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
5599 };
5600 
5601 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5602 struct DivTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5603 {
5604  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
5605 };
5606 
5607 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5608 struct DivTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5609 {
5610  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
5611 };
5612 
5613 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5614 struct DivTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5615 {
5616  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
5617 };
5618 
5619 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5620 struct DivTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5621 {
5622  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
5623 };
5624 
5625 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5626 struct DivTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5627 {
5628  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
5629 };
5631 //*************************************************************************************************
5632 
5633 
5634 
5635 
5636 //=================================================================================================
5637 //
5638 // SUBVECTORTRAIT SPECIALIZATIONS
5639 //
5640 //=================================================================================================
5641 
5642 //*************************************************************************************************
5644 template< typename T1, bool AF, bool PF, bool TF >
5645 struct SubvectorTrait< CustomVector<T1,AF,PF,TF> >
5646 {
5647  using Type = DynamicVector<T1,TF>;
5648 };
5650 //*************************************************************************************************
5651 
5652 } // namespace blaze
5653 
5654 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:133
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
constexpr bool useOptimizedKernels
Configuration switch for optimized kernels.This configuration switch enables/disables all optimized c...
Definition: Optimizations.h:84
DenseVector< This, TF > BaseType
Base type of this CustomVector instance.
Definition: CustomVector.h:428
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the AlignmentOf type trait.
Header file for the alignment flag values.
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
CustomVector()
The default constructor for CustomVector.
Definition: CustomVector.h:732
Iterator begin() noexcept
Returns an iterator to the first element of the custom vector.
Definition: CustomVector.h:1082
Header file for basic type definitions.
No-delete policy class.
Definition: NoDelete.h:51
Header file for the SparseVector base class.
size_t size_
The size/dimension of the custom vector.
Definition: CustomVector.h:695
const Type & ReturnType
Return type for expression template evaluations.
Definition: CustomVector.h:433
const Type * ConstPointer
Pointer to a constant vector value.
Definition: CustomVector.h:439
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: CustomVector.h:1900
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:79
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
const Type & ConstReference
Reference to a constant vector value.
Definition: CustomVector.h:437
Header file for the serial shim.
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the custom vector.
Definition: CustomVector.h:1116
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
constexpr size_t cacheSize
Cache size of the target architecture.This setting specifies the available cache size in Byte of the ...
Definition: CacheSize.h:48
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: CustomVector.h:2049
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
Iterator end() noexcept
Returns an iterator just past the last element of the custom vector.
Definition: CustomVector.h:1133
const bool aligned
Alignment flag for aligned vectors and matrices.Via this flag it is possible to specify subvectors...
Definition: AlignmentFlag.h:85
void swap(CustomVector &v) noexcept
Swapping the contents of two vectors.
Definition: CustomVector.h:1712
CustomVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: CustomVector.h:1192
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:315
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: CustomVector.h:1963
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
EnableIf_< IsDenseVector< VT1 > > smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:193
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
DynamicVector< Type,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: CustomVector.h:430
Header file for the DenseVector base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
Efficient implementation of an arbitrary sized vector.The DynamicVector class template is the represe...
Definition: DynamicVector.h:176
System settings for performance optimizations.
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
STL namespace.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:77
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: CustomVector.h:2140
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
Header file for the implementation of an arbitrarily sized vector.
Header file for the NoDelete policy classes.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: CustomVector.h:1922
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2807
Header file for the std::initializer_list aliases.
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: CustomVector.h:1942
Header file for the DisableIf class template.
Header file for the IsCustom type trait.
Header file for the multiplication trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5148
Compile time assertion.
constexpr bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Optimizations.h:68
constexpr bool defaultTransposeFlag
The default transpose flag for all vectors of the Blaze library.This value specifies the default tran...
Definition: TransposeFlag.h:56
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Header file for the IsSMPAssignable type trait.
EnableIf_< IsDenseMatrix< MT1 > > smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
const bool padded
Padding flag for padded vectors and matrices.Via this flag it is possible to specify custom vectors a...
Definition: PaddingFlag.h:86
BLAZE_ALWAYS_INLINE void stream(size_t index, const SIMDType &value) noexcept
Aligned, non-temporal store of a SIMD element of the vector.
Definition: CustomVector.h:2172
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the HasSIMDAdd type trait.
Header file for the DenseIterator class template.
void clear()
Clearing the vector to its default state.
Definition: CustomVector.h:1674
Header file for the subvector trait.
Header file for all SIMD functionality.
DenseIterator< const Type, AF > ConstIterator
Iterator over constant elements.
Definition: CustomVector.h:442
Constraint on the data type.
boost::shared_array< Type > v_
The custom array of elements.
Definition: CustomVector.h:696
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:78
Constraint on the data type.
Efficient implementation of a customizable vector.
Definition: CustomVector.h:423
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:80
void reset()
Reset to the default initial values.
Definition: CustomVector.h:1653
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a vectorizable data type...
Definition: Vectorizable.h:61
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the custom vector.
Definition: CustomVector.h:1167
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: CustomVector.h:2107
size_t size() const noexcept
Returns the size/dimension of the vector.
Definition: CustomVector.h:1595
Header file for the exception macros of the math module.
Compile time check for data types.This type trait tests whether or not the given template parameter i...
Definition: IsSMPAssignable.h:119
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
DenseIterator< Type, AF > Iterator
Iterator over non-constant elements.
Definition: CustomVector.h:441
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: CustomVector.h:1630
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the IsPadded type trait.
DynamicVector< Type, TF > ResultType
Result type for expression template evaluations.
Definition: CustomVector.h:429
typename DivTrait< T1, T2 >::Type DivTrait_
Auxiliary alias declaration for the DivTrait class template.The DivTrait_ alias declaration provides ...
Definition: DivTrait.h:245
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
SIMDTrait_< ElementType > SIMDType
SIMD type of the vector elements.
Definition: CustomVector.h:432
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > stream(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned, non-temporal store of a vector of 1-byte integral values.
Definition: Stream.h:75
Header file for the IsSparseVector type trait.
Header file for the HasSIMDMult type trait.
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: CustomVector.h:2015
Rebind mechanism to obtain a CustomVector with different data/element type.
Definition: CustomVector.h:449
Type * Pointer
Pointer to a non-constant vector value.
Definition: CustomVector.h:438
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: CustomVector.h:1046
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
Constraint on the data type.
EnableIf_< IsDenseVector< VT1 > > smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:222
Header file for the cache size of the target architecture.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Reference at(size_t index)
Checked access to the vector elements.
Definition: CustomVector.h:999
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:258
Type & Reference
Reference to a non-constant vector value.
Definition: CustomVector.h:436
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: CustomVector.h:2080
Constraint on the data type.
Header file for the HasSIMDSub type trait.
Header file for the HasMutableDataAccess type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: CustomVector.h:954
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Header file for the padding flag values.
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition: Storeu.h:76
CustomVector< ET, AF, PF, TF > Other
The type of the other CustomVector.
Definition: CustomVector.h:450
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
Header file for the AreSIMDCombinable type trait.
Header file for the HasSIMDDiv type trait.
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:154
Header file for the default transpose flag for all vectors of the Blaze library.
Initializer list type of the Blaze library.
Header file for the alignment check function.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:110
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
size_t capacity() const noexcept
Returns the maximum capacity of the vector.
Definition: CustomVector.h:1611
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
Rebind mechanism to obtain a CompressedMatrix with different data/element type.
Definition: CompressedMatrix.h:2654
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
Type ElementType
Type of the vector elements.
Definition: CustomVector.h:431
CustomVector< Type, AF, PF, TF > This
Type of this CustomVector instance.
Definition: CustomVector.h:427
System settings for the inline keywords.
const CustomVector & CompositeType
Data type for composite expression templates.
Definition: CustomVector.h:434
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.In case the given data type T is not a dense or sparse vector type and in...
Definition: TransposeFlag.h:63
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#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
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: CustomVector.h:1987
Header file for the TrueType type/value trait base class.
Header file for the IsClass type trait.