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>
101 #include <blaze/util/Unused.h>
102 
103 
104 namespace blaze {
105 
106 //=================================================================================================
107 //
108 // CLASS DEFINITION
109 //
110 //=================================================================================================
111 
112 //*************************************************************************************************
418 template< typename Type // Data type of the vector
419  , bool AF // Alignment flag
420  , bool PF // Padding flag
421  , bool TF = defaultTransposeFlag > // Transpose flag
422 class CustomVector : public DenseVector< CustomVector<Type,AF,PF,TF>, TF >
423 {
424  public:
425  //**Type definitions****************************************************************************
430  typedef Type ElementType;
432  typedef const Type& ReturnType;
433  typedef const CustomVector& CompositeType;
434 
435  typedef Type& Reference;
436  typedef const Type& ConstReference;
437  typedef Type* Pointer;
438  typedef const Type* ConstPointer;
439 
442  //**********************************************************************************************
443 
444  //**Rebind struct definition********************************************************************
447  template< typename NewType > // Data type of the other vector
448  struct Rebind {
450  };
451  //**********************************************************************************************
452 
453  //**Resize struct definition********************************************************************
456  template< size_t NewN > // Number of elements of the other vector
457  struct Resize {
459  };
460  //**********************************************************************************************
461 
462  //**Compilation flags***************************************************************************
464 
468  enum : bool { simdEnabled = IsVectorizable<Type>::value };
469 
471 
474  enum : bool { smpAssignable = !IsSMPAssignable<Type>::value };
475  //**********************************************************************************************
476 
477  //**Constructors********************************************************************************
480  explicit inline CustomVector();
481  explicit inline CustomVector( Type* ptr, size_t n );
482  explicit inline CustomVector( Type* ptr, size_t n, size_t nn );
483 
484  template< typename Deleter, typename = DisableIf_< IsIntegral<Deleter> > >
485  explicit inline CustomVector( Type* ptr, size_t n, Deleter d );
486 
487  template< typename Deleter >
488  explicit inline CustomVector( Type* ptr, size_t n, size_t nn, Deleter d );
489 
490  inline CustomVector( const CustomVector& v );
491  inline CustomVector( CustomVector&& v ) noexcept;
493  //**********************************************************************************************
494 
495  //**Destructor**********************************************************************************
496  // No explicitly declared destructor.
497  //**********************************************************************************************
498 
499  //**Data access functions***********************************************************************
502  inline Reference operator[]( size_t index ) noexcept;
503  inline ConstReference operator[]( size_t index ) const noexcept;
504  inline Reference at( size_t index );
505  inline ConstReference at( size_t index ) const;
506  inline Pointer data () noexcept;
507  inline ConstPointer data () const noexcept;
508  inline Iterator begin () noexcept;
509  inline ConstIterator begin () const noexcept;
510  inline ConstIterator cbegin() const noexcept;
511  inline Iterator end () noexcept;
512  inline ConstIterator end () const noexcept;
513  inline ConstIterator cend () const noexcept;
515  //**********************************************************************************************
516 
517  //**Assignment operators************************************************************************
520  inline CustomVector& operator=( const Type& rhs );
522 
523  template< typename Other, size_t N >
524  inline CustomVector& operator=( const Other (&array)[N] );
525 
526  inline CustomVector& operator=( const CustomVector& rhs );
527  inline CustomVector& operator=( CustomVector&& rhs ) noexcept;
528 
529  template< typename VT > inline CustomVector& operator= ( const Vector<VT,TF>& rhs );
530  template< typename VT > inline CustomVector& operator+=( const Vector<VT,TF>& rhs );
531  template< typename VT > inline CustomVector& operator-=( const Vector<VT,TF>& rhs );
532  template< typename VT > inline CustomVector& operator*=( const Vector<VT,TF>& rhs );
533  template< typename VT > inline CustomVector& operator/=( const DenseVector<VT,TF>& rhs );
534 
535  template< typename Other >
536  inline EnableIf_<IsNumeric<Other>, CustomVector >& operator*=( Other rhs );
537 
538  template< typename Other >
539  inline EnableIf_<IsNumeric<Other>, CustomVector >& operator/=( Other rhs );
541  //**********************************************************************************************
542 
543  //**Utility functions***************************************************************************
546  inline size_t size() const noexcept;
547  inline size_t capacity() const noexcept;
548  inline size_t nonZeros() const;
549  inline void reset();
550  inline void clear();
551  inline void swap( CustomVector& v ) noexcept;
553  //**********************************************************************************************
554 
555  //**Numeric functions***************************************************************************
558  template< typename Other > inline CustomVector& scale( const Other& scalar );
560  //**********************************************************************************************
561 
562  //**Resource management functions***************************************************************
565  inline void reset( Type* ptr, size_t n );
566  inline void reset( Type* ptr, size_t n, size_t nn );
567 
568  template< typename Deleter, typename = DisableIf_< IsIntegral<Deleter> > >
569  inline void reset( Type* ptr, size_t n, Deleter d );
570 
571  template< typename Deleter >
572  inline void reset( Type* ptr, size_t n, size_t nn, Deleter d );
574  //**********************************************************************************************
575 
576  private:
577  //**********************************************************************************************
579  template< typename VT >
581  struct VectorizedAssign {
582  enum : bool { value = useOptimizedKernels &&
583  simdEnabled && VT::simdEnabled &&
585  };
587  //**********************************************************************************************
588 
589  //**********************************************************************************************
591  template< typename VT >
593  struct VectorizedAddAssign {
594  enum : bool { value = useOptimizedKernels &&
595  simdEnabled && VT::simdEnabled &&
598  };
600  //**********************************************************************************************
601 
602  //**********************************************************************************************
604  template< typename VT >
606  struct VectorizedSubAssign {
607  enum : bool { value = useOptimizedKernels &&
608  simdEnabled && VT::simdEnabled &&
611  };
613  //**********************************************************************************************
614 
615  //**********************************************************************************************
617  template< typename VT >
619  struct VectorizedMultAssign {
620  enum : bool { value = useOptimizedKernels &&
621  simdEnabled && VT::simdEnabled &&
624  };
626  //**********************************************************************************************
627 
628  //**********************************************************************************************
630  template< typename VT >
632  struct VectorizedDivAssign {
633  enum : bool { value = useOptimizedKernels &&
634  simdEnabled && VT::simdEnabled &&
637  };
639  //**********************************************************************************************
640 
641  //**SIMD properties*****************************************************************************
643  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
644  //**********************************************************************************************
645 
646  public:
647  //**Expression template evaluation functions****************************************************
650  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
651  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
652 
653  inline bool isAligned () const noexcept;
654  inline bool canSMPAssign() const noexcept;
655 
656  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
657  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
658  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
659 
660  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
661  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
662  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
663  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
664 
665  template< typename VT >
666  inline DisableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
667 
668  template< typename VT >
669  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
670 
671  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
672 
673  template< typename VT >
674  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
675 
676  template< typename VT >
677  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
678 
679  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
680 
681  template< typename VT >
682  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
683 
684  template< typename VT >
685  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
686 
687  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
688 
689  template< typename VT >
690  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
691 
692  template< typename VT >
693  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
694 
695  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
696 
697  template< typename VT >
698  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
699 
700  template< typename VT >
701  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
703  //**********************************************************************************************
704 
705  private:
706  //**Member variables****************************************************************************
709  size_t size_;
710  boost::shared_array<Type> v_;
711 
717  //**********************************************************************************************
718 
719  //**Compile time checks*************************************************************************
726  //**********************************************************************************************
727 };
728 //*************************************************************************************************
729 
730 
731 
732 
733 //=================================================================================================
734 //
735 // CONSTRUCTORS
736 //
737 //=================================================================================================
738 
739 //*************************************************************************************************
742 template< typename Type // Data type of the vector
743  , bool AF // Alignment flag
744  , bool PF // Padding flag
745  , bool TF > // Transpose flag
747  : size_( 0UL ) // The size/dimension of the vector
748  , v_ ( ) // The custom array of elements
749 {}
750 //*************************************************************************************************
751 
752 
753 //*************************************************************************************************
771 template< typename Type // Data type of the vector
772  , bool AF // Alignment flag
773  , bool PF // Padding flag
774  , bool TF > // Transpose flag
775 inline CustomVector<Type,AF,PF,TF>::CustomVector( Type* ptr, size_t n )
776  : size_( n ) // The size/dimension of the vector
777  , v_ ( ) // The custom array of elements
778 {
779  if( ptr == nullptr ) {
780  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array of elements" );
781  }
782 
783  if( AF && !checkAlignment( ptr ) ) {
784  BLAZE_THROW_INVALID_ARGUMENT( "Invalid alignment detected" );
785  }
786 
787  v_.reset( ptr, NoDelete() );
788 }
789 //*************************************************************************************************
790 
791 
792 //*************************************************************************************************
814 template< typename Type // Data type of the vector
815  , bool AF // Alignment flag
816  , bool PF // Padding flag
817  , bool TF > // Transpose flag
818 inline CustomVector<Type,AF,PF,TF>::CustomVector( Type* ptr, size_t n, size_t nn )
819  : size_( 0UL ) // The size/dimension of the vector
820  , v_ ( ) // The custom array of elements
821 {
822  BLAZE_STATIC_ASSERT( PF == padded );
823 
824  UNUSED_PARAMETER( ptr, n, nn );
825 }
826 //*************************************************************************************************
827 
828 
829 //*************************************************************************************************
847 template< typename Type // Data type of the vector
848  , bool AF // Alignment flag
849  , bool PF // Padding flag
850  , bool TF > // Transpose flag
851 template< typename Deleter // Type of the custom deleter
852  , typename > // Type restriction on the custom deleter
853 inline CustomVector<Type,AF,PF,TF>::CustomVector( Type* ptr, size_t n, Deleter d )
854  : size_( n ) // The size/dimension of the vector
855  , v_ ( ) // The custom array of elements
856 {
857  if( ptr == nullptr ) {
858  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array of elements" );
859  }
860 
861  if( AF && !checkAlignment( ptr ) ) {
862  BLAZE_THROW_INVALID_ARGUMENT( "Invalid alignment detected" );
863  }
864 
865  v_.reset( ptr, d );
866 }
867 //*************************************************************************************************
868 
869 
870 //*************************************************************************************************
892 template< typename Type // Data type of the vector
893  , bool AF // Alignment flag
894  , bool PF // Padding flag
895  , bool TF > // Transpose flag
896 template< typename Deleter > // Type of the custom deleter
897 inline CustomVector<Type,AF,PF,TF>::CustomVector( Type* ptr, size_t n, size_t nn, Deleter d )
898  : size_( 0UL ) // The size/dimension of the vector
899  , v_ ( ) // The custom array of elements
900 {
901  BLAZE_STATIC_ASSERT( PF == padded );
902 
903  UNUSED_PARAMETER( ptr, n, nn, d );
904 }
905 //*************************************************************************************************
906 
907 
908 //*************************************************************************************************
915 template< typename Type // Data type of the vector
916  , bool AF // Alignment flag
917  , bool PF // Padding flag
918  , bool TF > // Transpose flag
920  : size_( v.size_ ) // The size/dimension of the vector
921  , v_ ( v.v_ ) // The custom array of elements
922 {}
923 //*************************************************************************************************
924 
925 
926 //*************************************************************************************************
931 template< typename Type // Data type of the vector
932  , bool AF // Alignment flag
933  , bool PF // Padding flag
934  , bool TF > // Transpose flag
936  : size_( v.size_ ) // The size/dimension of the vector
937  , v_ ( std::move( v.v_ ) ) // The custom array of elements
938 {
939  v.size_ = 0UL;
940 
941  BLAZE_INTERNAL_ASSERT( v.data() == nullptr, "Invalid data reference detected" );
942 }
943 //*************************************************************************************************
944 
945 
946 
947 
948 //=================================================================================================
949 //
950 // DATA ACCESS FUNCTIONS
951 //
952 //=================================================================================================
953 
954 //*************************************************************************************************
963 template< typename Type // Data type of the vector
964  , bool AF // Alignment flag
965  , bool PF // Padding flag
966  , bool TF > // Transpose flag
969 {
970  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
971  return v_[index];
972 }
973 //*************************************************************************************************
974 
975 
976 //*************************************************************************************************
985 template< typename Type // Data type of the vector
986  , bool AF // Alignment flag
987  , bool PF // Padding flag
988  , bool TF > // Transpose flag
990  CustomVector<Type,AF,PF,TF>::operator[]( size_t index ) const noexcept
991 {
992  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
993  return v_[index];
994 }
995 //*************************************************************************************************
996 
997 
998 //*************************************************************************************************
1008 template< typename Type // Data type of the vector
1009  , bool AF // Alignment flag
1010  , bool PF // Padding flag
1011  , bool TF > // Transpose flag
1014 {
1015  if( index >= size_ ) {
1016  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
1017  }
1018  return (*this)[index];
1019 }
1020 //*************************************************************************************************
1021 
1022 
1023 //*************************************************************************************************
1033 template< typename Type // Data type of the vector
1034  , bool AF // Alignment flag
1035  , bool PF // Padding flag
1036  , bool TF > // Transpose flag
1038  CustomVector<Type,AF,PF,TF>::at( size_t index ) const
1039 {
1040  if( index >= size_ ) {
1041  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
1042  }
1043  return (*this)[index];
1044 }
1045 //*************************************************************************************************
1046 
1047 
1048 //*************************************************************************************************
1055 template< typename Type // Data type of the vector
1056  , bool AF // Alignment flag
1057  , bool PF // Padding flag
1058  , bool TF > // Transpose flag
1061 {
1062  return v_.get();
1063 }
1064 //*************************************************************************************************
1065 
1066 
1067 //*************************************************************************************************
1074 template< typename Type // Data type of the vector
1075  , bool AF // Alignment flag
1076  , bool PF // Padding flag
1077  , bool TF > // Transpose flag
1080 {
1081  return v_.get();
1082 }
1083 //*************************************************************************************************
1084 
1085 
1086 //*************************************************************************************************
1091 template< typename Type // Data type of the vector
1092  , bool AF // Alignment flag
1093  , bool PF // Padding flag
1094  , bool TF > // Transpose flag
1097 {
1098  return Iterator( v_.get() );
1099 }
1100 //*************************************************************************************************
1101 
1102 
1103 //*************************************************************************************************
1108 template< typename Type // Data type of the vector
1109  , bool AF // Alignment flag
1110  , bool PF // Padding flag
1111  , bool TF > // Transpose flag
1114 {
1115  return ConstIterator( v_.get() );
1116 }
1117 //*************************************************************************************************
1118 
1119 
1120 //*************************************************************************************************
1125 template< typename Type // Data type of the vector
1126  , bool AF // Alignment flag
1127  , bool PF // Padding flag
1128  , bool TF > // Transpose flag
1131 {
1132  return ConstIterator( v_.get() );
1133 }
1134 //*************************************************************************************************
1135 
1136 
1137 //*************************************************************************************************
1142 template< typename Type // Data type of the vector
1143  , bool AF // Alignment flag
1144  , bool PF // Padding flag
1145  , bool TF > // Transpose flag
1148 {
1149  return Iterator( v_.get() + size_ );
1150 }
1151 //*************************************************************************************************
1152 
1153 
1154 //*************************************************************************************************
1159 template< typename Type // Data type of the vector
1160  , bool AF // Alignment flag
1161  , bool PF // Padding flag
1162  , bool TF > // Transpose flag
1165 {
1166  return ConstIterator( v_.get() + size_ );
1167 }
1168 //*************************************************************************************************
1169 
1170 
1171 //*************************************************************************************************
1176 template< typename Type // Data type of the vector
1177  , bool AF // Alignment flag
1178  , bool PF // Padding flag
1179  , bool TF > // Transpose flag
1182 {
1183  return ConstIterator( v_.get() + size_ );
1184 }
1185 //*************************************************************************************************
1186 
1187 
1188 
1189 
1190 //=================================================================================================
1191 //
1192 // ASSIGNMENT OPERATORS
1193 //
1194 //=================================================================================================
1195 
1196 //*************************************************************************************************
1202 template< typename Type // Data type of the vector
1203  , bool AF // Alignment flag
1204  , bool PF // Padding flag
1205  , bool TF > // Transpose flag
1207 {
1208  for( size_t i=0UL; i<size_; ++i )
1209  v_[i] = rhs;
1210  return *this;
1211 }
1212 //*************************************************************************************************
1213 
1214 
1215 //*************************************************************************************************
1239 template< typename Type // Data type of the vector
1240  , bool AF // Alignment flag
1241  , bool PF // Padding flag
1242  , bool TF > // Transpose flag
1244 {
1245  if( list.size() > size_ ) {
1246  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to custom vector" );
1247  }
1248 
1249  std::fill( std::copy( list.begin(), list.end(), v_.get() ), v_.get()+size_, Type() );
1250 
1251  return *this;
1252 }
1253 //*************************************************************************************************
1254 
1255 
1256 //*************************************************************************************************
1283 template< typename Type // Data type of the vector
1284  , bool AF // Alignment flag
1285  , bool PF // Padding flag
1286  , bool TF > // Transpose flag
1287 template< typename Other // Data type of the initialization array
1288  , size_t N > // Dimension of the initialization array
1290 {
1291  if( size_ != N ) {
1292  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array size" );
1293  }
1294 
1295  for( size_t i=0UL; i<N; ++i )
1296  v_[i] = array[i];
1297 
1298  return *this;
1299 }
1300 //*************************************************************************************************
1301 
1302 
1303 //*************************************************************************************************
1313 template< typename Type // Data type of the vector
1314  , bool AF // Alignment flag
1315  , bool PF // Padding flag
1316  , bool TF > // Transpose flag
1318 {
1319  if( rhs.size() != size_ ) {
1320  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1321  }
1322 
1323  smpAssign( *this, ~rhs );
1324 
1325  return *this;
1326 }
1327 //*************************************************************************************************
1328 
1329 
1330 //*************************************************************************************************
1336 template< typename Type // Data type of the vector
1337  , bool AF // Alignment flag
1338  , bool PF // Padding flag
1339  , bool TF > // Transpose flag
1342 {
1343  size_ = rhs.size_;
1344  v_ = std::move( rhs.v_ );
1345 
1346  rhs.size_ = 0UL;
1347 
1348  BLAZE_INTERNAL_ASSERT( rhs.data() == nullptr, "Invalid data reference detected" );
1349 
1350  return *this;
1351 }
1352 //*************************************************************************************************
1353 
1354 
1355 //*************************************************************************************************
1365 template< typename Type // Data type of the vector
1366  , bool AF // Alignment flag
1367  , bool PF // Padding flag
1368  , bool TF > // Transpose flag
1369 template< typename VT > // Type of the right-hand side vector
1371 {
1372  if( (~rhs).size() != size_ ) {
1373  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1374  }
1375 
1376  if( (~rhs).canAlias( this ) ) {
1377  const ResultType_<VT> tmp( ~rhs );
1378  smpAssign( *this, tmp );
1379  }
1380  else {
1382  reset();
1383  smpAssign( *this, ~rhs );
1384  }
1385 
1386  return *this;
1387 }
1388 //*************************************************************************************************
1389 
1390 
1391 //*************************************************************************************************
1401 template< typename Type // Data type of the vector
1402  , bool AF // Alignment flag
1403  , bool PF // Padding flag
1404  , bool TF > // Transpose flag
1405 template< typename VT > // Type of the right-hand side vector
1407 {
1408  if( (~rhs).size() != size_ ) {
1409  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1410  }
1411 
1412  if( (~rhs).canAlias( this ) ) {
1413  const ResultType_<VT> tmp( ~rhs );
1414  smpAddAssign( *this, tmp );
1415  }
1416  else {
1417  smpAddAssign( *this, ~rhs );
1418  }
1419 
1420  return *this;
1421 }
1422 //*************************************************************************************************
1423 
1424 
1425 //*************************************************************************************************
1436 template< typename Type // Data type of the vector
1437  , bool AF // Alignment flag
1438  , bool PF // Padding flag
1439  , bool TF > // Transpose flag
1440 template< typename VT > // Type of the right-hand side vector
1442 {
1443  if( (~rhs).size() != size_ ) {
1444  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1445  }
1446 
1447  if( (~rhs).canAlias( this ) ) {
1448  const ResultType_<VT> tmp( ~rhs );
1449  smpSubAssign( *this, tmp );
1450  }
1451  else {
1452  smpSubAssign( *this, ~rhs );
1453  }
1454 
1455  return *this;
1456 }
1457 //*************************************************************************************************
1458 
1459 
1460 //*************************************************************************************************
1471 template< typename Type // Data type of the vector
1472  , bool AF // Alignment flag
1473  , bool PF // Padding flag
1474  , bool TF > // Transpose flag
1475 template< typename VT > // Type of the right-hand side vector
1477 {
1480 
1481  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
1482 
1485 
1486  if( (~rhs).size() != size_ ) {
1487  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1488  }
1489 
1490  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1491  const MultType tmp( *this * (~rhs) );
1492  this->operator=( tmp );
1493  }
1494  else {
1495  smpMultAssign( *this, ~rhs );
1496  }
1497 
1498  return *this;
1499 }
1500 //*************************************************************************************************
1501 
1502 
1503 //*************************************************************************************************
1513 template< typename Type // Data type of the vector
1514  , bool AF // Alignment flag
1515  , bool PF // Padding flag
1516  , bool TF > // Transpose flag
1517 template< typename VT > // Type of the right-hand side vector
1520 {
1523 
1524  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
1525 
1528 
1529  if( (~rhs).size() != size_ ) {
1530  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1531  }
1532 
1533  if( (~rhs).canAlias( this ) ) {
1534  const DivType tmp( *this / (~rhs) );
1535  this->operator=( tmp );
1536  }
1537  else {
1538  smpDivAssign( *this, ~rhs );
1539  }
1540 
1541  return *this;
1542 }
1543 //*************************************************************************************************
1544 
1545 
1546 //*************************************************************************************************
1553 template< typename Type // Data type of the vector
1554  , bool AF // Alignment flag
1555  , bool PF // Padding flag
1556  , bool TF > // Transpose flag
1557 template< typename Other > // Data type of the right-hand side scalar
1560 {
1561  smpAssign( *this, (*this) * rhs );
1562  return *this;
1563 }
1564 //*************************************************************************************************
1565 
1566 
1567 //*************************************************************************************************
1576 template< typename Type // Data type of the vector
1577  , bool AF // Alignment flag
1578  , bool PF // Padding flag
1579  , bool TF > // Transpose flag
1580 template< typename Other > // Data type of the right-hand side scalar
1581 inline EnableIf_<IsNumeric<Other>, CustomVector<Type,AF,PF,TF> >&
1583 {
1584  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1585 
1586  smpAssign( *this, (*this) / rhs );
1587  return *this;
1588 }
1589 //*************************************************************************************************
1590 
1591 
1592 
1593 
1594 //=================================================================================================
1595 //
1596 // UTILITY FUNCTIONS
1597 //
1598 //=================================================================================================
1599 
1600 //*************************************************************************************************
1605 template< typename Type // Data type of the vector
1606  , bool AF // Alignment flag
1607  , bool PF // Padding flag
1608  , bool TF > // Transpose flag
1609 inline size_t CustomVector<Type,AF,PF,TF>::size() const noexcept
1610 {
1611  return size_;
1612 }
1613 //*************************************************************************************************
1614 
1615 
1616 //*************************************************************************************************
1621 template< typename Type // Data type of the vector
1622  , bool AF // Alignment flag
1623  , bool PF // Padding flag
1624  , bool TF > // Transpose flag
1625 inline size_t CustomVector<Type,AF,PF,TF>::capacity() const noexcept
1626 {
1627  return size_;
1628 }
1629 //*************************************************************************************************
1630 
1631 
1632 //*************************************************************************************************
1640 template< typename Type // Data type of the vector
1641  , bool AF // Alignment flag
1642  , bool PF // Padding flag
1643  , bool TF > // Transpose flag
1645 {
1646  size_t nonzeros( 0 );
1647 
1648  for( size_t i=0UL; i<size_; ++i ) {
1649  if( !isDefault( v_[i] ) )
1650  ++nonzeros;
1651  }
1652 
1653  return nonzeros;
1654 }
1655 //*************************************************************************************************
1656 
1657 
1658 //*************************************************************************************************
1663 template< typename Type // Data type of the vector
1664  , bool AF // Alignment flag
1665  , bool PF // Padding flag
1666  , bool TF > // Transpose flag
1668 {
1669  using blaze::clear;
1670  for( size_t i=0UL; i<size_; ++i )
1671  clear( v_[i] );
1672 }
1673 //*************************************************************************************************
1674 
1675 
1676 //*************************************************************************************************
1684 template< typename Type // Data type of the vector
1685  , bool AF // Alignment flag
1686  , bool PF // Padding flag
1687  , bool TF > // Transpose flag
1689 {
1690  size_ = 0UL;
1691  v_.reset();
1692 }
1693 //*************************************************************************************************
1694 
1695 
1696 //*************************************************************************************************
1702 template< typename Type // Data type of the vector
1703  , bool AF // Alignment flag
1704  , bool PF // Padding flag
1705  , bool TF > // Transpose flag
1707 {
1708  using std::swap;
1709 
1710  swap( size_, v.size_ );
1711  swap( v_, v.v_ );
1712 }
1713 //*************************************************************************************************
1714 
1715 
1716 
1717 
1718 //=================================================================================================
1719 //
1720 // NUMERIC FUNCTIONS
1721 //
1722 //=================================================================================================
1723 
1724 //*************************************************************************************************
1730 template< typename Type // Data type of the vector
1731  , bool AF // Alignment flag
1732  , bool PF // Padding flag
1733  , bool TF > // Transpose flag
1734 template< typename Other > // Data type of the scalar value
1736 {
1737  for( size_t i=0UL; i<size_; ++i )
1738  v_[i] *= scalar;
1739  return *this;
1740 }
1741 //*************************************************************************************************
1742 
1743 
1744 
1745 
1746 //=================================================================================================
1747 //
1748 // RESOURCE MANAGEMENT FUNCTIONS
1749 //
1750 //=================================================================================================
1751 
1752 //*************************************************************************************************
1774 template< typename Type // Data type of the vector
1775  , bool AF // Alignment flag
1776  , bool PF // Padding flag
1777  , bool TF > // Transpose flag
1778 inline void CustomVector<Type,AF,PF,TF>::reset( Type* ptr, size_t n )
1779 {
1780  CustomVector tmp( ptr, n );
1781  swap( tmp );
1782 }
1783 //*************************************************************************************************
1784 
1785 
1786 //*************************************************************************************************
1811 template< typename Type // Data type of the vector
1812  , bool AF // Alignment flag
1813  , bool PF // Padding flag
1814  , bool TF > // Transpose flag
1815 inline void CustomVector<Type,AF,PF,TF>::reset( Type* ptr, size_t n, size_t nn )
1816 {
1817  BLAZE_STATIC_ASSERT( PF == padded );
1818 
1819  UNUSED_PARAMETER( ptr, n, nn );
1820 }
1821 //*************************************************************************************************
1822 
1823 
1824 //*************************************************************************************************
1846 template< typename Type // Data type of the vector
1847  , bool AF // Alignment flag
1848  , bool PF // Padding flag
1849  , bool TF > // Transpose flag
1850 template< typename Deleter // Type of the custom deleter
1851  , typename > // Type restriction on the custom deleter
1852 inline void CustomVector<Type,AF,PF,TF>::reset( Type* ptr, size_t n, Deleter d )
1853 {
1854  CustomVector tmp( ptr, n, d );
1855  swap( tmp );
1856 }
1857 //*************************************************************************************************
1858 
1859 
1860 //*************************************************************************************************
1885 template< typename Type // Data type of the vector
1886  , bool AF // Alignment flag
1887  , bool PF // Padding flag
1888  , bool TF > // Transpose flag
1889 template< typename Deleter > // Type of the custom deleter
1890 inline void CustomVector<Type,AF,PF,TF>::reset( Type* ptr, size_t n, size_t nn, Deleter d )
1891 {
1892  BLAZE_STATIC_ASSERT( PF == padded );
1893 
1894  UNUSED_PARAMETER( ptr, n, nn, d );
1895 }
1896 //*************************************************************************************************
1897 
1898 
1899 
1900 
1901 //=================================================================================================
1902 //
1903 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
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>::canAlias( const Other* alias ) const noexcept
1923 {
1924  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1925 }
1926 //*************************************************************************************************
1927 
1928 
1929 //*************************************************************************************************
1939 template< typename Type // Data type of the vector
1940  , bool AF // Alignment flag
1941  , bool PF // Padding flag
1942  , bool TF > // Transpose flag
1943 template< typename Other > // Data type of the foreign expression
1944 inline bool CustomVector<Type,AF,PF,TF>::isAliased( const Other* alias ) const noexcept
1945 {
1946  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1947 }
1948 //*************************************************************************************************
1949 
1950 
1951 //*************************************************************************************************
1960 template< typename Type // Data type of the vector
1961  , bool AF // Alignment flag
1962  , bool PF // Padding flag
1963  , bool TF > // Transpose flag
1964 inline bool CustomVector<Type,AF,PF,TF>::isAligned() const noexcept
1965 {
1966  return ( AF || checkAlignment( v_.get() ) );
1967 }
1968 //*************************************************************************************************
1969 
1970 
1971 //*************************************************************************************************
1981 template< typename Type // Data type of the vector
1982  , bool AF // Alignment flag
1983  , bool PF // Padding flag
1984  , bool TF > // Transpose flag
1985 inline bool CustomVector<Type,AF,PF,TF>::canSMPAssign() const noexcept
1986 {
1987  return ( size() > SMP_DVECASSIGN_THRESHOLD );
1988 }
1989 //*************************************************************************************************
1990 
1991 
1992 //*************************************************************************************************
2004 template< typename Type // Data type of the vector
2005  , bool AF // Alignment flag
2006  , bool PF // Padding flag
2007  , bool TF > // Transpose flag
2009  CustomVector<Type,AF,PF,TF>::load( size_t index ) const noexcept
2010 {
2011  if( AF )
2012  return loada( index );
2013  else
2014  return loadu( index );
2015 }
2016 //*************************************************************************************************
2017 
2018 
2019 //*************************************************************************************************
2032 template< typename Type // Data type of the vector
2033  , bool AF // Alignment flag
2034  , bool PF // Padding flag
2035  , bool TF > // Transpose flag
2037  CustomVector<Type,AF,PF,TF>::loada( size_t index ) const noexcept
2038 {
2039  using blaze::loada;
2040 
2042 
2043  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2044  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2045  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
2046  BLAZE_INTERNAL_ASSERT( checkAlignment( v_.get()+index ), "Invalid vector access index" );
2047 
2048  return loada( v_.get()+index );
2049 }
2050 //*************************************************************************************************
2051 
2052 
2053 //*************************************************************************************************
2066 template< typename Type // Data type of the vector
2067  , bool AF // Alignment flag
2068  , bool PF // Padding flag
2069  , bool TF > // Transpose flag
2071  CustomVector<Type,AF,PF,TF>::loadu( size_t index ) const noexcept
2072 {
2073  using blaze::loadu;
2074 
2076 
2077  BLAZE_INTERNAL_ASSERT( index< size_, "Invalid vector access index" );
2078  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2079 
2080  return loadu( v_.get()+index );
2081 }
2082 //*************************************************************************************************
2083 
2084 
2085 //*************************************************************************************************
2098 template< typename Type // Data type of the vector
2099  , bool AF // Alignment flag
2100  , bool PF // Padding flag
2101  , bool TF > // Transpose flag
2102 BLAZE_ALWAYS_INLINE void CustomVector<Type,AF,PF,TF>::store( size_t index, const SIMDType& value ) noexcept
2103 {
2104  if( AF )
2105  storea( index, value );
2106  else
2107  storeu( index, value );
2108 }
2109 //*************************************************************************************************
2110 
2111 
2112 //*************************************************************************************************
2125 template< typename Type // Data type of the vector
2126  , bool AF // Alignment flag
2127  , bool PF // Padding flag
2128  , bool TF > // Transpose flag
2129 BLAZE_ALWAYS_INLINE void CustomVector<Type,AF,PF,TF>::storea( size_t index, const SIMDType& value ) noexcept
2130 {
2131  using blaze::storea;
2132 
2134 
2135  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2136  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2137  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
2138  BLAZE_INTERNAL_ASSERT( checkAlignment( v_.get()+index ), "Invalid vector access index" );
2139 
2140  storea( v_.get()+index, value );
2141 }
2142 //*************************************************************************************************
2143 
2144 
2145 //*************************************************************************************************
2158 template< typename Type // Data type of the vector
2159  , bool AF // Alignment flag
2160  , bool PF // Padding flag
2161  , bool TF > // Transpose flag
2162 BLAZE_ALWAYS_INLINE void CustomVector<Type,AF,PF,TF>::storeu( size_t index, const SIMDType& value ) noexcept
2163 {
2164  using blaze::storeu;
2165 
2167 
2168  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2169  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2170 
2171  storeu( v_.get()+index, value );
2172 }
2173 //*************************************************************************************************
2174 
2175 
2176 //*************************************************************************************************
2190 template< typename Type // Data type of the vector
2191  , bool AF // Alignment flag
2192  , bool PF // Padding flag
2193  , bool TF > // Transpose flag
2194 BLAZE_ALWAYS_INLINE void CustomVector<Type,AF,PF,TF>::stream( size_t index, const SIMDType& value ) noexcept
2195 {
2196  using blaze::stream;
2197 
2199 
2200  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2201  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2202  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
2203  BLAZE_INTERNAL_ASSERT( checkAlignment( v_.get()+index ), "Invalid vector access index" );
2204 
2205  stream( v_.get()+index, value );
2206 }
2207 //*************************************************************************************************
2208 
2209 
2210 //*************************************************************************************************
2221 template< typename Type // Data type of the vector
2222  , bool AF // Alignment flag
2223  , bool PF // Padding flag
2224  , bool TF > // Transpose flag
2225 template< typename VT > // Type of the right-hand side dense vector
2228 {
2229  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2230 
2231  const size_t ipos( size_ & size_t(-2) );
2232  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2233 
2234  for( size_t i=0UL; i<ipos; i+=2UL ) {
2235  v_[i ] = (~rhs)[i ];
2236  v_[i+1UL] = (~rhs)[i+1UL];
2237  }
2238  if( ipos < (~rhs).size() )
2239  v_[ipos] = (~rhs)[ipos];
2240 }
2241 //*************************************************************************************************
2242 
2243 
2244 //*************************************************************************************************
2255 template< typename Type // Data type of the vector
2256  , bool AF // Alignment flag
2257  , bool PF // Padding flag
2258  , bool TF > // Transpose flag
2259 template< typename VT > // Type of the right-hand side dense vector
2262 {
2264 
2265  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2266 
2267  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2268  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2269 
2270  if( AF && useStreaming && size_ > ( cacheSize/( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
2271  {
2272  size_t i( 0UL );
2273 
2274  for( ; i<ipos; i+=SIMDSIZE ) {
2275  stream( i, (~rhs).load(i) );
2276  }
2277  for( ; i<size_; ++i ) {
2278  v_[i] = (~rhs)[i];
2279  }
2280  }
2281  else
2282  {
2283  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2284  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2285  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2286 
2287  size_t i( 0UL );
2288  ConstIterator_<VT> it( (~rhs).begin() );
2289 
2290  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2291  store( i , it.load() ); it += SIMDSIZE;
2292  store( i+SIMDSIZE , it.load() ); it += SIMDSIZE;
2293  store( i+SIMDSIZE*2UL, it.load() ); it += SIMDSIZE;
2294  store( i+SIMDSIZE*3UL, it.load() ); it += SIMDSIZE;
2295  }
2296  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2297  store( i, it.load() );
2298  }
2299  for( ; i<size_; ++i, ++it ) {
2300  v_[i] = *it;
2301  }
2302  }
2303 }
2304 //*************************************************************************************************
2305 
2306 
2307 //*************************************************************************************************
2318 template< typename Type // Data type of the vector
2319  , bool AF // Alignment flag
2320  , bool PF // Padding flag
2321  , bool TF > // Transpose flag
2322 template< typename VT > // Type of the right-hand side sparse vector
2324 {
2325  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2326 
2327  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2328  v_[element->index()] = element->value();
2329 }
2330 //*************************************************************************************************
2331 
2332 
2333 //*************************************************************************************************
2344 template< typename Type // Data type of the vector
2345  , bool AF // Alignment flag
2346  , bool PF // Padding flag
2347  , bool TF > // Transpose flag
2348 template< typename VT > // Type of the right-hand side dense vector
2351 {
2352  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2353 
2354  const size_t ipos( size_ & size_t(-2) );
2355  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2356 
2357  for( size_t i=0UL; i<ipos; i+=2UL ) {
2358  v_[i ] += (~rhs)[i ];
2359  v_[i+1UL] += (~rhs)[i+1UL];
2360  }
2361  if( ipos < (~rhs).size() )
2362  v_[ipos] += (~rhs)[ipos];
2363 }
2364 //*************************************************************************************************
2365 
2366 
2367 //*************************************************************************************************
2378 template< typename Type // Data type of the vector
2379  , bool AF // Alignment flag
2380  , bool PF // Padding flag
2381  , bool TF > // Transpose flag
2382 template< typename VT > // Type of the right-hand side dense vector
2385 {
2387 
2388  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2389 
2390  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2391  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2392 
2393  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2394  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2395  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2396 
2397  size_t i( 0UL );
2398  ConstIterator_<VT> it( (~rhs).begin() );
2399 
2400  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2401  store( i , load(i ) + it.load() ); it += SIMDSIZE;
2402  store( i+SIMDSIZE , load(i+SIMDSIZE ) + it.load() ); it += SIMDSIZE;
2403  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) + it.load() ); it += SIMDSIZE;
2404  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) + it.load() ); it += SIMDSIZE;
2405  }
2406  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2407  store( i, load(i) + it.load() );
2408  }
2409  for( ; i<size_; ++i, ++it ) {
2410  v_[i] += *it;
2411  }
2412 }
2413 //*************************************************************************************************
2414 
2415 
2416 //*************************************************************************************************
2427 template< typename Type // Data type of the vector
2428  , bool AF // Alignment flag
2429  , bool PF // Padding flag
2430  , bool TF > // Transpose flag
2431 template< typename VT > // Type of the right-hand side sparse vector
2433 {
2434  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2435 
2436  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2437  v_[element->index()] += element->value();
2438 }
2439 //*************************************************************************************************
2440 
2441 
2442 //*************************************************************************************************
2453 template< typename Type // Data type of the vector
2454  , bool AF // Alignment flag
2455  , bool PF // Padding flag
2456  , bool TF > // Transpose flag
2457 template< typename VT > // Type of the right-hand side dense vector
2460 {
2461  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2462 
2463  const size_t ipos( size_ & size_t(-2) );
2464  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2465 
2466  for( size_t i=0UL; i<ipos; i+=2UL ) {
2467  v_[i ] -= (~rhs)[i ];
2468  v_[i+1UL] -= (~rhs)[i+1UL];
2469  }
2470  if( ipos < (~rhs).size() )
2471  v_[ipos] -= (~rhs)[ipos];
2472 }
2473 //*************************************************************************************************
2474 
2475 
2476 //*************************************************************************************************
2487 template< typename Type // Data type of the vector
2488  , bool AF // Alignment flag
2489  , bool PF // Padding flag
2490  , bool TF > // Transpose flag
2491 template< typename VT > // Type of the right-hand side dense vector
2494 {
2496 
2497  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2498 
2499  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2500  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2501 
2502  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2503  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2504  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2505 
2506  size_t i( 0UL );
2507  ConstIterator_<VT> it( (~rhs).begin() );
2508 
2509  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2510  store( i , load(i ) - it.load() ); it += SIMDSIZE;
2511  store( i+SIMDSIZE , load(i+SIMDSIZE ) - it.load() ); it += SIMDSIZE;
2512  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) - it.load() ); it += SIMDSIZE;
2513  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) - it.load() ); it += SIMDSIZE;
2514  }
2515  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2516  store( i, load(i) - it.load() );
2517  }
2518  for( ; i<size_; ++i, ++it ) {
2519  v_[i] -= *it;
2520  }
2521 }
2522 //*************************************************************************************************
2523 
2524 
2525 //*************************************************************************************************
2536 template< typename Type // Data type of the vector
2537  , bool AF // Alignment flag
2538  , bool PF // Padding flag
2539  , bool TF > // Transpose flag
2540 template< typename VT > // Type of the right-hand side sparse vector
2542 {
2543  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2544 
2545  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2546  v_[element->index()] -= element->value();
2547 }
2548 //*************************************************************************************************
2549 
2550 
2551 //*************************************************************************************************
2562 template< typename Type // Data type of the vector
2563  , bool AF // Alignment flag
2564  , bool PF // Padding flag
2565  , bool TF > // Transpose flag
2566 template< typename VT > // Type of the right-hand side dense vector
2569 {
2570  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2571 
2572  const size_t ipos( size_ & size_t(-2) );
2573  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2574 
2575  for( size_t i=0UL; i<ipos; i+=2UL ) {
2576  v_[i ] *= (~rhs)[i ];
2577  v_[i+1UL] *= (~rhs)[i+1UL];
2578  }
2579  if( ipos < (~rhs).size() )
2580  v_[ipos] *= (~rhs)[ipos];
2581 }
2582 //*************************************************************************************************
2583 
2584 
2585 //*************************************************************************************************
2596 template< typename Type // Data type of the vector
2597  , bool AF // Alignment flag
2598  , bool PF // Padding flag
2599  , bool TF > // Transpose flag
2600 template< typename VT > // Type of the right-hand side dense vector
2603 {
2605 
2606  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2607 
2608  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2609  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2610 
2611  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2612  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2613  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2614 
2615  size_t i( 0UL );
2616  ConstIterator_<VT> it( (~rhs).begin() );
2617 
2618  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2619  store( i , load(i ) * it.load() ); it += SIMDSIZE;
2620  store( i+SIMDSIZE , load(i+SIMDSIZE ) * it.load() ); it += SIMDSIZE;
2621  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) * it.load() ); it += SIMDSIZE;
2622  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) * it.load() ); it += SIMDSIZE;
2623  }
2624  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2625  store( i, load(i) * it.load() );
2626  }
2627  for( ; i<size_; ++i, ++it ) {
2628  v_[i] *= *it;
2629  }
2630 }
2631 //*************************************************************************************************
2632 
2633 
2634 //*************************************************************************************************
2645 template< typename Type // Data type of the vector
2646  , bool AF // Alignment flag
2647  , bool PF // Padding flag
2648  , bool TF > // Transpose flag
2649 template< typename VT > // Type of the right-hand side sparse vector
2651 {
2652  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2653 
2654  const DynamicVector<Type,TF> tmp( serial( *this ) );
2655 
2656  reset();
2657 
2658  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2659  v_[element->index()] = tmp[element->index()] * element->value();
2660 }
2661 //*************************************************************************************************
2662 
2663 
2664 //*************************************************************************************************
2675 template< typename Type // Data type of the vector
2676  , bool AF // Alignment flag
2677  , bool PF // Padding flag
2678  , bool TF > // Transpose flag
2679 template< typename VT > // Type of the right-hand side dense vector
2682 {
2683  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2684 
2685  const size_t ipos( size_ & size_t(-2) );
2686  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2687 
2688  for( size_t i=0UL; i<ipos; i+=2UL ) {
2689  v_[i ] /= (~rhs)[i ];
2690  v_[i+1UL] /= (~rhs)[i+1UL];
2691  }
2692  if( ipos < (~rhs).size() )
2693  v_[ipos] /= (~rhs)[ipos];
2694 }
2695 //*************************************************************************************************
2696 
2697 
2698 //*************************************************************************************************
2709 template< typename Type // Data type of the vector
2710  , bool AF // Alignment flag
2711  , bool PF // Padding flag
2712  , bool TF > // Transpose flag
2713 template< typename VT > // Type of the right-hand side dense vector
2716 {
2718 
2719  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2720 
2721  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2722  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2723 
2724  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2725  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2726  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2727 
2728  size_t i( 0UL );
2729  ConstIterator_<VT> it( (~rhs).begin() );
2730 
2731  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2732  store( i , load(i ) / it.load() ); it += SIMDSIZE;
2733  store( i+SIMDSIZE , load(i+SIMDSIZE ) / it.load() ); it += SIMDSIZE;
2734  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) / it.load() ); it += SIMDSIZE;
2735  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) / it.load() ); it += SIMDSIZE;
2736  }
2737  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2738  store( i, load(i) / it.load() );
2739  }
2740  for( ; i<size_; ++i, ++it ) {
2741  v_[i] /= *it;
2742  }
2743 }
2744 //*************************************************************************************************
2745 
2746 
2747 
2748 
2749 
2750 
2751 
2752 
2753 //=================================================================================================
2754 //
2755 // CLASS TEMPLATE SPECIALIZATION FOR PADDED VECTORS
2756 //
2757 //=================================================================================================
2758 
2759 //*************************************************************************************************
2767 template< typename Type // Data type of the vector
2768  , bool AF // Alignment flag
2769  , bool TF > // Transpose flag
2770 class CustomVector<Type,AF,padded,TF>
2771  : public DenseVector< CustomVector<Type,AF,padded,TF>, TF >
2772 {
2773  public:
2774  //**Type definitions****************************************************************************
2778  typedef Type ElementType;
2780  typedef const Type& ReturnType;
2781  typedef const CustomVector& CompositeType;
2782 
2783  typedef Type& Reference;
2784  typedef const Type& ConstReference;
2785  typedef Type* Pointer;
2786  typedef const Type* ConstPointer;
2787 
2790  //**********************************************************************************************
2791 
2792  //**Rebind struct definition********************************************************************
2795  template< typename NewType > // Data type of the other vector
2796  struct Rebind {
2797  typedef CustomVector<NewType,AF,padded,TF> Other;
2798  };
2799  //**********************************************************************************************
2800 
2801  //**Resize struct definition********************************************************************
2804  template< size_t NewN > // Number of elements of the other vector
2805  struct Resize {
2806  typedef CustomVector<Type,AF,padded,TF> Other;
2807  };
2808  //**********************************************************************************************
2809 
2810  //**Compilation flags***************************************************************************
2812 
2816  enum : bool { simdEnabled = IsVectorizable<Type>::value };
2817 
2819 
2822  enum : bool { smpAssignable = !IsSMPAssignable<Type>::value };
2823  //**********************************************************************************************
2824 
2825  //**Constructors********************************************************************************
2828  explicit inline CustomVector();
2829  explicit inline CustomVector( Type* ptr, size_t n, size_t nn );
2830 
2831  template< typename Deleter >
2832  explicit inline CustomVector( Type* ptr, size_t n, size_t nn, Deleter d );
2833 
2834  inline CustomVector( const CustomVector& v );
2835  inline CustomVector( CustomVector&& v ) noexcept;
2837  //**********************************************************************************************
2838 
2839  //**Destructor**********************************************************************************
2840  // No explicitly declared destructor.
2841  //**********************************************************************************************
2842 
2843  //**Data access functions***********************************************************************
2846  inline Reference operator[]( size_t index ) noexcept;
2847  inline ConstReference operator[]( size_t index ) const noexcept;
2848  inline Reference at( size_t index );
2849  inline ConstReference at( size_t index ) const;
2850  inline Pointer data () noexcept;
2851  inline ConstPointer data () const noexcept;
2852  inline Iterator begin () noexcept;
2853  inline ConstIterator begin () const noexcept;
2854  inline ConstIterator cbegin() const noexcept;
2855  inline Iterator end () noexcept;
2856  inline ConstIterator end () const noexcept;
2857  inline ConstIterator cend () const noexcept;
2859  //**********************************************************************************************
2860 
2861  //**Assignment operators************************************************************************
2864  inline CustomVector& operator=( const Type& rhs );
2866 
2867  template< typename Other, size_t N >
2868  inline CustomVector& operator=( const Other (&array)[N] );
2869 
2870  inline CustomVector& operator=( const CustomVector& rhs );
2871  inline CustomVector& operator=( CustomVector&& rhs ) noexcept;
2872 
2873  template< typename VT > inline CustomVector& operator= ( const Vector<VT,TF>& rhs );
2874  template< typename VT > inline CustomVector& operator+=( const Vector<VT,TF>& rhs );
2875  template< typename VT > inline CustomVector& operator-=( const Vector<VT,TF>& rhs );
2876  template< typename VT > inline CustomVector& operator*=( const Vector<VT,TF>& rhs );
2877  template< typename VT > inline CustomVector& operator/=( const DenseVector<VT,TF>& rhs );
2878 
2879  template< typename Other >
2880  inline EnableIf_<IsNumeric<Other>, CustomVector >& operator*=( Other rhs );
2881 
2882  template< typename Other >
2883  inline EnableIf_<IsNumeric<Other>, CustomVector >& operator/=( Other rhs );
2885  //**********************************************************************************************
2886 
2887  //**Utility functions***************************************************************************
2890  inline size_t size() const noexcept;
2891  inline size_t capacity() const noexcept;
2892  inline size_t nonZeros() const;
2893  inline void reset();
2894  inline void clear();
2895  inline void swap( CustomVector& v ) noexcept;
2897  //**********************************************************************************************
2898 
2899  //**Numeric functions***************************************************************************
2902  template< typename Other > inline CustomVector& scale( const Other& scalar );
2904  //**********************************************************************************************
2905 
2906  //**Resource management functions***************************************************************
2909  inline void reset( Type* ptr, size_t n, size_t nn );
2910  template< typename Deleter > inline void reset( Type* ptr, size_t n, size_t nn, Deleter d );
2912  //**********************************************************************************************
2913 
2914  private:
2915  //**********************************************************************************************
2917  template< typename VT >
2918  struct VectorizedAssign {
2919  enum : bool { value = useOptimizedKernels &&
2920  simdEnabled && VT::simdEnabled &&
2922  };
2923  //**********************************************************************************************
2924 
2925  //**********************************************************************************************
2927  template< typename VT >
2928  struct VectorizedAddAssign {
2929  enum : bool { value = useOptimizedKernels &&
2930  simdEnabled && VT::simdEnabled &&
2933  };
2934  //**********************************************************************************************
2935 
2936  //**********************************************************************************************
2938  template< typename VT >
2939  struct VectorizedSubAssign {
2940  enum : bool { value = useOptimizedKernels &&
2941  simdEnabled && VT::simdEnabled &&
2944  };
2945  //**********************************************************************************************
2946 
2947  //**********************************************************************************************
2949  template< typename VT >
2950  struct VectorizedMultAssign {
2951  enum : bool { value = useOptimizedKernels &&
2952  simdEnabled && VT::simdEnabled &&
2955  };
2956  //**********************************************************************************************
2957 
2958  //**********************************************************************************************
2960  template< typename VT >
2961  struct VectorizedDivAssign {
2962  enum : bool { value = useOptimizedKernels &&
2963  simdEnabled && VT::simdEnabled &&
2966  };
2967  //**********************************************************************************************
2968 
2969  //**SIMD properties*****************************************************************************
2971  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
2972  //**********************************************************************************************
2973 
2974  public:
2975  //**Expression template evaluation functions****************************************************
2978  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
2979  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
2980 
2981  inline bool isAligned () const noexcept;
2982  inline bool canSMPAssign() const noexcept;
2983 
2984  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
2985  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
2986  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
2987 
2988  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
2989  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
2990  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
2991  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
2992 
2993  template< typename VT >
2994  inline DisableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
2995 
2996  template< typename VT >
2997  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
2998 
2999  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
3000 
3001  template< typename VT >
3002  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
3003 
3004  template< typename VT >
3005  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
3006 
3007  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
3008 
3009  template< typename VT >
3010  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
3011 
3012  template< typename VT >
3013  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
3014 
3015  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
3016 
3017  template< typename VT >
3018  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
3019 
3020  template< typename VT >
3021  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
3022 
3023  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
3024 
3025  template< typename VT >
3026  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
3027 
3028  template< typename VT >
3029  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
3031  //**********************************************************************************************
3032 
3033  private:
3034  //**Member variables****************************************************************************
3037  size_t size_;
3038  size_t capacity_;
3039  boost::shared_array<Type> v_;
3040 
3046  //**********************************************************************************************
3047 
3048  //**Compile time checks*************************************************************************
3053  //**********************************************************************************************
3054 };
3056 //*************************************************************************************************
3057 
3058 
3059 
3060 
3061 //=================================================================================================
3062 //
3063 // CONSTRUCTORS
3064 //
3065 //=================================================================================================
3066 
3067 //*************************************************************************************************
3071 template< typename Type // Data type of the vector
3072  , bool AF // Alignment flag
3073  , bool TF > // Transpose flag
3075  : size_ ( 0UL ) // The size/dimension of the vector
3076  , capacity_( 0UL ) // The maximum capacity of the vector
3077  , v_ ( ) // The custom array of elements
3078 {}
3080 //*************************************************************************************************
3081 
3082 
3083 //*************************************************************************************************
3105 template< typename Type // Data type of the vector
3106  , bool AF // Alignment flag
3107  , bool TF > // Transpose flag
3108 inline CustomVector<Type,AF,padded,TF>::CustomVector( Type* ptr, size_t n, size_t nn )
3109  : size_ ( n ) // The size/dimension of the vector
3110  , capacity_( nn ) // The maximum capacity of the vector
3111  , v_ ( ) // The custom array of elements
3112 {
3113  if( ptr == nullptr ) {
3114  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array of elements" );
3115  }
3116 
3117  if( AF && !checkAlignment( ptr ) ) {
3118  BLAZE_THROW_INVALID_ARGUMENT( "Invalid alignment detected" );
3119  }
3120 
3121  if( IsVectorizable<Type>::value && capacity_ < nextMultiple<size_t>( size_, SIMDSIZE ) ) {
3122  BLAZE_THROW_INVALID_ARGUMENT( "Insufficient capacity for padded vector" );
3123  }
3124 
3125  v_.reset( ptr, NoDelete() );
3126 
3128  for( size_t i=size_; i<capacity_; ++i )
3129  v_[i] = Type();
3130  }
3131 }
3133 //*************************************************************************************************
3134 
3135 
3136 //*************************************************************************************************
3157 template< typename Type // Data type of the vector
3158  , bool AF // Alignment flag
3159  , bool TF > // Transpose flag
3160 template< typename Deleter > // Type of the custom deleter
3161 inline CustomVector<Type,AF,padded,TF>::CustomVector( Type* ptr, size_t n, size_t nn, Deleter d )
3162  : size_ ( n ) // The custom array of elements
3163  , capacity_( nn ) // The maximum capacity of the vector
3164  , v_ ( ) // The custom array of elements
3165 {
3166  if( ptr == nullptr ) {
3167  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array of elements" );
3168  }
3169 
3170  if( AF && !checkAlignment( ptr ) ) {
3171  BLAZE_THROW_INVALID_ARGUMENT( "Invalid alignment detected" );
3172  }
3173 
3174  if( IsVectorizable<Type>::value && capacity_ < nextMultiple<size_t>( size_, SIMDSIZE ) ) {
3175  BLAZE_THROW_INVALID_ARGUMENT( "Insufficient capacity for padded vector" );
3176  }
3177 
3178  v_.reset( ptr, d );
3179 
3181  for( size_t i=size_; i<capacity_; ++i )
3182  v_[i] = Type();
3183  }
3184 }
3186 //*************************************************************************************************
3187 
3188 
3189 //*************************************************************************************************
3197 template< typename Type // Data type of the vector
3198  , bool AF // Alignment flag
3199  , bool TF > // Transpose flag
3201  : size_ ( v.size_ ) // The size/dimension of the vector
3202  , capacity_( v.capacity_ ) // The maximum capacity of the vector
3203  , v_ ( v.v_ ) // The custom array of elements
3204 {}
3206 //*************************************************************************************************
3207 
3208 
3209 //*************************************************************************************************
3215 template< typename Type // Data type of the vector
3216  , bool AF // Alignment flag
3217  , bool TF > // Transpose flag
3219  : size_ ( v.size_ ) // The size/dimension of the vector
3220  , capacity_( v.capacity_ ) // The maximum capacity of the vector
3221  , v_ ( std::move( v.v_ ) ) // The custom array of elements
3222 {
3223  v.size_ = 0UL;
3224  v.capacity_ = 0UL;
3225 
3226  BLAZE_INTERNAL_ASSERT( v.data() == nullptr, "Invalid data reference detected" );
3227 }
3229 //*************************************************************************************************
3230 
3231 
3232 
3233 
3234 //=================================================================================================
3235 //
3236 // DATA ACCESS FUNCTIONS
3237 //
3238 //=================================================================================================
3239 
3240 //*************************************************************************************************
3250 template< typename Type // Data type of the vector
3251  , bool AF // Alignment flag
3252  , bool TF > // Transpose flag
3254  CustomVector<Type,AF,padded,TF>::operator[]( size_t index ) noexcept
3255 {
3256  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
3257  return v_[index];
3258 }
3260 //*************************************************************************************************
3261 
3262 
3263 //*************************************************************************************************
3273 template< typename Type // Data type of the vector
3274  , bool AF // Alignment flag
3275  , bool TF > // Transpose flag
3277  CustomVector<Type,AF,padded,TF>::operator[]( size_t index ) const noexcept
3278 {
3279  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
3280  return v_[index];
3281 }
3283 //*************************************************************************************************
3284 
3285 
3286 //*************************************************************************************************
3297 template< typename Type // Data type of the vector
3298  , bool AF // Alignment flag
3299  , bool TF > // Transpose flag
3301  CustomVector<Type,AF,padded,TF>::at( size_t index )
3302 {
3303  if( index >= size_ ) {
3304  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
3305  }
3306  return (*this)[index];
3307 }
3309 //*************************************************************************************************
3310 
3311 
3312 //*************************************************************************************************
3323 template< typename Type // Data type of the vector
3324  , bool AF // Alignment flag
3325  , bool TF > // Transpose flag
3327  CustomVector<Type,AF,padded,TF>::at( size_t index ) const
3328 {
3329  if( index >= size_ ) {
3330  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
3331  }
3332  return (*this)[index];
3333 }
3335 //*************************************************************************************************
3336 
3337 
3338 //*************************************************************************************************
3346 template< typename Type // Data type of the vector
3347  , bool AF // Alignment flag
3348  , bool TF > // Transpose flag
3351 {
3352  return v_.get();
3353 }
3355 //*************************************************************************************************
3356 
3357 
3358 //*************************************************************************************************
3366 template< typename Type // Data type of the vector
3367  , bool AF // Alignment flag
3368  , bool TF > // Transpose flag
3370  CustomVector<Type,AF,padded,TF>::data() const noexcept
3371 {
3372  return v_.get();
3373 }
3375 //*************************************************************************************************
3376 
3377 
3378 //*************************************************************************************************
3384 template< typename Type // Data type of the vector
3385  , bool AF // Alignment flag
3386  , bool TF > // Transpose flag
3389 {
3390  return Iterator( v_.get() );
3391 }
3393 //*************************************************************************************************
3394 
3395 
3396 //*************************************************************************************************
3402 template< typename Type // Data type of the vector
3403  , bool AF // Alignment flag
3404  , bool TF > // Transpose flag
3407 {
3408  return ConstIterator( v_.get() );
3409 }
3411 //*************************************************************************************************
3412 
3413 
3414 //*************************************************************************************************
3420 template< typename Type // Data type of the vector
3421  , bool AF // Alignment flag
3422  , bool TF > // Transpose flag
3425 {
3426  return ConstIterator( v_.get() );
3427 }
3429 //*************************************************************************************************
3430 
3431 
3432 //*************************************************************************************************
3438 template< typename Type // Data type of the vector
3439  , bool AF // Alignment flag
3440  , bool TF > // Transpose flag
3443 {
3444  return Iterator( v_.get() + size_ );
3445 }
3447 //*************************************************************************************************
3448 
3449 
3450 //*************************************************************************************************
3456 template< typename Type // Data type of the vector
3457  , bool AF // Alignment flag
3458  , bool TF > // Transpose flag
3460  CustomVector<Type,AF,padded,TF>::end() const noexcept
3461 {
3462  return ConstIterator( v_.get() + size_ );
3463 }
3465 //*************************************************************************************************
3466 
3467 
3468 //*************************************************************************************************
3474 template< typename Type // Data type of the vector
3475  , bool AF // Alignment flag
3476  , bool TF > // Transpose flag
3478  CustomVector<Type,AF,padded,TF>::cend() const noexcept
3479 {
3480  return ConstIterator( v_.get() + size_ );
3481 }
3483 //*************************************************************************************************
3484 
3485 
3486 
3487 
3488 //=================================================================================================
3489 //
3490 // ASSIGNMENT OPERATORS
3491 //
3492 //=================================================================================================
3493 
3494 //*************************************************************************************************
3501 template< typename Type // Data type of the vector
3502  , bool AF // Alignment flag
3503  , bool TF > // Transpose flag
3506 {
3507  for( size_t i=0UL; i<size_; ++i )
3508  v_[i] = rhs;
3509  return *this;
3510 }
3512 //*************************************************************************************************
3513 
3514 
3515 //*************************************************************************************************
3540 template< typename Type // Data type of the vector
3541  , bool AF // Alignment flag
3542  , bool TF > // Transpose flag
3545 {
3546  if( list.size() > size_ ) {
3547  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to custom vector" );
3548  }
3549 
3550  std::fill( std::copy( list.begin(), list.end(), v_.get() ), v_.get()+capacity_, Type() );
3551 
3552  return *this;
3553 }
3555 //*************************************************************************************************
3556 
3557 
3558 //*************************************************************************************************
3586 template< typename Type // Data type of the vector
3587  , bool AF // Alignment flag
3588  , bool TF > // Transpose flag
3589 template< typename Other // Data type of the initialization array
3590  , size_t N > // Dimension of the initialization array
3592  CustomVector<Type,AF,padded,TF>::operator=( const Other (&array)[N] )
3593 {
3594  if( size_ != N ) {
3595  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array size" );
3596  }
3597 
3598  for( size_t i=0UL; i<N; ++i )
3599  v_[i] = array[i];
3600 
3601  return *this;
3602 }
3604 //*************************************************************************************************
3605 
3606 
3607 //*************************************************************************************************
3618 template< typename Type // Data type of the vector
3619  , bool AF // Alignment flag
3620  , bool TF > // Transpose flag
3623 {
3624  if( rhs.size() != size_ ) {
3625  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3626  }
3627 
3628  smpAssign( *this, ~rhs );
3629 
3630  return *this;
3631 }
3633 //*************************************************************************************************
3634 
3635 
3636 //*************************************************************************************************
3643 template< typename Type // Data type of the vector
3644  , bool AF // Alignment flag
3645  , bool TF > // Transpose flag
3648 {
3649  size_ = rhs.size_;
3650  capacity_ = rhs.capacity_;
3651  v_ = std::move( rhs.v_ );
3652 
3653  rhs.size_ = 0UL;
3654  rhs.capacity_ = 0UL;
3655 
3656  BLAZE_INTERNAL_ASSERT( rhs.data() == nullptr, "Invalid data reference detected" );
3657 
3658  return *this;
3659 }
3661 //*************************************************************************************************
3662 
3663 
3664 //*************************************************************************************************
3675 template< typename Type // Data type of the vector
3676  , bool AF // Alignment flag
3677  , bool TF > // Transpose flag
3678 template< typename VT > // Type of the right-hand side vector
3681 {
3682  if( (~rhs).size() != size_ ) {
3683  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3684  }
3685 
3686  if( (~rhs).canAlias( this ) ) {
3687  const ResultType_<VT> tmp( ~rhs );
3688  smpAssign( *this, tmp );
3689  }
3690  else {
3692  reset();
3693  smpAssign( *this, ~rhs );
3694  }
3695 
3696  return *this;
3697 }
3699 //*************************************************************************************************
3700 
3701 
3702 //*************************************************************************************************
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
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  smpAddAssign( *this, tmp );
3727  }
3728  else {
3729  smpAddAssign( *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
3756 {
3757  if( (~rhs).size() != size_ ) {
3758  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3759  }
3760 
3761  if( (~rhs).canAlias( this ) ) {
3762  const ResultType_<VT> tmp( ~rhs );
3763  smpSubAssign( *this, tmp );
3764  }
3765  else {
3766  smpSubAssign( *this, ~rhs );
3767  }
3768 
3769  return *this;
3770 }
3772 //*************************************************************************************************
3773 
3774 
3775 //*************************************************************************************************
3787 template< typename Type // Data type of the vector
3788  , bool AF // Alignment flag
3789  , bool TF > // Transpose flag
3790 template< typename VT > // Type of the right-hand side vector
3793 {
3796 
3797  typedef MultTrait_< ResultType, ResultType_<VT> > MultType;
3798 
3801 
3802  if( (~rhs).size() != size_ ) {
3803  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3804  }
3805 
3806  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
3807  const MultType tmp( *this * (~rhs) );
3808  this->operator=( tmp );
3809  }
3810  else {
3811  smpMultAssign( *this, ~rhs );
3812  }
3813 
3814  return *this;
3815 }
3817 //*************************************************************************************************
3818 
3819 
3820 //*************************************************************************************************
3831 template< typename Type // Data type of the vector
3832  , bool AF // Alignment flag
3833  , bool TF > // Transpose flag
3834 template< typename VT > // Type of the right-hand side vector
3837 {
3840 
3841  typedef DivTrait_< ResultType, ResultType_<VT> > DivType;
3842 
3845 
3846  if( (~rhs).size() != size_ ) {
3847  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3848  }
3849 
3850  if( (~rhs).canAlias( this ) ) {
3851  const DivType tmp( *this / (~rhs) );
3852  this->operator=( tmp );
3853  }
3854  else {
3855  smpDivAssign( *this, ~rhs );
3856  }
3857 
3858  return *this;
3859 }
3861 //*************************************************************************************************
3862 
3863 
3864 //*************************************************************************************************
3872 template< typename Type // Data type of the vector
3873  , bool AF // Alignment flag
3874  , bool TF > // Transpose flag
3875 template< typename Other > // Data type of the right-hand side scalar
3876 inline EnableIf_<IsNumeric<Other>, CustomVector<Type,AF,padded,TF> >&
3878 {
3879  smpAssign( *this, (*this) * rhs );
3880  return *this;
3881 }
3883 //*************************************************************************************************
3884 
3885 
3886 //*************************************************************************************************
3896 template< typename Type // Data type of the vector
3897  , bool AF // Alignment flag
3898  , bool TF > // Transpose flag
3899 template< typename Other > // Data type of the right-hand side scalar
3900 inline EnableIf_<IsNumeric<Other>, CustomVector<Type,AF,padded,TF> >&
3902 {
3903  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3904 
3905  smpAssign( *this, (*this) / rhs );
3906  return *this;
3907 }
3909 //*************************************************************************************************
3910 
3911 
3912 
3913 
3914 //=================================================================================================
3915 //
3916 // UTILITY FUNCTIONS
3917 //
3918 //=================================================================================================
3919 
3920 //*************************************************************************************************
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>::size() const noexcept
3930 {
3931  return size_;
3932 }
3934 //*************************************************************************************************
3935 
3936 
3937 //*************************************************************************************************
3943 template< typename Type // Data type of the vector
3944  , bool AF // Alignment flag
3945  , bool TF > // Transpose flag
3946 inline size_t CustomVector<Type,AF,padded,TF>::capacity() const noexcept
3947 {
3948  return capacity_;
3949 }
3951 //*************************************************************************************************
3952 
3953 
3954 //*************************************************************************************************
3963 template< typename Type // Data type of the vector
3964  , bool AF // Alignment flag
3965  , bool TF > // Transpose flag
3966 inline size_t CustomVector<Type,AF,padded,TF>::nonZeros() const
3967 {
3968  size_t nonzeros( 0 );
3969 
3970  for( size_t i=0UL; i<size_; ++i ) {
3971  if( !isDefault( v_[i] ) )
3972  ++nonzeros;
3973  }
3974 
3975  return nonzeros;
3976 }
3978 //*************************************************************************************************
3979 
3980 
3981 //*************************************************************************************************
3987 template< typename Type // Data type of the vector
3988  , bool AF // Alignment flag
3989  , bool TF > // Transpose flag
3991 {
3992  using blaze::clear;
3993  for( size_t i=0UL; i<size_; ++i )
3994  clear( v_[i] );
3995 }
3997 //*************************************************************************************************
3998 
3999 
4000 //*************************************************************************************************
4009 template< typename Type // Data type of the vector
4010  , bool AF // Alignment flag
4011  , bool TF > // Transpose flag
4013 {
4014  size_ = 0UL;
4015  capacity_ = 0UL;
4016  v_.reset();
4017 }
4019 //*************************************************************************************************
4020 
4021 
4022 //*************************************************************************************************
4029 template< typename Type // Data type of the vector
4030  , bool AF // Alignment flag
4031  , bool TF > // Transpose flag
4032 inline void CustomVector<Type,AF,padded,TF>::swap( CustomVector& v ) noexcept
4033 {
4034  using std::swap;
4035 
4036  swap( size_, v.size_ );
4037  swap( capacity_, v.capacity_ );
4038  swap( v_, v.v_ );
4039 }
4041 //*************************************************************************************************
4042 
4043 
4044 
4045 
4046 //=================================================================================================
4047 //
4048 // NUMERIC FUNCTIONS
4049 //
4050 //=================================================================================================
4051 
4052 //*************************************************************************************************
4059 template< typename Type // Data type of the vector
4060  , bool AF // Alignment flag
4061  , bool TF > // Transpose flag
4062 template< typename Other > // Data type of the scalar value
4064  CustomVector<Type,AF,padded,TF>::scale( const Other& scalar )
4065 {
4066  for( size_t i=0UL; i<size_; ++i )
4067  v_[i] *= scalar;
4068  return *this;
4069 }
4071 //*************************************************************************************************
4072 
4073 
4074 
4075 
4076 //=================================================================================================
4077 //
4078 // RESOURCE MANAGEMENT FUNCTIONS
4079 //
4080 //=================================================================================================
4081 
4082 //*************************************************************************************************
4105 template< typename Type // Data type of the vector
4106  , bool AF // Alignment flag
4107  , bool TF > // Transpose flag
4108 inline void CustomVector<Type,AF,padded,TF>::reset( Type* ptr, size_t n, size_t nn )
4109 {
4110  CustomVector tmp( ptr, n, nn );
4111  swap( tmp );
4112 }
4114 //*************************************************************************************************
4115 
4116 
4117 //*************************************************************************************************
4140 template< typename Type // Data type of the vector
4141  , bool AF // Alignment flag
4142  , bool TF > // Transpose flag
4143 template< typename Deleter > // Type of the custom deleter
4144 inline void CustomVector<Type,AF,padded,TF>::reset( Type* ptr, size_t n, size_t nn, Deleter d )
4145 {
4146  CustomVector tmp( ptr, n, nn, d );
4147  swap( tmp );
4148 }
4150 //*************************************************************************************************
4151 
4152 
4153 
4154 
4155 //=================================================================================================
4156 //
4157 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
4158 //
4159 //=================================================================================================
4160 
4161 //*************************************************************************************************
4172 template< typename Type // Data type of the vector
4173  , bool AF // Alignment flag
4174  , bool TF > // Transpose flag
4175 template< typename Other > // Data type of the foreign expression
4176 inline bool CustomVector<Type,AF,padded,TF>::canAlias( const Other* alias ) const noexcept
4177 {
4178  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4179 }
4181 //*************************************************************************************************
4182 
4183 
4184 //*************************************************************************************************
4195 template< typename Type // Data type of the vector
4196  , bool AF // Alignment flag
4197  , bool TF > // Transpose flag
4198 template< typename Other > // Data type of the foreign expression
4199 inline bool CustomVector<Type,AF,padded,TF>::isAliased( const Other* alias ) const noexcept
4200 {
4201  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4202 }
4204 //*************************************************************************************************
4205 
4206 
4207 //*************************************************************************************************
4217 template< typename Type // Data type of the vector
4218  , bool AF // Alignment flag
4219  , bool TF > // Transpose flag
4220 inline bool CustomVector<Type,AF,padded,TF>::isAligned() const noexcept
4221 {
4222  return ( AF || checkAlignment( v_.get() ) );
4223 }
4225 //*************************************************************************************************
4226 
4227 
4228 //*************************************************************************************************
4239 template< typename Type // Data type of the vector
4240  , bool AF // Alignment flag
4241  , bool TF > // Transpose flag
4242 inline bool CustomVector<Type,AF,padded,TF>::canSMPAssign() const noexcept
4243 {
4244  return ( size() > SMP_DVECASSIGN_THRESHOLD );
4245 }
4247 //*************************************************************************************************
4248 
4249 
4250 //*************************************************************************************************
4263 template< typename Type // Data type of the vector
4264  , bool AF // Alignment flag
4265  , bool TF > // Transpose flag
4267  CustomVector<Type,AF,padded,TF>::load( size_t index ) const noexcept
4268 {
4269  if( AF )
4270  return loada( index );
4271  else
4272  return loadu( index );
4273 }
4275 //*************************************************************************************************
4276 
4277 
4278 //*************************************************************************************************
4292 template< typename Type // Data type of the vector
4293  , bool AF // Alignment flag
4294  , bool TF > // Transpose flag
4296  CustomVector<Type,AF,padded,TF>::loada( size_t index ) const noexcept
4297 {
4298  using blaze::loada;
4299 
4301 
4302  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4303  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4304  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
4305  BLAZE_INTERNAL_ASSERT( checkAlignment( v_.get()+index ), "Invalid vector access index" );
4306 
4307  return loada( v_.get()+index );
4308 }
4310 //*************************************************************************************************
4311 
4312 
4313 //*************************************************************************************************
4327 template< typename Type // Data type of the vector
4328  , bool AF // Alignment flag
4329  , bool TF > // Transpose flag
4331  CustomVector<Type,AF,padded,TF>::loadu( size_t index ) const noexcept
4332 {
4333  using blaze::loadu;
4334 
4336 
4337  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4338  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4339 
4340  return loadu( v_.get()+index );
4341 }
4343 //*************************************************************************************************
4344 
4345 
4346 //*************************************************************************************************
4360 template< typename Type // Data type of the vector
4361  , bool AF // Alignment flag
4362  , bool TF > // Transpose flag
4364  CustomVector<Type,AF,padded,TF>::store( size_t index, const SIMDType& value ) noexcept
4365 {
4366  if( AF )
4367  storea( index, value );
4368  else
4369  storeu( index, value );
4370 }
4372 //*************************************************************************************************
4373 
4374 
4375 //*************************************************************************************************
4389 template< typename Type // Data type of the vector
4390  , bool AF // Alignment flag
4391  , bool TF > // Transpose flag
4393  CustomVector<Type,AF,padded,TF>::storea( size_t index, const SIMDType& value ) noexcept
4394 {
4395  using blaze::storea;
4396 
4398 
4399  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4400  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4401  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
4402  BLAZE_INTERNAL_ASSERT( checkAlignment( v_.get()+index ), "Invalid vector access index" );
4403 
4404  storea( v_.get()+index, value );
4405 }
4407 //*************************************************************************************************
4408 
4409 
4410 //*************************************************************************************************
4424 template< typename Type // Data type of the vector
4425  , bool AF // Alignment flag
4426  , bool TF > // Transpose flag
4428  CustomVector<Type,AF,padded,TF>::storeu( size_t index, const SIMDType& value ) noexcept
4429 {
4430  using blaze::storeu;
4431 
4433 
4434  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4435  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4436 
4437  storeu( v_.get()+index, value );
4438 }
4440 //*************************************************************************************************
4441 
4442 
4443 //*************************************************************************************************
4458 template< typename Type // Data type of the vector
4459  , bool AF // Alignment flag
4460  , bool TF > // Transpose flag
4462  CustomVector<Type,AF,padded,TF>::stream( size_t index, const SIMDType& value ) noexcept
4463 {
4464  using blaze::stream;
4465 
4467 
4468  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4469  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4470  BLAZE_INTERNAL_ASSERT( checkAlignment( v_.get()+index ), "Invalid vector access index" );
4471 
4472  stream( v_.get()+index, value );
4473 }
4475 //*************************************************************************************************
4476 
4477 
4478 //*************************************************************************************************
4490 template< typename Type // Data type of the vector
4491  , bool AF // Alignment flag
4492  , bool TF > // Transpose flag
4493 template< typename VT > // Type of the right-hand side dense vector
4496 {
4497  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4498 
4499  const size_t ipos( size_ & size_t(-2) );
4500  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4501 
4502  for( size_t i=0UL; i<ipos; i+=2UL ) {
4503  v_[i ] = (~rhs)[i ];
4504  v_[i+1UL] = (~rhs)[i+1UL];
4505  }
4506  if( ipos < (~rhs).size() )
4507  v_[ipos] = (~rhs)[ipos];
4508 }
4510 //*************************************************************************************************
4511 
4512 
4513 //*************************************************************************************************
4525 template< typename Type // Data type of the vector
4526  , bool AF // Alignment flag
4527  , bool TF > // Transpose flag
4528 template< typename VT > // Type of the right-hand side dense vector
4531 {
4533 
4534  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4535 
4536  constexpr bool remainder( !IsPadded<VT>::value );
4537 
4538  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
4539  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4540 
4541  if( AF && useStreaming && size_ > ( cacheSize/( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
4542  {
4543  size_t i( 0UL );
4544 
4545  for( ; i<ipos; i+=SIMDSIZE ) {
4546  stream( i, (~rhs).load(i) );
4547  }
4548  for( ; remainder && i<size_; ++i ) {
4549  v_[i] = (~rhs)[i];
4550  }
4551  }
4552  else
4553  {
4554  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4555  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4556  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4557 
4558  size_t i( 0UL );
4559  ConstIterator_<VT> it( (~rhs).begin() );
4560 
4561  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4562  store( i , it.load() ); it += SIMDSIZE;
4563  store( i+SIMDSIZE , it.load() ); it += SIMDSIZE;
4564  store( i+SIMDSIZE*2UL, it.load() ); it += SIMDSIZE;
4565  store( i+SIMDSIZE*3UL, it.load() ); it += SIMDSIZE;
4566  }
4567  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4568  store( i, it.load() );
4569  }
4570  for( ; remainder && i<size_; ++i, ++it ) {
4571  v_[i] = *it;
4572  }
4573  }
4574 }
4576 //*************************************************************************************************
4577 
4578 
4579 //*************************************************************************************************
4591 template< typename Type // Data type of the vector
4592  , bool AF // Alignment flag
4593  , bool TF > // Transpose flag
4594 template< typename VT > // Type of the right-hand side sparse vector
4596 {
4597  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4598 
4599  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
4600  v_[element->index()] = element->value();
4601 }
4603 //*************************************************************************************************
4604 
4605 
4606 //*************************************************************************************************
4618 template< typename Type // Data type of the vector
4619  , bool AF // Alignment flag
4620  , bool TF > // Transpose flag
4621 template< typename VT > // Type of the right-hand side dense vector
4624 {
4625  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4626 
4627  const size_t ipos( size_ & size_t(-2) );
4628  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4629 
4630  for( size_t i=0UL; i<ipos; i+=2UL ) {
4631  v_[i ] += (~rhs)[i ];
4632  v_[i+1UL] += (~rhs)[i+1UL];
4633  }
4634  if( ipos < (~rhs).size() )
4635  v_[ipos] += (~rhs)[ipos];
4636 }
4638 //*************************************************************************************************
4639 
4640 
4641 //*************************************************************************************************
4653 template< typename Type // Data type of the vector
4654  , bool AF // Alignment flag
4655  , bool TF > // Transpose flag
4656 template< typename VT > // Type of the right-hand side dense vector
4659 {
4661 
4662  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4663 
4664  constexpr bool remainder( !IsPadded<VT>::value );
4665 
4666  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
4667  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4668 
4669  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4670  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4671  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4672 
4673  size_t i( 0UL );
4674  ConstIterator_<VT> it( (~rhs).begin() );
4675 
4676  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4677  store( i , load(i ) + it.load() ); it += SIMDSIZE;
4678  store( i+SIMDSIZE , load(i+SIMDSIZE ) + it.load() ); it += SIMDSIZE;
4679  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) + it.load() ); it += SIMDSIZE;
4680  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) + it.load() ); it += SIMDSIZE;
4681  }
4682  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4683  store( i, load(i) + it.load() );
4684  }
4685  for( ; remainder && i<size_; ++i, ++it ) {
4686  v_[i] += *it;
4687  }
4688 }
4690 //*************************************************************************************************
4691 
4692 
4693 //*************************************************************************************************
4705 template< typename Type // Data type of the vector
4706  , bool AF // Alignment flag
4707  , bool TF > // Transpose flag
4708 template< typename VT > // Type of the right-hand side sparse vector
4710 {
4711  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4712 
4713  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
4714  v_[element->index()] += element->value();
4715 }
4717 //*************************************************************************************************
4718 
4719 
4720 //*************************************************************************************************
4732 template< typename Type // Data type of the vector
4733  , bool AF // Alignment flag
4734  , bool TF > // Transpose flag
4735 template< typename VT > // Type of the right-hand side dense vector
4738 {
4739  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4740 
4741  const size_t ipos( size_ & size_t(-2) );
4742  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4743 
4744  for( size_t i=0UL; i<ipos; i+=2UL ) {
4745  v_[i ] -= (~rhs)[i ];
4746  v_[i+1UL] -= (~rhs)[i+1UL];
4747  }
4748  if( ipos < (~rhs).size() )
4749  v_[ipos] -= (~rhs)[ipos];
4750 }
4752 //*************************************************************************************************
4753 
4754 
4755 //*************************************************************************************************
4767 template< typename Type // Data type of the vector
4768  , bool AF // Alignment flag
4769  , bool TF > // Transpose flag
4770 template< typename VT > // Type of the right-hand side dense vector
4773 {
4775 
4776  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4777 
4778  constexpr bool remainder( !IsPadded<VT>::value );
4779 
4780  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
4781  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4782 
4783  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4784  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4785  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4786 
4787  size_t i( 0UL );
4788  ConstIterator_<VT> it( (~rhs).begin() );
4789 
4790  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4791  store( i , load(i ) - it.load() ); it += SIMDSIZE;
4792  store( i+SIMDSIZE , load(i+SIMDSIZE ) - it.load() ); it += SIMDSIZE;
4793  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) - it.load() ); it += SIMDSIZE;
4794  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) - it.load() ); it += SIMDSIZE;
4795  }
4796  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4797  store( i, load(i) - it.load() );
4798  }
4799  for( ; remainder && i<size_; ++i, ++it ) {
4800  v_[i] -= *it;
4801  }
4802 }
4804 //*************************************************************************************************
4805 
4806 
4807 //*************************************************************************************************
4819 template< typename Type // Data type of the vector
4820  , bool AF // Alignment flag
4821  , bool TF > // Transpose flag
4822 template< typename VT > // Type of the right-hand side sparse vector
4824 {
4825  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4826 
4827  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
4828  v_[element->index()] -= element->value();
4829 }
4831 //*************************************************************************************************
4832 
4833 
4834 //*************************************************************************************************
4846 template< typename Type // Data type of the vector
4847  , bool AF // Alignment flag
4848  , bool TF > // Transpose flag
4849 template< typename VT > // Type of the right-hand side dense vector
4852 {
4853  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4854 
4855  const size_t ipos( size_ & size_t(-2) );
4856  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4857 
4858  for( size_t i=0UL; i<ipos; i+=2UL ) {
4859  v_[i ] *= (~rhs)[i ];
4860  v_[i+1UL] *= (~rhs)[i+1UL];
4861  }
4862  if( ipos < (~rhs).size() )
4863  v_[ipos] *= (~rhs)[ipos];
4864 }
4866 //*************************************************************************************************
4867 
4868 
4869 //*************************************************************************************************
4881 template< typename Type // Data type of the vector
4882  , bool AF // Alignment flag
4883  , bool TF > // Transpose flag
4884 template< typename VT > // Type of the right-hand side dense vector
4887 {
4889 
4890  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4891 
4892  constexpr bool remainder( !IsPadded<VT>::value );
4893 
4894  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
4895  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4896 
4897  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4898  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4899  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4900 
4901  size_t i( 0UL );
4902  ConstIterator_<VT> it( (~rhs).begin() );
4903 
4904  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4905  store( i , load(i ) * it.load() ); it += SIMDSIZE;
4906  store( i+SIMDSIZE , load(i+SIMDSIZE ) * it.load() ); it += SIMDSIZE;
4907  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) * it.load() ); it += SIMDSIZE;
4908  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) * it.load() ); it += SIMDSIZE;
4909  }
4910  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4911  store( i, load(i) * it.load() );
4912  }
4913  for( ; remainder && i<size_; ++i, ++it ) {
4914  v_[i] *= *it;
4915  }
4916 }
4918 //*************************************************************************************************
4919 
4920 
4921 //*************************************************************************************************
4933 template< typename Type // Data type of the vector
4934  , bool AF // Alignment flag
4935  , bool TF > // Transpose flag
4936 template< typename VT > // Type of the right-hand side sparse vector
4938 {
4939  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4940 
4941  const DynamicVector<Type,TF> tmp( serial( *this ) );
4942 
4943  reset();
4944 
4945  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
4946  v_[element->index()] = tmp[element->index()] * element->value();
4947 }
4949 //*************************************************************************************************
4950 
4951 
4952 //*************************************************************************************************
4964 template< typename Type // Data type of the vector
4965  , bool AF // Alignment flag
4966  , bool TF > // Transpose flag
4967 template< typename VT > // Type of the right-hand side dense vector
4970 {
4971  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4972 
4973  const size_t ipos( size_ & size_t(-2) );
4974  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4975 
4976  for( size_t i=0UL; i<ipos; i+=2UL ) {
4977  v_[i ] /= (~rhs)[i ];
4978  v_[i+1UL] /= (~rhs)[i+1UL];
4979  }
4980  if( ipos < (~rhs).size() )
4981  v_[ipos] /= (~rhs)[ipos];
4982 }
4984 //*************************************************************************************************
4985 
4986 
4987 //*************************************************************************************************
4999 template< typename Type // Data type of the vector
5000  , bool AF // Alignment flag
5001  , bool TF > // Transpose flag
5002 template< typename VT > // Type of the right-hand side dense vector
5005 {
5007 
5008  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
5009 
5010  const size_t ipos( size_ & size_t(-SIMDSIZE) );
5011  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
5012 
5013  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
5014  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
5015  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
5016 
5017  size_t i( 0UL );
5018  ConstIterator_<VT> it( (~rhs).begin() );
5019 
5020  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
5021  store( i , load(i ) / it.load() ); it += SIMDSIZE;
5022  store( i+SIMDSIZE , load(i+SIMDSIZE ) / it.load() ); it += SIMDSIZE;
5023  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) / it.load() ); it += SIMDSIZE;
5024  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) / it.load() ); it += SIMDSIZE;
5025  }
5026  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
5027  store( i, load(i) / it.load() );
5028  }
5029  for( ; i<size_; ++i, ++it ) {
5030  v_[i] /= *it;
5031  }
5032 }
5034 //*************************************************************************************************
5035 
5036 
5037 
5038 
5039 
5040 
5041 
5042 
5043 //=================================================================================================
5044 //
5045 // CUSTOMVECTOR OPERATORS
5046 //
5047 //=================================================================================================
5048 
5049 //*************************************************************************************************
5052 template< typename Type, bool AF, bool PF, bool TF >
5053 inline void reset( CustomVector<Type,AF,PF,TF>& v );
5054 
5055 template< typename Type, bool AF, bool PF, bool TF >
5056 inline void clear( CustomVector<Type,AF,PF,TF>& v );
5057 
5058 template< bool RF, typename Type, bool AF, bool PF, bool TF >
5059 inline bool isDefault( const CustomVector<Type,AF,PF,TF>& v );
5060 
5061 template< typename Type, bool AF, bool PF, bool TF >
5062 inline bool isIntact( const CustomVector<Type,AF,PF,TF>& v ) noexcept;
5063 
5064 template< typename Type, bool AF, bool PF, bool TF >
5065 inline void swap( CustomVector<Type,AF,PF,TF>& a, CustomVector<Type,AF,PF,TF>& b ) noexcept;
5067 //*************************************************************************************************
5068 
5069 
5070 //*************************************************************************************************
5077 template< typename Type // Data type of the vector
5078  , bool AF // Alignment flag
5079  , bool PF // Padding flag
5080  , bool TF > // Transpose flag
5082 {
5083  v.reset();
5084 }
5085 //*************************************************************************************************
5086 
5087 
5088 //*************************************************************************************************
5095 template< typename Type // Data type of the vector
5096  , bool AF // Alignment flag
5097  , bool PF // Padding flag
5098  , bool TF > // Transpose flag
5100 {
5101  v.clear();
5102 }
5103 //*************************************************************************************************
5104 
5105 
5106 //*************************************************************************************************
5134 template< bool RF // Relaxation flag
5135  , typename Type // Data type of the vector
5136  , bool AF // Alignment flag
5137  , bool PF // Padding flag
5138  , bool TF > // Transpose flag
5140 {
5141  return ( v.size() == 0UL );
5142 }
5143 //*************************************************************************************************
5144 
5145 
5146 //*************************************************************************************************
5167 template< typename Type // Data type of the vector
5168  , bool AF // Alignment flag
5169  , bool PF // Padding flag
5170  , bool TF > // Transpose flag
5171 inline bool isIntact( const CustomVector<Type,AF,PF,TF>& v ) noexcept
5172 {
5173  return ( v.size() <= v.capacity() );
5174 }
5175 //*************************************************************************************************
5176 
5177 
5178 //*************************************************************************************************
5186 template< typename Type // Data type of the vector
5187  , bool AF // Alignment flag
5188  , bool PF // Padding flag
5189  , bool TF > // Transpose flag
5191 {
5192  a.swap( b );
5193 }
5194 //*************************************************************************************************
5195 
5196 
5197 
5198 
5199 //=================================================================================================
5200 //
5201 // HASCONSTDATAACCESS SPECIALIZATIONS
5202 //
5203 //=================================================================================================
5204 
5205 //*************************************************************************************************
5207 template< typename T, bool AF, bool PF, bool TF >
5208 struct HasConstDataAccess< CustomVector<T,AF,PF,TF> > : public TrueType
5209 {};
5211 //*************************************************************************************************
5212 
5213 
5214 
5215 
5216 //=================================================================================================
5217 //
5218 // HASMUTABLEDATAACCESS SPECIALIZATIONS
5219 //
5220 //=================================================================================================
5221 
5222 //*************************************************************************************************
5224 template< typename T, bool AF, bool PF, bool TF >
5225 struct HasMutableDataAccess< CustomVector<T,AF,PF,TF> > : public TrueType
5226 {};
5228 //*************************************************************************************************
5229 
5230 
5231 
5232 
5233 //=================================================================================================
5234 //
5235 // ISCUSTOM SPECIALIZATIONS
5236 //
5237 //=================================================================================================
5238 
5239 //*************************************************************************************************
5241 template< typename T, bool AF, bool PF, bool TF >
5242 struct IsCustom< CustomVector<T,AF,PF,TF> > : public TrueType
5243 {};
5245 //*************************************************************************************************
5246 
5247 
5248 
5249 
5250 //=================================================================================================
5251 //
5252 // ISALIGNED SPECIALIZATIONS
5253 //
5254 //=================================================================================================
5255 
5256 //*************************************************************************************************
5258 template< typename T, bool PF, bool TF >
5259 struct IsAligned< CustomVector<T,aligned,PF,TF> > : public TrueType
5260 {};
5262 //*************************************************************************************************
5263 
5264 
5265 
5266 
5267 //=================================================================================================
5268 //
5269 // ISPADDED SPECIALIZATIONS
5270 //
5271 //=================================================================================================
5272 
5273 //*************************************************************************************************
5275 template< typename T, bool AF, bool TF >
5276 struct IsPadded< CustomVector<T,AF,padded,TF> > : public TrueType
5277 {};
5279 //*************************************************************************************************
5280 
5281 
5282 
5283 
5284 //=================================================================================================
5285 //
5286 // ADDTRAIT SPECIALIZATIONS
5287 //
5288 //=================================================================================================
5289 
5290 //*************************************************************************************************
5292 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5293 struct AddTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF> >
5294 {
5295  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
5296 };
5297 
5298 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5299 struct AddTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5300 {
5301  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
5302 };
5303 
5304 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5305 struct AddTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5306 {
5307  using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
5308 };
5309 
5310 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5311 struct AddTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5312 {
5313  using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
5314 };
5315 
5316 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5317 struct AddTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5318 {
5319  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
5320 };
5321 
5322 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5323 struct AddTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5324 {
5325  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
5326 };
5327 
5328 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5329 struct AddTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5330 {
5331  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
5332 };
5334 //*************************************************************************************************
5335 
5336 
5337 
5338 
5339 //=================================================================================================
5340 //
5341 // SUBTRAIT SPECIALIZATIONS
5342 //
5343 //=================================================================================================
5344 
5345 //*************************************************************************************************
5347 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5348 struct SubTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF> >
5349 {
5350  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
5351 };
5352 
5353 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5354 struct SubTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5355 {
5356  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
5357 };
5358 
5359 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5360 struct SubTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5361 {
5362  using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
5363 };
5364 
5365 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5366 struct SubTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5367 {
5368  using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
5369 };
5370 
5371 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5372 struct SubTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5373 {
5374  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
5375 };
5376 
5377 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5378 struct SubTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5379 {
5380  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
5381 };
5382 
5383 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5384 struct SubTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5385 {
5386  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
5387 };
5389 //*************************************************************************************************
5390 
5391 
5392 
5393 
5394 //=================================================================================================
5395 //
5396 // MULTTRAIT SPECIALIZATIONS
5397 //
5398 //=================================================================================================
5399 
5400 //*************************************************************************************************
5402 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5403 struct MultTrait< CustomVector<T1,AF,PF,TF>, T2, EnableIf_<IsNumeric<T2> > >
5404 {
5405  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5406 };
5407 
5408 template< typename T1, typename T2, bool AF, bool PF, bool TF >
5409 struct MultTrait< T1, CustomVector<T2,AF,PF,TF>, EnableIf_<IsNumeric<T1> > >
5410 {
5411  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5412 };
5413 
5414 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5415 struct MultTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF> >
5416 {
5417  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
5418 };
5419 
5420 template< typename T1, bool AF, bool PF, typename T2, size_t N >
5421 struct MultTrait< CustomVector<T1,AF,PF,false>, StaticVector<T2,N,true> >
5422 {
5423  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5424 };
5425 
5426 template< typename T1, bool AF, bool PF, typename T2, size_t N >
5427 struct MultTrait< CustomVector<T1,AF,PF,true>, StaticVector<T2,N,false> >
5428 {
5429  using Type = MultTrait_<T1,T2>;
5430 };
5431 
5432 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5433 struct MultTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5434 {
5435  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
5436 };
5437 
5438 template< typename T1, size_t N, typename T2, bool AF, bool PF >
5439 struct MultTrait< StaticVector<T1,N,false>, CustomVector<T2,AF,PF,true> >
5440 {
5441  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5442 };
5443 
5444 template< typename T1, size_t N, typename T2, bool AF, bool PF >
5445 struct MultTrait< StaticVector<T1,N,true>, CustomVector<T2,AF,PF,false> >
5446 {
5447  using Type = MultTrait_<T1,T2>;
5448 };
5449 
5450 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5451 struct MultTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5452 {
5453  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
5454 };
5455 
5456 template< typename T1, bool AF, bool PF, typename T2, size_t N >
5457 struct MultTrait< CustomVector<T1,AF,PF,false>, HybridVector<T2,N,true> >
5458 {
5459  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5460 };
5461 
5462 template< typename T1, bool AF, bool PF, typename T2, size_t N >
5463 struct MultTrait< CustomVector<T1,AF,PF,true>, HybridVector<T2,N,false> >
5464 {
5465  using Type = MultTrait_<T1,T2>;
5466 };
5467 
5468 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5469 struct MultTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5470 {
5471  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
5472 };
5473 
5474 template< typename T1, size_t N, typename T2, bool AF, bool PF >
5475 struct MultTrait< HybridVector<T1,N,false>, CustomVector<T2,AF,PF,true> >
5476 {
5477  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5478 };
5479 
5480 template< typename T1, size_t N, typename T2, bool AF, bool PF >
5481 struct MultTrait< HybridVector<T1,N,true>, CustomVector<T2,AF,PF,false> >
5482 {
5483  using Type = MultTrait_<T1,T2>;
5484 };
5485 
5486 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5487 struct MultTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5488 {
5489  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5490 };
5491 
5492 template< typename T1, bool AF, bool PF, typename T2 >
5493 struct MultTrait< CustomVector<T1,AF,PF,false>, DynamicVector<T2,true> >
5494 {
5495  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5496 };
5497 
5498 template< typename T1, bool AF, bool PF, typename T2 >
5499 struct MultTrait< CustomVector<T1,AF,PF,true>, DynamicVector<T2,false> >
5500 {
5501  using Type = MultTrait_<T1,T2>;
5502 };
5503 
5504 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5505 struct MultTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5506 {
5507  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5508 };
5509 
5510 template< typename T1, typename T2, bool AF, bool PF >
5511 struct MultTrait< DynamicVector<T1,false>, CustomVector<T2,AF,PF,true> >
5512 {
5513  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5514 };
5515 
5516 template< typename T1, typename T2, bool AF, bool PF >
5517 struct MultTrait< DynamicVector<T1,true>, CustomVector<T2,AF,PF,false> >
5518 {
5519  using Type = MultTrait_<T1,T2>;
5520 };
5521 
5522 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5523 struct MultTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5524 {
5525  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5526 };
5527 
5528 template< typename T1, bool AF1, bool PF1, typename T2, bool AF2, bool PF2 >
5529 struct MultTrait< CustomVector<T1,AF1,PF1,false>, CustomVector<T2,AF2,PF2,true> >
5530 {
5531  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5532 };
5533 
5534 template< typename T1, bool AF1, bool PF1, typename T2, bool AF2, bool PF2 >
5535 struct MultTrait< CustomVector<T1,AF1,PF1,true>, CustomVector<T2,AF2,PF2,false> >
5536 {
5537  using Type = MultTrait_<T1,T2>;
5538 };
5540 //*************************************************************************************************
5541 
5542 
5543 
5544 
5545 //=================================================================================================
5546 //
5547 // CROSSTRAIT SPECIALIZATIONS
5548 //
5549 //=================================================================================================
5550 
5551 //*************************************************************************************************
5553 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5554 struct CrossTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,3UL,TF> >
5555 {
5556  private:
5557  using T = MultTrait_<T1,T2>;
5558 
5559  public:
5560  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5561 };
5562 
5563 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5564 struct CrossTrait< StaticVector<T1,3UL,TF>, CustomVector<T2,AF,PF,TF> >
5565 {
5566  private:
5567  using T = MultTrait_<T1,T2>;
5568 
5569  public:
5570  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5571 };
5572 
5573 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5574 struct CrossTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5575 {
5576  private:
5577  using T = MultTrait_<T1,T2>;
5578 
5579  public:
5580  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5581 };
5582 
5583 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5584 struct CrossTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5585 {
5586  private:
5587  using T = MultTrait_<T1,T2>;
5588 
5589  public:
5590  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5591 };
5592 
5593 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5594 struct CrossTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5595 {
5596  private:
5597  using T = MultTrait_<T1,T2>;
5598 
5599  public:
5600  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5601 };
5602 
5603 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5604 struct CrossTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5605 {
5606  private:
5607  using T = MultTrait_<T1,T2>;
5608 
5609  public:
5610  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5611 };
5612 
5613 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5614 struct CrossTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5615 {
5616  private:
5617  using T = MultTrait_<T1,T2>;
5618 
5619  public:
5620  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5621 };
5623 //*************************************************************************************************
5624 
5625 
5626 
5627 
5628 //=================================================================================================
5629 //
5630 // DIVTRAIT SPECIALIZATIONS
5631 //
5632 //=================================================================================================
5633 
5634 //*************************************************************************************************
5636 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5637 struct DivTrait< CustomVector<T1,AF,PF,TF>, T2, EnableIf_<IsNumeric<T2> > >
5638 {
5639  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
5640 };
5641 
5642 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5643 struct DivTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF> >
5644 {
5645  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
5646 };
5647 
5648 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5649 struct DivTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5650 {
5651  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
5652 };
5653 
5654 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5655 struct DivTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5656 {
5657  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
5658 };
5659 
5660 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5661 struct DivTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5662 {
5663  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
5664 };
5665 
5666 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5667 struct DivTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5668 {
5669  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
5670 };
5671 
5672 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5673 struct DivTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5674 {
5675  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
5676 };
5677 
5678 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5679 struct DivTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5680 {
5681  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
5682 };
5684 //*************************************************************************************************
5685 
5686 
5687 
5688 
5689 //=================================================================================================
5690 //
5691 // SUBVECTORTRAIT SPECIALIZATIONS
5692 //
5693 //=================================================================================================
5694 
5695 //*************************************************************************************************
5697 template< typename T1, bool AF, bool PF, bool TF >
5698 struct SubvectorTrait< CustomVector<T1,AF,PF,TF> >
5699 {
5700  using Type = DynamicVector<T1,TF>;
5701 };
5703 //*************************************************************************************************
5704 
5705 } // namespace blaze
5706 
5707 #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.
Availability of a SIMD subtraction for the given data types.Depending on the available instruction se...
Definition: HasSIMDSub.h:163
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:427
Compile time check for low-level access to constant data.This type trait tests whether the given data...
Definition: HasConstDataAccess.h:75
#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 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:746
Iterator begin() noexcept
Returns an iterator to the first element of the custom vector.
Definition: CustomVector.h:1096
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:709
const Type & ReturnType
Return type for expression template evaluations.
Definition: CustomVector.h:432
const Type * ConstPointer
Pointer to a constant vector value.
Definition: CustomVector.h:438
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:436
Header file for the serial shim.
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
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
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
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: CustomVector.h:2009
Iterator end() noexcept
Returns an iterator just past the last element of the custom vector.
Definition: CustomVector.h:1147
void swap(CustomVector &v) noexcept
Swapping the contents of two vectors.
Definition: CustomVector.h:1706
CustomVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: CustomVector.h:1206
Availability of a SIMD multiplication for the given data types.Depending on the available instruction...
Definition: HasSIMDMult.h:162
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:315
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:429
Header file for the IsIntegral type trait.
Header file for the DenseVector base class.
Availability of a SIMD addition for the given data types.Depending on the available instruction set (...
Definition: HasSIMDAdd.h:163
#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:721
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
Efficient implementation of an arbitrary sized vector.The DynamicVector class template is the represe...
Definition: DynamicVector.h:177
System settings for performance optimizations.
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:204
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
Compile time check for data types.This type trait tests whether or not the given types can be combine...
Definition: IsSIMDCombinable.h:120
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:2162
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.
Constraint on the data type.
Base template for the CrossTrait class.
Definition: CrossTrait.h:110
Efficient implementation of a fixed-sized vector.The StaticVector class template is the representatio...
Definition: Forward.h:61
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:3137
Header file for the std::initializer_list aliases.
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:120
Efficient implementation of a dynamically sized vector with static memory.The HybridVector class temp...
Definition: Forward.h:59
Compile time check for low-level access to mutable data.This type trait tests whether the given data ...
Definition: HasMutableDataAccess.h:75
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: CustomVector.h:2071
Header file for the DisableIf class template.
size_t size() const noexcept
Returns the size/dimension of the vector.
Definition: CustomVector.h:1609
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:5635
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.
#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.
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:76
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:2194
#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:1688
Header file for the subvector trait.
Header file for all SIMD functionality.
DenseIterator< const Type, AF > ConstIterator
Iterator over constant elements.
Definition: CustomVector.h:441
Constraint on the data type.
boost::shared_array< Type > v_
The custom array of elements.
Definition: CustomVector.h:710
Availability of a SIMD division for the given data types.Depending on the available instruction set (...
Definition: HasSIMDDiv.h:144
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:422
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
Compile time check for custom data types.This type trait tests whether the given data type is a custo...
Definition: IsCustom.h:84
void reset()
Reset to the default initial values.
Definition: CustomVector.h:1667
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the custom vector.
Definition: CustomVector.h:1130
#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
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: CustomVector.h:2129
CustomVector< Type, AF, PF, TF > Other
The type of the other CustomVector.
Definition: CustomVector.h:458
Header file for the exception macros of the math module.
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the custom vector.
Definition: CustomVector.h:1181
Compile time check for data types.This type trait tests whether or not the given template parameter i...
Definition: IsSMPAssignable.h:119
DenseIterator< Type, AF > Iterator
Iterator over non-constant elements.
Definition: CustomVector.h:440
Constraint on the data type.
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:428
typename DivTrait< T1, T2 >::Type DivTrait_
Auxiliary alias declaration for the DivTrait class template.The DivTrait_ alias declaration provides ...
Definition: DivTrait.h:245
CustomVector< NewType, AF, PF, TF > Other
The type of the other CustomVector.
Definition: CustomVector.h:449
Header file for the IsVectorizable type trait.
Resize mechanism to obtain a CustomVector with a different fixed number of elements.
Definition: CustomVector.h:457
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: CustomVector.h:1985
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:431
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 IsSIMDCombinable type trait.
Header file for the IsSparseVector type trait.
size_t capacity() const noexcept
Returns the maximum capacity of the vector.
Definition: CustomVector.h:1625
Header file for the HasSIMDMult type trait.
Rebind mechanism to obtain a CustomVector with different data/element type.
Definition: CustomVector.h:448
Type * Pointer
Pointer to a non-constant vector value.
Definition: CustomVector.h:437
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.
Base template for the AddTrait class.
Definition: AddTrait.h:143
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: CustomVector.h:1060
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: CustomVector.h:1944
Base template for the MultTrait class.
Definition: MultTrait.h:143
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
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:296
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
Reference at(size_t index)
Checked access to the vector elements.
Definition: CustomVector.h:1013
Header file for the isDefault shim.
Type & Reference
Reference to a non-constant vector value.
Definition: CustomVector.h:435
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: CustomVector.h:2102
Constraint on the data type.
Header file for the HasSIMDSub type trait.
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: CustomVector.h:1964
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
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: CustomVector.h:1922
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: CustomVector.h:968
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Base template for the DivTrait class.
Definition: DivTrait.h:143
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
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: CustomVector.h:2037
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
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:164
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:120
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:249
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Base template for the SubTrait class.
Definition: SubTrait.h:143
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:430
CustomVector< Type, AF, PF, TF > This
Type of this CustomVector instance.
Definition: CustomVector.h:426
System settings for the inline keywords.
const CustomVector & CompositeType
Data type for composite expression templates.
Definition: CustomVector.h:433
#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.
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: CustomVector.h:1644
#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
Header file for the TrueType type/value trait base class.