All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseSubvector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_DENSESUBVECTOR_H_
36 #define _BLAZE_MATH_VIEWS_DENSESUBVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <stdexcept>
57 #include <blaze/math/Intrinsics.h>
58 #include <blaze/math/shims/Clear.h>
66 #include <blaze/system/CacheSize.h>
67 #include <blaze/system/Streaming.h>
70 #include <blaze/util/Assert.h>
72 #include <blaze/util/DisableIf.h>
73 #include <blaze/util/EnableIf.h>
75 #include <blaze/util/mpl/Or.h>
76 #include <blaze/util/SelectType.h>
77 #include <blaze/util/Template.h>
78 #include <blaze/util/Types.h>
82 
83 
84 namespace blaze {
85 
86 //=================================================================================================
87 //
88 // CLASS DEFINITION
89 //
90 //=================================================================================================
91 
92 //*************************************************************************************************
373 template< typename VT // Type of the dense vector
374  , bool AF = unaligned // Alignment flag
375  , bool TF = IsRowVector<VT>::value > // Transpose flag
376 class DenseSubvector : public DenseVector< DenseSubvector<VT,AF,TF>, TF >
377  , private Subvector
378 {
379  private:
380  //**Type definitions****************************************************************************
382  typedef typename SelectType< IsExpression<VT>::value, VT, VT& >::Type Operand;
383 
386  //**********************************************************************************************
387 
388  //**********************************************************************************************
390 
396  enum { useConst = IsConst<VT>::value };
397  //**********************************************************************************************
398 
399  public:
400  //**Type definitions****************************************************************************
404  typedef typename VT::ElementType ElementType;
405  typedef typename IT::Type IntrinsicType;
406  typedef typename VT::ReturnType ReturnType;
407  typedef const DenseSubvector& CompositeType;
408 
411 
414 
416  typedef const ElementType* ConstPointer;
417 
420  //**********************************************************************************************
421 
422  //**SubvectorIterator class definition**********************************************************
425  template< typename IteratorType > // Type of the dense vector iterator
427  {
428  public:
429  //**Type definitions*************************************************************************
431  typedef typename std::iterator_traits<IteratorType>::iterator_category IteratorCategory;
432 
434  typedef typename std::iterator_traits<IteratorType>::value_type ValueType;
435 
437  typedef typename std::iterator_traits<IteratorType>::pointer PointerType;
438 
440  typedef typename std::iterator_traits<IteratorType>::reference ReferenceType;
441 
443  typedef typename std::iterator_traits<IteratorType>::difference_type DifferenceType;
444 
445  // STL iterator requirements
451  //*******************************************************************************************
452 
453  //**Constructor******************************************************************************
457  : iterator_ ( ) // Iterator to the current subvector element
458  , final_ ( 0UL ) // The final iterator for intrinsic operations
459  , rest_ ( 0UL ) // The number of remaining elements beyond the final iterator
460  , isAligned_( false ) // Memory alignment flag
461  {}
462  //*******************************************************************************************
463 
464  //**Constructor******************************************************************************
472  inline SubvectorIterator( IteratorType iterator, IteratorType finalIterator,
473  size_t remainingElements, bool isMemoryAligned )
474  : iterator_ ( iterator ) // Iterator to the current subvector element
475  , final_ ( finalIterator ) // The final iterator for intrinsic operations
476  , rest_ ( remainingElements ) // The number of remaining elements beyond the final iterator
477  , isAligned_( isMemoryAligned ) // Memory alignment flag
478  {}
479  //*******************************************************************************************
480 
481  //**Constructor******************************************************************************
486  template< typename IteratorType2 >
488  : iterator_ ( it.base() ) // Iterator to the current subvector element
489  , final_ ( it.final() ) // The final iterator for intrinsic operations
490  , rest_ ( it.rest() ) // The number of remaining elements beyond the final iterator
491  , isAligned_( it.isAligned() ) // Memory alignment flag
492  {}
493  //*******************************************************************************************
494 
495  //**Addition assignment operator*************************************************************
501  inline SubvectorIterator& operator+=( size_t inc ) {
502  iterator_ += inc;
503  return *this;
504  }
505  //*******************************************************************************************
506 
507  //**Subtraction assignment operator**********************************************************
513  inline SubvectorIterator& operator-=( size_t dec ) {
514  iterator_ -= dec;
515  return *this;
516  }
517  //*******************************************************************************************
518 
519  //**Prefix increment operator****************************************************************
525  ++iterator_;
526  return *this;
527  }
528  //*******************************************************************************************
529 
530  //**Postfix increment operator***************************************************************
535  inline const SubvectorIterator operator++( int ) {
537  }
538  //*******************************************************************************************
539 
540  //**Prefix decrement operator****************************************************************
546  --iterator_;
547  return *this;
548  }
549  //*******************************************************************************************
550 
551  //**Postfix decrement operator***************************************************************
556  inline const SubvectorIterator operator--( int ) {
558  }
559  //*******************************************************************************************
560 
561  //**Element access operator******************************************************************
566  inline ReferenceType operator*() const {
567  return *iterator_;
568  }
569  //*******************************************************************************************
570 
571  //**Load function****************************************************************************
581  inline IntrinsicType load() const {
582  return loadu();
583  }
584  //*******************************************************************************************
585 
586  //**Loadu function***************************************************************************
596  inline IntrinsicType loadu() const {
597  if( isAligned_ ) {
598  return iterator_.load();
599  }
600  else if( iterator_ != final_ ) {
601  return iterator_.loadu();
602  }
603  else {
605  for( size_t i=0UL; i<rest_; ++i )
606  array[i] = *(iterator_+i);
607  for( size_t i=rest_; i<IT::size; ++i )
608  array[i] = ElementType();
609  return blaze::load( array.data() );
610  }
611  }
612  //*******************************************************************************************
613 
614  //**Equality operator************************************************************************
620  inline bool operator==( const SubvectorIterator& rhs ) const {
621  return iterator_ == rhs.iterator_;
622  }
623  //*******************************************************************************************
624 
625  //**Inequality operator**********************************************************************
631  inline bool operator!=( const SubvectorIterator& rhs ) const {
632  return iterator_ != rhs.iterator_;
633  }
634  //*******************************************************************************************
635 
636  //**Less-than operator***********************************************************************
642  inline bool operator<( const SubvectorIterator& rhs ) const {
643  return iterator_ < rhs.iterator_;
644  }
645  //*******************************************************************************************
646 
647  //**Greater-than operator********************************************************************
653  inline bool operator>( const SubvectorIterator& rhs ) const {
654  return iterator_ > rhs.iterator_;
655  }
656  //*******************************************************************************************
657 
658  //**Less-or-equal-than operator**************************************************************
664  inline bool operator<=( const SubvectorIterator& rhs ) const {
665  return iterator_ <= rhs.iterator_;
666  }
667  //*******************************************************************************************
668 
669  //**Greater-or-equal-than operator***********************************************************
675  inline bool operator>=( const SubvectorIterator& rhs ) const {
676  return iterator_ >= rhs.iterator_;
677  }
678  //*******************************************************************************************
679 
680  //**Subtraction operator*********************************************************************
686  inline DifferenceType operator-( const SubvectorIterator& rhs ) const {
687  return iterator_ - rhs.iterator_;
688  }
689  //*******************************************************************************************
690 
691  //**Addition operator************************************************************************
698  friend inline const SubvectorIterator operator+( const SubvectorIterator& it, size_t inc ) {
699  return SubvectorIterator( it.iterator_ + inc, it.final_, it.rest_, it.isAligned_ );
700  }
701  //*******************************************************************************************
702 
703  //**Addition operator************************************************************************
710  friend inline const SubvectorIterator operator+( size_t inc, const SubvectorIterator& it ) {
711  return SubvectorIterator( it.iterator_ + inc, it.final_, it.rest_, it.isAligned_ );
712  }
713  //*******************************************************************************************
714 
715  //**Subtraction operator*********************************************************************
722  friend inline const SubvectorIterator operator-( const SubvectorIterator& it, size_t dec ) {
723  return SubvectorIterator( it.iterator_ - dec, it.final_, it.rest_, it.isAligned_ );
724  }
725  //*******************************************************************************************
726 
727  //**Base function****************************************************************************
732  inline IteratorType base() const {
733  return iterator_;
734  }
735  //*******************************************************************************************
736 
737  //**Final function***************************************************************************
742  inline IteratorType final() const {
743  return final_;
744  }
745  //*******************************************************************************************
746 
747  //**Rest function****************************************************************************
752  inline size_t rest() const {
753  return rest_;
754  }
755  //*******************************************************************************************
756 
757  //**IsAligned function***********************************************************************
762  inline bool isAligned() const {
763  return isAligned_;
764  }
765  //*******************************************************************************************
766 
767  private:
768  //**Member variables*************************************************************************
769  IteratorType iterator_;
770  IteratorType final_;
771  size_t rest_;
772  bool isAligned_;
773  //*******************************************************************************************
774  };
775  //**********************************************************************************************
776 
777  //**Type definitions****************************************************************************
780 
783  //**********************************************************************************************
784 
785  //**Compilation flags***************************************************************************
787  enum { vectorizable = VT::vectorizable };
788 
790  enum { smpAssignable = VT::smpAssignable };
791  //**********************************************************************************************
792 
793  //**Constructors********************************************************************************
796  explicit inline DenseSubvector( Operand vector, size_t index, size_t n );
797  // No explicitly declared copy constructor.
799  //**********************************************************************************************
800 
801  //**Destructor**********************************************************************************
802  // No explicitly declared destructor.
803  //**********************************************************************************************
804 
805  //**Data access functions***********************************************************************
808  inline Reference operator[]( size_t index );
809  inline ConstReference operator[]( size_t index ) const;
810  inline Pointer data ();
811  inline ConstPointer data () const;
812  inline Iterator begin ();
813  inline ConstIterator begin () const;
814  inline ConstIterator cbegin() const;
815  inline Iterator end ();
816  inline ConstIterator end () const;
817  inline ConstIterator cend () const;
819  //**********************************************************************************************
820 
821  //**Assignment operators************************************************************************
824  inline DenseSubvector& operator= ( const ElementType& rhs );
825  inline DenseSubvector& operator= ( const DenseSubvector& rhs );
826  template< typename VT2 > inline DenseSubvector& operator= ( const Vector<VT2,TF>& rhs );
827  template< typename VT2 > inline DenseSubvector& operator+=( const Vector<VT2,TF>& rhs );
828  template< typename VT2 > inline DenseSubvector& operator-=( const Vector<VT2,TF>& rhs );
829  template< typename VT2 > inline DenseSubvector& operator*=( const Vector<VT2,TF>& rhs );
830 
831  template< typename Other >
832  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
833  operator*=( Other rhs );
834 
835  template< typename Other >
836  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
837  operator/=( Other rhs );
839  //**********************************************************************************************
840 
841  //**Utility functions***************************************************************************
844  inline size_t size() const;
845  inline size_t capacity() const;
846  inline size_t nonZeros() const;
847  inline void reset();
848  template< typename Other > inline DenseSubvector& scale( const Other& scalar );
850  //**********************************************************************************************
851 
852  private:
853  //**********************************************************************************************
855  template< typename VT2 >
857  struct VectorizedAssign {
858  enum { value = vectorizable && VT2::vectorizable &&
859  IsSame<ElementType,typename VT2::ElementType>::value };
860  };
862  //**********************************************************************************************
863 
864  //**********************************************************************************************
866  template< typename VT2 >
868  struct VectorizedAddAssign {
869  enum { value = vectorizable && VT2::vectorizable &&
870  IsSame<ElementType,typename VT2::ElementType>::value &&
871  IntrinsicTrait<ElementType>::addition };
872  };
874  //**********************************************************************************************
875 
876  //**********************************************************************************************
878  template< typename VT2 >
880  struct VectorizedSubAssign {
881  enum { value = vectorizable && VT2::vectorizable &&
882  IsSame<ElementType,typename VT2::ElementType>::value &&
883  IntrinsicTrait<ElementType>::subtraction };
884  };
886  //**********************************************************************************************
887 
888  //**********************************************************************************************
890  template< typename VT2 >
892  struct VectorizedMultAssign {
893  enum { value = vectorizable && VT2::vectorizable &&
894  IsSame<ElementType,typename VT2::ElementType>::value &&
895  IntrinsicTrait<ElementType>::multiplication };
896  };
898  //**********************************************************************************************
899 
900  public:
901  //**Expression template evaluation functions****************************************************
904  template< typename Other >
905  inline bool canAlias( const Other* alias ) const;
906 
907  template< typename VT2, bool AF2, bool TF2 >
908  inline bool canAlias( const DenseSubvector<VT2,AF2,TF2>* alias ) const;
909 
910  template< typename Other >
911  inline bool isAliased( const Other* alias ) const;
912 
913  template< typename VT2, bool AF2, bool TF2 >
914  inline bool isAliased( const DenseSubvector<VT2,AF2,TF2>* alias ) const;
915 
916  inline bool isAligned () const;
917  inline bool canSMPAssign() const;
918 
919  inline IntrinsicType load ( size_t index ) const;
920  inline IntrinsicType loadu ( size_t index ) const;
921  inline void store ( size_t index, const IntrinsicType& value );
922  inline void storeu( size_t index, const IntrinsicType& value );
923  inline void stream( size_t index, const IntrinsicType& value );
924 
925  template< typename VT2 >
926  inline typename DisableIf< VectorizedAssign<VT2> >::Type
927  assign( const DenseVector <VT2,TF>& rhs );
928 
929  template< typename VT2 >
930  inline typename EnableIf< VectorizedAssign<VT2> >::Type
931  assign( const DenseVector <VT2,TF>& rhs );
932 
933  template< typename VT2 > inline void assign( const SparseVector<VT2,TF>& rhs );
934 
935  template< typename VT2 >
936  inline typename DisableIf< VectorizedAddAssign<VT2> >::Type
937  addAssign( const DenseVector <VT2,TF>& rhs );
938 
939  template< typename VT2 >
940  inline typename EnableIf< VectorizedAddAssign<VT2> >::Type
941  addAssign ( const DenseVector <VT2,TF>& rhs );
942 
943  template< typename VT2 > inline void addAssign( const SparseVector<VT2,TF>& rhs );
944 
945  template< typename VT2 >
946  inline typename DisableIf< VectorizedSubAssign<VT2> >::Type
947  subAssign ( const DenseVector <VT2,TF>& rhs );
948 
949  template< typename VT2 >
950  inline typename EnableIf< VectorizedSubAssign<VT2> >::Type
951  subAssign( const DenseVector <VT2,TF>& rhs );
952 
953  template< typename VT2 > inline void subAssign( const SparseVector<VT2,TF>& rhs );
954 
955  template< typename VT2 >
956  inline typename DisableIf< VectorizedMultAssign<VT2> >::Type
957  multAssign( const DenseVector <VT2,TF>& rhs );
958 
959  template< typename VT2 >
960  inline typename EnableIf< VectorizedMultAssign<VT2> >::Type
961  multAssign( const DenseVector <VT2,TF>& rhs );
962 
963  template< typename VT2 > inline void multAssign( const SparseVector<VT2,TF>& rhs );
965  //**********************************************************************************************
966 
967  private:
968  //**Member variables****************************************************************************
972  const size_t offset_;
973  const size_t size_;
974  const size_t rest_;
975  const size_t final_;
976 
980  const bool isAligned_;
981 
991  //**********************************************************************************************
992 
993  //**Friend declarations*************************************************************************
995  template< typename VT2, bool AF2, bool TF2 > friend class DenseSubvector;
996 
997  template< bool AF1, typename VT2, bool AF2, bool TF2 >
998  friend const DenseSubvector<VT2,AF1,TF2>
999  subvector( const DenseSubvector<VT2,AF2,TF2>& dv, size_t index, size_t size );
1000 
1001  template< typename VT2, bool AF2, bool TF2 >
1002  friend bool isSame( const DenseSubvector<VT2,AF2,TF2>& a, const DenseVector<VT2,TF2>& b );
1003 
1004  template< typename VT2, bool AF2, bool TF2 >
1005  friend bool isSame( const DenseVector<VT2,TF2>& a, const DenseSubvector<VT2,AF2,TF2>& b );
1006 
1007  template< typename VT2, bool AF2, bool TF2 >
1008  friend bool isSame( const DenseSubvector<VT2,AF2,TF2>& a, const DenseSubvector<VT2,AF2,TF2>& b );
1010  //**********************************************************************************************
1011 
1012  //**Compile time checks*************************************************************************
1020  //**********************************************************************************************
1021 };
1022 //*************************************************************************************************
1023 
1024 
1025 
1026 
1027 //=================================================================================================
1028 //
1029 // CONSTRUCTOR
1030 //
1031 //=================================================================================================
1032 
1033 //*************************************************************************************************
1045 template< typename VT // Type of the dense vector
1046  , bool AF // Alignment flag
1047  , bool TF > // Transpose flag
1048 inline DenseSubvector<VT,AF,TF>::DenseSubvector( Operand vector, size_t index, size_t n )
1049  : vector_ ( vector ) // The vector containing the subvector
1050  , offset_ ( index ) // The offset of the subvector within the dense vector
1051  , size_ ( n ) // The size of the subvector
1052  , rest_ ( n % IT::size ) // The number of remaining elements in an unaligned intrinsic operation
1053  , final_ ( n - rest_ ) // The final index for unaligned intrinsic operations
1054  , isAligned_( ( index % IT::size == 0UL ) &&
1055  ( index + n == vector.size() || n % IT::size == 0UL ) )
1056 {
1057  if( index + n > vector.size() )
1058  throw std::invalid_argument( "Invalid subvector specification" );
1059 }
1060 //*************************************************************************************************
1061 
1062 
1063 
1064 
1065 //=================================================================================================
1066 //
1067 // DATA ACCESS FUNCTIONS
1068 //
1069 //=================================================================================================
1070 
1071 //*************************************************************************************************
1077 template< typename VT // Type of the dense vector
1078  , bool AF // Alignment flag
1079  , bool TF > // Transpose flag
1082 {
1083  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
1084  return vector_[offset_+index];
1085 }
1086 //*************************************************************************************************
1087 
1088 
1089 //*************************************************************************************************
1095 template< typename VT // Type of the dense vector
1096  , bool AF // Alignment flag
1097  , bool TF > // Transpose flag
1100 {
1101  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
1102  return const_cast<const VT&>( vector_ )[offset_+index];
1103 }
1104 //*************************************************************************************************
1105 
1106 
1107 //*************************************************************************************************
1114 template< typename VT // Type of the dense vector
1115  , bool AF // Alignment flag
1116  , bool TF > // Transpose flag
1118 {
1119  return vector_.data() + offset_;
1120 }
1121 //*************************************************************************************************
1122 
1123 
1124 //*************************************************************************************************
1131 template< typename VT // Type of the dense vector
1132  , bool AF // Alignment flag
1133  , bool TF > // Transpose flag
1135 {
1136  return vector_.data() + offset_;
1137 }
1138 //*************************************************************************************************
1139 
1140 
1141 //*************************************************************************************************
1148 template< typename VT // Type of the dense vector
1149  , bool AF // Alignment flag
1150  , bool TF > // Transpose flag
1152 {
1153  const typename VT::Iterator first( vector_.begin() + offset_ );
1154  return Iterator( first, first + final_, rest_, isAligned_ );
1155 }
1156 //*************************************************************************************************
1157 
1158 
1159 //*************************************************************************************************
1166 template< typename VT // Type of the dense vector
1167  , bool AF // Alignment flag
1168  , bool TF > // Transpose flag
1170 {
1171  const typename VT::ConstIterator first( vector_.cbegin() + offset_ );
1172  return ConstIterator( first, first + final_, rest_, isAligned_ );
1173 }
1174 //*************************************************************************************************
1175 
1176 
1177 //*************************************************************************************************
1184 template< typename VT // Type of the dense vector
1185  , bool AF // Alignment flag
1186  , bool TF > // Transpose flag
1188 {
1189  const typename VT::ConstIterator first( vector_.cbegin() + offset_ );
1190  return ConstIterator( first, first + final_, rest_, isAligned_ );
1191 }
1192 //*************************************************************************************************
1193 
1194 
1195 //*************************************************************************************************
1202 template< typename VT // Type of the dense vector
1203  , bool AF // Alignment flag
1204  , bool TF > // Transpose flag
1206 {
1207  const typename VT::Iterator last( vector_.begin() + offset_ + size_ );
1208  return Iterator( last, last, rest_, isAligned_ );
1209 }
1210 //*************************************************************************************************
1211 
1212 
1213 //*************************************************************************************************
1220 template< typename VT // Type of the dense vector
1221  , bool AF // Alignment flag
1222  , bool TF > // Transpose flag
1224 {
1225  const typename VT::ConstIterator last( vector_.cbegin() + offset_ + size_ );
1226  return ConstIterator( last, last, rest_, isAligned_ );
1227 }
1228 //*************************************************************************************************
1229 
1230 
1231 //*************************************************************************************************
1238 template< typename VT // Type of the dense vector
1239  , bool AF // Alignment flag
1240  , bool TF > // Transpose flag
1242 {
1243  const typename VT::ConstIterator last( vector_.cbegin() + offset_ + size_ );
1244  return ConstIterator( last, last, rest_, isAligned_ );
1245 }
1246 //*************************************************************************************************
1247 
1248 
1249 
1250 
1251 //=================================================================================================
1252 //
1253 // ASSIGNMENT OPERATORS
1254 //
1255 //=================================================================================================
1256 
1257 //*************************************************************************************************
1263 template< typename VT // Type of the dense vector
1264  , bool AF // Alignment flag
1265  , bool TF > // Transpose flag
1267 {
1268  const size_t iend( offset_ + size_ );
1269 
1270  for( size_t i=offset_; i<iend; ++i )
1271  vector_[i] = rhs;
1272 
1273  return *this;
1274 }
1275 //*************************************************************************************************
1276 
1277 
1278 //*************************************************************************************************
1288 template< typename VT // Type of the dense vector
1289  , bool AF // Alignment flag
1290  , bool TF > // Transpose flag
1292 {
1295 
1296  if( &rhs == this || ( &vector_ == &rhs.vector_ && offset_ == rhs.offset_ ) )
1297  return *this;
1298 
1299  if( size() != rhs.size() )
1300  throw std::invalid_argument( "Subvector sizes do not match" );
1301 
1302  if( rhs.canAlias( &vector_ ) ) {
1303  const ResultType tmp( ~rhs );
1304  smpAssign( *this, tmp );
1305  }
1306  else {
1307  smpAssign( *this, rhs );
1308  }
1309 
1310  return *this;
1311 }
1312 //*************************************************************************************************
1313 
1314 
1315 //*************************************************************************************************
1325 template< typename VT // Type of the dense vector
1326  , bool AF // Alignment flag
1327  , bool TF > // Transpose flag
1328 template< typename VT2 > // Type of the right-hand side vector
1330 {
1333 
1334  if( size() != (~rhs).size() )
1335  throw std::invalid_argument( "Vector sizes do not match" );
1336 
1337  if( (~rhs).canAlias( &vector_ ) ) {
1338  const typename VT2::ResultType tmp( ~rhs );
1339  smpAssign( *this, tmp );
1340  }
1341  else {
1343  reset();
1344  smpAssign( *this, ~rhs );
1345  }
1346 
1347  return *this;
1348 }
1349 //*************************************************************************************************
1350 
1351 
1352 //*************************************************************************************************
1362 template< typename VT // Type of the dense vector
1363  , bool AF // Alignment flag
1364  , bool TF > // Transpose flag
1365 template< typename VT2 > // Type of the right-hand side vector
1367 {
1370 
1371  if( size() != (~rhs).size() )
1372  throw std::invalid_argument( "Vector sizes do not match" );
1373 
1374  if( (~rhs).canAlias( &vector_ ) ) {
1375  const typename VT2::ResultType tmp( ~rhs );
1376  smpAddAssign( *this, tmp );
1377  }
1378  else {
1379  smpAddAssign( *this, ~rhs );
1380  }
1381 
1382  return *this;
1383 }
1384 //*************************************************************************************************
1385 
1386 
1387 //*************************************************************************************************
1397 template< typename VT // Type of the dense vector
1398  , bool AF // Alignment flag
1399  , bool TF > // Transpose flag
1400 template< typename VT2 > // Type of the right-hand side vector
1402 {
1405 
1406  if( size() != (~rhs).size() )
1407  throw std::invalid_argument( "Vector sizes do not match" );
1408 
1409  if( (~rhs).canAlias( &vector_ ) ) {
1410  const typename VT2::ResultType tmp( ~rhs );
1411  smpSubAssign( *this, tmp );
1412  }
1413  else {
1414  smpSubAssign( *this, ~rhs );
1415  }
1416 
1417  return *this;
1418 }
1419 //*************************************************************************************************
1420 
1421 
1422 //*************************************************************************************************
1433 template< typename VT // Type of the dense vector
1434  , bool AF // Alignment flag
1435  , bool TF > // Transpose flag
1436 template< typename VT2 > // Type of the right-hand side vector
1438 {
1441 
1442  if( size() != (~rhs).size() )
1443  throw std::invalid_argument( "Vector sizes do not match" );
1444 
1445  if( (~rhs).canAlias( &vector_ ) || IsSparseVector<VT2>::value ) {
1446  const ResultType tmp( *this * (~rhs) );
1447  smpAssign( *this, tmp );
1448  }
1449  else {
1450  smpMultAssign( *this, ~rhs );
1451  }
1452 
1453  return *this;
1454 }
1455 //*************************************************************************************************
1456 
1457 
1458 //*************************************************************************************************
1465 template< typename VT // Type of the dense vector
1466  , bool AF // Alignment flag
1467  , bool TF > // Transpose flag
1468 template< typename Other > // Data type of the right-hand side scalar
1469 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,AF,TF> >::Type&
1471 {
1472  smpAssign( *this, (*this) * rhs );
1473  return *this;
1474 }
1475 //*************************************************************************************************
1476 
1477 
1478 //*************************************************************************************************
1487 template< typename VT // Type of the dense vector
1488  , bool AF // Alignment flag
1489  , bool TF > // Transpose flag
1490 template< typename Other > // Data type of the right-hand side scalar
1491 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,AF,TF> >::Type&
1493 {
1494  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1495 
1496  smpAssign( *this, (*this) / rhs );
1497  return *this;
1498 }
1499 //*************************************************************************************************
1500 
1501 
1502 
1503 
1504 //=================================================================================================
1505 //
1506 // UTILITY FUNCTIONS
1507 //
1508 //=================================================================================================
1509 
1510 //*************************************************************************************************
1515 template< typename VT // Type of the dense vector
1516  , bool AF // Alignment flag
1517  , bool TF > // Transpose flag
1518 inline size_t DenseSubvector<VT,AF,TF>::size() const
1519 {
1520  return size_;
1521 }
1522 //*************************************************************************************************
1523 
1524 
1525 //*************************************************************************************************
1530 template< typename VT // Type of the dense vector
1531  , bool AF // Alignment flag
1532  , bool TF > // Transpose flag
1534 {
1535  return vector_.capacity() - offset_;
1536 }
1537 //*************************************************************************************************
1538 
1539 
1540 //*************************************************************************************************
1548 template< typename VT // Type of the dense vector
1549  , bool AF // Alignment flag
1550  , bool TF > // Transpose flag
1552 {
1553  size_t nonzeros( 0 );
1554 
1555  const size_t iend( offset_ + size_ );
1556  for( size_t i=offset_; i<iend; ++i ) {
1557  if( !isDefault( vector_[i] ) )
1558  ++nonzeros;
1559  }
1560 
1561  return nonzeros;
1562 }
1563 //*************************************************************************************************
1564 
1565 
1566 //*************************************************************************************************
1571 template< typename VT // Type of the dense vector
1572  , bool AF // Alignment flag
1573  , bool TF > // Transpose flag
1575 {
1576  using blaze::clear;
1577 
1578  const size_t iend( offset_ + size_ );
1579  for( size_t i=offset_; i<iend; ++i )
1580  clear( vector_[i] );
1581 }
1582 //*************************************************************************************************
1583 
1584 
1585 //*************************************************************************************************
1591 template< typename VT // Type of the dense vector
1592  , bool AF // Alignment flag
1593  , bool TF > // Transpose flag
1594 template< typename Other > // Data type of the scalar value
1596 {
1597  const size_t iend( offset_ + size_ );
1598  for( size_t i=offset_; i<iend; ++i )
1599  vector_[i] *= scalar;
1600  return *this;
1601 }
1602 //*************************************************************************************************
1603 
1604 
1605 
1606 
1607 //=================================================================================================
1608 //
1609 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1610 //
1611 //=================================================================================================
1612 
1613 //*************************************************************************************************
1623 template< typename VT // Type of the dense vector
1624  , bool AF // Alignment flag
1625  , bool TF > // Transpose flag
1626 template< typename Other > // Data type of the foreign expression
1627 inline bool DenseSubvector<VT,AF,TF>::canAlias( const Other* alias ) const
1628 {
1629  return vector_.isAliased( alias );
1630 }
1631 //*************************************************************************************************
1632 
1633 
1634 //*************************************************************************************************
1644 template< typename VT // Type of the dense vector
1645  , bool AF // Alignment flag
1646  , bool TF > // Transpose flag
1647 template< typename VT2 // Data type of the foreign dense subvector
1648  , bool AF2 // Alignment flag of the foreign dense subvector
1649  , bool TF2 > // Transpose flag of the foreign dense subvector
1651 {
1652  return ( vector_.isAliased( &alias->vector_ ) &&
1653  ( offset_ + size_ > alias->offset_ ) && ( offset_ < alias->offset_ + alias->size_ ) );
1654 }
1655 //*************************************************************************************************
1656 
1657 
1658 //*************************************************************************************************
1668 template< typename VT // Type of the dense vector
1669  , bool AF // Alignment flag
1670  , bool TF > // Transpose flag
1671 template< typename Other > // Data type of the foreign expression
1672 inline bool DenseSubvector<VT,AF,TF>::isAliased( const Other* alias ) const
1673 {
1674  return vector_.isAliased( alias );
1675 }
1676 //*************************************************************************************************
1677 
1678 
1679 //*************************************************************************************************
1689 template< typename VT // Type of the dense vector
1690  , bool AF // Alignment flag
1691  , bool TF > // Transpose flag
1692 template< typename VT2 // Data type of the foreign dense subvector
1693  , bool AF2 // Alignment flag of the foreign dense subvector
1694  , bool TF2 > // Transpose flag of the foreign dense subvector
1696 {
1697  return ( vector_.isAliased( &alias->vector_ ) &&
1698  ( offset_ + size_ > alias->offset_ ) && ( offset_ < alias->offset_ + alias->size_ ) );
1699 }
1700 //*************************************************************************************************
1701 
1702 
1703 //*************************************************************************************************
1712 template< typename VT // Type of the dense vector
1713  , bool AF // Alignment flag
1714  , bool TF > // Transpose flag
1716 {
1717  return isAligned_;
1718 }
1719 //*************************************************************************************************
1720 
1721 
1722 //*************************************************************************************************
1732 template< typename VT // Type of the dense vector
1733  , bool AF // Alignment flag
1734  , bool TF > // Transpose flag
1736 {
1737  return ( size() > SMP_DVECASSIGN_THRESHOLD );
1738 }
1739 //*************************************************************************************************
1740 
1741 
1742 //*************************************************************************************************
1755 template< typename VT // Type of the dense vector
1756  , bool AF // Alignment flag
1757  , bool TF > // Transpose flag
1759  DenseSubvector<VT,AF,TF>::load( size_t index ) const
1760 {
1761  return loadu( index );
1762 }
1763 //*************************************************************************************************
1764 
1765 
1766 //*************************************************************************************************
1779 template< typename VT // Type of the dense vector
1780  , bool AF // Alignment flag
1781  , bool TF > // Transpose flag
1783  DenseSubvector<VT,AF,TF>::loadu( size_t index ) const
1784 {
1785  using blaze::load;
1786 
1788 
1789  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
1790  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
1791 
1792  if( isAligned_ ) {
1793  return vector_.load( offset_+index );
1794  }
1795  else if( index != final_ ) {
1796  return vector_.loadu( offset_+index );
1797  }
1798  else {
1800  for( size_t i=0UL; i<rest_; ++i )
1801  array[i] = vector_[offset_+index+i];
1802  for( size_t i=rest_; i<IT::size; ++i )
1803  array[i] = ElementType();
1804  return load( array.data() );
1805  }
1806 }
1807 //*************************************************************************************************
1808 
1809 
1810 //*************************************************************************************************
1824 template< typename VT // Type of the dense vector
1825  , bool AF // Alignment flag
1826  , bool TF > // Transpose flag
1827 inline void DenseSubvector<VT,AF,TF>::store( size_t index, const IntrinsicType& value )
1828 {
1829  storeu( index, value );
1830 }
1831 //*************************************************************************************************
1832 
1833 
1834 //*************************************************************************************************
1848 template< typename VT // Type of the dense vector
1849  , bool AF // Alignment flag
1850  , bool TF > // Transpose flag
1851 inline void DenseSubvector<VT,AF,TF>::storeu( size_t index, const IntrinsicType& value )
1852 {
1853  using blaze::store;
1854 
1856 
1857  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
1858  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
1859 
1860  if( isAligned_ ) {
1861  vector_.store( offset_+index, value );
1862  }
1863  else if( index != final_ ) {
1864  vector_.storeu( offset_+index, value );
1865  }
1866  else {
1868  store( array.data(), value );
1869  for( size_t i=0UL; i<rest_; ++i )
1870  vector_[offset_+index+i] = array[i];
1871  }
1872 }
1873 //*************************************************************************************************
1874 
1875 
1876 //*************************************************************************************************
1890 template< typename VT // Type of the dense vector
1891  , bool AF // Alignment flag
1892  , bool TF > // Transpose flag
1893 inline void DenseSubvector<VT,AF,TF>::stream( size_t index, const IntrinsicType& value )
1894 {
1895  storeu( index, value );
1896 }
1897 //*************************************************************************************************
1898 
1899 
1900 //*************************************************************************************************
1911 template< typename VT // Type of the dense vector
1912  , bool AF // Alignment flag
1913  , bool TF > // Transpose flag
1914 template< typename VT2 > // Type of the right-hand side dense vector
1915 inline typename DisableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
1917 {
1918  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1919 
1920  const size_t iend( size() & size_t(-2) );
1921  for( size_t i=0UL; i<iend; i+=2UL ) {
1922  vector_[i+offset_ ] = (~rhs)[i ];
1923  vector_[i+offset_+1UL] = (~rhs)[i+1UL];
1924  }
1925  if( iend < size() ) {
1926  vector_[iend+offset_] = (~rhs)[iend];
1927  }
1928 }
1929 //*************************************************************************************************
1930 
1931 
1932 //*************************************************************************************************
1943 template< typename VT // Type of the dense vector
1944  , bool AF // Alignment flag
1945  , bool TF > // Transpose flag
1946 template< typename VT2 > // Type of the right-hand side dense vector
1947 inline typename EnableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
1949 {
1950  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1951 
1953 
1954  if( useStreaming && isAligned_ &&
1955  ( size_ > ( cacheSize/( sizeof(ElementType) * 3UL ) ) ) &&
1956  !(~rhs).isAliased( &vector_ ) )
1957  {
1958  for( size_t i=0UL; i<size(); i+=IT::size ) {
1959  vector_.stream( offset_+i, (~rhs).load(i) );
1960  }
1961  }
1962  else
1963  {
1964  const size_t iend( size_ & size_t(-IT::size*4) );
1965  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
1966 
1967  typename VT2::ConstIterator it( (~rhs).begin() );
1968  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1969  vector_.storeu( offset_+i , it.load() ); it += IT::size;
1970  vector_.storeu( offset_+i+IT::size , it.load() ); it += IT::size;
1971  vector_.storeu( offset_+i+IT::size*2UL, it.load() ); it += IT::size;
1972  vector_.storeu( offset_+i+IT::size*3UL, it.load() ); it += IT::size;
1973  }
1974  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
1975  storeu( i, it.load() );
1976  }
1977  }
1978 }
1979 //*************************************************************************************************
1980 
1981 
1982 //*************************************************************************************************
1993 template< typename VT // Type of the dense vector
1994  , bool AF // Alignment flag
1995  , bool TF > // Transpose flag
1996 template< typename VT2 > // Type of the right-hand side dense vector
1998 {
1999  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2000 
2001  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2002  vector_[element->index()+offset_] = element->value();
2003 }
2004 //*************************************************************************************************
2005 
2006 
2007 //*************************************************************************************************
2018 template< typename VT // Type of the dense vector
2019  , bool AF // Alignment flag
2020  , bool TF > // Transpose flag
2021 template< typename VT2 > // Type of the right-hand side dense vector
2022 inline typename DisableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
2024 {
2025  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2026 
2027  const size_t iend( size() & size_t(-2) );
2028  for( size_t i=0UL; i<iend; i+=2UL ) {
2029  vector_[i+offset_ ] += (~rhs)[i ];
2030  vector_[i+offset_+1UL] += (~rhs)[i+1UL];
2031  }
2032  if( iend < size() ) {
2033  vector_[iend+offset_] += (~rhs)[iend];
2034  }
2035 }
2036 //*************************************************************************************************
2037 
2038 
2039 //*************************************************************************************************
2050 template< typename VT // Type of the dense vector
2051  , bool AF // Alignment flag
2052  , bool TF > // Transpose flag
2053 template< typename VT2 > // Type of the right-hand side dense vector
2054 inline typename EnableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
2056 {
2057  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2058 
2060 
2061  const size_t iend( size_ & size_t(-IT::size*4) );
2062  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
2063 
2064  typename VT2::ConstIterator it( (~rhs).begin() );
2065  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
2066  vector_.storeu( offset_+i , load(i ) + it.load() ); it += IT::size;
2067  vector_.storeu( offset_+i+IT::size , load(i+IT::size ) + it.load() ); it += IT::size;
2068  vector_.storeu( offset_+i+IT::size*2UL, load(i+IT::size*2UL) + it.load() ); it += IT::size;
2069  vector_.storeu( offset_+i+IT::size*3UL, load(i+IT::size*3UL) + it.load() ); it += IT::size;
2070  }
2071  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
2072  storeu( i, load(i) + it.load() );
2073  }
2074 }
2075 //*************************************************************************************************
2076 
2077 
2078 //*************************************************************************************************
2089 template< typename VT // Type of the dense vector
2090  , bool AF // Alignment flag
2091  , bool TF > // Transpose flag
2092 template< typename VT2 > // Type of the right-hand side dense vector
2094 {
2095  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2096 
2097  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2098  vector_[element->index()+offset_] += element->value();
2099 }
2100 //*************************************************************************************************
2101 
2102 
2103 //*************************************************************************************************
2114 template< typename VT // Type of the dense vector
2115  , bool AF // Alignment flag
2116  , bool TF > // Transpose flag
2117 template< typename VT2 > // Type of the right-hand side dense vector
2118 inline typename DisableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
2120 {
2121  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2122 
2123  const size_t iend( size() & size_t(-2) );
2124  for( size_t i=0UL; i<iend; i+=2UL ) {
2125  vector_[i+offset_ ] -= (~rhs)[i ];
2126  vector_[i+offset_+1UL] -= (~rhs)[i+1UL];
2127  }
2128  if( iend < size() ) {
2129  vector_[iend+offset_] -= (~rhs)[iend];
2130  }
2131 }
2132 //*************************************************************************************************
2133 
2134 
2135 //*************************************************************************************************
2146 template< typename VT // Type of the dense vector
2147  , bool AF // Alignment flag
2148  , bool TF > // Transpose flag
2149 template< typename VT2 > // Type of the right-hand side dense vector
2150 inline typename EnableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
2152 {
2153  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2154 
2156 
2157  const size_t iend( size_ & size_t(-IT::size*4) );
2158  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
2159 
2160  typename VT2::ConstIterator it( (~rhs).begin() );
2161  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
2162  vector_.storeu( offset_+i , load(i ) - it.load() ); it += IT::size;
2163  vector_.storeu( offset_+i+IT::size , load(i+IT::size ) - it.load() ); it += IT::size;
2164  vector_.storeu( offset_+i+IT::size*2UL, load(i+IT::size*2UL) - it.load() ); it += IT::size;
2165  vector_.storeu( offset_+i+IT::size*3UL, load(i+IT::size*3UL) - it.load() ); it += IT::size;
2166  }
2167  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
2168  storeu( i, load(i) - it.load() );
2169  }
2170 }
2171 //*************************************************************************************************
2172 
2173 
2174 //*************************************************************************************************
2185 template< typename VT // Type of the dense vector
2186  , bool AF // Alignment flag
2187  , bool TF > // Transpose flag
2188 template< typename VT2 > // Type of the right-hand side dense vector
2190 {
2191  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2192 
2193  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2194  vector_[element->index()+offset_] -= element->value();
2195 }
2196 //*************************************************************************************************
2197 
2198 
2199 //*************************************************************************************************
2210 template< typename VT // Type of the dense vector
2211  , bool AF // Alignment flag
2212  , bool TF > // Transpose flag
2213 template< typename VT2 > // Type of the right-hand side dense vector
2214 inline typename DisableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
2216 {
2217  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2218 
2219  const size_t iend( size() & size_t(-2) );
2220  for( size_t i=0UL; i<iend; i+=2UL ) {
2221  vector_[i+offset_ ] *= (~rhs)[i ];
2222  vector_[i+offset_+1UL] *= (~rhs)[i+1UL];
2223  }
2224  if( iend < size() ) {
2225  vector_[iend+offset_] *= (~rhs)[iend];
2226  }
2227 }
2228 //*************************************************************************************************
2229 
2230 
2231 //*************************************************************************************************
2242 template< typename VT // Type of the dense vector
2243  , bool AF // Alignment flag
2244  , bool TF > // Transpose flag
2245 template< typename VT2 > // Type of the right-hand side dense vector
2246 inline typename EnableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
2248 {
2249  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2250 
2252 
2253  const size_t iend( size_ & size_t(-IT::size*4) );
2254  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
2255 
2256  typename VT2::ConstIterator it( (~rhs).begin() );
2257  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
2258  vector_.storeu( offset_+i , load(i ) * it.load() ); it += IT::size;
2259  vector_.storeu( offset_+i+IT::size , load(i+IT::size ) * it.load() ); it += IT::size;
2260  vector_.storeu( offset_+i+IT::size*2UL, load(i+IT::size*2UL) * it.load() ); it += IT::size;
2261  vector_.storeu( offset_+i+IT::size*3UL, load(i+IT::size*3UL) * it.load() ); it += IT::size;
2262  }
2263  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
2264  storeu( i, load(i) * it.load() );
2265  }
2266 }
2267 //*************************************************************************************************
2268 
2269 
2270 //*************************************************************************************************
2281 template< typename VT // Type of the dense vector
2282  , bool AF // Alignment flag
2283  , bool TF > // Transpose flag
2284 template< typename VT2 > // Type of the right-hand side dense vector
2286 {
2287  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2288 
2289  const ResultType tmp( serial( *this ) );
2290 
2291  reset();
2292 
2293  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2294  vector_[element->index()+offset_] = tmp[element->index()] * element->value();
2295 }
2296 //*************************************************************************************************
2297 
2298 
2299 
2300 
2301 
2302 
2303 
2304 
2305 //=================================================================================================
2306 //
2307 // CLASS TEMPLATE SPECIALIZATION FOR ALIGNED SUBVECTORS
2308 //
2309 //=================================================================================================
2310 
2311 //*************************************************************************************************
2319 template< typename VT // Type of the dense vector
2320  , bool TF > // Transpose flag
2321 class DenseSubvector<VT,aligned,TF> : public DenseVector< DenseSubvector<VT,aligned,TF>, TF >
2322  , private Subvector
2323 {
2324  private:
2325  //**Type definitions****************************************************************************
2327  typedef typename SelectType< IsExpression<VT>::value, VT, VT& >::Type Operand;
2328 
2331  //**********************************************************************************************
2332 
2333  //**********************************************************************************************
2335 
2341  enum { useConst = IsConst<VT>::value };
2342  //**********************************************************************************************
2343 
2344  public:
2345  //**Type definitions****************************************************************************
2346  typedef DenseSubvector<VT,aligned,TF> This;
2347  typedef typename SubvectorTrait<VT>::Type ResultType;
2348  typedef typename ResultType::TransposeType TransposeType;
2349  typedef typename VT::ElementType ElementType;
2350  typedef typename IT::Type IntrinsicType;
2351  typedef typename VT::ReturnType ReturnType;
2352  typedef const DenseSubvector& CompositeType;
2353 
2355  typedef typename VT::ConstReference ConstReference;
2356 
2358  typedef typename SelectType< useConst, ConstReference, typename VT::Reference >::Type Reference;
2359 
2361  typedef const ElementType* ConstPointer;
2362 
2364  typedef typename SelectType< useConst, ConstPointer, ElementType* >::Type Pointer;
2365 
2367  typedef typename VT::ConstIterator ConstIterator;
2368 
2370  typedef typename SelectType< useConst, ConstIterator, typename VT::Iterator >::Type Iterator;
2371  //**********************************************************************************************
2372 
2373  //**Compilation flags***************************************************************************
2375  enum { vectorizable = VT::vectorizable };
2376 
2378  enum { smpAssignable = VT::smpAssignable };
2379  //**********************************************************************************************
2380 
2381  //**Constructors********************************************************************************
2384  explicit inline DenseSubvector( Operand vector, size_t index, size_t n );
2385  // No explicitly declared copy constructor.
2387  //**********************************************************************************************
2388 
2389  //**Destructor**********************************************************************************
2390  // No explicitly declared destructor.
2391  //**********************************************************************************************
2392 
2393  //**Data access functions***********************************************************************
2396  inline Reference operator[]( size_t index );
2397  inline ConstReference operator[]( size_t index ) const;
2398  inline Pointer data ();
2399  inline ConstPointer data () const;
2400  inline Iterator begin ();
2401  inline ConstIterator begin () const;
2402  inline ConstIterator cbegin() const;
2403  inline Iterator end ();
2404  inline ConstIterator end () const;
2405  inline ConstIterator cend () const;
2407  //**********************************************************************************************
2408 
2409  //**Assignment operators************************************************************************
2412  inline DenseSubvector& operator= ( const ElementType& rhs );
2413  inline DenseSubvector& operator= ( const DenseSubvector& rhs );
2414  template< typename VT2 > inline DenseSubvector& operator= ( const Vector<VT2,TF>& rhs );
2415  template< typename VT2 > inline DenseSubvector& operator+=( const Vector<VT2,TF>& rhs );
2416  template< typename VT2 > inline DenseSubvector& operator-=( const Vector<VT2,TF>& rhs );
2417  template< typename VT2 > inline DenseSubvector& operator*=( const Vector<VT2,TF>& rhs );
2418 
2419  template< typename Other >
2420  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
2421  operator*=( Other rhs );
2422 
2423  template< typename Other >
2424  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
2425  operator/=( Other rhs );
2427  //**********************************************************************************************
2428 
2429  //**Utility functions***************************************************************************
2432  inline size_t size() const;
2433  inline size_t capacity() const;
2434  inline size_t nonZeros() const;
2435  inline void reset();
2436  template< typename Other > inline DenseSubvector& scale( const Other& scalar );
2438  //**********************************************************************************************
2439 
2440  private:
2441  //**********************************************************************************************
2443  template< typename VT2 >
2444  struct VectorizedAssign {
2445  enum { value = vectorizable && VT2::vectorizable &&
2446  IsSame<ElementType,typename VT2::ElementType>::value };
2447  };
2448  //**********************************************************************************************
2449 
2450  //**********************************************************************************************
2452  template< typename VT2 >
2453  struct VectorizedAddAssign {
2454  enum { value = vectorizable && VT2::vectorizable &&
2455  IsSame<ElementType,typename VT2::ElementType>::value &&
2456  IntrinsicTrait<ElementType>::addition };
2457  };
2458  //**********************************************************************************************
2459 
2460  //**********************************************************************************************
2462  template< typename VT2 >
2463  struct VectorizedSubAssign {
2464  enum { value = vectorizable && VT2::vectorizable &&
2465  IsSame<ElementType,typename VT2::ElementType>::value &&
2466  IntrinsicTrait<ElementType>::subtraction };
2467  };
2468  //**********************************************************************************************
2469 
2470  //**********************************************************************************************
2472  template< typename VT2 >
2473  struct VectorizedMultAssign {
2474  enum { value = vectorizable && VT2::vectorizable &&
2475  IsSame<ElementType,typename VT2::ElementType>::value &&
2476  IntrinsicTrait<ElementType>::multiplication };
2477  };
2478  //**********************************************************************************************
2479 
2480  public:
2481  //**Expression template evaluation functions****************************************************
2484  template< typename Other >
2485  inline bool canAlias( const Other* alias ) const;
2486 
2487  template< typename VT2, bool AF2, bool TF2 >
2488  inline bool canAlias( const DenseSubvector<VT2,AF2,TF2>* alias ) const;
2489 
2490  template< typename Other >
2491  inline bool isAliased( const Other* alias ) const;
2492 
2493  template< typename VT2, bool AF2, bool TF2 >
2494  inline bool isAliased( const DenseSubvector<VT2,AF2,TF2>* alias ) const;
2495 
2496  inline bool isAligned () const;
2497  inline bool canSMPAssign() const;
2498 
2499  inline IntrinsicType load ( size_t index ) const;
2500  inline IntrinsicType loadu ( size_t index ) const;
2501  inline void store ( size_t index, const IntrinsicType& value );
2502  inline void storeu( size_t index, const IntrinsicType& value );
2503  inline void stream( size_t index, const IntrinsicType& value );
2504 
2505  template< typename VT2 >
2506  inline typename DisableIf< VectorizedAssign<VT2> >::Type
2507  assign( const DenseVector <VT2,TF>& rhs );
2508 
2509  template< typename VT2 >
2510  inline typename EnableIf< VectorizedAssign<VT2> >::Type
2511  assign( const DenseVector <VT2,TF>& rhs );
2512 
2513  template< typename VT2 > inline void assign( const SparseVector<VT2,TF>& rhs );
2514 
2515  template< typename VT2 >
2516  inline typename DisableIf< VectorizedAddAssign<VT2> >::Type
2517  addAssign( const DenseVector <VT2,TF>& rhs );
2518 
2519  template< typename VT2 >
2520  inline typename EnableIf< VectorizedAddAssign<VT2> >::Type
2521  addAssign ( const DenseVector <VT2,TF>& rhs );
2522 
2523  template< typename VT2 > inline void addAssign( const SparseVector<VT2,TF>& rhs );
2524 
2525  template< typename VT2 >
2526  inline typename DisableIf< VectorizedSubAssign<VT2> >::Type
2527  subAssign ( const DenseVector <VT2,TF>& rhs );
2528 
2529  template< typename VT2 >
2530  inline typename EnableIf< VectorizedSubAssign<VT2> >::Type
2531  subAssign( const DenseVector <VT2,TF>& rhs );
2532 
2533  template< typename VT2 > inline void subAssign( const SparseVector<VT2,TF>& rhs );
2534 
2535  template< typename VT2 >
2536  inline typename DisableIf< VectorizedMultAssign<VT2> >::Type
2537  multAssign( const DenseVector <VT2,TF>& rhs );
2538 
2539  template< typename VT2 >
2540  inline typename EnableIf< VectorizedMultAssign<VT2> >::Type
2541  multAssign( const DenseVector <VT2,TF>& rhs );
2542 
2543  template< typename VT2 > inline void multAssign( const SparseVector<VT2,TF>& rhs );
2545  //**********************************************************************************************
2546 
2547  private:
2548  //**Member variables****************************************************************************
2551  Operand vector_;
2552  const size_t offset_;
2553  const size_t size_;
2554 
2555  //**********************************************************************************************
2556 
2557  //**Friend declarations*************************************************************************
2558  template< typename VT2, bool AF2, bool TF2 > friend class DenseSubvector;
2559 
2560  template< bool AF1, typename VT2, bool AF2, bool TF2 >
2561  friend const DenseSubvector<VT2,AF1,TF2>
2562  subvector( const DenseSubvector<VT2,AF2,TF2>& dv, size_t index, size_t size );
2563 
2564  template< typename VT2, bool AF2, bool TF2 >
2565  friend bool isSame( const DenseSubvector<VT2,AF2,TF2>& a, const DenseVector<VT2,TF2>& b );
2566 
2567  template< typename VT2, bool AF2, bool TF2 >
2568  friend bool isSame( const DenseVector<VT2,TF2>& a, const DenseSubvector<VT2,AF2,TF2>& b );
2569 
2570  template< typename VT2, bool AF2, bool TF2 >
2571  friend bool isSame( const DenseSubvector<VT2,AF2,TF2>& a, const DenseSubvector<VT2,AF2,TF2>& b );
2572  //**********************************************************************************************
2573 
2574  //**Compile time checks*************************************************************************
2580  //**********************************************************************************************
2581 };
2583 //*************************************************************************************************
2584 
2585 
2586 
2587 
2588 //=================================================================================================
2589 //
2590 // CONSTRUCTOR
2591 //
2592 //=================================================================================================
2593 
2594 //*************************************************************************************************
2607 template< typename VT // Type of the dense vector
2608  , bool TF > // Transpose flag
2609 inline DenseSubvector<VT,aligned,TF>::DenseSubvector( Operand vector, size_t index, size_t n )
2610  : vector_( vector ) // The vector containing the subvector
2611  , offset_( index ) // The offset of the subvector within the dense vector
2612  , size_ ( n ) // The size of the subvector
2613 {
2614  if( index + n > vector.size() )
2615  throw std::invalid_argument( "Invalid subvector specification" );
2616 
2617  if( offset_ % IT::size != 0UL || ( offset_ + size_ != vector_.size() && size_ % IT::size != 0UL ) )
2618  throw std::invalid_argument( "Invalid subvector alignment" );
2619 }
2621 //*************************************************************************************************
2622 
2623 
2624 
2625 
2626 //=================================================================================================
2627 //
2628 // DATA ACCESS FUNCTIONS
2629 //
2630 //=================================================================================================
2631 
2632 //*************************************************************************************************
2639 template< typename VT // Type of the dense vector
2640  , bool TF > // Transpose flag
2643 {
2644  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
2645  return vector_[offset_+index];
2646 }
2648 //*************************************************************************************************
2649 
2650 
2651 //*************************************************************************************************
2658 template< typename VT // Type of the dense vector
2659  , bool TF > // Transpose flag
2661  DenseSubvector<VT,aligned,TF>::operator[]( size_t index ) const
2662 {
2663  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
2664  return const_cast<const VT&>( vector_ )[offset_+index];
2665 }
2667 //*************************************************************************************************
2668 
2669 
2670 //*************************************************************************************************
2678 template< typename VT // Type of the dense vector
2679  , bool TF > // Transpose flag
2680 inline typename DenseSubvector<VT,aligned,TF>::Pointer DenseSubvector<VT,aligned,TF>::data()
2681 {
2682  return vector_.data() + offset_;
2683 }
2685 //*************************************************************************************************
2686 
2687 
2688 //*************************************************************************************************
2696 template< typename VT // Type of the dense vector
2697  , bool TF > // Transpose flag
2698 inline typename DenseSubvector<VT,aligned,TF>::ConstPointer DenseSubvector<VT,aligned,TF>::data() const
2699 {
2700  return vector_.data() + offset_;
2701 }
2703 //*************************************************************************************************
2704 
2705 
2706 //*************************************************************************************************
2714 template< typename VT // Type of the dense vector
2715  , bool TF > // Transpose flag
2717 {
2718  return ( vector_.begin() + offset_ );
2719 }
2721 //*************************************************************************************************
2722 
2723 
2724 //*************************************************************************************************
2732 template< typename VT // Type of the dense vector
2733  , bool TF > // Transpose flag
2736 {
2737  return ( vector_.cbegin() + offset_ );
2738 }
2740 //*************************************************************************************************
2741 
2742 
2743 //*************************************************************************************************
2751 template< typename VT // Type of the dense vector
2752  , bool TF > // Transpose flag
2755 {
2756  return ( vector_.cbegin() + offset_ );
2757 }
2759 //*************************************************************************************************
2760 
2761 
2762 //*************************************************************************************************
2770 template< typename VT // Type of the dense vector
2771  , bool TF > // Transpose flag
2773 {
2774  return ( vector_.begin() + offset_ + size_ );
2775 }
2777 //*************************************************************************************************
2778 
2779 
2780 //*************************************************************************************************
2788 template< typename VT // Type of the dense vector
2789  , bool TF > // Transpose flag
2792 {
2793  return ( vector_.cbegin() + offset_ + size_ );
2794 }
2796 //*************************************************************************************************
2797 
2798 
2799 //*************************************************************************************************
2807 template< typename VT // Type of the dense vector
2808  , bool TF > // Transpose flag
2811 {
2812  return ( vector_.cbegin() + offset_ + size_ );
2813 }
2815 //*************************************************************************************************
2816 
2817 
2818 
2819 
2820 //=================================================================================================
2821 //
2822 // ASSIGNMENT OPERATORS
2823 //
2824 //=================================================================================================
2825 
2826 //*************************************************************************************************
2833 template< typename VT // Type of the dense vector
2834  , bool TF > // Transpose flag
2835 inline DenseSubvector<VT,aligned,TF>&
2837 {
2838  const size_t iend( offset_ + size_ );
2839 
2840  for( size_t i=offset_; i<iend; ++i )
2841  vector_[i] = rhs;
2842 
2843  return *this;
2844 }
2846 //*************************************************************************************************
2847 
2848 
2849 //*************************************************************************************************
2860 template< typename VT // Type of the dense vector
2861  , bool TF > // Transpose flag
2862 inline DenseSubvector<VT,aligned,TF>&
2863  DenseSubvector<VT,aligned,TF>::operator=( const DenseSubvector& rhs )
2864 {
2867 
2868  if( &rhs == this || ( &vector_ == &rhs.vector_ && offset_ == rhs.offset_ ) )
2869  return *this;
2870 
2871  if( size() != rhs.size() )
2872  throw std::invalid_argument( "Subvector sizes do not match" );
2873 
2874  if( rhs.canAlias( &vector_ ) ) {
2875  const ResultType tmp( ~rhs );
2876  smpAssign( *this, tmp );
2877  }
2878  else {
2879  smpAssign( *this, rhs );
2880  }
2881 
2882  return *this;
2883 }
2885 //*************************************************************************************************
2886 
2887 
2888 //*************************************************************************************************
2899 template< typename VT // Type of the dense vector
2900  , bool TF > // Transpose flag
2901 template< typename VT2 > // Type of the right-hand side vector
2902 inline DenseSubvector<VT,aligned,TF>&
2903  DenseSubvector<VT,aligned,TF>::operator=( const Vector<VT2,TF>& rhs )
2904 {
2907 
2908  if( size() != (~rhs).size() )
2909  throw std::invalid_argument( "Vector sizes do not match" );
2910 
2911  if( (~rhs).canAlias( &vector_ ) ) {
2912  const typename VT2::ResultType tmp( ~rhs );
2913  smpAssign( *this, tmp );
2914  }
2915  else {
2916  if( IsSparseVector<VT2>::value )
2917  reset();
2918  smpAssign( *this, ~rhs );
2919  }
2920 
2921  return *this;
2922 }
2924 //*************************************************************************************************
2925 
2926 
2927 //*************************************************************************************************
2938 template< typename VT // Type of the dense vector
2939  , bool TF > // Transpose flag
2940 template< typename VT2 > // Type of the right-hand side vector
2941 inline DenseSubvector<VT,aligned,TF>&
2942  DenseSubvector<VT,aligned,TF>::operator+=( const Vector<VT2,TF>& rhs )
2943 {
2946 
2947  if( size() != (~rhs).size() )
2948  throw std::invalid_argument( "Vector sizes do not match" );
2949 
2950  if( (~rhs).canAlias( &vector_ ) ) {
2951  const typename VT2::ResultType tmp( ~rhs );
2952  smpAddAssign( *this, tmp );
2953  }
2954  else {
2955  smpAddAssign( *this, ~rhs );
2956  }
2957 
2958  return *this;
2959 }
2961 //*************************************************************************************************
2962 
2963 
2964 //*************************************************************************************************
2975 template< typename VT // Type of the dense vector
2976  , bool TF > // Transpose flag
2977 template< typename VT2 > // Type of the right-hand side vector
2978 inline DenseSubvector<VT,aligned,TF>&
2979  DenseSubvector<VT,aligned,TF>::operator-=( const Vector<VT2,TF>& rhs )
2980 {
2983 
2984  if( size() != (~rhs).size() )
2985  throw std::invalid_argument( "Vector sizes do not match" );
2986 
2987  if( (~rhs).canAlias( &vector_ ) ) {
2988  const typename VT2::ResultType tmp( ~rhs );
2989  smpSubAssign( *this, tmp );
2990  }
2991  else {
2992  smpSubAssign( *this, ~rhs );
2993  }
2994 
2995  return *this;
2996 }
2998 //*************************************************************************************************
2999 
3000 
3001 //*************************************************************************************************
3013 template< typename VT // Type of the dense vector
3014  , bool TF > // Transpose flag
3015 template< typename VT2 > // Type of the right-hand side vector
3016 inline DenseSubvector<VT,aligned,TF>&
3017  DenseSubvector<VT,aligned,TF>::operator*=( const Vector<VT2,TF>& rhs )
3018 {
3021 
3022  if( size() != (~rhs).size() )
3023  throw std::invalid_argument( "Vector sizes do not match" );
3024 
3025  if( (~rhs).canAlias( &vector_ ) || IsSparseVector<VT2>::value ) {
3026  const ResultType tmp( *this * (~rhs) );
3027  smpAssign( *this, tmp );
3028  }
3029  else {
3030  smpMultAssign( *this, ~rhs );
3031  }
3032 
3033  return *this;
3034 }
3036 //*************************************************************************************************
3037 
3038 
3039 //*************************************************************************************************
3047 template< typename VT // Type of the dense vector
3048  , bool TF > // Transpose flag
3049 template< typename Other > // Data type of the right-hand side scalar
3050 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,aligned,TF> >::Type&
3051  DenseSubvector<VT,aligned,TF>::operator*=( Other rhs )
3052 {
3053  smpAssign( *this, (*this) * rhs );
3054  return *this;
3055 }
3057 //*************************************************************************************************
3058 
3059 
3060 //*************************************************************************************************
3070 template< typename VT // Type of the dense vector
3071  , bool TF > // Transpose flag
3072 template< typename Other > // Data type of the right-hand side scalar
3073 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,aligned,TF> >::Type&
3074  DenseSubvector<VT,aligned,TF>::operator/=( Other rhs )
3075 {
3076  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3077 
3078  smpAssign( *this, (*this) / rhs );
3079  return *this;
3080 }
3082 //*************************************************************************************************
3083 
3084 
3085 
3086 
3087 //=================================================================================================
3088 //
3089 // UTILITY FUNCTIONS
3090 //
3091 //=================================================================================================
3092 
3093 //*************************************************************************************************
3099 template< typename VT // Type of the dense vector
3100  , bool TF > // Transpose flag
3101 inline size_t DenseSubvector<VT,aligned,TF>::size() const
3102 {
3103  return size_;
3104 }
3106 //*************************************************************************************************
3107 
3108 
3109 //*************************************************************************************************
3115 template< typename VT // Type of the dense vector
3116  , bool TF > // Transpose flag
3117 inline size_t DenseSubvector<VT,aligned,TF>::capacity() const
3118 {
3119  return vector_.capacity() - offset_;
3120 }
3122 //*************************************************************************************************
3123 
3124 
3125 //*************************************************************************************************
3134 template< typename VT // Type of the dense vector
3135  , bool TF > // Transpose flag
3136 inline size_t DenseSubvector<VT,aligned,TF>::nonZeros() const
3137 {
3138  size_t nonzeros( 0 );
3139 
3140  const size_t iend( offset_ + size_ );
3141  for( size_t i=offset_; i<iend; ++i ) {
3142  if( !isDefault( vector_[i] ) )
3143  ++nonzeros;
3144  }
3145 
3146  return nonzeros;
3147 }
3149 //*************************************************************************************************
3150 
3151 
3152 //*************************************************************************************************
3158 template< typename VT // Type of the dense vector
3159  , bool TF > // Transpose flag
3161 {
3162  using blaze::clear;
3163 
3164  const size_t iend( offset_ + size_ );
3165  for( size_t i=offset_; i<iend; ++i )
3166  clear( vector_[i] );
3167 }
3169 //*************************************************************************************************
3170 
3171 
3172 //*************************************************************************************************
3179 template< typename VT // Type of the dense vector
3180  , bool TF > // Transpose flag
3181 template< typename Other > // Data type of the scalar value
3182 inline DenseSubvector<VT,aligned,TF>& DenseSubvector<VT,aligned,TF>::scale( const Other& scalar )
3183 {
3184  const size_t iend( offset_ + size_ );
3185  for( size_t i=offset_; i<iend; ++i )
3186  vector_[i] *= scalar;
3187  return *this;
3188 }
3190 //*************************************************************************************************
3191 
3192 
3193 
3194 
3195 //=================================================================================================
3196 //
3197 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
3198 //
3199 //=================================================================================================
3200 
3201 //*************************************************************************************************
3212 template< typename VT // Type of the dense vector
3213  , bool TF > // Transpose flag
3214 template< typename Other > // Data type of the foreign expression
3215 inline bool DenseSubvector<VT,aligned,TF>::canAlias( const Other* alias ) const
3216 {
3217  return vector_.isAliased( alias );
3218 }
3220 //*************************************************************************************************
3221 
3222 
3223 //*************************************************************************************************
3234 template< typename VT // Type of the dense vector
3235  , bool TF > // Transpose flag
3236 template< typename VT2 // Data type of the foreign dense subvector
3237  , bool AF2 // Alignment flag of the foreign dense subvector
3238  , bool TF2 > // Transpose flag of the foreign dense subvector
3239 inline bool DenseSubvector<VT,aligned,TF>::canAlias( const DenseSubvector<VT2,AF2,TF2>* alias ) const
3240 {
3241  return ( vector_.isAliased( &alias->vector_ ) &&
3242  ( offset_ + size_ > alias->offset_ ) && ( offset_ < alias->offset_ + alias->size_ ) );
3243 }
3245 //*************************************************************************************************
3246 
3247 
3248 //*************************************************************************************************
3259 template< typename VT // Type of the dense vector
3260  , bool TF > // Transpose flag
3261 template< typename Other > // Data type of the foreign expression
3262 inline bool DenseSubvector<VT,aligned,TF>::isAliased( const Other* alias ) const
3263 {
3264  return vector_.isAliased( alias );
3265 }
3267 //*************************************************************************************************
3268 
3269 
3270 //*************************************************************************************************
3281 template< typename VT // Type of the dense vector
3282  , bool TF > // Transpose flag
3283 template< typename VT2 // Data type of the foreign dense subvector
3284  , bool AF2 // Alignment flag of the foreign dense subvector
3285  , bool TF2 > // Transpose flag of the foreign dense subvector
3286 inline bool DenseSubvector<VT,aligned,TF>::isAliased( const DenseSubvector<VT2,AF2,TF2>* alias ) const
3287 {
3288  return ( vector_.isAliased( &alias->vector_ ) &&
3289  ( offset_ + size_ > alias->offset_ ) && ( offset_ < alias->offset_ + alias->size_ ) );
3290 }
3292 //*************************************************************************************************
3293 
3294 
3295 //*************************************************************************************************
3305 template< typename VT // Type of the dense vector
3306  , bool TF > // Transpose flag
3307 inline bool DenseSubvector<VT,aligned,TF>::isAligned() const
3308 {
3309  return true;
3310 }
3312 //*************************************************************************************************
3313 
3314 
3315 //*************************************************************************************************
3326 template< typename VT // Type of the dense vector
3327  , bool TF > // Transpose flag
3329 {
3330  return ( size() > SMP_DVECASSIGN_THRESHOLD );
3331 }
3333 //*************************************************************************************************
3334 
3335 
3336 //*************************************************************************************************
3350 template< typename VT // Type of the dense vector
3351  , bool TF > // Transpose flag
3352 inline typename DenseSubvector<VT,aligned,TF>::IntrinsicType
3353  DenseSubvector<VT,aligned,TF>::load( size_t index ) const
3354 {
3356 
3357  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3358  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3359 
3360  return vector_.load( offset_+index );
3361 }
3363 //*************************************************************************************************
3364 
3365 
3366 //*************************************************************************************************
3380 template< typename VT // Type of the dense vector
3381  , bool TF > // Transpose flag
3382 inline typename DenseSubvector<VT,aligned,TF>::IntrinsicType
3383  DenseSubvector<VT,aligned,TF>::loadu( size_t index ) const
3384 {
3386 
3387  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3388  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3389 
3390  return vector_.loadu( offset_+index );
3391 }
3393 //*************************************************************************************************
3394 
3395 
3396 //*************************************************************************************************
3411 template< typename VT // Type of the dense vector
3412  , bool TF > // Transpose flag
3413 inline void DenseSubvector<VT,aligned,TF>::store( size_t index, const IntrinsicType& value )
3414 {
3416 
3417  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3418  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3419 
3420  vector_.store( offset_+index, value );
3421 }
3423 //*************************************************************************************************
3424 
3425 
3426 //*************************************************************************************************
3441 template< typename VT // Type of the dense vector
3442  , bool TF > // Transpose flag
3443 inline void DenseSubvector<VT,aligned,TF>::storeu( size_t index, const IntrinsicType& value )
3444 {
3446 
3447  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3448  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3449 
3450  vector_.storeu( offset_+index, value );
3451 }
3453 //*************************************************************************************************
3454 
3455 
3456 //*************************************************************************************************
3471 template< typename VT // Type of the dense vector
3472  , bool TF > // Transpose flag
3473 inline void DenseSubvector<VT,aligned,TF>::stream( size_t index, const IntrinsicType& value )
3474 {
3476 
3477  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3478  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3479 
3480  vector_.stream( offset_+index, value );
3481 }
3483 //*************************************************************************************************
3484 
3485 
3486 //*************************************************************************************************
3498 template< typename VT // Type of the dense vector
3499  , bool TF > // Transpose flag
3500 template< typename VT2 > // Type of the right-hand side dense vector
3501 inline typename DisableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
3502  DenseSubvector<VT,aligned,TF>::assign( const DenseVector<VT2,TF>& rhs )
3503 {
3504  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3505 
3506  const size_t iend( size() & size_t(-2) );
3507  for( size_t i=0UL; i<iend; i+=2UL ) {
3508  vector_[i+offset_ ] = (~rhs)[i ];
3509  vector_[i+offset_+1UL] = (~rhs)[i+1UL];
3510  }
3511  if( iend < size() ) {
3512  vector_[iend+offset_] = (~rhs)[iend];
3513  }
3514 }
3516 //*************************************************************************************************
3517 
3518 
3519 //*************************************************************************************************
3531 template< typename VT // Type of the dense vector
3532  , bool TF > // Transpose flag
3533 template< typename VT2 > // Type of the right-hand side dense vector
3534 inline typename EnableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
3535  DenseSubvector<VT,aligned,TF>::assign( const DenseVector<VT2,TF>& rhs )
3536 {
3537  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3538 
3540 
3541  if( useStreaming && size_ > ( cacheSize/( sizeof(ElementType) * 3UL ) ) && !(~rhs).isAliased( &vector_ ) )
3542  {
3543  for( size_t i=0UL; i<size(); i+=IT::size ) {
3544  vector_.stream( offset_+i, (~rhs).load(i) );
3545  }
3546  }
3547  else
3548  {
3549  const size_t iend( size_ & size_t(-IT::size*4) );
3550  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
3551 
3552  typename VT2::ConstIterator it( (~rhs).begin() );
3553  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
3554  store( i , it.load() ); it += IT::size;
3555  store( i+IT::size , it.load() ); it += IT::size;
3556  store( i+IT::size*2UL, it.load() ); it += IT::size;
3557  store( i+IT::size*3UL, it.load() ); it += IT::size;
3558  }
3559  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
3560  store( i, it.load() );
3561  }
3562  }
3563 }
3565 //*************************************************************************************************
3566 
3567 
3568 //*************************************************************************************************
3580 template< typename VT // Type of the dense vector
3581  , bool TF > // Transpose flag
3582 template< typename VT2 > // Type of the right-hand side dense vector
3583 inline void DenseSubvector<VT,aligned,TF>::assign( const SparseVector<VT2,TF>& rhs )
3584 {
3585  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3586 
3587  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3588  vector_[element->index()+offset_] = element->value();
3589 }
3591 //*************************************************************************************************
3592 
3593 
3594 //*************************************************************************************************
3606 template< typename VT // Type of the dense vector
3607  , bool TF > // Transpose flag
3608 template< typename VT2 > // Type of the right-hand side dense vector
3609 inline typename DisableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
3610  DenseSubvector<VT,aligned,TF>::addAssign( const DenseVector<VT2,TF>& rhs )
3611 {
3612  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3613 
3614  const size_t iend( size() & size_t(-2) );
3615  for( size_t i=0UL; i<iend; i+=2UL ) {
3616  vector_[i+offset_ ] += (~rhs)[i ];
3617  vector_[i+offset_+1UL] += (~rhs)[i+1UL];
3618  }
3619  if( iend < size() ) {
3620  vector_[iend+offset_] += (~rhs)[iend];
3621  }
3622 }
3624 //*************************************************************************************************
3625 
3626 
3627 //*************************************************************************************************
3639 template< typename VT // Type of the dense vector
3640  , bool TF > // Transpose flag
3641 template< typename VT2 > // Type of the right-hand side dense vector
3642 inline typename EnableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
3643  DenseSubvector<VT,aligned,TF>::addAssign( const DenseVector<VT2,TF>& rhs )
3644 {
3645  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3646 
3648 
3649  const size_t iend( size_ & size_t(-IT::size*4) );
3650  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
3651 
3652  typename VT2::ConstIterator it( (~rhs).begin() );
3653  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
3654  store( i , load(i ) + it.load() ); it += IT::size;
3655  store( i+IT::size , load(i+IT::size ) + it.load() ); it += IT::size;
3656  store( i+IT::size*2UL, load(i+IT::size*2UL) + it.load() ); it += IT::size;
3657  store( i+IT::size*3UL, load(i+IT::size*3UL) + it.load() ); it += IT::size;
3658  }
3659  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
3660  store( i, load(i) + it.load() );
3661  }
3662 }
3664 //*************************************************************************************************
3665 
3666 
3667 //*************************************************************************************************
3679 template< typename VT // Type of the dense vector
3680  , bool TF > // Transpose flag
3681 template< typename VT2 > // Type of the right-hand side dense vector
3682 inline void DenseSubvector<VT,aligned,TF>::addAssign( const SparseVector<VT2,TF>& rhs )
3683 {
3684  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3685 
3686  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3687  vector_[element->index()+offset_] += element->value();
3688 }
3690 //*************************************************************************************************
3691 
3692 
3693 //*************************************************************************************************
3705 template< typename VT // Type of the dense vector
3706  , bool TF > // Transpose flag
3707 template< typename VT2 > // Type of the right-hand side dense vector
3708 inline typename DisableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
3709  DenseSubvector<VT,aligned,TF>::subAssign( const DenseVector<VT2,TF>& rhs )
3710 {
3711  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3712 
3713  const size_t iend( size() & size_t(-2) );
3714  for( size_t i=0UL; i<iend; i+=2UL ) {
3715  vector_[i+offset_ ] -= (~rhs)[i ];
3716  vector_[i+offset_+1UL] -= (~rhs)[i+1UL];
3717  }
3718  if( iend < size() ) {
3719  vector_[iend+offset_] -= (~rhs)[iend];
3720  }
3721 }
3723 //*************************************************************************************************
3724 
3725 
3726 //*************************************************************************************************
3738 template< typename VT // Type of the dense vector
3739  , bool TF > // Transpose flag
3740 template< typename VT2 > // Type of the right-hand side dense vector
3741 inline typename EnableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
3742  DenseSubvector<VT,aligned,TF>::subAssign( const DenseVector<VT2,TF>& rhs )
3743 {
3744  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3745 
3747 
3748  const size_t iend( size_ & size_t(-IT::size*4) );
3749  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
3750 
3751  typename VT2::ConstIterator it( (~rhs).begin() );
3752  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
3753  store( i , load(i ) - it.load() ); it += IT::size;
3754  store( i+IT::size , load(i+IT::size ) - it.load() ); it += IT::size;
3755  store( i+IT::size*2UL, load(i+IT::size*2UL) - it.load() ); it += IT::size;
3756  store( i+IT::size*3UL, load(i+IT::size*3UL) - it.load() ); it += IT::size;
3757  }
3758  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
3759  store( i, load(i) - it.load() );
3760  }
3761 }
3763 //*************************************************************************************************
3764 
3765 
3766 //*************************************************************************************************
3778 template< typename VT // Type of the dense vector
3779  , bool TF > // Transpose flag
3780 template< typename VT2 > // Type of the right-hand side dense vector
3781 inline void DenseSubvector<VT,aligned,TF>::subAssign( const SparseVector<VT2,TF>& rhs )
3782 {
3783  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3784 
3785  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3786  vector_[element->index()+offset_] -= element->value();
3787 }
3789 //*************************************************************************************************
3790 
3791 
3792 //*************************************************************************************************
3804 template< typename VT // Type of the dense vector
3805  , bool TF > // Transpose flag
3806 template< typename VT2 > // Type of the right-hand side dense vector
3807 inline typename DisableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
3808  DenseSubvector<VT,aligned,TF>::multAssign( const DenseVector<VT2,TF>& rhs )
3809 {
3810  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3811 
3812  const size_t iend( size() & size_t(-2) );
3813  for( size_t i=0UL; i<iend; i+=2UL ) {
3814  vector_[i+offset_ ] *= (~rhs)[i ];
3815  vector_[i+offset_+1UL] *= (~rhs)[i+1UL];
3816  }
3817  if( iend < size() ) {
3818  vector_[iend+offset_] *= (~rhs)[iend];
3819  }
3820 }
3822 //*************************************************************************************************
3823 
3824 
3825 //*************************************************************************************************
3837 template< typename VT // Type of the dense vector
3838  , bool TF > // Transpose flag
3839 template< typename VT2 > // Type of the right-hand side dense vector
3840 inline typename EnableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
3841  DenseSubvector<VT,aligned,TF>::multAssign( const DenseVector<VT2,TF>& rhs )
3842 {
3843  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3844 
3846 
3847  const size_t iend( size_ & size_t(-IT::size*4) );
3848  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
3849 
3850  typename VT2::ConstIterator it( (~rhs).begin() );
3851  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
3852  store( i , load(i ) * it.load() ); it += IT::size;
3853  store( i+IT::size , load(i+IT::size ) * it.load() ); it += IT::size;
3854  store( i+IT::size*2UL, load(i+IT::size*2UL) * it.load() ); it += IT::size;
3855  store( i+IT::size*3UL, load(i+IT::size*3UL) * it.load() ); it += IT::size;
3856  }
3857  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
3858  store( i, load(i) * it.load() );
3859  }
3860 }
3862 //*************************************************************************************************
3863 
3864 
3865 //*************************************************************************************************
3877 template< typename VT // Type of the dense vector
3878  , bool TF > // Transpose flag
3879 template< typename VT2 > // Type of the right-hand side dense vector
3880 inline void DenseSubvector<VT,aligned,TF>::multAssign( const SparseVector<VT2,TF>& rhs )
3881 {
3882  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3883 
3884  const ResultType tmp( serial( *this ) );
3885 
3886  reset();
3887 
3888  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3889  vector_[element->index()+offset_] = tmp[element->index()] * element->value();
3890 }
3892 //*************************************************************************************************
3893 
3894 
3895 
3896 
3897 
3898 
3899 
3900 
3901 //=================================================================================================
3902 //
3903 // CLASS TEMPLATE SPECIALIZATION FOR DVECDVECCROSSEXPR
3904 //
3905 //=================================================================================================
3906 
3907 //*************************************************************************************************
3915 template< typename VT1 // Type of the left-hand side dense vector
3916  , typename VT2 > // Type of the right-hand side dense vector
3917 class DenseSubvector< DVecDVecCrossExpr<VT1,VT2>, unaligned, false >
3918  : public DenseVector< DenseSubvector< DVecDVecCrossExpr<VT1,VT2>, unaligned, false >, false >
3919  , private Subvector
3920 {
3921  private:
3922  //**Type definitions****************************************************************************
3923  typedef DVecDVecCrossExpr<VT1,VT2> CPE;
3924  typedef typename CPE::ResultType RT;
3925  //**********************************************************************************************
3926 
3927  public:
3928  //**Type definitions****************************************************************************
3929  typedef DenseSubvector<CPE,unaligned,false> This;
3930  typedef typename SubvectorTrait<RT>::Type ResultType;
3931  typedef typename ResultType::TransposeType TransposeType;
3932  typedef typename CPE::ElementType ElementType;
3933  typedef typename CPE::ReturnType ReturnType;
3934  typedef const ResultType CompositeType;
3935  //**********************************************************************************************
3936 
3937  //**Compilation flags***************************************************************************
3939  enum { vectorizable = 0 };
3940 
3942  enum { smpAssignable = 0 };
3943  //**********************************************************************************************
3944 
3945  //**Constructor*********************************************************************************
3952  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
3953  : vector_( vector ) // The dense vector/dense vector cross product expression
3954  , offset_( index ) // The offset of the subvector within the cross product expression
3955  , size_ ( n ) // The size of the subvector
3956  {}
3957  //**********************************************************************************************
3958 
3959  //**Subscript operator**************************************************************************
3965  inline ReturnType operator[]( size_t index ) const {
3966  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
3967  return vector_[offset_+index];
3968  }
3969  //**********************************************************************************************
3970 
3971  //**Size function*******************************************************************************
3976  inline size_t size() const {
3977  return size_;
3978  }
3979  //**********************************************************************************************
3980 
3981  //**********************************************************************************************
3987  template< typename T >
3988  inline bool canAlias( const T* alias ) const {
3989  return vector_.canAlias( alias );
3990  }
3991  //**********************************************************************************************
3992 
3993  //**********************************************************************************************
3999  template< typename T >
4000  inline bool isAliased( const T* alias ) const {
4001  return vector_.isAliased( alias );
4002  }
4003  //**********************************************************************************************
4004 
4005  private:
4006  //**Member variables****************************************************************************
4009  CPE vector_;
4010  const size_t offset_;
4011  const size_t size_;
4012 
4013  //**********************************************************************************************
4014 
4015  //**Friend declarations*************************************************************************
4016  template< bool AF1, typename VT, bool AF2, bool TF >
4017  friend const DenseSubvector<VT,AF1,TF>
4018  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size );
4019 
4020  template< typename VT3, bool AF3, bool TF3 >
4021  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseVector<VT3,TF3>& b );
4022 
4023  template< typename VT3, bool AF3, bool TF3 >
4024  friend bool isSame( const DenseVector<VT3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4025 
4026  template< typename VT3, bool AF3, bool TF3 >
4027  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4028  //**********************************************************************************************
4029 };
4031 //*************************************************************************************************
4032 
4033 
4034 
4035 
4036 
4037 
4038 
4039 
4040 //=================================================================================================
4041 //
4042 // CLASS TEMPLATE SPECIALIZATION FOR DVECSVECCROSSEXPR
4043 //
4044 //=================================================================================================
4045 
4046 //*************************************************************************************************
4054 template< typename VT1 // Type of the left-hand side dense vector
4055  , typename VT2 > // Type of the right-hand side sparse vector
4056 class DenseSubvector< DVecSVecCrossExpr<VT1,VT2>, unaligned, false >
4057  : public DenseVector< DenseSubvector< DVecSVecCrossExpr<VT1,VT2>, unaligned, false >, false >
4058  , private Subvector
4059 {
4060  private:
4061  //**Type definitions****************************************************************************
4062  typedef DVecSVecCrossExpr<VT1,VT2> CPE;
4063  typedef typename CPE::ResultType RT;
4064  //**********************************************************************************************
4065 
4066  public:
4067  //**Type definitions****************************************************************************
4068  typedef DenseSubvector<CPE,unaligned,false> This;
4069  typedef typename SubvectorTrait<RT>::Type ResultType;
4070  typedef typename ResultType::TransposeType TransposeType;
4071  typedef typename CPE::ElementType ElementType;
4072  typedef typename CPE::ReturnType ReturnType;
4073  typedef const ResultType CompositeType;
4074  //**********************************************************************************************
4075 
4076  //**Compilation flags***************************************************************************
4078  enum { vectorizable = 0 };
4079 
4081  enum { smpAssignable = 0 };
4082  //**********************************************************************************************
4083 
4084  //**Constructor*********************************************************************************
4091  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
4092  : vector_( vector ) // The dense vector/sparse vector cross product expression
4093  , offset_( index ) // The offset of the subvector within the cross product expression
4094  , size_ ( n ) // The size of the subvector
4095  {}
4096  //**********************************************************************************************
4097 
4098  //**Subscript operator**************************************************************************
4104  inline ReturnType operator[]( size_t index ) const {
4105  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4106  return vector_[offset_+index];
4107  }
4108  //**********************************************************************************************
4109 
4110  //**Size function*******************************************************************************
4115  inline size_t size() const {
4116  return size_;
4117  }
4118  //**********************************************************************************************
4119 
4120  //**********************************************************************************************
4126  template< typename T >
4127  inline bool canAlias( const T* alias ) const {
4128  return vector_.canAlias( alias );
4129  }
4130  //**********************************************************************************************
4131 
4132  //**********************************************************************************************
4138  template< typename T >
4139  inline bool isAliased( const T* alias ) const {
4140  return vector_.isAliased( alias );
4141  }
4142  //**********************************************************************************************
4143 
4144  private:
4145  //**Member variables****************************************************************************
4148  CPE vector_;
4149  const size_t offset_;
4150  const size_t size_;
4151 
4152  //**********************************************************************************************
4153 
4154  //**Friend declarations*************************************************************************
4155  template< bool AF1, typename VT, bool AF2, bool TF >
4156  friend const DenseSubvector<VT,AF1,TF>
4157  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size );
4158 
4159  template< typename VT3, bool AF3, bool TF3 >
4160  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseVector<VT3,TF3>& b );
4161 
4162  template< typename VT3, bool AF3, bool TF3 >
4163  friend bool isSame( const DenseVector<VT3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4164 
4165  template< typename VT3, bool AF3, bool TF3 >
4166  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4167  //**********************************************************************************************
4168 };
4170 //*************************************************************************************************
4171 
4172 
4173 
4174 
4175 
4176 
4177 
4178 
4179 //=================================================================================================
4180 //
4181 // CLASS TEMPLATE SPECIALIZATION FOR SVECDVECCROSSEXPR
4182 //
4183 //=================================================================================================
4184 
4185 //*************************************************************************************************
4193 template< typename VT1 // Type of the left-hand side sparse vector
4194  , typename VT2 > // Type of the right-hand side dense vector
4195 class DenseSubvector< SVecDVecCrossExpr<VT1,VT2>, unaligned, false >
4196  : public DenseVector< DenseSubvector< SVecDVecCrossExpr<VT1,VT2>, unaligned, false >, false >
4197  , private Subvector
4198 {
4199  private:
4200  //**Type definitions****************************************************************************
4201  typedef SVecDVecCrossExpr<VT1,VT2> CPE;
4202  typedef typename CPE::ResultType RT;
4203  //**********************************************************************************************
4204 
4205  public:
4206  //**Type definitions****************************************************************************
4207  typedef DenseSubvector<CPE,unaligned,false> This;
4208  typedef typename SubvectorTrait<RT>::Type ResultType;
4209  typedef typename ResultType::TransposeType TransposeType;
4210  typedef typename CPE::ElementType ElementType;
4211  typedef typename CPE::ReturnType ReturnType;
4212  typedef const ResultType CompositeType;
4213  //**********************************************************************************************
4214 
4215  //**Compilation flags***************************************************************************
4217  enum { vectorizable = 0 };
4218 
4220  enum { smpAssignable = 0 };
4221  //**********************************************************************************************
4222 
4223  //**Constructor*********************************************************************************
4230  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
4231  : vector_( vector ) // The sparse vector/dense vector cross product expression
4232  , offset_( index ) // The offset of the subvector within the cross product expression
4233  , size_ ( n ) // The size of the subvector
4234  {}
4235  //**********************************************************************************************
4236 
4237  //**Subscript operator**************************************************************************
4243  inline ReturnType operator[]( size_t index ) const {
4244  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4245  return vector_[offset_+index];
4246  }
4247  //**********************************************************************************************
4248 
4249  //**Size function*******************************************************************************
4254  inline size_t size() const {
4255  return size_;
4256  }
4257  //**********************************************************************************************
4258 
4259  //**********************************************************************************************
4265  template< typename T >
4266  inline bool canAlias( const T* alias ) const {
4267  return vector_.canAlias( alias );
4268  }
4269  //**********************************************************************************************
4270 
4271  //**********************************************************************************************
4277  template< typename T >
4278  inline bool isAliased( const T* alias ) const {
4279  return vector_.isAliased( alias );
4280  }
4281  //**********************************************************************************************
4282 
4283  private:
4284  //**Member variables****************************************************************************
4287  CPE vector_;
4288  const size_t offset_;
4289  const size_t size_;
4290 
4291  //**********************************************************************************************
4292 
4293  //**Friend declarations*************************************************************************
4294  template< bool AF1, typename VT, bool AF2, bool TF >
4295  friend const DenseSubvector<VT,AF1,TF>
4296  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size );
4297 
4298  template< typename VT3, bool AF3, bool TF3 >
4299  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseVector<VT3,TF3>& b );
4300 
4301  template< typename VT3, bool AF3, bool TF3 >
4302  friend bool isSame( const DenseVector<VT3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4303 
4304  template< typename VT3, bool AF3, bool TF3 >
4305  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4306  //**********************************************************************************************
4307 };
4309 //*************************************************************************************************
4310 
4311 
4312 
4313 
4314 
4315 
4316 
4317 
4318 //=================================================================================================
4319 //
4320 // CLASS TEMPLATE SPECIALIZATION FOR SVECSVECCROSSEXPR
4321 //
4322 //=================================================================================================
4323 
4324 //*************************************************************************************************
4332 template< typename VT1 // Type of the left-hand side sparse vector
4333  , typename VT2 > // Type of the right-hand side sparse vector
4334 class DenseSubvector< SVecSVecCrossExpr<VT1,VT2>, unaligned, false >
4335  : public DenseVector< DenseSubvector< SVecSVecCrossExpr<VT1,VT2>, unaligned, false >, false >
4336  , private Subvector
4337 {
4338  private:
4339  //**Type definitions****************************************************************************
4340  typedef SVecSVecCrossExpr<VT1,VT2> CPE;
4341  typedef typename CPE::ResultType RT;
4342  //**********************************************************************************************
4343 
4344  public:
4345  //**Type definitions****************************************************************************
4346  typedef DenseSubvector<CPE,unaligned,false> This;
4347  typedef typename SubvectorTrait<RT>::Type ResultType;
4348  typedef typename ResultType::TransposeType TransposeType;
4349  typedef typename CPE::ElementType ElementType;
4350  typedef typename CPE::ReturnType ReturnType;
4351  typedef const ResultType CompositeType;
4352  //**********************************************************************************************
4353 
4354  //**Compilation flags***************************************************************************
4356  enum { vectorizable = 0 };
4357 
4359  enum { smpAssignable = 0 };
4360  //**********************************************************************************************
4361 
4362  //**Constructor*********************************************************************************
4369  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
4370  : vector_( vector ) // The sparse vector/sparse vector cross product expression
4371  , offset_( index ) // The offset of the subvector within the cross product expression
4372  , size_ ( n ) // The size of the subvector
4373  {}
4374  //**********************************************************************************************
4375 
4376  //**Subscript operator**************************************************************************
4382  inline ReturnType operator[]( size_t index ) const {
4383  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4384  return vector_[offset_+index];
4385  }
4386  //**********************************************************************************************
4387 
4388  //**Size function*******************************************************************************
4393  inline size_t size() const {
4394  return size_;
4395  }
4396  //**********************************************************************************************
4397 
4398  //**********************************************************************************************
4404  template< typename T >
4405  inline bool canAlias( const T* alias ) const {
4406  return vector_.canAlias( alias );
4407  }
4408  //**********************************************************************************************
4409 
4410  //**********************************************************************************************
4416  template< typename T >
4417  inline bool isAliased( const T* alias ) const {
4418  return vector_.isAliased( alias );
4419  }
4420  //**********************************************************************************************
4421 
4422  private:
4423  //**Member variables****************************************************************************
4426  CPE vector_;
4427  const size_t offset_;
4428  const size_t size_;
4429 
4430  //**********************************************************************************************
4431 
4432  //**Friend declarations*************************************************************************
4433  template< bool AF1, typename VT, bool AF2, bool TF >
4434  friend const DenseSubvector<VT,AF1,TF>
4435  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size );
4436 
4437  template< typename VT3, bool AF3, bool TF3 >
4438  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseVector<VT3,TF3>& b );
4439 
4440  template< typename VT3, bool AF3, bool TF3 >
4441  friend bool isSame( const DenseVector<VT3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4442 
4443  template< typename VT3, bool AF3, bool TF3 >
4444  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4445  //**********************************************************************************************
4446 };
4448 //*************************************************************************************************
4449 
4450 
4451 
4452 
4453 
4454 
4455 
4456 
4457 //=================================================================================================
4458 //
4459 // DENSESUBVECTOR OPERATORS
4460 //
4461 //=================================================================================================
4462 
4463 //*************************************************************************************************
4466 template< typename VT, bool AF, bool TF >
4467 inline void reset( DenseSubvector<VT,AF,TF>& dv );
4468 
4469 template< typename VT, bool AF, bool TF >
4470 inline void clear( DenseSubvector<VT,AF,TF>& dv );
4471 
4472 template< typename VT, bool AF, bool TF >
4473 inline bool isDefault( const DenseSubvector<VT,AF,TF>& dv );
4474 
4475 template< typename VT, bool AF, bool TF >
4476 inline bool isSame( const DenseSubvector<VT,AF,TF>& a, const DenseVector<VT,TF>& b );
4477 
4478 template< typename VT, bool AF, bool TF >
4479 inline bool isSame( const DenseVector<VT,TF>& a, const DenseSubvector<VT,AF,TF>& b );
4480 
4481 template< typename VT, bool AF, bool TF >
4482 inline bool isSame( const DenseSubvector<VT,AF,TF>& a, const DenseSubvector<VT,AF,TF>& b );
4484 //*************************************************************************************************
4485 
4486 
4487 //*************************************************************************************************
4494 template< typename VT // Type of the dense vector
4495  , bool AF // Alignment flag
4496  , bool TF > // Transpose flag
4498 {
4499  dv.reset();
4500 }
4501 //*************************************************************************************************
4502 
4503 
4504 //*************************************************************************************************
4511 template< typename VT // Type of the dense vector
4512  , bool AF // Alignment flag
4513  , bool TF > // Transpose flag
4515 {
4516  dv.reset();
4517 }
4518 //*************************************************************************************************
4519 
4520 
4521 //*************************************************************************************************
4540 template< typename VT // Type of the dense vector
4541  , bool AF // Alignment flag
4542  , bool TF > // Transpose flag
4543 inline bool isDefault( const DenseSubvector<VT,AF,TF>& dv )
4544 {
4545  for( size_t i=0UL; i<dv.size(); ++i )
4546  if( !isDefault( dv[i] ) ) return false;
4547  return true;
4548 }
4549 //*************************************************************************************************
4550 
4551 
4552 //*************************************************************************************************
4564 template< typename VT, bool AF, bool TF >
4565 inline bool isSame( const DenseSubvector<VT,AF,TF>& a, const DenseVector<VT,TF>& b )
4566 {
4567  return ( isSame( a.vector_, ~b ) && ( a.size() == (~b).size() ) );
4568 }
4569 //*************************************************************************************************
4570 
4571 
4572 //*************************************************************************************************
4584 template< typename VT, bool AF, bool TF >
4585 inline bool isSame( const DenseVector<VT,TF>& a, const DenseSubvector<VT,AF,TF>& b )
4586 {
4587  return ( isSame( ~a, b.vector_ ) && ( (~a).size() == b.size() ) );
4588 }
4589 //*************************************************************************************************
4590 
4591 
4592 //*************************************************************************************************
4604 template< typename VT, bool AF, bool TF >
4606 {
4607  return ( isSame( a.vector_, b.vector_ ) && ( a.offset_ == b.offset_ ) && ( a.size_ == b.size_ ) );
4608 }
4609 //*************************************************************************************************
4610 
4611 
4612 
4613 
4614 //=================================================================================================
4615 //
4616 // GLOBAL RESTRUCTURING OPERATORS
4617 //
4618 //=================================================================================================
4619 
4620 //*************************************************************************************************
4633 template< bool AF1 // Required alignment flag
4634  , typename VT // Type of the dense vector
4635  , bool AF2 // Present alignment flag
4636  , bool TF > // Transpose flag
4637 inline const DenseSubvector<VT,AF1,TF>
4638  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size )
4639 {
4641 
4642  if( index + size > dv.size() )
4643  throw std::invalid_argument( "Invalid subvector specification" );
4644 
4645  return DenseSubvector<VT,AF1,TF>( dv.vector_, dv.offset_ + index, size );
4646 }
4648 //*************************************************************************************************
4649 
4650 
4651 
4652 
4653 //=================================================================================================
4654 //
4655 // SUBVECTORTRAIT SPECIALIZATIONS
4656 //
4657 //=================================================================================================
4658 
4659 //*************************************************************************************************
4661 template< typename VT, bool AF, bool TF >
4662 struct SubvectorTrait< DenseSubvector<VT,AF,TF> >
4663 {
4665 };
4667 //*************************************************************************************************
4668 
4669 
4670 
4671 
4672 //=================================================================================================
4673 //
4674 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
4675 //
4676 //=================================================================================================
4677 
4678 //*************************************************************************************************
4680 template< typename VT, bool AF1, bool TF, bool AF2 >
4681 struct SubvectorExprTrait< DenseSubvector<VT,AF1,TF>, AF2 >
4682 {
4683  typedef DenseSubvector<VT,AF2,TF> Type;
4684 };
4686 //*************************************************************************************************
4687 
4688 
4689 //*************************************************************************************************
4691 template< typename VT, bool AF1, bool TF, bool AF2 >
4692 struct SubvectorExprTrait< const DenseSubvector<VT,AF1,TF>, AF2 >
4693 {
4694  typedef DenseSubvector<VT,AF2,TF> Type;
4695 };
4697 //*************************************************************************************************
4698 
4699 
4700 //*************************************************************************************************
4702 template< typename VT, bool AF1, bool TF, bool AF2 >
4703 struct SubvectorExprTrait< volatile DenseSubvector<VT,AF1,TF>, AF2 >
4704 {
4705  typedef DenseSubvector<VT,AF2,TF> Type;
4706 };
4708 //*************************************************************************************************
4709 
4710 
4711 //*************************************************************************************************
4713 template< typename VT, bool AF1, bool TF, bool AF2 >
4714 struct SubvectorExprTrait< const volatile DenseSubvector<VT,AF1,TF>, AF2 >
4715 {
4716  typedef DenseSubvector<VT,AF2,TF> Type;
4717 };
4719 //*************************************************************************************************
4720 
4721 
4722 //*************************************************************************************************
4724 template< typename VT1, typename VT2, bool AF >
4725 struct SubvectorExprTrait< DVecDVecCrossExpr<VT1,VT2>, AF >
4726 {
4727  public:
4728  //**********************************************************************************************
4729  typedef DenseSubvector< DVecDVecCrossExpr<VT1,VT2>, unaligned, false > Type;
4730  //**********************************************************************************************
4731 };
4733 //*************************************************************************************************
4734 
4735 
4736 //*************************************************************************************************
4738 template< typename VT1, typename VT2, bool AF >
4739 struct SubvectorExprTrait< DVecSVecCrossExpr<VT1,VT2>, AF >
4740 {
4741  public:
4742  //**********************************************************************************************
4743  typedef DenseSubvector< DVecSVecCrossExpr<VT1,VT2>, unaligned, false > Type;
4744  //**********************************************************************************************
4745 };
4747 //*************************************************************************************************
4748 
4749 
4750 //*************************************************************************************************
4752 template< typename VT1, typename VT2, bool AF >
4753 struct SubvectorExprTrait< SVecDVecCrossExpr<VT1,VT2>, AF >
4754 {
4755  public:
4756  //**********************************************************************************************
4757  typedef DenseSubvector< SVecDVecCrossExpr<VT1,VT2>, unaligned, false > Type;
4758  //**********************************************************************************************
4759 };
4761 //*************************************************************************************************
4762 
4763 
4764 //*************************************************************************************************
4766 template< typename VT1, typename VT2, bool AF >
4767 struct SubvectorExprTrait< SVecSVecCrossExpr<VT1,VT2>, AF >
4768 {
4769  public:
4770  //**********************************************************************************************
4771  typedef DenseSubvector< SVecSVecCrossExpr<VT1,VT2>, unaligned, false > Type;
4772  //**********************************************************************************************
4773 };
4775 //*************************************************************************************************
4776 
4777 } // namespace blaze
4778 
4779 #endif
const ElementType * ConstPointer
Pointer to a constant subvector value.
Definition: DenseSubvector.h:416
Constraint on the data type.
const size_t final_
The final index for unaligned intrinsic operations.
Definition: DenseSubvector.h:975
Constraint on the data type.
BLAZE_ALWAYS_INLINE void multAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the multiplication assignment of a matrix to a matrix.
Definition: Matrix.h:879
bool canAlias(const Other *alias) const
Returns whether the dense subvector can alias with the given address alias.
Definition: DenseSubvector.h:1627
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the subvector/submatrix alignment flag values.
const size_t rest_
The number of remaining elements in an unaligned intrinsic operation.
Definition: DenseSubvector.h:974
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:258
SubvectorIterator(IteratorType iterator, IteratorType finalIterator, size_t remainingElements, bool isMemoryAligned)
Constructor of the SubvectorIterator class.
Definition: DenseSubvector.h:472
SubvectorIterator()
Default constructor of the SubvectorIterator class.
Definition: DenseSubvector.h:456
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:258
IT::Type IntrinsicType
Intrinsic type of the subvector elements.
Definition: DenseSubvector.h:405
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:118
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:946
ReferenceType reference
Reference return type.
Definition: DenseSubvector.h:449
Header file for the IsSame and IsStrictlySame type traits.
size_t nonZeros() const
Returns the number of non-zero elements in the subvector.
Definition: DenseSubvector.h:1551
const bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Streaming.h:50
bool isAligned_
Memory alignment flag.
Definition: DenseSubvector.h:772
Header file for the IsRowVector type trait.
const DenseSubvector & CompositeType
Data type for composite expression templates.
Definition: DenseSubvector.h:407
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:224
Header file for the DenseVector base class.
SelectType< useConst, ConstReference, typename VT::Reference >::Type Reference
Reference to a non-constant subvector value.
Definition: DenseSubvector.h:413
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:695
SubvectorIterator(const SubvectorIterator< IteratorType2 > &it)
Conversion constructor from different SubvectorIterator instances.
Definition: DenseSubvector.h:487
Header file for the Computation base class.
IntrinsicType loadu() const
Unaligned load of an intrinsic element of the dense subvector.
Definition: DenseSubvector.h:596
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:118
bool operator==(const SubvectorIterator &rhs) const
Equality comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:620
DenseSubvector(Operand vector, size_t index, size_t n)
The constructor for DenseSubvector.
Definition: DenseSubvector.h:1048
IntrinsicTrait< typename VT::ElementType > IT
Intrinsic trait for the vector element type.
Definition: DenseSubvector.h:385
const size_t offset_
The offset of the subvector within the dense vector.
Definition: DenseSubvector.h:972
size_t capacity() const
Returns the maximum capacity of the dense subvector.
Definition: DenseSubvector.h:1533
Iterator begin()
Returns an iterator to the first element of the subvector.
Definition: DenseSubvector.h:1151
DenseSubvector & operator=(const ElementType &rhs)
Homogenous assignment to all subvector elements.
Definition: DenseSubvector.h:1266
const bool aligned
Alignment flag for aligned subvectors and submatrices.
Definition: AlignmentFlag.h:83
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:123
void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the subvector.
Definition: DenseSubvector.h:1893
Constraint on the data type.
void reset()
Reset to the default initial values.
Definition: DenseSubvector.h:1574
Pointer data()
Low-level data access to the subvector elements.
Definition: DenseSubvector.h:1117
DifferenceType difference_type
Difference between two iterators.
Definition: DenseSubvector.h:450
Pointer data()
Low-level data access to the array elements.
Definition: AlignedArray.h:441
SubvectorTrait< VT >::Type ResultType
Result type for expression template evaluations.
Definition: DenseSubvector.h:402
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the DisableIf class template.
void store(size_t index, const IntrinsicType &value)
Aligned store of an intrinsic element of the subvector.
Definition: DenseSubvector.h:1827
Operand vector_
The dense vector containing the subvector.
Definition: DenseSubvector.h:971
const SubvectorIterator operator--(int)
Post-decrement operator.
Definition: DenseSubvector.h:556
Header file for the clear shim.
Header file for nested template disabiguation.
Header file for the Subvector base class.
Reference operator[](size_t index)
Subscript operator for the direct access to the subvector elements.
Definition: DenseSubvector.h:1081
SubvectorIterator & operator++()
Pre-increment operator.
Definition: DenseSubvector.h:524
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
Header file for the Or class template.
friend const SubvectorIterator operator-(const SubvectorIterator &it, size_t dec)
Subtraction between a SubvectorIterator and an integral value.
Definition: DenseSubvector.h:722
std::iterator_traits< IteratorType >::difference_type DifferenceType
Difference between two iterators.
Definition: DenseSubvector.h:443
ConstIterator cbegin() const
Returns an iterator to the first element of the subvector.
Definition: DenseSubvector.h:1187
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
DifferenceType operator-(const SubvectorIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DenseSubvector.h:686
VT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: DenseSubvector.h:406
Header file for the subvector trait.
DenseSubvector< VT, AF, TF > This
Type of this DenseSubvector instance.
Definition: DenseSubvector.h:401
friend const SubvectorIterator operator+(size_t inc, const SubvectorIterator &it)
Addition between an integral value and a SubvectorIterator.
Definition: DenseSubvector.h:710
bool operator!=(const SubvectorIterator &rhs) const
Inequality comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:631
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
SubvectorIterator & operator--()
Pre-decrement operator.
Definition: DenseSubvector.h:545
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:221
IteratorType iterator_
Iterator to the current subvector element.
Definition: DenseSubvector.h:769
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a vectorizable data type...
Definition: Vectorizable.h:79
IteratorType base() const
Access to the current position of the subvector iterator.
Definition: DenseSubvector.h:732
Constraint on the data type.
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:195
size_t size() const
Returns the current size/dimension of the dense subvector.
Definition: DenseSubvector.h:1518
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2476
Constraint on the data type.
Header file for the SelectType class template.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2480
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DenseSubvector.h:403
SelectType< useConst, ConstPointer, ElementType * >::Type Pointer
Pointer to a non-constant subvector value.
Definition: DenseSubvector.h:419
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
const bool unaligned
Alignment flag for unaligned subvectors and submatrices.
Definition: AlignmentFlag.h:63
std::iterator_traits< IteratorType >::iterator_category IteratorCategory
The iterator category.
Definition: DenseSubvector.h:431
Header file for the CrossExpr base class.
Header file for the IsNumeric type trait.
size_t rest_
The number of remaining elements beyond the final iterator.
Definition: DenseSubvector.h:771
SelectType< useConst, ConstIterator, SubvectorIterator< typename VT::Iterator > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseSubvector.h:782
EnableIf< IsDenseMatrix< MT1 > >::Type smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
Header file for the IsSparseVector type trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2477
Header file for the IsConst type trait.
Iterator end()
Returns an iterator just past the last element of the subvector.
Definition: DenseSubvector.h:1205
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:749
Header file for run time assertion macros.
EnableIf< IsDenseMatrix< MT1 > >::Type smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
Base class for all subvectors.The Subvector class serves as a tag for all subvectors (i...
Definition: Subvector.h:64
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
View on a specific subvector of a dense vector.The DenseSubvector template represents a view on a spe...
Definition: DenseSubvector.h:376
SubvectorIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DenseSubvector.h:501
bool operator>(const SubvectorIterator &rhs) const
Greater-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:653
bool isAligned() const
Returns whether the subvector is properly aligned in memory.
Definition: DenseSubvector.h:1715
std::iterator_traits< IteratorType >::pointer PointerType
Pointer return type.
Definition: DenseSubvector.h:437
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
SubvectorExprTrait< VT, unaligned >::Type subvector(Vector< VT, TF > &vector, size_t index, size_t size)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:135
ValueType value_type
Type of the underlying elements.
Definition: DenseSubvector.h:447
Header file for the AlignedArray implementation.
Header file for the cache size of the target architecture.
bool canSMPAssign() const
Returns whether the subvector can be used in SMP assignments.
Definition: DenseSubvector.h:1735
bool isAligned() const
Access to the iterator's memory alignment flag.
Definition: DenseSubvector.h:762
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2481
Header file for the isDefault shim.
ReferenceType operator*() const
Direct access to the element at the current iterator position.
Definition: DenseSubvector.h:566
IteratorType final() const
Access to the final position of the subvector iterator.
Definition: DenseSubvector.h:742
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
const size_t size_
The size of the subvector.
Definition: DenseSubvector.h:973
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
#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:118
IntrinsicType load() const
Aligned load of an intrinsic element of the dense subvector.
Definition: DenseSubvector.h:581
const SubvectorIterator operator++(int)
Post-increment operator.
Definition: DenseSubvector.h:535
IteratorCategory iterator_category
The iterator category.
Definition: DenseSubvector.h:446
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Compile time check for constant data types.The IsConst type trait tests whether or not the given temp...
Definition: IsConst.h:94
size_t rest() const
Access to the number of remaining elements beyond the final iterator.
Definition: DenseSubvector.h:752
VT::ConstReference ConstReference
Reference to a constant subvector value.
Definition: DenseSubvector.h:410
SubvectorIterator< typename VT::ConstIterator > ConstIterator
Iterator over constant elements.
Definition: DenseSubvector.h:779
Header file for all intrinsic functionality.
IntrinsicType loadu(size_t index) const
Unaligned load of an intrinsic element of the dense subvector.
Definition: DenseSubvector.h:1783
friend const SubvectorIterator operator+(const SubvectorIterator &it, size_t inc)
Addition between a SubvectorIterator and an integral value.
Definition: DenseSubvector.h:698
bool isAliased(const Other *alias) const
Returns whether the dense subvector is aliased with the given address alias.
Definition: DenseSubvector.h:1672
#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:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SUBVECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is a subvector type (i.e. a dense or sparse subvector), a compilation error is created.
Definition: Subvector.h:118
PointerType pointer
Pointer return type.
Definition: DenseSubvector.h:448
const bool isAligned_
Memory alignment flag.
Definition: DenseSubvector.h:980
IteratorType final_
The final iterator for intrinsic operations.
Definition: DenseSubvector.h:770
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:151
IntrinsicType load(size_t index) const
Aligned load of an intrinsic element of the dense subvector.
Definition: DenseSubvector.h:1759
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:256
EnableIf< IsDenseMatrix< MT1 > >::Type smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
bool operator>=(const SubvectorIterator &rhs) const
Greater-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:675
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2473
ConstIterator cend() const
Returns an iterator just past the last element of the subvector.
Definition: DenseSubvector.h:1241
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:218
Header file for the SubvectorExprTrait class template.
SubvectorIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DenseSubvector.h:513
Implementation of a static array with a fixed alignment.The AlignedArray class template represents a ...
Definition: AlignedArray.h:264
Iterator over the elements of the sparse subvector.
Definition: DenseSubvector.h:426
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2479
std::iterator_traits< IteratorType >::value_type ValueType
Type of the underlying elements.
Definition: DenseSubvector.h:434
VT::ElementType ElementType
Type of the subvector elements.
Definition: DenseSubvector.h:404
const size_t SMP_DVECASSIGN_THRESHOLD
SMP dense vector assignment threshold.This threshold specifies when an assignment of a simple dense v...
Definition: Thresholds.h:207
void storeu(size_t index, const IntrinsicType &value)
Unaligned store of an intrinsic element of the subvector.
Definition: DenseSubvector.h:1851
SelectType< IsExpression< VT >::value, VT, VT & >::Type Operand
Composite data type of the dense vector expression.
Definition: DenseSubvector.h:382
const size_t cacheSize
Cache size of the target architecture.This setting specifies the available cache size in Byte of the ...
Definition: CacheSize.h:48
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:225
bool operator<(const SubvectorIterator &rhs) const
Less-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:642
EnableIf< IsDenseVector< VT1 > >::Type 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:189
bool operator<=(const SubvectorIterator &rhs) const
Less-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:664
#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:238
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
std::iterator_traits< IteratorType >::reference ReferenceType
Reference return type.
Definition: DenseSubvector.h:440
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849