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 <blaze/math/Aliases.h>
52 #include <blaze/math/Exception.h>
55 #include <blaze/math/Forward.h>
56 #include <blaze/math/Functions.h>
58 #include <blaze/math/PaddingFlag.h>
59 #include <blaze/math/shims/Clear.h>
62 #include <blaze/math/SIMD.h>
82 #include <blaze/system/CacheSize.h>
83 #include <blaze/system/Inline.h>
88 #include <blaze/util/Assert.h>
93 #include <blaze/util/DisableIf.h>
94 #include <blaze/util/EnableIf.h>
96 #include <blaze/util/Template.h>
97 #include <blaze/util/TrueType.h>
98 #include <blaze/util/Types.h>
103 #include <blaze/util/Unused.h>
104 
105 
106 namespace blaze {
107 
108 //=================================================================================================
109 //
110 // CLASS DEFINITION
111 //
112 //=================================================================================================
113 
114 //*************************************************************************************************
393 template< typename Type // Data type of the vector
394  , bool AF // Alignment flag
395  , bool PF // Padding flag
396  , bool TF = defaultTransposeFlag > // Transpose flag
398  : public DenseVector< CustomVector<Type,AF,PF,TF>, TF >
399 {
400  public:
401  //**Type definitions****************************************************************************
404 
407 
410 
411  using ElementType = Type;
413  using ReturnType = const Type&;
414  using CompositeType = const CustomVector&;
415 
416  using Reference = Type&;
417  using ConstReference = const Type&;
418  using Pointer = Type*;
419  using ConstPointer = const Type*;
420 
423  //**********************************************************************************************
424 
425  //**Rebind struct definition********************************************************************
428  template< typename NewType > // Data type of the other vector
429  struct Rebind {
431  };
432  //**********************************************************************************************
433 
434  //**Resize struct definition********************************************************************
437  template< size_t NewN > // Number of elements of the other vector
438  struct Resize {
440  };
441  //**********************************************************************************************
442 
443  //**Compilation flags***************************************************************************
445 
449  enum : bool { simdEnabled = IsVectorizable<Type>::value };
450 
452 
455  enum : bool { smpAssignable = !IsSMPAssignable<Type>::value };
456  //**********************************************************************************************
457 
458  //**Constructors********************************************************************************
461  explicit inline CustomVector();
462  explicit inline CustomVector( Type* ptr, size_t n );
463  explicit inline CustomVector( Type* ptr, size_t n, size_t nn );
464 
465  inline CustomVector( const CustomVector& v );
466  inline CustomVector( CustomVector&& v ) noexcept;
468  //**********************************************************************************************
469 
470  //**Destructor**********************************************************************************
471  // No explicitly declared destructor.
472  //**********************************************************************************************
473 
474  //**Data access functions***********************************************************************
477  inline Reference operator[]( size_t index ) noexcept;
478  inline ConstReference operator[]( size_t index ) const noexcept;
479  inline Reference at( size_t index );
480  inline ConstReference at( size_t index ) const;
481  inline Pointer data () noexcept;
482  inline ConstPointer data () const noexcept;
483  inline Iterator begin () noexcept;
484  inline ConstIterator begin () const noexcept;
485  inline ConstIterator cbegin() const noexcept;
486  inline Iterator end () noexcept;
487  inline ConstIterator end () const noexcept;
488  inline ConstIterator cend () const noexcept;
490  //**********************************************************************************************
491 
492  //**Assignment operators************************************************************************
495  inline CustomVector& operator=( const Type& rhs );
497 
498  template< typename Other, size_t N >
499  inline CustomVector& operator=( const Other (&array)[N] );
500 
501  inline CustomVector& operator=( const CustomVector& rhs );
502  inline CustomVector& operator=( CustomVector&& rhs ) noexcept;
503 
504  template< typename VT > inline CustomVector& operator= ( const Vector<VT,TF>& rhs );
505  template< typename VT > inline CustomVector& operator+=( const Vector<VT,TF>& rhs );
506  template< typename VT > inline CustomVector& operator-=( const Vector<VT,TF>& rhs );
507  template< typename VT > inline CustomVector& operator*=( const Vector<VT,TF>& rhs );
508  template< typename VT > inline CustomVector& operator/=( const DenseVector<VT,TF>& rhs );
509  template< typename VT > inline CustomVector& operator%=( const Vector<VT,TF>& rhs );
510 
511  template< typename Other >
512  inline EnableIf_<IsNumeric<Other>, CustomVector >& operator*=( Other rhs );
513 
514  template< typename Other >
515  inline EnableIf_<IsNumeric<Other>, CustomVector >& operator/=( Other rhs );
517  //**********************************************************************************************
518 
519  //**Utility functions***************************************************************************
522  inline size_t size() const noexcept;
523  inline size_t spacing() const noexcept;
524  inline size_t capacity() const noexcept;
525  inline size_t nonZeros() const;
526  inline void reset();
527  inline void clear();
528  inline void swap( CustomVector& v ) noexcept;
530  //**********************************************************************************************
531 
532  //**Numeric functions***************************************************************************
535  template< typename Other > inline CustomVector& scale( const Other& scalar );
537  //**********************************************************************************************
538 
539  //**Resource management functions***************************************************************
542  inline void reset( Type* ptr, size_t n );
543  inline void reset( Type* ptr, size_t n, size_t nn );
545  //**********************************************************************************************
546 
547  private:
548  //**********************************************************************************************
550  template< typename VT >
552  struct VectorizedAssign {
553  enum : bool { value = useOptimizedKernels &&
554  simdEnabled && VT::simdEnabled &&
556  };
558  //**********************************************************************************************
559 
560  //**********************************************************************************************
562  template< typename VT >
564  struct VectorizedAddAssign {
565  enum : bool { value = useOptimizedKernels &&
566  simdEnabled && VT::simdEnabled &&
569  };
571  //**********************************************************************************************
572 
573  //**********************************************************************************************
575  template< typename VT >
577  struct VectorizedSubAssign {
578  enum : bool { value = useOptimizedKernels &&
579  simdEnabled && VT::simdEnabled &&
582  };
584  //**********************************************************************************************
585 
586  //**********************************************************************************************
588  template< typename VT >
590  struct VectorizedMultAssign {
591  enum : bool { value = useOptimizedKernels &&
592  simdEnabled && VT::simdEnabled &&
595  };
597  //**********************************************************************************************
598 
599  //**********************************************************************************************
601  template< typename VT >
603  struct VectorizedDivAssign {
604  enum : bool { value = useOptimizedKernels &&
605  simdEnabled && VT::simdEnabled &&
608  };
610  //**********************************************************************************************
611 
612  //**SIMD properties*****************************************************************************
614  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
615  //**********************************************************************************************
616 
617  public:
618  //**Expression template evaluation functions****************************************************
621  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
622  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
623 
624  inline bool isAligned () const noexcept;
625  inline bool canSMPAssign() const noexcept;
626 
627  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
628  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
629  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
630 
631  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
632  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
633  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
634  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
635 
636  template< typename VT >
637  inline DisableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
638 
639  template< typename VT >
640  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
641 
642  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
643 
644  template< typename VT >
645  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
646 
647  template< typename VT >
648  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
649 
650  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
651 
652  template< typename VT >
653  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
654 
655  template< typename VT >
656  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
657 
658  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
659 
660  template< typename VT >
661  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
662 
663  template< typename VT >
664  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
665 
666  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
667 
668  template< typename VT >
669  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
670 
671  template< typename VT >
672  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
674  //**********************************************************************************************
675 
676  private:
677  //**Member variables****************************************************************************
680  size_t size_;
681  Type* v_;
682 
688  //**********************************************************************************************
689 
690  //**Compile time checks*************************************************************************
696  //**********************************************************************************************
697 };
698 //*************************************************************************************************
699 
700 
701 
702 
703 //=================================================================================================
704 //
705 // CONSTRUCTORS
706 //
707 //=================================================================================================
708 
709 //*************************************************************************************************
712 template< typename Type // Data type of the vector
713  , bool AF // Alignment flag
714  , bool PF // Padding flag
715  , bool TF > // Transpose flag
717  : size_( 0UL ) // The size/dimension of the vector
718  , v_ ( nullptr ) // The custom array of elements
719 {}
720 //*************************************************************************************************
721 
722 
723 //*************************************************************************************************
741 template< typename Type // Data type of the vector
742  , bool AF // Alignment flag
743  , bool PF // Padding flag
744  , bool TF > // Transpose flag
745 inline CustomVector<Type,AF,PF,TF>::CustomVector( Type* ptr, size_t n )
746  : size_( n ) // The size/dimension of the vector
747  , v_ ( ptr ) // The custom array of elements
748 {
749  if( ptr == nullptr ) {
750  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array of elements" );
751  }
752 
753  if( AF && !checkAlignment( ptr ) ) {
754  BLAZE_THROW_INVALID_ARGUMENT( "Invalid alignment detected" );
755  }
756 }
757 //*************************************************************************************************
758 
759 
760 //*************************************************************************************************
782 template< typename Type // Data type of the vector
783  , bool AF // Alignment flag
784  , bool PF // Padding flag
785  , bool TF > // Transpose flag
786 inline CustomVector<Type,AF,PF,TF>::CustomVector( Type* ptr, size_t n, size_t nn )
787  : size_( 0UL ) // The size/dimension of the vector
788  , v_ ( nullptr ) // The custom array of elements
789 {
790  BLAZE_STATIC_ASSERT( PF == padded );
791 
792  UNUSED_PARAMETER( ptr, n, nn );
793 }
794 //*************************************************************************************************
795 
796 
797 //*************************************************************************************************
804 template< typename Type // Data type of the vector
805  , bool AF // Alignment flag
806  , bool PF // Padding flag
807  , bool TF > // Transpose flag
809  : size_( v.size_ ) // The size/dimension of the vector
810  , v_ ( v.v_ ) // The custom array of elements
811 {}
812 //*************************************************************************************************
813 
814 
815 //*************************************************************************************************
820 template< typename Type // Data type of the vector
821  , bool AF // Alignment flag
822  , bool PF // Padding flag
823  , bool TF > // Transpose flag
825  : size_( v.size_ ) // The size/dimension of the vector
826  , v_ ( v.v_ ) // The custom array of elements
827 {
828  v.size_ = 0UL;
829  v.v_ = nullptr;
830 
831  BLAZE_INTERNAL_ASSERT( v.data() == nullptr, "Invalid data reference detected" );
832 }
833 //*************************************************************************************************
834 
835 
836 
837 
838 //=================================================================================================
839 //
840 // DATA ACCESS FUNCTIONS
841 //
842 //=================================================================================================
843 
844 //*************************************************************************************************
853 template< typename Type // Data type of the vector
854  , bool AF // Alignment flag
855  , bool PF // Padding flag
856  , bool TF > // Transpose flag
859 {
860  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
861  return v_[index];
862 }
863 //*************************************************************************************************
864 
865 
866 //*************************************************************************************************
875 template< typename Type // Data type of the vector
876  , bool AF // Alignment flag
877  , bool PF // Padding flag
878  , bool TF > // Transpose flag
880  CustomVector<Type,AF,PF,TF>::operator[]( size_t index ) const noexcept
881 {
882  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
883  return v_[index];
884 }
885 //*************************************************************************************************
886 
887 
888 //*************************************************************************************************
898 template< typename Type // Data type of the vector
899  , bool AF // Alignment flag
900  , bool PF // Padding flag
901  , bool TF > // Transpose flag
904 {
905  if( index >= size_ ) {
906  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
907  }
908  return (*this)[index];
909 }
910 //*************************************************************************************************
911 
912 
913 //*************************************************************************************************
923 template< typename Type // Data type of the vector
924  , bool AF // Alignment flag
925  , bool PF // Padding flag
926  , bool TF > // Transpose flag
928  CustomVector<Type,AF,PF,TF>::at( size_t index ) const
929 {
930  if( index >= size_ ) {
931  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
932  }
933  return (*this)[index];
934 }
935 //*************************************************************************************************
936 
937 
938 //*************************************************************************************************
945 template< typename Type // Data type of the vector
946  , bool AF // Alignment flag
947  , bool PF // Padding flag
948  , bool TF > // Transpose flag
951 {
952  return v_;
953 }
954 //*************************************************************************************************
955 
956 
957 //*************************************************************************************************
964 template< typename Type // Data type of the vector
965  , bool AF // Alignment flag
966  , bool PF // Padding flag
967  , bool TF > // Transpose flag
970 {
971  return v_;
972 }
973 //*************************************************************************************************
974 
975 
976 //*************************************************************************************************
981 template< typename Type // Data type of the vector
982  , bool AF // Alignment flag
983  , bool PF // Padding flag
984  , bool TF > // Transpose flag
987 {
988  return Iterator( v_ );
989 }
990 //*************************************************************************************************
991 
992 
993 //*************************************************************************************************
998 template< typename Type // Data type of the vector
999  , bool AF // Alignment flag
1000  , bool PF // Padding flag
1001  , bool TF > // Transpose flag
1004 {
1005  return ConstIterator( v_ );
1006 }
1007 //*************************************************************************************************
1008 
1009 
1010 //*************************************************************************************************
1015 template< typename Type // Data type of the vector
1016  , bool AF // Alignment flag
1017  , bool PF // Padding flag
1018  , bool TF > // Transpose flag
1021 {
1022  return ConstIterator( v_ );
1023 }
1024 //*************************************************************************************************
1025 
1026 
1027 //*************************************************************************************************
1032 template< typename Type // Data type of the vector
1033  , bool AF // Alignment flag
1034  , bool PF // Padding flag
1035  , bool TF > // Transpose flag
1038 {
1039  return Iterator( v_+size_ );
1040 }
1041 //*************************************************************************************************
1042 
1043 
1044 //*************************************************************************************************
1049 template< typename Type // Data type of the vector
1050  , bool AF // Alignment flag
1051  , bool PF // Padding flag
1052  , bool TF > // Transpose flag
1055 {
1056  return ConstIterator( v_+size_ );
1057 }
1058 //*************************************************************************************************
1059 
1060 
1061 //*************************************************************************************************
1066 template< typename Type // Data type of the vector
1067  , bool AF // Alignment flag
1068  , bool PF // Padding flag
1069  , bool TF > // Transpose flag
1072 {
1073  return ConstIterator( v_+size_ );
1074 }
1075 //*************************************************************************************************
1076 
1077 
1078 
1079 
1080 //=================================================================================================
1081 //
1082 // ASSIGNMENT OPERATORS
1083 //
1084 //=================================================================================================
1085 
1086 //*************************************************************************************************
1092 template< typename Type // Data type of the vector
1093  , bool AF // Alignment flag
1094  , bool PF // Padding flag
1095  , bool TF > // Transpose flag
1097 {
1098  for( size_t i=0UL; i<size_; ++i )
1099  v_[i] = rhs;
1100  return *this;
1101 }
1102 //*************************************************************************************************
1103 
1104 
1105 //*************************************************************************************************
1129 template< typename Type // Data type of the vector
1130  , bool AF // Alignment flag
1131  , bool PF // Padding flag
1132  , bool TF > // Transpose flag
1134 {
1135  if( list.size() > size_ ) {
1136  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to custom vector" );
1137  }
1138 
1139  std::fill( std::copy( list.begin(), list.end(), v_ ), v_+size_, Type() );
1140 
1141  return *this;
1142 }
1143 //*************************************************************************************************
1144 
1145 
1146 //*************************************************************************************************
1173 template< typename Type // Data type of the vector
1174  , bool AF // Alignment flag
1175  , bool PF // Padding flag
1176  , bool TF > // Transpose flag
1177 template< typename Other // Data type of the initialization array
1178  , size_t N > // Dimension of the initialization array
1180 {
1181  if( size_ != N ) {
1182  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array size" );
1183  }
1184 
1185  for( size_t i=0UL; i<N; ++i )
1186  v_[i] = array[i];
1187 
1188  return *this;
1189 }
1190 //*************************************************************************************************
1191 
1192 
1193 //*************************************************************************************************
1203 template< typename Type // Data type of the vector
1204  , bool AF // Alignment flag
1205  , bool PF // Padding flag
1206  , bool TF > // Transpose flag
1208 {
1209  if( rhs.size() != size_ ) {
1210  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1211  }
1212 
1213  smpAssign( *this, ~rhs );
1214 
1215  return *this;
1216 }
1217 //*************************************************************************************************
1218 
1219 
1220 //*************************************************************************************************
1226 template< typename Type // Data type of the vector
1227  , bool AF // Alignment flag
1228  , bool PF // Padding flag
1229  , bool TF > // Transpose flag
1232 {
1233  size_ = rhs.size_;
1234  v_ = rhs.v_;
1235 
1236  rhs.size_ = 0UL;
1237  rhs.v_ = nullptr;
1238 
1239  BLAZE_INTERNAL_ASSERT( rhs.data() == nullptr, "Invalid data reference detected" );
1240 
1241  return *this;
1242 }
1243 //*************************************************************************************************
1244 
1245 
1246 //*************************************************************************************************
1256 template< typename Type // Data type of the vector
1257  , bool AF // Alignment flag
1258  , bool PF // Padding flag
1259  , bool TF > // Transpose flag
1260 template< typename VT > // Type of the right-hand side vector
1262 {
1263  if( (~rhs).size() != size_ ) {
1264  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1265  }
1266 
1267  if( (~rhs).canAlias( this ) ) {
1268  const ResultType_<VT> tmp( ~rhs );
1269  smpAssign( *this, tmp );
1270  }
1271  else {
1273  reset();
1274  smpAssign( *this, ~rhs );
1275  }
1276 
1277  return *this;
1278 }
1279 //*************************************************************************************************
1280 
1281 
1282 //*************************************************************************************************
1292 template< typename Type // Data type of the vector
1293  , bool AF // Alignment flag
1294  , bool PF // Padding flag
1295  , bool TF > // Transpose flag
1296 template< typename VT > // Type of the right-hand side vector
1298 {
1299  if( (~rhs).size() != size_ ) {
1300  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1301  }
1302 
1303  if( (~rhs).canAlias( this ) ) {
1304  const ResultType_<VT> tmp( ~rhs );
1305  smpAddAssign( *this, tmp );
1306  }
1307  else {
1308  smpAddAssign( *this, ~rhs );
1309  }
1310 
1311  return *this;
1312 }
1313 //*************************************************************************************************
1314 
1315 
1316 //*************************************************************************************************
1327 template< typename Type // Data type of the vector
1328  , bool AF // Alignment flag
1329  , bool PF // Padding flag
1330  , bool TF > // Transpose flag
1331 template< typename VT > // Type of the right-hand side vector
1333 {
1334  if( (~rhs).size() != size_ ) {
1335  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1336  }
1337 
1338  if( (~rhs).canAlias( this ) ) {
1339  const ResultType_<VT> tmp( ~rhs );
1340  smpSubAssign( *this, tmp );
1341  }
1342  else {
1343  smpSubAssign( *this, ~rhs );
1344  }
1345 
1346  return *this;
1347 }
1348 //*************************************************************************************************
1349 
1350 
1351 //*************************************************************************************************
1362 template< typename Type // Data type of the vector
1363  , bool AF // Alignment flag
1364  , bool PF // Padding flag
1365  , bool TF > // Transpose flag
1366 template< typename VT > // Type of the right-hand side vector
1368 {
1371 
1372  using MultType = MultTrait_< ResultType, ResultType_<VT> >;
1373 
1376 
1377  if( (~rhs).size() != size_ ) {
1378  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1379  }
1380 
1381  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
1382  const MultType tmp( *this * (~rhs) );
1384  reset();
1385  smpAssign( *this, tmp );
1386  }
1387  else {
1388  smpMultAssign( *this, ~rhs );
1389  }
1390 
1391  return *this;
1392 }
1393 //*************************************************************************************************
1394 
1395 
1396 //*************************************************************************************************
1406 template< typename Type // Data type of the vector
1407  , bool AF // Alignment flag
1408  , bool PF // Padding flag
1409  , bool TF > // Transpose flag
1410 template< typename VT > // Type of the right-hand side vector
1413 {
1416 
1417  using DivType = DivTrait_< ResultType, ResultType_<VT> >;
1418 
1422 
1423  if( (~rhs).size() != size_ ) {
1424  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1425  }
1426 
1427  if( (~rhs).canAlias( this ) ) {
1428  const DivType tmp( *this / (~rhs) );
1429  smpAssign( *this, tmp );
1430  }
1431  else {
1432  smpDivAssign( *this, ~rhs );
1433  }
1434 
1435  return *this;
1436 }
1437 //*************************************************************************************************
1438 
1439 
1440 //*************************************************************************************************
1451 template< typename Type // Data type of the vector
1452  , bool AF // Alignment flag
1453  , bool PF // Padding flag
1454  , bool TF > // Transpose flag
1455 template< typename VT > // Type of the right-hand side vector
1457 {
1458  using blaze::assign;
1459 
1462 
1463  using CrossType = CrossTrait_< ResultType, ResultType_<VT> >;
1464 
1468 
1469  if( size_ != 3UL || (~rhs).size() != 3UL ) {
1470  BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1471  }
1472 
1473  const CrossType tmp( *this % (~rhs) );
1474  assign( *this, tmp );
1475 
1476  return *this;
1477 }
1478 //*************************************************************************************************
1479 
1480 
1481 //*************************************************************************************************
1488 template< typename Type // Data type of the vector
1489  , bool AF // Alignment flag
1490  , bool PF // Padding flag
1491  , bool TF > // Transpose flag
1492 template< typename Other > // Data type of the right-hand side scalar
1495 {
1496  smpAssign( *this, (*this) * rhs );
1497  return *this;
1498 }
1499 //*************************************************************************************************
1500 
1501 
1502 //*************************************************************************************************
1511 template< typename Type // Data type of the vector
1512  , bool AF // Alignment flag
1513  , bool PF // Padding flag
1514  , bool TF > // Transpose flag
1515 template< typename Other > // Data type of the right-hand side scalar
1516 inline EnableIf_<IsNumeric<Other>, CustomVector<Type,AF,PF,TF> >&
1518 {
1519  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1520 
1521  smpAssign( *this, (*this) / rhs );
1522  return *this;
1523 }
1524 //*************************************************************************************************
1525 
1526 
1527 
1528 
1529 //=================================================================================================
1530 //
1531 // UTILITY FUNCTIONS
1532 //
1533 //=================================================================================================
1534 
1535 //*************************************************************************************************
1540 template< typename Type // Data type of the vector
1541  , bool AF // Alignment flag
1542  , bool PF // Padding flag
1543  , bool TF > // Transpose flag
1544 inline size_t CustomVector<Type,AF,PF,TF>::size() const noexcept
1545 {
1546  return size_;
1547 }
1548 //*************************************************************************************************
1549 
1550 
1551 //*************************************************************************************************
1559 template< typename Type // Data type of the vector
1560  , bool AF // Alignment flag
1561  , bool PF // Padding flag
1562  , bool TF > // Transpose flag
1563 inline size_t CustomVector<Type,AF,PF,TF>::spacing() const noexcept
1564 {
1565  return size_;
1566 }
1567 //*************************************************************************************************
1568 
1569 
1570 //*************************************************************************************************
1575 template< typename Type // Data type of the vector
1576  , bool AF // Alignment flag
1577  , bool PF // Padding flag
1578  , bool TF > // Transpose flag
1579 inline size_t CustomVector<Type,AF,PF,TF>::capacity() const noexcept
1580 {
1581  return size_;
1582 }
1583 //*************************************************************************************************
1584 
1585 
1586 //*************************************************************************************************
1594 template< typename Type // Data type of the vector
1595  , bool AF // Alignment flag
1596  , bool PF // Padding flag
1597  , bool TF > // Transpose flag
1599 {
1600  size_t nonzeros( 0 );
1601 
1602  for( size_t i=0UL; i<size_; ++i ) {
1603  if( !isDefault( v_[i] ) )
1604  ++nonzeros;
1605  }
1606 
1607  return nonzeros;
1608 }
1609 //*************************************************************************************************
1610 
1611 
1612 //*************************************************************************************************
1617 template< typename Type // Data type of the vector
1618  , bool AF // Alignment flag
1619  , bool PF // Padding flag
1620  , bool TF > // Transpose flag
1622 {
1623  using blaze::clear;
1624  for( size_t i=0UL; i<size_; ++i )
1625  clear( v_[i] );
1626 }
1627 //*************************************************************************************************
1628 
1629 
1630 //*************************************************************************************************
1638 template< typename Type // Data type of the vector
1639  , bool AF // Alignment flag
1640  , bool PF // Padding flag
1641  , bool TF > // Transpose flag
1643 {
1644  size_ = 0UL;
1645  v_ = nullptr;
1646 }
1647 //*************************************************************************************************
1648 
1649 
1650 //*************************************************************************************************
1656 template< typename Type // Data type of the vector
1657  , bool AF // Alignment flag
1658  , bool PF // Padding flag
1659  , bool TF > // Transpose flag
1661 {
1662  using std::swap;
1663 
1664  swap( size_, v.size_ );
1665  swap( v_, v.v_ );
1666 }
1667 //*************************************************************************************************
1668 
1669 
1670 
1671 
1672 //=================================================================================================
1673 //
1674 // NUMERIC FUNCTIONS
1675 //
1676 //=================================================================================================
1677 
1678 //*************************************************************************************************
1699 template< typename Type // Data type of the vector
1700  , bool AF // Alignment flag
1701  , bool PF // Padding flag
1702  , bool TF > // Transpose flag
1703 template< typename Other > // Data type of the scalar value
1705 {
1706  for( size_t i=0UL; i<size_; ++i )
1707  v_[i] *= scalar;
1708  return *this;
1709 }
1710 //*************************************************************************************************
1711 
1712 
1713 
1714 
1715 //=================================================================================================
1716 //
1717 // RESOURCE MANAGEMENT FUNCTIONS
1718 //
1719 //=================================================================================================
1720 
1721 //*************************************************************************************************
1743 template< typename Type // Data type of the vector
1744  , bool AF // Alignment flag
1745  , bool PF // Padding flag
1746  , bool TF > // Transpose flag
1747 inline void CustomVector<Type,AF,PF,TF>::reset( Type* ptr, size_t n )
1748 {
1749  CustomVector tmp( ptr, n );
1750  swap( tmp );
1751 }
1752 //*************************************************************************************************
1753 
1754 
1755 //*************************************************************************************************
1780 template< typename Type // Data type of the vector
1781  , bool AF // Alignment flag
1782  , bool PF // Padding flag
1783  , bool TF > // Transpose flag
1784 inline void CustomVector<Type,AF,PF,TF>::reset( Type* ptr, size_t n, size_t nn )
1785 {
1786  BLAZE_STATIC_ASSERT( PF == padded );
1787 
1788  UNUSED_PARAMETER( ptr, n, nn );
1789 }
1790 //*************************************************************************************************
1791 
1792 
1793 
1794 
1795 //=================================================================================================
1796 //
1797 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1798 //
1799 //=================================================================================================
1800 
1801 //*************************************************************************************************
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 template< typename Other > // Data type of the foreign expression
1816 inline bool CustomVector<Type,AF,PF,TF>::canAlias( const Other* alias ) const noexcept
1817 {
1818  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1819 }
1820 //*************************************************************************************************
1821 
1822 
1823 //*************************************************************************************************
1833 template< typename Type // Data type of the vector
1834  , bool AF // Alignment flag
1835  , bool PF // Padding flag
1836  , bool TF > // Transpose flag
1837 template< typename Other > // Data type of the foreign expression
1838 inline bool CustomVector<Type,AF,PF,TF>::isAliased( const Other* alias ) const noexcept
1839 {
1840  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1841 }
1842 //*************************************************************************************************
1843 
1844 
1845 //*************************************************************************************************
1854 template< typename Type // Data type of the vector
1855  , bool AF // Alignment flag
1856  , bool PF // Padding flag
1857  , bool TF > // Transpose flag
1858 inline bool CustomVector<Type,AF,PF,TF>::isAligned() const noexcept
1859 {
1860  return ( AF || checkAlignment( v_ ) );
1861 }
1862 //*************************************************************************************************
1863 
1864 
1865 //*************************************************************************************************
1875 template< typename Type // Data type of the vector
1876  , bool AF // Alignment flag
1877  , bool PF // Padding flag
1878  , bool TF > // Transpose flag
1879 inline bool CustomVector<Type,AF,PF,TF>::canSMPAssign() const noexcept
1880 {
1881  return ( size() > SMP_DVECASSIGN_THRESHOLD );
1882 }
1883 //*************************************************************************************************
1884 
1885 
1886 //*************************************************************************************************
1898 template< typename Type // Data type of the vector
1899  , bool AF // Alignment flag
1900  , bool PF // Padding flag
1901  , bool TF > // Transpose flag
1903  CustomVector<Type,AF,PF,TF>::load( size_t index ) const noexcept
1904 {
1905  if( AF )
1906  return loada( index );
1907  else
1908  return loadu( index );
1909 }
1910 //*************************************************************************************************
1911 
1912 
1913 //*************************************************************************************************
1926 template< typename Type // Data type of the vector
1927  , bool AF // Alignment flag
1928  , bool PF // Padding flag
1929  , bool TF > // Transpose flag
1931  CustomVector<Type,AF,PF,TF>::loada( size_t index ) const noexcept
1932 {
1933  using blaze::loada;
1934 
1936 
1937  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1938  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
1939  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
1940  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+index ), "Invalid vector access index" );
1941 
1942  return loada( v_+index );
1943 }
1944 //*************************************************************************************************
1945 
1946 
1947 //*************************************************************************************************
1960 template< typename Type // Data type of the vector
1961  , bool AF // Alignment flag
1962  , bool PF // Padding flag
1963  , bool TF > // Transpose flag
1965  CustomVector<Type,AF,PF,TF>::loadu( size_t index ) const noexcept
1966 {
1967  using blaze::loadu;
1968 
1970 
1971  BLAZE_INTERNAL_ASSERT( index< size_, "Invalid vector access index" );
1972  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
1973 
1974  return loadu( v_+index );
1975 }
1976 //*************************************************************************************************
1977 
1978 
1979 //*************************************************************************************************
1992 template< typename Type // Data type of the vector
1993  , bool AF // Alignment flag
1994  , bool PF // Padding flag
1995  , bool TF > // Transpose flag
1996 BLAZE_ALWAYS_INLINE void CustomVector<Type,AF,PF,TF>::store( size_t index, const SIMDType& value ) noexcept
1997 {
1998  if( AF )
1999  storea( index, value );
2000  else
2001  storeu( index, value );
2002 }
2003 //*************************************************************************************************
2004 
2005 
2006 //*************************************************************************************************
2019 template< typename Type // Data type of the vector
2020  , bool AF // Alignment flag
2021  , bool PF // Padding flag
2022  , bool TF > // Transpose flag
2023 BLAZE_ALWAYS_INLINE void CustomVector<Type,AF,PF,TF>::storea( size_t index, const SIMDType& value ) noexcept
2024 {
2025  using blaze::storea;
2026 
2028 
2029  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2030  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2031  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
2032  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+index ), "Invalid vector access index" );
2033 
2034  storea( v_+index, value );
2035 }
2036 //*************************************************************************************************
2037 
2038 
2039 //*************************************************************************************************
2052 template< typename Type // Data type of the vector
2053  , bool AF // Alignment flag
2054  , bool PF // Padding flag
2055  , bool TF > // Transpose flag
2056 BLAZE_ALWAYS_INLINE void CustomVector<Type,AF,PF,TF>::storeu( size_t index, const SIMDType& value ) noexcept
2057 {
2058  using blaze::storeu;
2059 
2061 
2062  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2063  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2064 
2065  storeu( v_+index, value );
2066 }
2067 //*************************************************************************************************
2068 
2069 
2070 //*************************************************************************************************
2084 template< typename Type // Data type of the vector
2085  , bool AF // Alignment flag
2086  , bool PF // Padding flag
2087  , bool TF > // Transpose flag
2088 BLAZE_ALWAYS_INLINE void CustomVector<Type,AF,PF,TF>::stream( size_t index, const SIMDType& value ) noexcept
2089 {
2090  using blaze::stream;
2091 
2093 
2094  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2095  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
2096  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
2097  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+index ), "Invalid vector access index" );
2098 
2099  stream( v_+index, value );
2100 }
2101 //*************************************************************************************************
2102 
2103 
2104 //*************************************************************************************************
2115 template< typename Type // Data type of the vector
2116  , bool AF // Alignment flag
2117  , bool PF // Padding flag
2118  , bool TF > // Transpose flag
2119 template< typename VT > // Type of the right-hand side dense vector
2122 {
2123  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2124 
2125  const size_t ipos( size_ & size_t(-2) );
2126  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2127 
2128  for( size_t i=0UL; i<ipos; i+=2UL ) {
2129  v_[i ] = (~rhs)[i ];
2130  v_[i+1UL] = (~rhs)[i+1UL];
2131  }
2132  if( ipos < (~rhs).size() )
2133  v_[ipos] = (~rhs)[ipos];
2134 }
2135 //*************************************************************************************************
2136 
2137 
2138 //*************************************************************************************************
2149 template< typename Type // Data type of the vector
2150  , bool AF // Alignment flag
2151  , bool PF // Padding flag
2152  , bool TF > // Transpose flag
2153 template< typename VT > // Type of the right-hand side dense vector
2156 {
2158 
2159  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2160 
2161  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2162  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2163 
2164  if( AF && useStreaming && size_ > ( cacheSize/( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
2165  {
2166  size_t i( 0UL );
2167 
2168  for( ; i<ipos; i+=SIMDSIZE ) {
2169  stream( i, (~rhs).load(i) );
2170  }
2171  for( ; i<size_; ++i ) {
2172  v_[i] = (~rhs)[i];
2173  }
2174  }
2175  else
2176  {
2177  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2178  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2179  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2180 
2181  size_t i( 0UL );
2182  ConstIterator_<VT> it( (~rhs).begin() );
2183 
2184  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2185  store( i , it.load() ); it += SIMDSIZE;
2186  store( i+SIMDSIZE , it.load() ); it += SIMDSIZE;
2187  store( i+SIMDSIZE*2UL, it.load() ); it += SIMDSIZE;
2188  store( i+SIMDSIZE*3UL, it.load() ); it += SIMDSIZE;
2189  }
2190  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2191  store( i, it.load() );
2192  }
2193  for( ; i<size_; ++i, ++it ) {
2194  v_[i] = *it;
2195  }
2196  }
2197 }
2198 //*************************************************************************************************
2199 
2200 
2201 //*************************************************************************************************
2212 template< typename Type // Data type of the vector
2213  , bool AF // Alignment flag
2214  , bool PF // Padding flag
2215  , bool TF > // Transpose flag
2216 template< typename VT > // Type of the right-hand side sparse vector
2218 {
2219  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2220 
2221  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2222  v_[element->index()] = element->value();
2223 }
2224 //*************************************************************************************************
2225 
2226 
2227 //*************************************************************************************************
2238 template< typename Type // Data type of the vector
2239  , bool AF // Alignment flag
2240  , bool PF // Padding flag
2241  , bool TF > // Transpose flag
2242 template< typename VT > // Type of the right-hand side dense vector
2245 {
2246  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2247 
2248  const size_t ipos( size_ & size_t(-2) );
2249  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2250 
2251  for( size_t i=0UL; i<ipos; i+=2UL ) {
2252  v_[i ] += (~rhs)[i ];
2253  v_[i+1UL] += (~rhs)[i+1UL];
2254  }
2255  if( ipos < (~rhs).size() )
2256  v_[ipos] += (~rhs)[ipos];
2257 }
2258 //*************************************************************************************************
2259 
2260 
2261 //*************************************************************************************************
2272 template< typename Type // Data type of the vector
2273  , bool AF // Alignment flag
2274  , bool PF // Padding flag
2275  , bool TF > // Transpose flag
2276 template< typename VT > // Type of the right-hand side dense vector
2279 {
2281 
2282  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2283 
2284  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2285  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2286 
2287  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2288  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2289  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2290 
2291  size_t i( 0UL );
2292  ConstIterator_<VT> it( (~rhs).begin() );
2293 
2294  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2295  store( i , load(i ) + it.load() ); it += SIMDSIZE;
2296  store( i+SIMDSIZE , load(i+SIMDSIZE ) + it.load() ); it += SIMDSIZE;
2297  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) + it.load() ); it += SIMDSIZE;
2298  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) + it.load() ); it += SIMDSIZE;
2299  }
2300  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2301  store( i, load(i) + it.load() );
2302  }
2303  for( ; i<size_; ++i, ++it ) {
2304  v_[i] += *it;
2305  }
2306 }
2307 //*************************************************************************************************
2308 
2309 
2310 //*************************************************************************************************
2321 template< typename Type // Data type of the vector
2322  , bool AF // Alignment flag
2323  , bool PF // Padding flag
2324  , bool TF > // Transpose flag
2325 template< typename VT > // Type of the right-hand side sparse vector
2327 {
2328  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2329 
2330  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2331  v_[element->index()] += element->value();
2332 }
2333 //*************************************************************************************************
2334 
2335 
2336 //*************************************************************************************************
2347 template< typename Type // Data type of the vector
2348  , bool AF // Alignment flag
2349  , bool PF // Padding flag
2350  , bool TF > // Transpose flag
2351 template< typename VT > // Type of the right-hand side dense vector
2354 {
2355  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2356 
2357  const size_t ipos( size_ & size_t(-2) );
2358  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2359 
2360  for( size_t i=0UL; i<ipos; i+=2UL ) {
2361  v_[i ] -= (~rhs)[i ];
2362  v_[i+1UL] -= (~rhs)[i+1UL];
2363  }
2364  if( ipos < (~rhs).size() )
2365  v_[ipos] -= (~rhs)[ipos];
2366 }
2367 //*************************************************************************************************
2368 
2369 
2370 //*************************************************************************************************
2381 template< typename Type // Data type of the vector
2382  , bool AF // Alignment flag
2383  , bool PF // Padding flag
2384  , bool TF > // Transpose flag
2385 template< typename VT > // Type of the right-hand side dense vector
2388 {
2390 
2391  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2392 
2393  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2394  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2395 
2396  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2397  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2398  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2399 
2400  size_t i( 0UL );
2401  ConstIterator_<VT> it( (~rhs).begin() );
2402 
2403  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2404  store( i , load(i ) - it.load() ); it += SIMDSIZE;
2405  store( i+SIMDSIZE , load(i+SIMDSIZE ) - it.load() ); it += SIMDSIZE;
2406  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) - it.load() ); it += SIMDSIZE;
2407  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) - it.load() ); it += SIMDSIZE;
2408  }
2409  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2410  store( i, load(i) - it.load() );
2411  }
2412  for( ; i<size_; ++i, ++it ) {
2413  v_[i] -= *it;
2414  }
2415 }
2416 //*************************************************************************************************
2417 
2418 
2419 //*************************************************************************************************
2430 template< typename Type // Data type of the vector
2431  , bool AF // Alignment flag
2432  , bool PF // Padding flag
2433  , bool TF > // Transpose flag
2434 template< typename VT > // Type of the right-hand side sparse vector
2436 {
2437  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2438 
2439  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2440  v_[element->index()] -= element->value();
2441 }
2442 //*************************************************************************************************
2443 
2444 
2445 //*************************************************************************************************
2456 template< typename Type // Data type of the vector
2457  , bool AF // Alignment flag
2458  , bool PF // Padding flag
2459  , bool TF > // Transpose flag
2460 template< typename VT > // Type of the right-hand side dense vector
2463 {
2464  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2465 
2466  const size_t ipos( size_ & size_t(-2) );
2467  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2468 
2469  for( size_t i=0UL; i<ipos; i+=2UL ) {
2470  v_[i ] *= (~rhs)[i ];
2471  v_[i+1UL] *= (~rhs)[i+1UL];
2472  }
2473  if( ipos < (~rhs).size() )
2474  v_[ipos] *= (~rhs)[ipos];
2475 }
2476 //*************************************************************************************************
2477 
2478 
2479 //*************************************************************************************************
2490 template< typename Type // Data type of the vector
2491  , bool AF // Alignment flag
2492  , bool PF // Padding flag
2493  , bool TF > // Transpose flag
2494 template< typename VT > // Type of the right-hand side dense vector
2497 {
2499 
2500  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2501 
2502  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2503  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2504 
2505  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2506  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2507  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2508 
2509  size_t i( 0UL );
2510  ConstIterator_<VT> it( (~rhs).begin() );
2511 
2512  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2513  store( i , load(i ) * it.load() ); it += SIMDSIZE;
2514  store( i+SIMDSIZE , load(i+SIMDSIZE ) * it.load() ); it += SIMDSIZE;
2515  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) * it.load() ); it += SIMDSIZE;
2516  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) * it.load() ); it += SIMDSIZE;
2517  }
2518  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2519  store( i, load(i) * it.load() );
2520  }
2521  for( ; i<size_; ++i, ++it ) {
2522  v_[i] *= *it;
2523  }
2524 }
2525 //*************************************************************************************************
2526 
2527 
2528 //*************************************************************************************************
2539 template< typename Type // Data type of the vector
2540  , bool AF // Alignment flag
2541  , bool PF // Padding flag
2542  , bool TF > // Transpose flag
2543 template< typename VT > // Type of the right-hand side sparse vector
2545 {
2546  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2547 
2548  const DynamicVector<Type,TF> tmp( serial( *this ) );
2549 
2550  reset();
2551 
2552  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2553  v_[element->index()] = tmp[element->index()] * element->value();
2554 }
2555 //*************************************************************************************************
2556 
2557 
2558 //*************************************************************************************************
2569 template< typename Type // Data type of the vector
2570  , bool AF // Alignment flag
2571  , bool PF // Padding flag
2572  , bool TF > // Transpose flag
2573 template< typename VT > // Type of the right-hand side dense vector
2576 {
2577  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2578 
2579  const size_t ipos( size_ & size_t(-2) );
2580  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
2581 
2582  for( size_t i=0UL; i<ipos; i+=2UL ) {
2583  v_[i ] /= (~rhs)[i ];
2584  v_[i+1UL] /= (~rhs)[i+1UL];
2585  }
2586  if( ipos < (~rhs).size() )
2587  v_[ipos] /= (~rhs)[ipos];
2588 }
2589 //*************************************************************************************************
2590 
2591 
2592 //*************************************************************************************************
2603 template< typename Type // Data type of the vector
2604  , bool AF // Alignment flag
2605  , bool PF // Padding flag
2606  , bool TF > // Transpose flag
2607 template< typename VT > // Type of the right-hand side dense vector
2610 {
2612 
2613  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
2614 
2615  const size_t ipos( size_ & size_t(-SIMDSIZE) );
2616  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
2617 
2618  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
2619  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
2620  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
2621 
2622  size_t i( 0UL );
2623  ConstIterator_<VT> it( (~rhs).begin() );
2624 
2625  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
2626  store( i , load(i ) / it.load() ); it += SIMDSIZE;
2627  store( i+SIMDSIZE , load(i+SIMDSIZE ) / it.load() ); it += SIMDSIZE;
2628  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) / it.load() ); it += SIMDSIZE;
2629  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) / it.load() ); it += SIMDSIZE;
2630  }
2631  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
2632  store( i, load(i) / it.load() );
2633  }
2634  for( ; i<size_; ++i, ++it ) {
2635  v_[i] /= *it;
2636  }
2637 }
2638 //*************************************************************************************************
2639 
2640 
2641 
2642 
2643 
2644 
2645 
2646 
2647 //=================================================================================================
2648 //
2649 // CLASS TEMPLATE SPECIALIZATION FOR PADDED VECTORS
2650 //
2651 //=================================================================================================
2652 
2653 //*************************************************************************************************
2661 template< typename Type // Data type of the vector
2662  , bool AF // Alignment flag
2663  , bool TF > // Transpose flag
2664 class CustomVector<Type,AF,padded,TF>
2665  : public DenseVector< CustomVector<Type,AF,padded,TF>, TF >
2666 {
2667  public:
2668  //**Type definitions****************************************************************************
2670  using BaseType = DenseVector<This,TF>;
2671 
2674 
2677 
2678  using ElementType = Type;
2680  using ReturnType = const Type&;
2681  using CompositeType = const CustomVector&;
2682 
2683  using Reference = Type&;
2684  using ConstReference = const Type&;
2685  using Pointer = Type*;
2686  using ConstPointer = const Type*;
2687 
2690  //**********************************************************************************************
2691 
2692  //**Rebind struct definition********************************************************************
2695  template< typename NewType > // Data type of the other vector
2696  struct Rebind {
2697  using Other = CustomVector<NewType,AF,padded,TF>;
2698  };
2699  //**********************************************************************************************
2700 
2701  //**Resize struct definition********************************************************************
2704  template< size_t NewN > // Number of elements of the other vector
2705  struct Resize {
2706  using Other = CustomVector<Type,AF,padded,TF>;
2707  };
2708  //**********************************************************************************************
2709 
2710  //**Compilation flags***************************************************************************
2712 
2716  enum : bool { simdEnabled = IsVectorizable<Type>::value };
2717 
2719 
2722  enum : bool { smpAssignable = !IsSMPAssignable<Type>::value };
2723  //**********************************************************************************************
2724 
2725  //**Constructors********************************************************************************
2728  explicit inline CustomVector();
2729  explicit inline CustomVector( Type* ptr, size_t n, size_t nn );
2730 
2731  inline CustomVector( const CustomVector& v );
2732  inline CustomVector( CustomVector&& v ) noexcept;
2734  //**********************************************************************************************
2735 
2736  //**Destructor**********************************************************************************
2737  // No explicitly declared destructor.
2738  //**********************************************************************************************
2739 
2740  //**Data access functions***********************************************************************
2743  inline Reference operator[]( size_t index ) noexcept;
2744  inline ConstReference operator[]( size_t index ) const noexcept;
2745  inline Reference at( size_t index );
2746  inline ConstReference at( size_t index ) const;
2747  inline Pointer data () noexcept;
2748  inline ConstPointer data () const noexcept;
2749  inline Iterator begin () noexcept;
2750  inline ConstIterator begin () const noexcept;
2751  inline ConstIterator cbegin() const noexcept;
2752  inline Iterator end () noexcept;
2753  inline ConstIterator end () const noexcept;
2754  inline ConstIterator cend () const noexcept;
2756  //**********************************************************************************************
2757 
2758  //**Assignment operators************************************************************************
2761  inline CustomVector& operator=( const Type& rhs );
2763 
2764  template< typename Other, size_t N >
2765  inline CustomVector& operator=( const Other (&array)[N] );
2766 
2767  inline CustomVector& operator=( const CustomVector& rhs );
2768  inline CustomVector& operator=( CustomVector&& rhs ) noexcept;
2769 
2770  template< typename VT > inline CustomVector& operator= ( const Vector<VT,TF>& rhs );
2771  template< typename VT > inline CustomVector& operator+=( const Vector<VT,TF>& rhs );
2772  template< typename VT > inline CustomVector& operator-=( const Vector<VT,TF>& rhs );
2773  template< typename VT > inline CustomVector& operator*=( const Vector<VT,TF>& rhs );
2774  template< typename VT > inline CustomVector& operator/=( const DenseVector<VT,TF>& rhs );
2775  template< typename VT > inline CustomVector& operator%=( const Vector<VT,TF>& rhs );
2776 
2777  template< typename Other >
2778  inline EnableIf_<IsNumeric<Other>, CustomVector >& operator*=( Other rhs );
2779 
2780  template< typename Other >
2781  inline EnableIf_<IsNumeric<Other>, CustomVector >& operator/=( Other rhs );
2783  //**********************************************************************************************
2784 
2785  //**Utility functions***************************************************************************
2788  inline size_t size() const noexcept;
2789  inline size_t spacing() const noexcept;
2790  inline size_t capacity() const noexcept;
2791  inline size_t nonZeros() const;
2792  inline void reset();
2793  inline void clear();
2794  inline void swap( CustomVector& v ) noexcept;
2796  //**********************************************************************************************
2797 
2798  //**Numeric functions***************************************************************************
2801  template< typename Other > inline CustomVector& scale( const Other& scalar );
2803  //**********************************************************************************************
2804 
2805  //**Resource management functions***************************************************************
2808  inline void reset( Type* ptr, size_t n, size_t nn );
2810  //**********************************************************************************************
2811 
2812  private:
2813  //**********************************************************************************************
2815  template< typename VT >
2816  struct VectorizedAssign {
2817  enum : bool { value = useOptimizedKernels &&
2818  simdEnabled && VT::simdEnabled &&
2820  };
2821  //**********************************************************************************************
2822 
2823  //**********************************************************************************************
2825  template< typename VT >
2826  struct VectorizedAddAssign {
2827  enum : bool { value = useOptimizedKernels &&
2828  simdEnabled && VT::simdEnabled &&
2831  };
2832  //**********************************************************************************************
2833 
2834  //**********************************************************************************************
2836  template< typename VT >
2837  struct VectorizedSubAssign {
2838  enum : bool { value = useOptimizedKernels &&
2839  simdEnabled && VT::simdEnabled &&
2842  };
2843  //**********************************************************************************************
2844 
2845  //**********************************************************************************************
2847  template< typename VT >
2848  struct VectorizedMultAssign {
2849  enum : bool { value = useOptimizedKernels &&
2850  simdEnabled && VT::simdEnabled &&
2853  };
2854  //**********************************************************************************************
2855 
2856  //**********************************************************************************************
2858  template< typename VT >
2859  struct VectorizedDivAssign {
2860  enum : bool { value = useOptimizedKernels &&
2861  simdEnabled && VT::simdEnabled &&
2864  };
2865  //**********************************************************************************************
2866 
2867  //**SIMD properties*****************************************************************************
2869  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
2870  //**********************************************************************************************
2871 
2872  public:
2873  //**Expression template evaluation functions****************************************************
2876  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
2877  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
2878 
2879  inline bool isAligned () const noexcept;
2880  inline bool canSMPAssign() const noexcept;
2881 
2882  BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
2883  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
2884  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
2885 
2886  BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
2887  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
2888  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
2889  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
2890 
2891  template< typename VT >
2892  inline DisableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
2893 
2894  template< typename VT >
2895  inline EnableIf_<VectorizedAssign<VT> > assign( const DenseVector<VT,TF>& rhs );
2896 
2897  template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
2898 
2899  template< typename VT >
2900  inline DisableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
2901 
2902  template< typename VT >
2903  inline EnableIf_<VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,TF>& rhs );
2904 
2905  template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
2906 
2907  template< typename VT >
2908  inline DisableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
2909 
2910  template< typename VT >
2911  inline EnableIf_<VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,TF>& rhs );
2912 
2913  template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
2914 
2915  template< typename VT >
2916  inline DisableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
2917 
2918  template< typename VT >
2919  inline EnableIf_<VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,TF>& rhs );
2920 
2921  template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
2922 
2923  template< typename VT >
2924  inline DisableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
2925 
2926  template< typename VT >
2927  inline EnableIf_<VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,TF>& rhs );
2929  //**********************************************************************************************
2930 
2931  private:
2932  //**Member variables****************************************************************************
2935  size_t size_;
2936  size_t capacity_;
2937  Type* v_;
2938 
2944  //**********************************************************************************************
2945 
2946  //**Compile time checks*************************************************************************
2950  //**********************************************************************************************
2951 };
2953 //*************************************************************************************************
2954 
2955 
2956 
2957 
2958 //=================================================================================================
2959 //
2960 // CONSTRUCTORS
2961 //
2962 //=================================================================================================
2963 
2964 //*************************************************************************************************
2968 template< typename Type // Data type of the vector
2969  , bool AF // Alignment flag
2970  , bool TF > // Transpose flag
2972  : size_ ( 0UL ) // The size/dimension of the vector
2973  , capacity_( 0UL ) // The maximum capacity of the vector
2974  , v_ ( nullptr ) // The custom array of elements
2975 {}
2977 //*************************************************************************************************
2978 
2979 
2980 //*************************************************************************************************
3002 template< typename Type // Data type of the vector
3003  , bool AF // Alignment flag
3004  , bool TF > // Transpose flag
3005 inline CustomVector<Type,AF,padded,TF>::CustomVector( Type* ptr, size_t n, size_t nn )
3006  : size_ ( n ) // The size/dimension of the vector
3007  , capacity_( nn ) // The maximum capacity of the vector
3008  , v_ ( ptr ) // The custom array of elements
3009 {
3010  if( ptr == nullptr ) {
3011  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array of elements" );
3012  }
3013 
3014  if( AF && !checkAlignment( ptr ) ) {
3015  BLAZE_THROW_INVALID_ARGUMENT( "Invalid alignment detected" );
3016  }
3017 
3018  if( IsVectorizable<Type>::value && capacity_ < nextMultiple<size_t>( size_, SIMDSIZE ) ) {
3019  BLAZE_THROW_INVALID_ARGUMENT( "Insufficient capacity for padded vector" );
3020  }
3021 
3023  for( size_t i=size_; i<capacity_; ++i )
3024  v_[i] = Type();
3025  }
3026 }
3028 //*************************************************************************************************
3029 
3030 
3031 //*************************************************************************************************
3039 template< typename Type // Data type of the vector
3040  , bool AF // Alignment flag
3041  , bool TF > // Transpose flag
3043  : size_ ( v.size_ ) // The size/dimension of the vector
3044  , capacity_( v.capacity_ ) // The maximum capacity of the vector
3045  , v_ ( v.v_ ) // The custom array of elements
3046 {}
3048 //*************************************************************************************************
3049 
3050 
3051 //*************************************************************************************************
3057 template< typename Type // Data type of the vector
3058  , bool AF // Alignment flag
3059  , bool TF > // Transpose flag
3061  : size_ ( v.size_ ) // The size/dimension of the vector
3062  , capacity_( v.capacity_ ) // The maximum capacity of the vector
3063  , v_ ( v.v_ ) // The custom array of elements
3064 {
3065  v.size_ = 0UL;
3066  v.capacity_ = 0UL;
3067  v.v_ = nullptr;
3068 
3069  BLAZE_INTERNAL_ASSERT( v.data() == nullptr, "Invalid data reference detected" );
3070 }
3072 //*************************************************************************************************
3073 
3074 
3075 
3076 
3077 //=================================================================================================
3078 //
3079 // DATA ACCESS FUNCTIONS
3080 //
3081 //=================================================================================================
3082 
3083 //*************************************************************************************************
3093 template< typename Type // Data type of the vector
3094  , bool AF // Alignment flag
3095  , bool TF > // Transpose flag
3097  CustomVector<Type,AF,padded,TF>::operator[]( size_t index ) noexcept
3098 {
3099  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
3100  return v_[index];
3101 }
3103 //*************************************************************************************************
3104 
3105 
3106 //*************************************************************************************************
3116 template< typename Type // Data type of the vector
3117  , bool AF // Alignment flag
3118  , bool TF > // Transpose flag
3120  CustomVector<Type,AF,padded,TF>::operator[]( size_t index ) const noexcept
3121 {
3122  BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
3123  return v_[index];
3124 }
3126 //*************************************************************************************************
3127 
3128 
3129 //*************************************************************************************************
3140 template< typename Type // Data type of the vector
3141  , bool AF // Alignment flag
3142  , bool TF > // Transpose flag
3144  CustomVector<Type,AF,padded,TF>::at( size_t index )
3145 {
3146  if( index >= size_ ) {
3147  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
3148  }
3149  return (*this)[index];
3150 }
3152 //*************************************************************************************************
3153 
3154 
3155 //*************************************************************************************************
3166 template< typename Type // Data type of the vector
3167  , bool AF // Alignment flag
3168  , bool TF > // Transpose flag
3170  CustomVector<Type,AF,padded,TF>::at( size_t index ) const
3171 {
3172  if( index >= size_ ) {
3173  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
3174  }
3175  return (*this)[index];
3176 }
3178 //*************************************************************************************************
3179 
3180 
3181 //*************************************************************************************************
3189 template< typename Type // Data type of the vector
3190  , bool AF // Alignment flag
3191  , bool TF > // Transpose flag
3194 {
3195  return v_;
3196 }
3198 //*************************************************************************************************
3199 
3200 
3201 //*************************************************************************************************
3209 template< typename Type // Data type of the vector
3210  , bool AF // Alignment flag
3211  , bool TF > // Transpose flag
3213  CustomVector<Type,AF,padded,TF>::data() const noexcept
3214 {
3215  return v_;
3216 }
3218 //*************************************************************************************************
3219 
3220 
3221 //*************************************************************************************************
3227 template< typename Type // Data type of the vector
3228  , bool AF // Alignment flag
3229  , bool TF > // Transpose flag
3232 {
3233  return Iterator( v_ );
3234 }
3236 //*************************************************************************************************
3237 
3238 
3239 //*************************************************************************************************
3245 template< typename Type // Data type of the vector
3246  , bool AF // Alignment flag
3247  , bool TF > // Transpose flag
3250 {
3251  return ConstIterator( v_ );
3252 }
3254 //*************************************************************************************************
3255 
3256 
3257 //*************************************************************************************************
3263 template< typename Type // Data type of the vector
3264  , bool AF // Alignment flag
3265  , bool TF > // Transpose flag
3268 {
3269  return ConstIterator( v_ );
3270 }
3272 //*************************************************************************************************
3273 
3274 
3275 //*************************************************************************************************
3281 template< typename Type // Data type of the vector
3282  , bool AF // Alignment flag
3283  , bool TF > // Transpose flag
3286 {
3287  return Iterator( v_+size_ );
3288 }
3290 //*************************************************************************************************
3291 
3292 
3293 //*************************************************************************************************
3299 template< typename Type // Data type of the vector
3300  , bool AF // Alignment flag
3301  , bool TF > // Transpose flag
3303  CustomVector<Type,AF,padded,TF>::end() const noexcept
3304 {
3305  return ConstIterator( v_+size_ );
3306 }
3308 //*************************************************************************************************
3309 
3310 
3311 //*************************************************************************************************
3317 template< typename Type // Data type of the vector
3318  , bool AF // Alignment flag
3319  , bool TF > // Transpose flag
3321  CustomVector<Type,AF,padded,TF>::cend() const noexcept
3322 {
3323  return ConstIterator( v_+size_ );
3324 }
3326 //*************************************************************************************************
3327 
3328 
3329 
3330 
3331 //=================================================================================================
3332 //
3333 // ASSIGNMENT OPERATORS
3334 //
3335 //=================================================================================================
3336 
3337 //*************************************************************************************************
3344 template< typename Type // Data type of the vector
3345  , bool AF // Alignment flag
3346  , bool TF > // Transpose flag
3349 {
3350  for( size_t i=0UL; i<size_; ++i )
3351  v_[i] = rhs;
3352  return *this;
3353 }
3355 //*************************************************************************************************
3356 
3357 
3358 //*************************************************************************************************
3383 template< typename Type // Data type of the vector
3384  , bool AF // Alignment flag
3385  , bool TF > // Transpose flag
3388 {
3389  if( list.size() > size_ ) {
3390  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to custom vector" );
3391  }
3392 
3393  std::fill( std::copy( list.begin(), list.end(), v_ ), v_+capacity_, Type() );
3394 
3395  return *this;
3396 }
3398 //*************************************************************************************************
3399 
3400 
3401 //*************************************************************************************************
3429 template< typename Type // Data type of the vector
3430  , bool AF // Alignment flag
3431  , bool TF > // Transpose flag
3432 template< typename Other // Data type of the initialization array
3433  , size_t N > // Dimension of the initialization array
3435  CustomVector<Type,AF,padded,TF>::operator=( const Other (&array)[N] )
3436 {
3437  if( size_ != N ) {
3438  BLAZE_THROW_INVALID_ARGUMENT( "Invalid array size" );
3439  }
3440 
3441  for( size_t i=0UL; i<N; ++i )
3442  v_[i] = array[i];
3443 
3444  return *this;
3445 }
3447 //*************************************************************************************************
3448 
3449 
3450 //*************************************************************************************************
3461 template< typename Type // Data type of the vector
3462  , bool AF // Alignment flag
3463  , bool TF > // Transpose flag
3466 {
3467  if( rhs.size() != size_ ) {
3468  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3469  }
3470 
3471  smpAssign( *this, ~rhs );
3472 
3473  return *this;
3474 }
3476 //*************************************************************************************************
3477 
3478 
3479 //*************************************************************************************************
3486 template< typename Type // Data type of the vector
3487  , bool AF // Alignment flag
3488  , bool TF > // Transpose flag
3491 {
3492  size_ = rhs.size_;
3493  capacity_ = rhs.capacity_;
3494  v_ = rhs.v_;
3495 
3496  rhs.size_ = 0UL;
3497  rhs.capacity_ = 0UL;
3498  rhs.v_ = nullptr;
3499 
3500  BLAZE_INTERNAL_ASSERT( rhs.data() == nullptr, "Invalid data reference detected" );
3501 
3502  return *this;
3503 }
3505 //*************************************************************************************************
3506 
3507 
3508 //*************************************************************************************************
3519 template< typename Type // Data type of the vector
3520  , bool AF // Alignment flag
3521  , bool TF > // Transpose flag
3522 template< typename VT > // Type of the right-hand side vector
3525 {
3526  if( (~rhs).size() != size_ ) {
3527  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3528  }
3529 
3530  if( (~rhs).canAlias( this ) ) {
3531  const ResultType_<VT> tmp( ~rhs );
3532  smpAssign( *this, tmp );
3533  }
3534  else {
3536  reset();
3537  smpAssign( *this, ~rhs );
3538  }
3539 
3540  return *this;
3541 }
3543 //*************************************************************************************************
3544 
3545 
3546 //*************************************************************************************************
3557 template< typename Type // Data type of the vector
3558  , bool AF // Alignment flag
3559  , bool TF > // Transpose flag
3560 template< typename VT > // Type of the right-hand side vector
3563 {
3564  if( (~rhs).size() != size_ ) {
3565  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3566  }
3567 
3568  if( (~rhs).canAlias( this ) ) {
3569  const ResultType_<VT> tmp( ~rhs );
3570  smpAddAssign( *this, tmp );
3571  }
3572  else {
3573  smpAddAssign( *this, ~rhs );
3574  }
3575 
3576  return *this;
3577 }
3579 //*************************************************************************************************
3580 
3581 
3582 //*************************************************************************************************
3594 template< typename Type // Data type of the vector
3595  , bool AF // Alignment flag
3596  , bool TF > // Transpose flag
3597 template< typename VT > // Type of the right-hand side vector
3600 {
3601  if( (~rhs).size() != size_ ) {
3602  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3603  }
3604 
3605  if( (~rhs).canAlias( this ) ) {
3606  const ResultType_<VT> tmp( ~rhs );
3607  smpSubAssign( *this, tmp );
3608  }
3609  else {
3610  smpSubAssign( *this, ~rhs );
3611  }
3612 
3613  return *this;
3614 }
3616 //*************************************************************************************************
3617 
3618 
3619 //*************************************************************************************************
3631 template< typename Type // Data type of the vector
3632  , bool AF // Alignment flag
3633  , bool TF > // Transpose flag
3634 template< typename VT > // Type of the right-hand side vector
3637 {
3640 
3641  using MultType = MultTrait_< ResultType, ResultType_<VT> >;
3642 
3645 
3646  if( (~rhs).size() != size_ ) {
3647  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3648  }
3649 
3650  if( IsSparseVector<VT>::value || (~rhs).canAlias( this ) ) {
3651  const MultType tmp( *this * (~rhs) );
3653  reset();
3654  smpAssign( *this, tmp );
3655  }
3656  else {
3657  smpMultAssign( *this, ~rhs );
3658  }
3659 
3660  return *this;
3661 }
3663 //*************************************************************************************************
3664 
3665 
3666 //*************************************************************************************************
3677 template< typename Type // Data type of the vector
3678  , bool AF // Alignment flag
3679  , bool TF > // Transpose flag
3680 template< typename VT > // Type of the right-hand side vector
3683 {
3686 
3687  using DivType = DivTrait_< ResultType, ResultType_<VT> >;
3688 
3692 
3693  if( (~rhs).size() != size_ ) {
3694  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3695  }
3696 
3697  if( (~rhs).canAlias( this ) ) {
3698  const DivType tmp( *this / (~rhs) );
3699  smpAssign( *this, tmp );
3700  }
3701  else {
3702  smpDivAssign( *this, ~rhs );
3703  }
3704 
3705  return *this;
3706 }
3708 //*************************************************************************************************
3709 
3710 
3711 //*************************************************************************************************
3723 template< typename Type // Data type of the vector
3724  , bool AF // Alignment flag
3725  , bool TF > // Transpose flag
3726 template< typename VT > // Type of the right-hand side vector
3729 {
3730  using blaze::assign;
3731 
3734 
3735  using CrossType = CrossTrait_< ResultType, ResultType_<VT> >;
3736 
3740 
3741  if( size_ != 3UL || (~rhs).size() != 3UL ) {
3742  BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
3743  }
3744 
3745  const CrossType tmp( *this % (~rhs) );
3746  assign( *this, tmp );
3747 
3748  return *this;
3749 }
3751 //*************************************************************************************************
3752 
3753 
3754 //*************************************************************************************************
3762 template< typename Type // Data type of the vector
3763  , bool AF // Alignment flag
3764  , bool TF > // Transpose flag
3765 template< typename Other > // Data type of the right-hand side scalar
3766 inline EnableIf_<IsNumeric<Other>, CustomVector<Type,AF,padded,TF> >&
3768 {
3769  smpAssign( *this, (*this) * rhs );
3770  return *this;
3771 }
3773 //*************************************************************************************************
3774 
3775 
3776 //*************************************************************************************************
3786 template< typename Type // Data type of the vector
3787  , bool AF // Alignment flag
3788  , bool TF > // Transpose flag
3789 template< typename Other > // Data type of the right-hand side scalar
3790 inline EnableIf_<IsNumeric<Other>, CustomVector<Type,AF,padded,TF> >&
3792 {
3793  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3794 
3795  smpAssign( *this, (*this) / rhs );
3796  return *this;
3797 }
3799 //*************************************************************************************************
3800 
3801 
3802 
3803 
3804 //=================================================================================================
3805 //
3806 // UTILITY FUNCTIONS
3807 //
3808 //=================================================================================================
3809 
3810 //*************************************************************************************************
3816 template< typename Type // Data type of the vector
3817  , bool AF // Alignment flag
3818  , bool TF > // Transpose flag
3819 inline size_t CustomVector<Type,AF,padded,TF>::size() const noexcept
3820 {
3821  return size_;
3822 }
3824 //*************************************************************************************************
3825 
3826 
3827 //*************************************************************************************************
3836 template< typename Type // Data type of the vector
3837  , bool AF // Alignment flag
3838  , bool TF > // Transpose flag
3839 inline size_t CustomVector<Type,AF,padded,TF>::spacing() const noexcept
3840 {
3841  return capacity_;
3842 }
3844 //*************************************************************************************************
3845 
3846 
3847 //*************************************************************************************************
3853 template< typename Type // Data type of the vector
3854  , bool AF // Alignment flag
3855  , bool TF > // Transpose flag
3856 inline size_t CustomVector<Type,AF,padded,TF>::capacity() const noexcept
3857 {
3858  return capacity_;
3859 }
3861 //*************************************************************************************************
3862 
3863 
3864 //*************************************************************************************************
3873 template< typename Type // Data type of the vector
3874  , bool AF // Alignment flag
3875  , bool TF > // Transpose flag
3876 inline size_t CustomVector<Type,AF,padded,TF>::nonZeros() const
3877 {
3878  size_t nonzeros( 0 );
3879 
3880  for( size_t i=0UL; i<size_; ++i ) {
3881  if( !isDefault( v_[i] ) )
3882  ++nonzeros;
3883  }
3884 
3885  return nonzeros;
3886 }
3888 //*************************************************************************************************
3889 
3890 
3891 //*************************************************************************************************
3897 template< typename Type // Data type of the vector
3898  , bool AF // Alignment flag
3899  , bool TF > // Transpose flag
3901 {
3902  using blaze::clear;
3903  for( size_t i=0UL; i<size_; ++i )
3904  clear( v_[i] );
3905 }
3907 //*************************************************************************************************
3908 
3909 
3910 //*************************************************************************************************
3919 template< typename Type // Data type of the vector
3920  , bool AF // Alignment flag
3921  , bool TF > // Transpose flag
3923 {
3924  size_ = 0UL;
3925  capacity_ = 0UL;
3926  v_ = nullptr;
3927 }
3929 //*************************************************************************************************
3930 
3931 
3932 //*************************************************************************************************
3939 template< typename Type // Data type of the vector
3940  , bool AF // Alignment flag
3941  , bool TF > // Transpose flag
3942 inline void CustomVector<Type,AF,padded,TF>::swap( CustomVector& v ) noexcept
3943 {
3944  using std::swap;
3945 
3946  swap( size_, v.size_ );
3947  swap( capacity_, v.capacity_ );
3948  swap( v_, v.v_ );
3949 }
3951 //*************************************************************************************************
3952 
3953 
3954 
3955 
3956 //=================================================================================================
3957 //
3958 // NUMERIC FUNCTIONS
3959 //
3960 //=================================================================================================
3961 
3962 //*************************************************************************************************
3984 template< typename Type // Data type of the vector
3985  , bool AF // Alignment flag
3986  , bool TF > // Transpose flag
3987 template< typename Other > // Data type of the scalar value
3989  CustomVector<Type,AF,padded,TF>::scale( const Other& scalar )
3990 {
3991  for( size_t i=0UL; i<size_; ++i )
3992  v_[i] *= scalar;
3993  return *this;
3994 }
3996 //*************************************************************************************************
3997 
3998 
3999 
4000 
4001 //=================================================================================================
4002 //
4003 // RESOURCE MANAGEMENT FUNCTIONS
4004 //
4005 //=================================================================================================
4006 
4007 //*************************************************************************************************
4030 template< typename Type // Data type of the vector
4031  , bool AF // Alignment flag
4032  , bool TF > // Transpose flag
4033 inline void CustomVector<Type,AF,padded,TF>::reset( Type* ptr, size_t n, size_t nn )
4034 {
4035  CustomVector tmp( ptr, n, nn );
4036  swap( tmp );
4037 }
4039 //*************************************************************************************************
4040 
4041 
4042 
4043 
4044 //=================================================================================================
4045 //
4046 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
4047 //
4048 //=================================================================================================
4049 
4050 //*************************************************************************************************
4061 template< typename Type // Data type of the vector
4062  , bool AF // Alignment flag
4063  , bool TF > // Transpose flag
4064 template< typename Other > // Data type of the foreign expression
4065 inline bool CustomVector<Type,AF,padded,TF>::canAlias( const Other* alias ) const noexcept
4066 {
4067  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4068 }
4070 //*************************************************************************************************
4071 
4072 
4073 //*************************************************************************************************
4084 template< typename Type // Data type of the vector
4085  , bool AF // Alignment flag
4086  , bool TF > // Transpose flag
4087 template< typename Other > // Data type of the foreign expression
4088 inline bool CustomVector<Type,AF,padded,TF>::isAliased( const Other* alias ) const noexcept
4089 {
4090  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4091 }
4093 //*************************************************************************************************
4094 
4095 
4096 //*************************************************************************************************
4106 template< typename Type // Data type of the vector
4107  , bool AF // Alignment flag
4108  , bool TF > // Transpose flag
4109 inline bool CustomVector<Type,AF,padded,TF>::isAligned() const noexcept
4110 {
4111  return ( AF || checkAlignment( v_ ) );
4112 }
4114 //*************************************************************************************************
4115 
4116 
4117 //*************************************************************************************************
4128 template< typename Type // Data type of the vector
4129  , bool AF // Alignment flag
4130  , bool TF > // Transpose flag
4131 inline bool CustomVector<Type,AF,padded,TF>::canSMPAssign() const noexcept
4132 {
4133  return ( size() > SMP_DVECASSIGN_THRESHOLD );
4134 }
4136 //*************************************************************************************************
4137 
4138 
4139 //*************************************************************************************************
4152 template< typename Type // Data type of the vector
4153  , bool AF // Alignment flag
4154  , bool TF > // Transpose flag
4156  CustomVector<Type,AF,padded,TF>::load( size_t index ) const noexcept
4157 {
4158  if( AF )
4159  return loada( index );
4160  else
4161  return loadu( index );
4162 }
4164 //*************************************************************************************************
4165 
4166 
4167 //*************************************************************************************************
4181 template< typename Type // Data type of the vector
4182  , bool AF // Alignment flag
4183  , bool TF > // Transpose flag
4185  CustomVector<Type,AF,padded,TF>::loada( size_t index ) const noexcept
4186 {
4187  using blaze::loada;
4188 
4190 
4191  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4192  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4193  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
4194  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+index ), "Invalid vector access index" );
4195 
4196  return loada( v_+index );
4197 }
4199 //*************************************************************************************************
4200 
4201 
4202 //*************************************************************************************************
4216 template< typename Type // Data type of the vector
4217  , bool AF // Alignment flag
4218  , bool TF > // Transpose flag
4220  CustomVector<Type,AF,padded,TF>::loadu( size_t index ) const noexcept
4221 {
4222  using blaze::loadu;
4223 
4225 
4226  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4227  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4228 
4229  return loadu( v_+index );
4230 }
4232 //*************************************************************************************************
4233 
4234 
4235 //*************************************************************************************************
4249 template< typename Type // Data type of the vector
4250  , bool AF // Alignment flag
4251  , bool TF > // Transpose flag
4253  CustomVector<Type,AF,padded,TF>::store( size_t index, const SIMDType& value ) noexcept
4254 {
4255  if( AF )
4256  storea( index, value );
4257  else
4258  storeu( index, value );
4259 }
4261 //*************************************************************************************************
4262 
4263 
4264 //*************************************************************************************************
4278 template< typename Type // Data type of the vector
4279  , bool AF // Alignment flag
4280  , bool TF > // Transpose flag
4282  CustomVector<Type,AF,padded,TF>::storea( size_t index, const SIMDType& value ) noexcept
4283 {
4284  using blaze::storea;
4285 
4287 
4288  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4289  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4290  BLAZE_INTERNAL_ASSERT( !AF || index % SIMDSIZE == 0UL, "Invalid vector access index" );
4291  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+index ), "Invalid vector access index" );
4292 
4293  storea( v_+index, value );
4294 }
4296 //*************************************************************************************************
4297 
4298 
4299 //*************************************************************************************************
4313 template< typename Type // Data type of the vector
4314  , bool AF // Alignment flag
4315  , bool TF > // Transpose flag
4317  CustomVector<Type,AF,padded,TF>::storeu( size_t index, const SIMDType& value ) noexcept
4318 {
4319  using blaze::storeu;
4320 
4322 
4323  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4324  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4325 
4326  storeu( v_+index, value );
4327 }
4329 //*************************************************************************************************
4330 
4331 
4332 //*************************************************************************************************
4347 template< typename Type // Data type of the vector
4348  , bool AF // Alignment flag
4349  , bool TF > // Transpose flag
4351  CustomVector<Type,AF,padded,TF>::stream( size_t index, const SIMDType& value ) noexcept
4352 {
4353  using blaze::stream;
4354 
4356 
4357  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4358  BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= capacity_, "Invalid vector access index" );
4359  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+index ), "Invalid vector access index" );
4360 
4361  stream( v_+index, value );
4362 }
4364 //*************************************************************************************************
4365 
4366 
4367 //*************************************************************************************************
4379 template< typename Type // Data type of the vector
4380  , bool AF // Alignment flag
4381  , bool TF > // Transpose flag
4382 template< typename VT > // Type of the right-hand side dense vector
4385 {
4386  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4387 
4388  const size_t ipos( size_ & size_t(-2) );
4389  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4390 
4391  for( size_t i=0UL; i<ipos; i+=2UL ) {
4392  v_[i ] = (~rhs)[i ];
4393  v_[i+1UL] = (~rhs)[i+1UL];
4394  }
4395  if( ipos < (~rhs).size() )
4396  v_[ipos] = (~rhs)[ipos];
4397 }
4399 //*************************************************************************************************
4400 
4401 
4402 //*************************************************************************************************
4414 template< typename Type // Data type of the vector
4415  , bool AF // Alignment flag
4416  , bool TF > // Transpose flag
4417 template< typename VT > // Type of the right-hand side dense vector
4420 {
4422 
4423  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4424 
4425  constexpr bool remainder( !IsPadded<VT>::value );
4426 
4427  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
4428  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4429 
4430  if( AF && useStreaming && size_ > ( cacheSize/( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
4431  {
4432  size_t i( 0UL );
4433 
4434  for( ; i<ipos; i+=SIMDSIZE ) {
4435  stream( i, (~rhs).load(i) );
4436  }
4437  for( ; remainder && i<size_; ++i ) {
4438  v_[i] = (~rhs)[i];
4439  }
4440  }
4441  else
4442  {
4443  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4444  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4445  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4446 
4447  size_t i( 0UL );
4448  ConstIterator_<VT> it( (~rhs).begin() );
4449 
4450  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4451  store( i , it.load() ); it += SIMDSIZE;
4452  store( i+SIMDSIZE , it.load() ); it += SIMDSIZE;
4453  store( i+SIMDSIZE*2UL, it.load() ); it += SIMDSIZE;
4454  store( i+SIMDSIZE*3UL, it.load() ); it += SIMDSIZE;
4455  }
4456  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4457  store( i, it.load() );
4458  }
4459  for( ; remainder && i<size_; ++i, ++it ) {
4460  v_[i] = *it;
4461  }
4462  }
4463 }
4465 //*************************************************************************************************
4466 
4467 
4468 //*************************************************************************************************
4480 template< typename Type // Data type of the vector
4481  , bool AF // Alignment flag
4482  , bool TF > // Transpose flag
4483 template< typename VT > // Type of the right-hand side sparse vector
4485 {
4486  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4487 
4488  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
4489  v_[element->index()] = element->value();
4490 }
4492 //*************************************************************************************************
4493 
4494 
4495 //*************************************************************************************************
4507 template< typename Type // Data type of the vector
4508  , bool AF // Alignment flag
4509  , bool TF > // Transpose flag
4510 template< typename VT > // Type of the right-hand side dense vector
4513 {
4514  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4515 
4516  const size_t ipos( size_ & size_t(-2) );
4517  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4518 
4519  for( size_t i=0UL; i<ipos; i+=2UL ) {
4520  v_[i ] += (~rhs)[i ];
4521  v_[i+1UL] += (~rhs)[i+1UL];
4522  }
4523  if( ipos < (~rhs).size() )
4524  v_[ipos] += (~rhs)[ipos];
4525 }
4527 //*************************************************************************************************
4528 
4529 
4530 //*************************************************************************************************
4542 template< typename Type // Data type of the vector
4543  , bool AF // Alignment flag
4544  , bool TF > // Transpose flag
4545 template< typename VT > // Type of the right-hand side dense vector
4548 {
4550 
4551  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4552 
4553  constexpr bool remainder( !IsPadded<VT>::value );
4554 
4555  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
4556  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4557 
4558  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4559  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4560  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4561 
4562  size_t i( 0UL );
4563  ConstIterator_<VT> it( (~rhs).begin() );
4564 
4565  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4566  store( i , load(i ) + it.load() ); it += SIMDSIZE;
4567  store( i+SIMDSIZE , load(i+SIMDSIZE ) + it.load() ); it += SIMDSIZE;
4568  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) + it.load() ); it += SIMDSIZE;
4569  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) + it.load() ); it += SIMDSIZE;
4570  }
4571  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4572  store( i, load(i) + it.load() );
4573  }
4574  for( ; remainder && i<size_; ++i, ++it ) {
4575  v_[i] += *it;
4576  }
4577 }
4579 //*************************************************************************************************
4580 
4581 
4582 //*************************************************************************************************
4594 template< typename Type // Data type of the vector
4595  , bool AF // Alignment flag
4596  , bool TF > // Transpose flag
4597 template< typename VT > // Type of the right-hand side sparse vector
4599 {
4600  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4601 
4602  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
4603  v_[element->index()] += element->value();
4604 }
4606 //*************************************************************************************************
4607 
4608 
4609 //*************************************************************************************************
4621 template< typename Type // Data type of the vector
4622  , bool AF // Alignment flag
4623  , bool TF > // Transpose flag
4624 template< typename VT > // Type of the right-hand side dense vector
4627 {
4628  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4629 
4630  const size_t ipos( size_ & size_t(-2) );
4631  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4632 
4633  for( size_t i=0UL; i<ipos; i+=2UL ) {
4634  v_[i ] -= (~rhs)[i ];
4635  v_[i+1UL] -= (~rhs)[i+1UL];
4636  }
4637  if( ipos < (~rhs).size() )
4638  v_[ipos] -= (~rhs)[ipos];
4639 }
4641 //*************************************************************************************************
4642 
4643 
4644 //*************************************************************************************************
4656 template< typename Type // Data type of the vector
4657  , bool AF // Alignment flag
4658  , bool TF > // Transpose flag
4659 template< typename VT > // Type of the right-hand side dense vector
4662 {
4664 
4665  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4666 
4667  constexpr bool remainder( !IsPadded<VT>::value );
4668 
4669  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
4670  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4671 
4672  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4673  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4674  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4675 
4676  size_t i( 0UL );
4677  ConstIterator_<VT> it( (~rhs).begin() );
4678 
4679  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4680  store( i , load(i ) - it.load() ); it += SIMDSIZE;
4681  store( i+SIMDSIZE , load(i+SIMDSIZE ) - it.load() ); it += SIMDSIZE;
4682  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) - it.load() ); it += SIMDSIZE;
4683  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) - it.load() ); it += SIMDSIZE;
4684  }
4685  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4686  store( i, load(i) - it.load() );
4687  }
4688  for( ; remainder && i<size_; ++i, ++it ) {
4689  v_[i] -= *it;
4690  }
4691 }
4693 //*************************************************************************************************
4694 
4695 
4696 //*************************************************************************************************
4708 template< typename Type // Data type of the vector
4709  , bool AF // Alignment flag
4710  , bool TF > // Transpose flag
4711 template< typename VT > // Type of the right-hand side sparse vector
4713 {
4714  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4715 
4716  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
4717  v_[element->index()] -= element->value();
4718 }
4720 //*************************************************************************************************
4721 
4722 
4723 //*************************************************************************************************
4735 template< typename Type // Data type of the vector
4736  , bool AF // Alignment flag
4737  , bool TF > // Transpose flag
4738 template< typename VT > // Type of the right-hand side dense vector
4741 {
4742  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4743 
4744  const size_t ipos( size_ & size_t(-2) );
4745  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4746 
4747  for( size_t i=0UL; i<ipos; i+=2UL ) {
4748  v_[i ] *= (~rhs)[i ];
4749  v_[i+1UL] *= (~rhs)[i+1UL];
4750  }
4751  if( ipos < (~rhs).size() )
4752  v_[ipos] *= (~rhs)[ipos];
4753 }
4755 //*************************************************************************************************
4756 
4757 
4758 //*************************************************************************************************
4770 template< typename Type // Data type of the vector
4771  , bool AF // Alignment flag
4772  , bool TF > // Transpose flag
4773 template< typename VT > // Type of the right-hand side dense vector
4776 {
4778 
4779  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4780 
4781  constexpr bool remainder( !IsPadded<VT>::value );
4782 
4783  const size_t ipos( ( remainder )?( size_ & size_t(-SIMDSIZE) ):( size_ ) );
4784  BLAZE_INTERNAL_ASSERT( !remainder || ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4785 
4786  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4787  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4788  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4789 
4790  size_t i( 0UL );
4791  ConstIterator_<VT> it( (~rhs).begin() );
4792 
4793  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4794  store( i , load(i ) * it.load() ); it += SIMDSIZE;
4795  store( i+SIMDSIZE , load(i+SIMDSIZE ) * it.load() ); it += SIMDSIZE;
4796  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) * it.load() ); it += SIMDSIZE;
4797  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) * it.load() ); it += SIMDSIZE;
4798  }
4799  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4800  store( i, load(i) * it.load() );
4801  }
4802  for( ; remainder && i<size_; ++i, ++it ) {
4803  v_[i] *= *it;
4804  }
4805 }
4807 //*************************************************************************************************
4808 
4809 
4810 //*************************************************************************************************
4822 template< typename Type // Data type of the vector
4823  , bool AF // Alignment flag
4824  , bool TF > // Transpose flag
4825 template< typename VT > // Type of the right-hand side sparse vector
4827 {
4828  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4829 
4830  const DynamicVector<Type,TF> tmp( serial( *this ) );
4831 
4832  reset();
4833 
4834  for( ConstIterator_<VT> element=(~rhs).begin(); element!=(~rhs).end(); ++element )
4835  v_[element->index()] = tmp[element->index()] * element->value();
4836 }
4838 //*************************************************************************************************
4839 
4840 
4841 //*************************************************************************************************
4853 template< typename Type // Data type of the vector
4854  , bool AF // Alignment flag
4855  , bool TF > // Transpose flag
4856 template< typename VT > // Type of the right-hand side dense vector
4859 {
4860  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4861 
4862  const size_t ipos( size_ & size_t(-2) );
4863  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % 2UL ) ) == ipos, "Invalid end calculation" );
4864 
4865  for( size_t i=0UL; i<ipos; i+=2UL ) {
4866  v_[i ] /= (~rhs)[i ];
4867  v_[i+1UL] /= (~rhs)[i+1UL];
4868  }
4869  if( ipos < (~rhs).size() )
4870  v_[ipos] /= (~rhs)[ipos];
4871 }
4873 //*************************************************************************************************
4874 
4875 
4876 //*************************************************************************************************
4888 template< typename Type // Data type of the vector
4889  , bool AF // Alignment flag
4890  , bool TF > // Transpose flag
4891 template< typename VT > // Type of the right-hand side dense vector
4894 {
4896 
4897  BLAZE_INTERNAL_ASSERT( size_ == (~rhs).size(), "Invalid vector sizes" );
4898 
4899  const size_t ipos( size_ & size_t(-SIMDSIZE) );
4900  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % SIMDSIZE ) ) == ipos, "Invalid end calculation" );
4901 
4902  const size_t i4way( size_ & size_t(-SIMDSIZE*4) );
4903  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (SIMDSIZE*4UL) ) ) == i4way, "Invalid end calculation" );
4904  BLAZE_INTERNAL_ASSERT( i4way <= ipos, "Invalid end calculation" );
4905 
4906  size_t i( 0UL );
4907  ConstIterator_<VT> it( (~rhs).begin() );
4908 
4909  for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4910  store( i , load(i ) / it.load() ); it += SIMDSIZE;
4911  store( i+SIMDSIZE , load(i+SIMDSIZE ) / it.load() ); it += SIMDSIZE;
4912  store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) / it.load() ); it += SIMDSIZE;
4913  store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) / it.load() ); it += SIMDSIZE;
4914  }
4915  for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4916  store( i, load(i) / it.load() );
4917  }
4918  for( ; i<size_; ++i, ++it ) {
4919  v_[i] /= *it;
4920  }
4921 }
4923 //*************************************************************************************************
4924 
4925 
4926 
4927 
4928 
4929 
4930 
4931 
4932 //=================================================================================================
4933 //
4934 // CUSTOMVECTOR OPERATORS
4935 //
4936 //=================================================================================================
4937 
4938 //*************************************************************************************************
4941 template< typename Type, bool AF, bool PF, bool TF >
4942 inline void reset( CustomVector<Type,AF,PF,TF>& v );
4943 
4944 template< typename Type, bool AF, bool PF, bool TF >
4945 inline void clear( CustomVector<Type,AF,PF,TF>& v );
4946 
4947 template< bool RF, typename Type, bool AF, bool PF, bool TF >
4948 inline bool isDefault( const CustomVector<Type,AF,PF,TF>& v );
4949 
4950 template< typename Type, bool AF, bool PF, bool TF >
4951 inline bool isIntact( const CustomVector<Type,AF,PF,TF>& v ) noexcept;
4952 
4953 template< typename Type, bool AF, bool PF, bool TF >
4954 inline void swap( CustomVector<Type,AF,PF,TF>& a, CustomVector<Type,AF,PF,TF>& b ) noexcept;
4956 //*************************************************************************************************
4957 
4958 
4959 //*************************************************************************************************
4966 template< typename Type // Data type of the vector
4967  , bool AF // Alignment flag
4968  , bool PF // Padding flag
4969  , bool TF > // Transpose flag
4971 {
4972  v.reset();
4973 }
4974 //*************************************************************************************************
4975 
4976 
4977 //*************************************************************************************************
4984 template< typename Type // Data type of the vector
4985  , bool AF // Alignment flag
4986  , bool PF // Padding flag
4987  , bool TF > // Transpose flag
4989 {
4990  v.clear();
4991 }
4992 //*************************************************************************************************
4993 
4994 
4995 //*************************************************************************************************
5023 template< bool RF // Relaxation flag
5024  , typename Type // Data type of the vector
5025  , bool AF // Alignment flag
5026  , bool PF // Padding flag
5027  , bool TF > // Transpose flag
5029 {
5030  return ( v.size() == 0UL );
5031 }
5032 //*************************************************************************************************
5033 
5034 
5035 //*************************************************************************************************
5056 template< typename Type // Data type of the vector
5057  , bool AF // Alignment flag
5058  , bool PF // Padding flag
5059  , bool TF > // Transpose flag
5060 inline bool isIntact( const CustomVector<Type,AF,PF,TF>& v ) noexcept
5061 {
5062  return ( v.size() <= v.capacity() );
5063 }
5064 //*************************************************************************************************
5065 
5066 
5067 //*************************************************************************************************
5075 template< typename Type // Data type of the vector
5076  , bool AF // Alignment flag
5077  , bool PF // Padding flag
5078  , bool TF > // Transpose flag
5080 {
5081  a.swap( b );
5082 }
5083 //*************************************************************************************************
5084 
5085 
5086 
5087 
5088 //=================================================================================================
5089 //
5090 // HASCONSTDATAACCESS SPECIALIZATIONS
5091 //
5092 //=================================================================================================
5093 
5094 //*************************************************************************************************
5096 template< typename T, bool AF, bool PF, bool TF >
5097 struct HasConstDataAccess< CustomVector<T,AF,PF,TF> >
5098  : public TrueType
5099 {};
5101 //*************************************************************************************************
5102 
5103 
5104 
5105 
5106 //=================================================================================================
5107 //
5108 // HASMUTABLEDATAACCESS SPECIALIZATIONS
5109 //
5110 //=================================================================================================
5111 
5112 //*************************************************************************************************
5114 template< typename T, bool AF, bool PF, bool TF >
5115 struct HasMutableDataAccess< CustomVector<T,AF,PF,TF> >
5116  : public TrueType
5117 {};
5119 //*************************************************************************************************
5120 
5121 
5122 
5123 
5124 //=================================================================================================
5125 //
5126 // ISCUSTOM SPECIALIZATIONS
5127 //
5128 //=================================================================================================
5129 
5130 //*************************************************************************************************
5132 template< typename T, bool AF, bool PF, bool TF >
5133 struct IsCustom< CustomVector<T,AF,PF,TF> >
5134  : public TrueType
5135 {};
5137 //*************************************************************************************************
5138 
5139 
5140 
5141 
5142 //=================================================================================================
5143 //
5144 // ISALIGNED SPECIALIZATIONS
5145 //
5146 //=================================================================================================
5147 
5148 //*************************************************************************************************
5150 template< typename T, bool PF, bool TF >
5151 struct IsAligned< CustomVector<T,aligned,PF,TF> >
5152  : public TrueType
5153 {};
5155 //*************************************************************************************************
5156 
5157 
5158 
5159 
5160 //=================================================================================================
5161 //
5162 // ISPADDED SPECIALIZATIONS
5163 //
5164 //=================================================================================================
5165 
5166 //*************************************************************************************************
5168 template< typename T, bool AF, bool TF >
5169 struct IsPadded< CustomVector<T,AF,padded,TF> >
5170  : public TrueType
5171 {};
5173 //*************************************************************************************************
5174 
5175 
5176 
5177 
5178 //=================================================================================================
5179 //
5180 // ADDTRAIT SPECIALIZATIONS
5181 //
5182 //=================================================================================================
5183 
5184 //*************************************************************************************************
5186 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5187 struct AddTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF> >
5188 {
5189  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
5190 };
5191 
5192 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5193 struct AddTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5194 {
5195  using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
5196 };
5197 
5198 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5199 struct AddTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5200 {
5201  using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
5202 };
5203 
5204 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5205 struct AddTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5206 {
5207  using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
5208 };
5209 
5210 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5211 struct AddTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5212 {
5213  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
5214 };
5215 
5216 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5217 struct AddTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5218 {
5219  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
5220 };
5221 
5222 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5223 struct AddTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5224 {
5225  using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
5226 };
5228 //*************************************************************************************************
5229 
5230 
5231 
5232 
5233 //=================================================================================================
5234 //
5235 // SUBTRAIT SPECIALIZATIONS
5236 //
5237 //=================================================================================================
5238 
5239 //*************************************************************************************************
5241 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5242 struct SubTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF> >
5243 {
5244  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
5245 };
5246 
5247 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5248 struct SubTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5249 {
5250  using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
5251 };
5252 
5253 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5254 struct SubTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5255 {
5256  using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
5257 };
5258 
5259 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5260 struct SubTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5261 {
5262  using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
5263 };
5264 
5265 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5266 struct SubTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5267 {
5268  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
5269 };
5270 
5271 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5272 struct SubTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5273 {
5274  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
5275 };
5276 
5277 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5278 struct SubTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5279 {
5280  using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
5281 };
5283 //*************************************************************************************************
5284 
5285 
5286 
5287 
5288 //=================================================================================================
5289 //
5290 // MULTTRAIT SPECIALIZATIONS
5291 //
5292 //=================================================================================================
5293 
5294 //*************************************************************************************************
5296 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5297 struct MultTrait< CustomVector<T1,AF,PF,TF>, T2, EnableIf_<IsNumeric<T2> > >
5298 {
5299  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5300 };
5301 
5302 template< typename T1, typename T2, bool AF, bool PF, bool TF >
5303 struct MultTrait< T1, CustomVector<T2,AF,PF,TF>, EnableIf_<IsNumeric<T1> > >
5304 {
5305  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5306 };
5307 
5308 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5309 struct MultTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF> >
5310 {
5311  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
5312 };
5313 
5314 template< typename T1, bool AF, bool PF, typename T2, size_t N >
5315 struct MultTrait< CustomVector<T1,AF,PF,false>, StaticVector<T2,N,true> >
5316 {
5317  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5318 };
5319 
5320 template< typename T1, bool AF, bool PF, typename T2, size_t N >
5321 struct MultTrait< CustomVector<T1,AF,PF,true>, StaticVector<T2,N,false> >
5322 {
5323  using Type = MultTrait_<T1,T2>;
5324 };
5325 
5326 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5327 struct MultTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5328 {
5329  using Type = StaticVector< MultTrait_<T1,T2>, N, TF >;
5330 };
5331 
5332 template< typename T1, size_t N, typename T2, bool AF, bool PF >
5333 struct MultTrait< StaticVector<T1,N,false>, CustomVector<T2,AF,PF,true> >
5334 {
5335  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5336 };
5337 
5338 template< typename T1, size_t N, typename T2, bool AF, bool PF >
5339 struct MultTrait< StaticVector<T1,N,true>, CustomVector<T2,AF,PF,false> >
5340 {
5341  using Type = MultTrait_<T1,T2>;
5342 };
5343 
5344 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5345 struct MultTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5346 {
5347  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
5348 };
5349 
5350 template< typename T1, bool AF, bool PF, typename T2, size_t N >
5351 struct MultTrait< CustomVector<T1,AF,PF,false>, HybridVector<T2,N,true> >
5352 {
5353  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5354 };
5355 
5356 template< typename T1, bool AF, bool PF, typename T2, size_t N >
5357 struct MultTrait< CustomVector<T1,AF,PF,true>, HybridVector<T2,N,false> >
5358 {
5359  using Type = MultTrait_<T1,T2>;
5360 };
5361 
5362 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5363 struct MultTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5364 {
5365  using Type = HybridVector< MultTrait_<T1,T2>, N, TF >;
5366 };
5367 
5368 template< typename T1, size_t N, typename T2, bool AF, bool PF >
5369 struct MultTrait< HybridVector<T1,N,false>, CustomVector<T2,AF,PF,true> >
5370 {
5371  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5372 };
5373 
5374 template< typename T1, size_t N, typename T2, bool AF, bool PF >
5375 struct MultTrait< HybridVector<T1,N,true>, CustomVector<T2,AF,PF,false> >
5376 {
5377  using Type = MultTrait_<T1,T2>;
5378 };
5379 
5380 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5381 struct MultTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5382 {
5383  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5384 };
5385 
5386 template< typename T1, bool AF, bool PF, typename T2 >
5387 struct MultTrait< CustomVector<T1,AF,PF,false>, DynamicVector<T2,true> >
5388 {
5389  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5390 };
5391 
5392 template< typename T1, bool AF, bool PF, typename T2 >
5393 struct MultTrait< CustomVector<T1,AF,PF,true>, DynamicVector<T2,false> >
5394 {
5395  using Type = MultTrait_<T1,T2>;
5396 };
5397 
5398 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5399 struct MultTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5400 {
5401  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5402 };
5403 
5404 template< typename T1, typename T2, bool AF, bool PF >
5405 struct MultTrait< DynamicVector<T1,false>, CustomVector<T2,AF,PF,true> >
5406 {
5407  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5408 };
5409 
5410 template< typename T1, typename T2, bool AF, bool PF >
5411 struct MultTrait< DynamicVector<T1,true>, CustomVector<T2,AF,PF,false> >
5412 {
5413  using Type = MultTrait_<T1,T2>;
5414 };
5415 
5416 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5417 struct MultTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5418 {
5419  using Type = DynamicVector< MultTrait_<T1,T2>, TF >;
5420 };
5421 
5422 template< typename T1, bool AF1, bool PF1, typename T2, bool AF2, bool PF2 >
5423 struct MultTrait< CustomVector<T1,AF1,PF1,false>, CustomVector<T2,AF2,PF2,true> >
5424 {
5425  using Type = DynamicMatrix< MultTrait_<T1,T2>, false >;
5426 };
5427 
5428 template< typename T1, bool AF1, bool PF1, typename T2, bool AF2, bool PF2 >
5429 struct MultTrait< CustomVector<T1,AF1,PF1,true>, CustomVector<T2,AF2,PF2,false> >
5430 {
5431  using Type = MultTrait_<T1,T2>;
5432 };
5434 //*************************************************************************************************
5435 
5436 
5437 
5438 
5439 //=================================================================================================
5440 //
5441 // DIVTRAIT SPECIALIZATIONS
5442 //
5443 //=================================================================================================
5444 
5445 //*************************************************************************************************
5447 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5448 struct DivTrait< CustomVector<T1,AF,PF,TF>, T2, EnableIf_<IsNumeric<T2> > >
5449 {
5450  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
5451 };
5452 
5453 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5454 struct DivTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF> >
5455 {
5456  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
5457 };
5458 
5459 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5460 struct DivTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5461 {
5462  using Type = StaticVector< DivTrait_<T1,T2>, N, TF >;
5463 };
5464 
5465 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5466 struct DivTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5467 {
5468  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
5469 };
5470 
5471 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5472 struct DivTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5473 {
5474  using Type = HybridVector< DivTrait_<T1,T2>, N, TF >;
5475 };
5476 
5477 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5478 struct DivTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5479 {
5480  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
5481 };
5482 
5483 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5484 struct DivTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5485 {
5486  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
5487 };
5488 
5489 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5490 struct DivTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5491 {
5492  using Type = DynamicVector< DivTrait_<T1,T2>, TF >;
5493 };
5495 //*************************************************************************************************
5496 
5497 
5498 
5499 
5500 //=================================================================================================
5501 //
5502 // CROSSTRAIT SPECIALIZATIONS
5503 //
5504 //=================================================================================================
5505 
5506 //*************************************************************************************************
5508 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5509 struct CrossTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,3UL,TF> >
5510 {
5511  private:
5512  using T = MultTrait_<T1,T2>;
5513 
5514  public:
5515  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5516 };
5517 
5518 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5519 struct CrossTrait< StaticVector<T1,3UL,TF>, CustomVector<T2,AF,PF,TF> >
5520 {
5521  private:
5522  using T = MultTrait_<T1,T2>;
5523 
5524  public:
5525  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5526 };
5527 
5528 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N >
5529 struct CrossTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF> >
5530 {
5531  private:
5532  using T = MultTrait_<T1,T2>;
5533 
5534  public:
5535  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5536 };
5537 
5538 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF >
5539 struct CrossTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF> >
5540 {
5541  private:
5542  using T = MultTrait_<T1,T2>;
5543 
5544  public:
5545  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5546 };
5547 
5548 template< typename T1, bool AF, bool PF, bool TF, typename T2 >
5549 struct CrossTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF> >
5550 {
5551  private:
5552  using T = MultTrait_<T1,T2>;
5553 
5554  public:
5555  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5556 };
5557 
5558 template< typename T1, bool TF, typename T2, bool AF, bool PF >
5559 struct CrossTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
5560 {
5561  private:
5562  using T = MultTrait_<T1,T2>;
5563 
5564  public:
5565  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5566 };
5567 
5568 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2 >
5569 struct CrossTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF> >
5570 {
5571  private:
5572  using T = MultTrait_<T1,T2>;
5573 
5574  public:
5575  using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
5576 };
5578 //*************************************************************************************************
5579 
5580 
5581 
5582 
5583 //=================================================================================================
5584 //
5585 // UNARYMAPTRAIT SPECIALIZATIONS
5586 //
5587 //=================================================================================================
5588 
5589 //*************************************************************************************************
5591 template< typename T, bool AF, bool PF, bool TF, typename OP >
5592 struct UnaryMapTrait< CustomVector<T,AF,PF,TF>, OP >
5593 {
5594  using Type = DynamicVector< UnaryMapTrait_<T,OP>, TF >;
5595 };
5597 //*************************************************************************************************
5598 
5599 
5600 
5601 
5602 //=================================================================================================
5603 //
5604 // BINARYMAPTRAIT SPECIALIZATIONS
5605 //
5606 //=================================================================================================
5607 
5608 //*************************************************************************************************
5610 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N, typename OP >
5611 struct BinaryMapTrait< CustomVector<T1,AF,PF,TF>, StaticVector<T2,N,TF>, OP >
5612 {
5613  using Type = StaticVector< BinaryMapTrait_<T1,T2,OP>, N, TF >;
5614 };
5615 
5616 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF, typename OP >
5617 struct BinaryMapTrait< StaticVector<T1,N,TF>, CustomVector<T2,AF,PF,TF>, OP >
5618 {
5619  using Type = StaticVector< BinaryMapTrait_<T1,T2,OP>, N, TF >;
5620 };
5621 
5622 template< typename T1, bool AF, bool PF, bool TF, typename T2, size_t N, typename OP >
5623 struct BinaryMapTrait< CustomVector<T1,AF,PF,TF>, HybridVector<T2,N,TF>, OP >
5624 {
5625  using Type = HybridVector< BinaryMapTrait_<T1,T2,OP>, N, TF >;
5626 };
5627 
5628 template< typename T1, size_t N, bool TF, typename T2, bool AF, bool PF, typename OP >
5629 struct BinaryMapTrait< HybridVector<T1,N,TF>, CustomVector<T2,AF,PF,TF>, OP >
5630 {
5631  using Type = HybridVector< BinaryMapTrait_<T1,T2,OP>, N, TF >;
5632 };
5633 
5634 template< typename T1, bool AF, bool PF, bool TF, typename T2, typename OP >
5635 struct BinaryMapTrait< CustomVector<T1,AF,PF,TF>, DynamicVector<T2,TF>, OP >
5636 {
5637  using Type = DynamicVector< BinaryMapTrait_<T1,T2,OP>, TF >;
5638 };
5639 
5640 template< typename T1, bool TF, typename T2, bool AF, bool PF, typename OP >
5641 struct BinaryMapTrait< DynamicVector<T1,TF>, CustomVector<T2,AF,PF,TF>, OP >
5642 {
5643  using Type = DynamicVector< BinaryMapTrait_<T1,T2,OP>, TF >;
5644 };
5645 
5646 template< typename T1, bool AF1, bool PF1, bool TF, typename T2, bool AF2, bool PF2, typename OP >
5647 struct BinaryMapTrait< CustomVector<T1,AF1,PF1,TF>, CustomVector<T2,AF2,PF2,TF>, OP >
5648 {
5649  using Type = DynamicVector< BinaryMapTrait_<T1,T2,OP>, TF >;
5650 };
5652 //*************************************************************************************************
5653 
5654 
5655 
5656 
5657 //=================================================================================================
5658 //
5659 // SUBVECTORTRAIT SPECIALIZATIONS
5660 //
5661 //=================================================================================================
5662 
5663 //*************************************************************************************************
5665 template< typename T, bool AF, bool PF, bool TF >
5666 struct SubvectorTrait< CustomVector<T,AF,PF,TF> >
5667 {
5668  using Type = DynamicVector<T,TF>;
5669 };
5671 //*************************************************************************************************
5672 
5673 } // namespace blaze
5674 
5675 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:135
Constraint on the data type.
#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:171
Header file for mathematical functions.
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
const Type & ConstReference
Reference to a constant vector value.
Definition: CustomVector.h:417
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:716
Iterator begin() noexcept
Returns an iterator to the first element of the custom vector.
Definition: CustomVector.h:986
Header file for basic type definitions.
Header file for the SparseVector base class.
size_t size_
The size/dimension of the custom vector.
Definition: CustomVector.h:680
Type * v_
The custom array of elements.
Definition: CustomVector.h:681
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:164
Header file for the serial shim.
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:1411
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: CustomVector.h:1903
Iterator end() noexcept
Returns an iterator just past the last element of the custom vector.
Definition: CustomVector.h:1037
void swap(CustomVector &v) noexcept
Swapping the contents of two vectors.
Definition: CustomVector.h:1660
CustomVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition: CustomVector.h:1096
Availability of a SIMD multiplication for the given data types.Depending on the available instruction...
Definition: HasSIMDMult.h:172
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:316
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:224
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:171
#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
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:250
Efficient implementation of an arbitrary sized vector.The DynamicVector class template is the represe...
Definition: DynamicVector.h:183
System settings for performance optimizations.
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:212
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:1393
Compile time check for data types.This type trait tests whether or not the given types can be combine...
Definition: IsSIMDCombinable.h:120
SIMDTrait_< ElementType > SIMDType
SIMD type of the vector elements.
Definition: CustomVector.h:412
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:2056
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
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:133
Header file for the implementation of an arbitrarily sized vector.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CustomVector.h:413
Constraint on the data type.
Base template for the CrossTrait class.
Definition: CrossTrait.h:116
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:3289
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:1965
Header file for the DisableIf class template.
size_t size() const noexcept
Returns the size/dimension of the vector.
Definition: CustomVector.h:1544
Header file for the IsCustom type trait.
Header file for the multiplication trait.
Header file for the unary map 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:5924
Compile time assertion.
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:102
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:2088
#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:1642
DenseIterator< const Type, AF > ConstIterator
Iterator over constant elements.
Definition: CustomVector.h:422
Header file for the subvector trait.
const Type * ConstPointer
Pointer to a constant vector value.
Definition: CustomVector.h:419
Header file for all SIMD functionality.
Constraint on the data type.
Availability of a SIMD division for the given data types.Depending on the available instruction set (...
Definition: HasSIMDDiv.h:150
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:103
Constraint on the data type.
Efficient implementation of a customizable vector.
Definition: CustomVector.h:397
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:87
void reset()
Reset to the default initial values.
Definition: CustomVector.h:1621
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the custom vector.
Definition: CustomVector.h:1020
#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
Type & Reference
Reference to a non-constant vector value.
Definition: CustomVector.h:416
Constraint on the data type.
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: CustomVector.h:2023
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:1071
Compile time check for data types.This type trait tests whether or not the given template parameter i...
Definition: IsSMPAssignable.h:119
typename CrossTrait< T1, T2 >::Type CrossTrait_
Auxiliary alias declaration for the CrossTrait class template.The CrossTrait_ alias declaration provi...
Definition: CrossTrait.h:159
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:580
Header file for the IsPadded type trait.
typename DivTrait< T1, T2 >::Type DivTrait_
Auxiliary alias declaration for the DivTrait class template.The DivTrait_ alias declaration provides ...
Definition: DivTrait.h:250
Header file for the IsVectorizable type trait.
Resize mechanism to obtain a CustomVector with a different fixed number of elements.
Definition: CustomVector.h:438
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: CustomVector.h:1879
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
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 RemoveConst type trait.
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:1579
Header file for the HasSIMDMult type trait.
Header file for the binary map trait.
Rebind mechanism to obtain a CustomVector with different data/element type.
Definition: CustomVector.h:429
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:1357
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:139
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: CustomVector.h:950
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: CustomVector.h:1838
Base template for the MultTrait class.
Definition: MultTrait.h:139
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
size_t spacing() const noexcept
Returns the minimum capacity of the vector.
Definition: CustomVector.h:1563
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:903
Header file for the isDefault shim.
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: CustomVector.h:1996
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:1858
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:819
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:1816
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: CustomVector.h:858
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
Base template for the DivTrait class.
Definition: DivTrait.h:139
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:1931
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
Type * Pointer
Pointer to a non-constant vector value.
Definition: CustomVector.h:418
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:177
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:130
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:252
Type ElementType
Type of the vector elements.
Definition: CustomVector.h:411
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
Base template for the SubTrait class.
Definition: SubTrait.h:139
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:1375
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
DenseIterator< Type, AF > Iterator
Iterator over non-constant elements.
Definition: CustomVector.h:421
Base template for the BinaryMapTrait class.
Definition: BinaryMapTrait.h:119
Base template for the UnaryMapTrait class.
Definition: UnaryMapTrait.h:117
System settings for the inline keywords.
#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.
constexpr bool padded
Padding flag for padded vectors and matrices.Via this flag it is possible to specify custom vectors a...
Definition: PaddingFlag.h:86
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: CustomVector.h:1598
#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.