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>
59 #include <blaze/math/shims/Reset.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******************************************************************************
461  explicit inline SubvectorIterator( IteratorType iterator, IteratorType final, size_t rest, bool isAligned )
462  : iterator_ ( iterator ) // Iterator to the current subvector element
463  , final_ ( final ) // The final iterator for intrinsic operations
464  , rest_ ( rest ) // The number of remaining elements beyond the final iterator
465  , isAligned_( isAligned ) // Memory alignment flag
466  {}
467  //*******************************************************************************************
468 
469  //**Addition assignment operator*************************************************************
475  inline SubvectorIterator& operator+=( size_t inc ) {
476  iterator_ += inc;
477  return *this;
478  }
479  //*******************************************************************************************
480 
481  //**Subtraction assignment operator**********************************************************
487  inline SubvectorIterator& operator-=( size_t dec ) {
488  iterator_ -= dec;
489  return *this;
490  }
491  //*******************************************************************************************
492 
493  //**Prefix increment operator****************************************************************
499  ++iterator_;
500  return *this;
501  }
502  //*******************************************************************************************
503 
504  //**Postfix increment operator***************************************************************
509  inline const SubvectorIterator operator++( int ) {
511  }
512  //*******************************************************************************************
513 
514  //**Prefix decrement operator****************************************************************
520  --iterator_;
521  return *this;
522  }
523  //*******************************************************************************************
524 
525  //**Postfix decrement operator***************************************************************
530  inline const SubvectorIterator operator--( int ) {
532  }
533  //*******************************************************************************************
534 
535  //**Element access operator******************************************************************
540  inline ReferenceType operator*() const {
541  return *iterator_;
542  }
543  //*******************************************************************************************
544 
545  //**Load function****************************************************************************
555  inline IntrinsicType load() const {
556  return loadu();
557  }
558  //*******************************************************************************************
559 
560  //**Loadu function***************************************************************************
570  inline IntrinsicType loadu() const {
571  if( isAligned_ ) {
572  return iterator_.load();
573  }
574  else if( iterator_ != final_ ) {
575  return iterator_.loadu();
576  }
577  else {
579  for( size_t i=0UL; i<rest_; ++i )
580  array[i] = *(iterator_+i);
581  for( size_t i=rest_; i<IT::size; ++i )
582  array[i] = ElementType();
583  return blaze::load( array.data() );
584  }
585  }
586  //*******************************************************************************************
587 
588  //**Equality operator************************************************************************
594  inline bool operator==( const SubvectorIterator& rhs ) const {
595  return iterator_ == rhs.iterator_;
596  }
597  //*******************************************************************************************
598 
599  //**Inequality operator**********************************************************************
605  inline bool operator!=( const SubvectorIterator& rhs ) const {
606  return iterator_ != rhs.iterator_;
607  }
608  //*******************************************************************************************
609 
610  //**Less-than operator***********************************************************************
616  inline bool operator<( const SubvectorIterator& rhs ) const {
617  return iterator_ < rhs.iterator_;
618  }
619  //*******************************************************************************************
620 
621  //**Greater-than operator********************************************************************
627  inline bool operator>( const SubvectorIterator& rhs ) const {
628  return iterator_ > rhs.iterator_;
629  }
630  //*******************************************************************************************
631 
632  //**Less-or-equal-than operator**************************************************************
638  inline bool operator<=( const SubvectorIterator& rhs ) const {
639  return iterator_ <= rhs.iterator_;
640  }
641  //*******************************************************************************************
642 
643  //**Greater-or-equal-than operator***********************************************************
649  inline bool operator>=( const SubvectorIterator& rhs ) const {
650  return iterator_ >= rhs.iterator_;
651  }
652  //*******************************************************************************************
653 
654  //**Subtraction operator*********************************************************************
660  inline DifferenceType operator-( const SubvectorIterator& rhs ) const {
661  return iterator_ - rhs.iterator_;
662  }
663  //*******************************************************************************************
664 
665  //**Addition operator************************************************************************
672  friend inline const SubvectorIterator operator+( const SubvectorIterator& it, size_t inc ) {
673  return SubvectorIterator( it.iterator_ + inc, it.final_, it.rest_, it.isAligned_ );
674  }
675  //*******************************************************************************************
676 
677  //**Addition operator************************************************************************
684  friend inline const SubvectorIterator operator+( size_t inc, const SubvectorIterator& it ) {
685  return SubvectorIterator( it.iterator_ + inc, it.final_, it.rest_, it.isAligned_ );
686  }
687  //*******************************************************************************************
688 
689  //**Subtraction operator*********************************************************************
696  friend inline const SubvectorIterator operator-( const SubvectorIterator& it, size_t dec ) {
697  return SubvectorIterator( it.iterator_ - dec, it.final_, it.rest_, it.isAligned_ );
698  }
699  //*******************************************************************************************
700 
701  private:
702  //**Member variables*************************************************************************
703  IteratorType iterator_;
704  IteratorType final_;
705  size_t rest_;
706  bool isAligned_;
707  //*******************************************************************************************
708  };
709  //**********************************************************************************************
710 
711  //**Type definitions****************************************************************************
714 
717  //**********************************************************************************************
718 
719  //**Compilation flags***************************************************************************
721  enum { vectorizable = VT::vectorizable };
722 
724  enum { smpAssignable = VT::smpAssignable };
725  //**********************************************************************************************
726 
727  //**Constructors********************************************************************************
730  explicit inline DenseSubvector( Operand vector, size_t index, size_t n );
731  // No explicitly declared copy constructor.
733  //**********************************************************************************************
734 
735  //**Destructor**********************************************************************************
736  // No explicitly declared destructor.
737  //**********************************************************************************************
738 
739  //**Data access functions***********************************************************************
742  inline Reference operator[]( size_t index );
743  inline ConstReference operator[]( size_t index ) const;
744  inline Pointer data ();
745  inline ConstPointer data () const;
746  inline Iterator begin ();
747  inline ConstIterator begin () const;
748  inline ConstIterator cbegin() const;
749  inline Iterator end ();
750  inline ConstIterator end () const;
751  inline ConstIterator cend () const;
753  //**********************************************************************************************
754 
755  //**Assignment operators************************************************************************
758  inline DenseSubvector& operator= ( const ElementType& rhs );
759  inline DenseSubvector& operator= ( const DenseSubvector& rhs );
760  template< typename VT2 > inline DenseSubvector& operator= ( const Vector<VT2,TF>& rhs );
761  template< typename VT2 > inline DenseSubvector& operator+=( const Vector<VT2,TF>& rhs );
762  template< typename VT2 > inline DenseSubvector& operator-=( const Vector<VT2,TF>& rhs );
763  template< typename VT2 > inline DenseSubvector& operator*=( const Vector<VT2,TF>& rhs );
764 
765  template< typename Other >
766  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
767  operator*=( Other rhs );
768 
769  template< typename Other >
770  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
771  operator/=( Other rhs );
773  //**********************************************************************************************
774 
775  //**Utility functions***************************************************************************
778  inline size_t size() const;
779  inline size_t capacity() const;
780  inline size_t nonZeros() const;
781  inline void reset();
782  template< typename Other > inline DenseSubvector& scale( const Other& scalar );
784  //**********************************************************************************************
785 
786  private:
787  //**********************************************************************************************
789  template< typename VT2 >
791  struct VectorizedAssign {
792  enum { value = vectorizable && VT2::vectorizable &&
793  IsSame<ElementType,typename VT2::ElementType>::value };
794  };
796  //**********************************************************************************************
797 
798  //**********************************************************************************************
800  template< typename VT2 >
802  struct VectorizedAddAssign {
803  enum { value = vectorizable && VT2::vectorizable &&
804  IsSame<ElementType,typename VT2::ElementType>::value &&
805  IntrinsicTrait<ElementType>::addition };
806  };
808  //**********************************************************************************************
809 
810  //**********************************************************************************************
812  template< typename VT2 >
814  struct VectorizedSubAssign {
815  enum { value = vectorizable && VT2::vectorizable &&
816  IsSame<ElementType,typename VT2::ElementType>::value &&
817  IntrinsicTrait<ElementType>::subtraction };
818  };
820  //**********************************************************************************************
821 
822  //**********************************************************************************************
824  template< typename VT2 >
826  struct VectorizedMultAssign {
827  enum { value = vectorizable && VT2::vectorizable &&
828  IsSame<ElementType,typename VT2::ElementType>::value &&
829  IntrinsicTrait<ElementType>::multiplication };
830  };
832  //**********************************************************************************************
833 
834  public:
835  //**Expression template evaluation functions****************************************************
838  template< typename Other >
839  inline bool canAlias( const Other* alias ) const;
840 
841  template< typename VT2, bool AF2, bool TF2 >
842  inline bool canAlias( const DenseSubvector<VT2,AF2,TF2>* alias ) const;
843 
844  template< typename Other >
845  inline bool isAliased( const Other* alias ) const;
846 
847  template< typename VT2, bool AF2, bool TF2 >
848  inline bool isAliased( const DenseSubvector<VT2,AF2,TF2>* alias ) const;
849 
850  inline bool isAligned () const;
851  inline bool canSMPAssign() const;
852 
853  inline IntrinsicType load ( size_t index ) const;
854  inline IntrinsicType loadu ( size_t index ) const;
855  inline void store ( size_t index, const IntrinsicType& value );
856  inline void storeu( size_t index, const IntrinsicType& value );
857  inline void stream( size_t index, const IntrinsicType& value );
858 
859  template< typename VT2 >
860  inline typename DisableIf< VectorizedAssign<VT2> >::Type
861  assign( const DenseVector <VT2,TF>& rhs );
862 
863  template< typename VT2 >
864  inline typename EnableIf< VectorizedAssign<VT2> >::Type
865  assign( const DenseVector <VT2,TF>& rhs );
866 
867  template< typename VT2 > inline void assign( const SparseVector<VT2,TF>& rhs );
868 
869  template< typename VT2 >
870  inline typename DisableIf< VectorizedAddAssign<VT2> >::Type
871  addAssign( const DenseVector <VT2,TF>& rhs );
872 
873  template< typename VT2 >
874  inline typename EnableIf< VectorizedAddAssign<VT2> >::Type
875  addAssign ( const DenseVector <VT2,TF>& rhs );
876 
877  template< typename VT2 > inline void addAssign( const SparseVector<VT2,TF>& rhs );
878 
879  template< typename VT2 >
880  inline typename DisableIf< VectorizedSubAssign<VT2> >::Type
881  subAssign ( const DenseVector <VT2,TF>& rhs );
882 
883  template< typename VT2 >
884  inline typename EnableIf< VectorizedSubAssign<VT2> >::Type
885  subAssign( const DenseVector <VT2,TF>& rhs );
886 
887  template< typename VT2 > inline void subAssign( const SparseVector<VT2,TF>& rhs );
888 
889  template< typename VT2 >
890  inline typename DisableIf< VectorizedMultAssign<VT2> >::Type
891  multAssign( const DenseVector <VT2,TF>& rhs );
892 
893  template< typename VT2 >
894  inline typename EnableIf< VectorizedMultAssign<VT2> >::Type
895  multAssign( const DenseVector <VT2,TF>& rhs );
896 
897  template< typename VT2 > inline void multAssign( const SparseVector<VT2,TF>& rhs );
899  //**********************************************************************************************
900 
901  private:
902  //**Member variables****************************************************************************
906  const size_t offset_;
907  const size_t size_;
908  const size_t rest_;
909  const size_t final_;
910 
914  const bool isAligned_;
915 
925  //**********************************************************************************************
926 
927  //**Friend declarations*************************************************************************
929  template< typename VT2, bool AF2, bool TF2 > friend class DenseSubvector;
930 
931  template< bool AF1, typename VT2, bool AF2, bool TF2 >
932  friend const DenseSubvector<VT2,AF1,TF2>
933  subvector( const DenseSubvector<VT2,AF2,TF2>& dv, size_t index, size_t size );
934 
935  template< typename VT2, bool AF2, bool TF2 >
936  friend bool isSame( const DenseSubvector<VT2,AF2,TF2>& a, const DenseVector<VT2,TF2>& b );
937 
938  template< typename VT2, bool AF2, bool TF2 >
939  friend bool isSame( const DenseVector<VT2,TF2>& a, const DenseSubvector<VT2,AF2,TF2>& b );
940 
941  template< typename VT2, bool AF2, bool TF2 >
942  friend bool isSame( const DenseSubvector<VT2,AF2,TF2>& a, const DenseSubvector<VT2,AF2,TF2>& b );
944  //**********************************************************************************************
945 
946  //**Compile time checks*************************************************************************
954  //**********************************************************************************************
955 };
956 //*************************************************************************************************
957 
958 
959 
960 
961 //=================================================================================================
962 //
963 // CONSTRUCTOR
964 //
965 //=================================================================================================
966 
967 //*************************************************************************************************
979 template< typename VT // Type of the dense vector
980  , bool AF // Alignment flag
981  , bool TF > // Transpose flag
982 inline DenseSubvector<VT,AF,TF>::DenseSubvector( Operand vector, size_t index, size_t n )
983  : vector_ ( vector ) // The vector containing the subvector
984  , offset_ ( index ) // The offset of the subvector within the dense vector
985  , size_ ( n ) // The size of the subvector
986  , rest_ ( n % IT::size ) // The number of remaining elements in an unaligned intrinsic operation
987  , final_ ( n - rest_ ) // The final index for unaligned intrinsic operations
988  , isAligned_( ( index % IT::size == 0UL ) &&
989  ( index + n == vector.size() || n % IT::size == 0UL ) )
990 {
991  if( index + n > vector.size() )
992  throw std::invalid_argument( "Invalid subvector specification" );
993 }
994 //*************************************************************************************************
995 
996 
997 
998 
999 //=================================================================================================
1000 //
1001 // DATA ACCESS FUNCTIONS
1002 //
1003 //=================================================================================================
1004 
1005 //*************************************************************************************************
1011 template< typename VT // Type of the dense vector
1012  , bool AF // Alignment flag
1013  , bool TF > // Transpose flag
1016 {
1017  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
1018  return vector_[offset_+index];
1019 }
1020 //*************************************************************************************************
1021 
1022 
1023 //*************************************************************************************************
1029 template< typename VT // Type of the dense vector
1030  , bool AF // Alignment flag
1031  , bool TF > // Transpose flag
1034 {
1035  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
1036  return const_cast<const VT&>( vector_ )[offset_+index];
1037 }
1038 //*************************************************************************************************
1039 
1040 
1041 //*************************************************************************************************
1048 template< typename VT // Type of the dense vector
1049  , bool AF // Alignment flag
1050  , bool TF > // Transpose flag
1052 {
1053  return vector_.data() + offset_;
1054 }
1055 //*************************************************************************************************
1056 
1057 
1058 //*************************************************************************************************
1065 template< typename VT // Type of the dense vector
1066  , bool AF // Alignment flag
1067  , bool TF > // Transpose flag
1069 {
1070  return vector_.data() + offset_;
1071 }
1072 //*************************************************************************************************
1073 
1074 
1075 //*************************************************************************************************
1082 template< typename VT // Type of the dense vector
1083  , bool AF // Alignment flag
1084  , bool TF > // Transpose flag
1086 {
1087  const typename VT::Iterator first( vector_.begin() + offset_ );
1088  return Iterator( first, first + final_, rest_, isAligned_ );
1089 }
1090 //*************************************************************************************************
1091 
1092 
1093 //*************************************************************************************************
1100 template< typename VT // Type of the dense vector
1101  , bool AF // Alignment flag
1102  , bool TF > // Transpose flag
1104 {
1105  const typename VT::ConstIterator first( vector_.cbegin() + offset_ );
1106  return ConstIterator( first, first + final_, rest_, isAligned_ );
1107 }
1108 //*************************************************************************************************
1109 
1110 
1111 //*************************************************************************************************
1118 template< typename VT // Type of the dense vector
1119  , bool AF // Alignment flag
1120  , bool TF > // Transpose flag
1122 {
1123  const typename VT::ConstIterator first( vector_.cbegin() + offset_ );
1124  return ConstIterator( first, first + final_, rest_, isAligned_ );
1125 }
1126 //*************************************************************************************************
1127 
1128 
1129 //*************************************************************************************************
1136 template< typename VT // Type of the dense vector
1137  , bool AF // Alignment flag
1138  , bool TF > // Transpose flag
1140 {
1141  const typename VT::Iterator last( vector_.begin() + offset_ + size_ );
1142  return Iterator( last, last, rest_, isAligned_ );
1143 }
1144 //*************************************************************************************************
1145 
1146 
1147 //*************************************************************************************************
1154 template< typename VT // Type of the dense vector
1155  , bool AF // Alignment flag
1156  , bool TF > // Transpose flag
1158 {
1159  const typename VT::ConstIterator last( vector_.cbegin() + offset_ + size_ );
1160  return ConstIterator( last, last, rest_, isAligned_ );
1161 }
1162 //*************************************************************************************************
1163 
1164 
1165 //*************************************************************************************************
1172 template< typename VT // Type of the dense vector
1173  , bool AF // Alignment flag
1174  , bool TF > // Transpose flag
1176 {
1177  const typename VT::ConstIterator last( vector_.cbegin() + offset_ + size_ );
1178  return ConstIterator( last, last, rest_, isAligned_ );
1179 }
1180 //*************************************************************************************************
1181 
1182 
1183 
1184 
1185 //=================================================================================================
1186 //
1187 // ASSIGNMENT OPERATORS
1188 //
1189 //=================================================================================================
1190 
1191 //*************************************************************************************************
1197 template< typename VT // Type of the dense vector
1198  , bool AF // Alignment flag
1199  , bool TF > // Transpose flag
1201 {
1202  const size_t iend( offset_ + size_ );
1203 
1204  for( size_t i=offset_; i<iend; ++i )
1205  vector_[i] = rhs;
1206 
1207  return *this;
1208 }
1209 //*************************************************************************************************
1210 
1211 
1212 //*************************************************************************************************
1222 template< typename VT // Type of the dense vector
1223  , bool AF // Alignment flag
1224  , bool TF > // Transpose flag
1226 {
1229 
1230  if( &rhs == this || ( &vector_ == &rhs.vector_ && offset_ == rhs.offset_ ) )
1231  return *this;
1232 
1233  if( size() != rhs.size() )
1234  throw std::invalid_argument( "Subvector sizes do not match" );
1235 
1236  if( rhs.canAlias( &vector_ ) ) {
1237  const ResultType tmp( ~rhs );
1238  smpAssign( *this, tmp );
1239  }
1240  else {
1241  smpAssign( *this, rhs );
1242  }
1243 
1244  return *this;
1245 }
1246 //*************************************************************************************************
1247 
1248 
1249 //*************************************************************************************************
1259 template< typename VT // Type of the dense vector
1260  , bool AF // Alignment flag
1261  , bool TF > // Transpose flag
1262 template< typename VT2 > // Type of the right-hand side vector
1264 {
1267 
1268  if( size() != (~rhs).size() )
1269  throw std::invalid_argument( "Vector sizes do not match" );
1270 
1271  if( (~rhs).canAlias( &vector_ ) ) {
1272  const typename VT2::ResultType tmp( ~rhs );
1273  smpAssign( *this, tmp );
1274  }
1275  else {
1277  reset();
1278  smpAssign( *this, ~rhs );
1279  }
1280 
1281  return *this;
1282 }
1283 //*************************************************************************************************
1284 
1285 
1286 //*************************************************************************************************
1296 template< typename VT // Type of the dense vector
1297  , bool AF // Alignment flag
1298  , bool TF > // Transpose flag
1299 template< typename VT2 > // Type of the right-hand side vector
1301 {
1304 
1305  if( size() != (~rhs).size() )
1306  throw std::invalid_argument( "Vector sizes do not match" );
1307 
1308  if( (~rhs).canAlias( &vector_ ) ) {
1309  const typename VT2::ResultType tmp( ~rhs );
1310  smpAddAssign( *this, tmp );
1311  }
1312  else {
1313  smpAddAssign( *this, ~rhs );
1314  }
1315 
1316  return *this;
1317 }
1318 //*************************************************************************************************
1319 
1320 
1321 //*************************************************************************************************
1331 template< typename VT // Type of the dense vector
1332  , bool AF // Alignment flag
1333  , bool TF > // Transpose flag
1334 template< typename VT2 > // Type of the right-hand side vector
1336 {
1339 
1340  if( size() != (~rhs).size() )
1341  throw std::invalid_argument( "Vector sizes do not match" );
1342 
1343  if( (~rhs).canAlias( &vector_ ) ) {
1344  const typename VT2::ResultType tmp( ~rhs );
1345  smpSubAssign( *this, tmp );
1346  }
1347  else {
1348  smpSubAssign( *this, ~rhs );
1349  }
1350 
1351  return *this;
1352 }
1353 //*************************************************************************************************
1354 
1355 
1356 //*************************************************************************************************
1367 template< typename VT // Type of the dense vector
1368  , bool AF // Alignment flag
1369  , bool TF > // Transpose flag
1370 template< typename VT2 > // Type of the right-hand side vector
1372 {
1375 
1376  if( size() != (~rhs).size() )
1377  throw std::invalid_argument( "Vector sizes do not match" );
1378 
1379  if( (~rhs).canAlias( &vector_ ) || IsSparseVector<VT2>::value ) {
1380  const ResultType tmp( *this * (~rhs) );
1381  smpAssign( *this, tmp );
1382  }
1383  else {
1384  smpMultAssign( *this, ~rhs );
1385  }
1386 
1387  return *this;
1388 }
1389 //*************************************************************************************************
1390 
1391 
1392 //*************************************************************************************************
1399 template< typename VT // Type of the dense vector
1400  , bool AF // Alignment flag
1401  , bool TF > // Transpose flag
1402 template< typename Other > // Data type of the right-hand side scalar
1403 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,AF,TF> >::Type&
1405 {
1406  smpAssign( *this, (*this) * rhs );
1407  return *this;
1408 }
1409 //*************************************************************************************************
1410 
1411 
1412 //*************************************************************************************************
1421 template< typename VT // Type of the dense vector
1422  , bool AF // Alignment flag
1423  , bool TF > // Transpose flag
1424 template< typename Other > // Data type of the right-hand side scalar
1425 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,AF,TF> >::Type&
1427 {
1428  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1429 
1430  smpAssign( *this, (*this) / rhs );
1431  return *this;
1432 }
1433 //*************************************************************************************************
1434 
1435 
1436 
1437 
1438 //=================================================================================================
1439 //
1440 // UTILITY FUNCTIONS
1441 //
1442 //=================================================================================================
1443 
1444 //*************************************************************************************************
1449 template< typename VT // Type of the dense vector
1450  , bool AF // Alignment flag
1451  , bool TF > // Transpose flag
1452 inline size_t DenseSubvector<VT,AF,TF>::size() const
1453 {
1454  return size_;
1455 }
1456 //*************************************************************************************************
1457 
1458 
1459 //*************************************************************************************************
1464 template< typename VT // Type of the dense vector
1465  , bool AF // Alignment flag
1466  , bool TF > // Transpose flag
1468 {
1469  return vector_.capacity() - offset_;
1470 }
1471 //*************************************************************************************************
1472 
1473 
1474 //*************************************************************************************************
1482 template< typename VT // Type of the dense vector
1483  , bool AF // Alignment flag
1484  , bool TF > // Transpose flag
1486 {
1487  size_t nonzeros( 0 );
1488 
1489  const size_t iend( offset_ + size_ );
1490  for( size_t i=offset_; i<iend; ++i ) {
1491  if( !isDefault( vector_[i] ) )
1492  ++nonzeros;
1493  }
1494 
1495  return nonzeros;
1496 }
1497 //*************************************************************************************************
1498 
1499 
1500 //*************************************************************************************************
1505 template< typename VT // Type of the dense vector
1506  , bool AF // Alignment flag
1507  , bool TF > // Transpose flag
1509 {
1510  using blaze::reset;
1511 
1512  const size_t iend( offset_ + size_ );
1513  for( size_t i=offset_; i<iend; ++i )
1514  reset( vector_[i] );
1515 }
1516 //*************************************************************************************************
1517 
1518 
1519 //*************************************************************************************************
1525 template< typename VT // Type of the dense vector
1526  , bool AF // Alignment flag
1527  , bool TF > // Transpose flag
1528 template< typename Other > // Data type of the scalar value
1530 {
1531  const size_t iend( offset_ + size_ );
1532  for( size_t i=offset_; i<iend; ++i )
1533  vector_[i] *= scalar;
1534  return *this;
1535 }
1536 //*************************************************************************************************
1537 
1538 
1539 
1540 
1541 //=================================================================================================
1542 //
1543 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1544 //
1545 //=================================================================================================
1546 
1547 //*************************************************************************************************
1557 template< typename VT // Type of the dense vector
1558  , bool AF // Alignment flag
1559  , bool TF > // Transpose flag
1560 template< typename Other > // Data type of the foreign expression
1561 inline bool DenseSubvector<VT,AF,TF>::canAlias( const Other* alias ) const
1562 {
1563  return vector_.isAliased( alias );
1564 }
1565 //*************************************************************************************************
1566 
1567 
1568 //*************************************************************************************************
1578 template< typename VT // Type of the dense vector
1579  , bool AF // Alignment flag
1580  , bool TF > // Transpose flag
1581 template< typename VT2 // Data type of the foreign dense subvector
1582  , bool AF2 // Alignment flag of the foreign dense subvector
1583  , bool TF2 > // Transpose flag of the foreign dense subvector
1585 {
1586  return ( vector_.isAliased( &alias->vector_ ) &&
1587  ( offset_ + size_ > alias->offset_ ) && ( offset_ < alias->offset_ + alias->size_ ) );
1588 }
1589 //*************************************************************************************************
1590 
1591 
1592 //*************************************************************************************************
1602 template< typename VT // Type of the dense vector
1603  , bool AF // Alignment flag
1604  , bool TF > // Transpose flag
1605 template< typename Other > // Data type of the foreign expression
1606 inline bool DenseSubvector<VT,AF,TF>::isAliased( const Other* alias ) const
1607 {
1608  return vector_.isAliased( alias );
1609 }
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 VT2 // Data type of the foreign dense subvector
1627  , bool AF2 // Alignment flag of the foreign dense subvector
1628  , bool TF2 > // Transpose flag of the foreign dense subvector
1630 {
1631  return ( vector_.isAliased( &alias->vector_ ) &&
1632  ( offset_ + size_ > alias->offset_ ) && ( offset_ < alias->offset_ + alias->size_ ) );
1633 }
1634 //*************************************************************************************************
1635 
1636 
1637 //*************************************************************************************************
1646 template< typename VT // Type of the dense vector
1647  , bool AF // Alignment flag
1648  , bool TF > // Transpose flag
1650 {
1651  return isAligned_;
1652 }
1653 //*************************************************************************************************
1654 
1655 
1656 //*************************************************************************************************
1666 template< typename VT // Type of the dense vector
1667  , bool AF // Alignment flag
1668  , bool TF > // Transpose flag
1670 {
1671  return ( size() > SMP_DVECASSIGN_THRESHOLD );
1672 }
1673 //*************************************************************************************************
1674 
1675 
1676 //*************************************************************************************************
1689 template< typename VT // Type of the dense vector
1690  , bool AF // Alignment flag
1691  , bool TF > // Transpose flag
1693  DenseSubvector<VT,AF,TF>::load( size_t index ) const
1694 {
1695  return loadu( index );
1696 }
1697 //*************************************************************************************************
1698 
1699 
1700 //*************************************************************************************************
1713 template< typename VT // Type of the dense vector
1714  , bool AF // Alignment flag
1715  , bool TF > // Transpose flag
1717  DenseSubvector<VT,AF,TF>::loadu( size_t index ) const
1718 {
1719  using blaze::load;
1720 
1722 
1723  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
1724  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
1725 
1726  if( isAligned_ ) {
1727  return vector_.load( offset_+index );
1728  }
1729  else if( index != final_ ) {
1730  return vector_.loadu( offset_+index );
1731  }
1732  else {
1734  for( size_t i=0UL; i<rest_; ++i )
1735  array[i] = vector_[offset_+index+i];
1736  for( size_t i=rest_; i<IT::size; ++i )
1737  array[i] = ElementType();
1738  return load( array.data() );
1739  }
1740 }
1741 //*************************************************************************************************
1742 
1743 
1744 //*************************************************************************************************
1758 template< typename VT // Type of the dense vector
1759  , bool AF // Alignment flag
1760  , bool TF > // Transpose flag
1761 inline void DenseSubvector<VT,AF,TF>::store( size_t index, const IntrinsicType& value )
1762 {
1763  storeu( index, value );
1764 }
1765 //*************************************************************************************************
1766 
1767 
1768 //*************************************************************************************************
1782 template< typename VT // Type of the dense vector
1783  , bool AF // Alignment flag
1784  , bool TF > // Transpose flag
1785 inline void DenseSubvector<VT,AF,TF>::storeu( size_t index, const IntrinsicType& value )
1786 {
1787  using blaze::store;
1788 
1790 
1791  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
1792  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
1793 
1794  if( isAligned_ ) {
1795  vector_.store( offset_+index, value );
1796  }
1797  else if( index != final_ ) {
1798  vector_.storeu( offset_+index, value );
1799  }
1800  else {
1802  store( array.data(), value );
1803  for( size_t i=0UL; i<rest_; ++i )
1804  vector_[offset_+index+i] = array[i];
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>::stream( size_t index, const IntrinsicType& value )
1828 {
1829  storeu( index, value );
1830 }
1831 //*************************************************************************************************
1832 
1833 
1834 //*************************************************************************************************
1845 template< typename VT // Type of the dense vector
1846  , bool AF // Alignment flag
1847  , bool TF > // Transpose flag
1848 template< typename VT2 > // Type of the right-hand side dense vector
1849 inline typename DisableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
1851 {
1852  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1853 
1854  const size_t iend( size() & size_t(-2) );
1855  for( size_t i=0UL; i<iend; i+=2UL ) {
1856  vector_[i+offset_ ] = (~rhs)[i ];
1857  vector_[i+offset_+1UL] = (~rhs)[i+1UL];
1858  }
1859  if( iend < size() ) {
1860  vector_[iend+offset_] = (~rhs)[iend];
1861  }
1862 }
1863 //*************************************************************************************************
1864 
1865 
1866 //*************************************************************************************************
1877 template< typename VT // Type of the dense vector
1878  , bool AF // Alignment flag
1879  , bool TF > // Transpose flag
1880 template< typename VT2 > // Type of the right-hand side dense vector
1881 inline typename EnableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
1883 {
1884  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1885 
1887 
1888  if( useStreaming && isAligned_ &&
1889  ( size_ > ( cacheSize/( sizeof(ElementType) * 3UL ) ) ) &&
1890  !(~rhs).isAliased( &vector_ ) )
1891  {
1892  for( size_t i=0UL; i<size(); i+=IT::size ) {
1893  vector_.stream( offset_+i, (~rhs).load(i) );
1894  }
1895  }
1896  else
1897  {
1898  const size_t iend( size_ & size_t(-IT::size*4) );
1899  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
1900 
1901  typename VT2::ConstIterator it( (~rhs).begin() );
1902  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1903  vector_.storeu( offset_+i , it.load() ); it += IT::size;
1904  vector_.storeu( offset_+i+IT::size , it.load() ); it += IT::size;
1905  vector_.storeu( offset_+i+IT::size*2UL, it.load() ); it += IT::size;
1906  vector_.storeu( offset_+i+IT::size*3UL, it.load() ); it += IT::size;
1907  }
1908  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
1909  storeu( i, it.load() );
1910  }
1911  }
1912 }
1913 //*************************************************************************************************
1914 
1915 
1916 //*************************************************************************************************
1927 template< typename VT // Type of the dense vector
1928  , bool AF // Alignment flag
1929  , bool TF > // Transpose flag
1930 template< typename VT2 > // Type of the right-hand side dense vector
1932 {
1933  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1934 
1935  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1936  vector_[element->index()+offset_] = element->value();
1937 }
1938 //*************************************************************************************************
1939 
1940 
1941 //*************************************************************************************************
1952 template< typename VT // Type of the dense vector
1953  , bool AF // Alignment flag
1954  , bool TF > // Transpose flag
1955 template< typename VT2 > // Type of the right-hand side dense vector
1956 inline typename DisableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
1958 {
1959  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1960 
1961  const size_t iend( size() & size_t(-2) );
1962  for( size_t i=0UL; i<iend; i+=2UL ) {
1963  vector_[i+offset_ ] += (~rhs)[i ];
1964  vector_[i+offset_+1UL] += (~rhs)[i+1UL];
1965  }
1966  if( iend < size() ) {
1967  vector_[iend+offset_] += (~rhs)[iend];
1968  }
1969 }
1970 //*************************************************************************************************
1971 
1972 
1973 //*************************************************************************************************
1984 template< typename VT // Type of the dense vector
1985  , bool AF // Alignment flag
1986  , bool TF > // Transpose flag
1987 template< typename VT2 > // Type of the right-hand side dense vector
1988 inline typename EnableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
1990 {
1991  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1992 
1994 
1995  const size_t iend( size_ & size_t(-IT::size*4) );
1996  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
1997 
1998  typename VT2::ConstIterator it( (~rhs).begin() );
1999  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
2000  vector_.storeu( offset_+i , load(i ) + it.load() ); it += IT::size;
2001  vector_.storeu( offset_+i+IT::size , load(i+IT::size ) + it.load() ); it += IT::size;
2002  vector_.storeu( offset_+i+IT::size*2UL, load(i+IT::size*2UL) + it.load() ); it += IT::size;
2003  vector_.storeu( offset_+i+IT::size*3UL, load(i+IT::size*3UL) + it.load() ); it += IT::size;
2004  }
2005  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
2006  storeu( i, load(i) + it.load() );
2007  }
2008 }
2009 //*************************************************************************************************
2010 
2011 
2012 //*************************************************************************************************
2023 template< typename VT // Type of the dense vector
2024  , bool AF // Alignment flag
2025  , bool TF > // Transpose flag
2026 template< typename VT2 > // Type of the right-hand side dense vector
2028 {
2029  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2030 
2031  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2032  vector_[element->index()+offset_] += element->value();
2033 }
2034 //*************************************************************************************************
2035 
2036 
2037 //*************************************************************************************************
2048 template< typename VT // Type of the dense vector
2049  , bool AF // Alignment flag
2050  , bool TF > // Transpose flag
2051 template< typename VT2 > // Type of the right-hand side dense vector
2052 inline typename DisableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
2054 {
2055  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2056 
2057  const size_t iend( size() & size_t(-2) );
2058  for( size_t i=0UL; i<iend; i+=2UL ) {
2059  vector_[i+offset_ ] -= (~rhs)[i ];
2060  vector_[i+offset_+1UL] -= (~rhs)[i+1UL];
2061  }
2062  if( iend < size() ) {
2063  vector_[iend+offset_] -= (~rhs)[iend];
2064  }
2065 }
2066 //*************************************************************************************************
2067 
2068 
2069 //*************************************************************************************************
2080 template< typename VT // Type of the dense vector
2081  , bool AF // Alignment flag
2082  , bool TF > // Transpose flag
2083 template< typename VT2 > // Type of the right-hand side dense vector
2084 inline typename EnableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
2086 {
2087  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2088 
2090 
2091  const size_t iend( size_ & size_t(-IT::size*4) );
2092  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
2093 
2094  typename VT2::ConstIterator it( (~rhs).begin() );
2095  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
2096  vector_.storeu( offset_+i , load(i ) - it.load() ); it += IT::size;
2097  vector_.storeu( offset_+i+IT::size , load(i+IT::size ) - it.load() ); it += IT::size;
2098  vector_.storeu( offset_+i+IT::size*2UL, load(i+IT::size*2UL) - it.load() ); it += IT::size;
2099  vector_.storeu( offset_+i+IT::size*3UL, load(i+IT::size*3UL) - it.load() ); it += IT::size;
2100  }
2101  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
2102  storeu( i, load(i) - it.load() );
2103  }
2104 }
2105 //*************************************************************************************************
2106 
2107 
2108 //*************************************************************************************************
2119 template< typename VT // Type of the dense vector
2120  , bool AF // Alignment flag
2121  , bool TF > // Transpose flag
2122 template< typename VT2 > // Type of the right-hand side dense vector
2124 {
2125  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2126 
2127  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2128  vector_[element->index()+offset_] -= element->value();
2129 }
2130 //*************************************************************************************************
2131 
2132 
2133 //*************************************************************************************************
2144 template< typename VT // Type of the dense vector
2145  , bool AF // Alignment flag
2146  , bool TF > // Transpose flag
2147 template< typename VT2 > // Type of the right-hand side dense vector
2148 inline typename DisableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
2150 {
2151  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2152 
2153  const size_t iend( size() & size_t(-2) );
2154  for( size_t i=0UL; i<iend; i+=2UL ) {
2155  vector_[i+offset_ ] *= (~rhs)[i ];
2156  vector_[i+offset_+1UL] *= (~rhs)[i+1UL];
2157  }
2158  if( iend < size() ) {
2159  vector_[iend+offset_] *= (~rhs)[iend];
2160  }
2161 }
2162 //*************************************************************************************************
2163 
2164 
2165 //*************************************************************************************************
2176 template< typename VT // Type of the dense vector
2177  , bool AF // Alignment flag
2178  , bool TF > // Transpose flag
2179 template< typename VT2 > // Type of the right-hand side dense vector
2180 inline typename EnableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
2182 {
2183  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2184 
2186 
2187  const size_t iend( size_ & size_t(-IT::size*4) );
2188  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
2189 
2190  typename VT2::ConstIterator it( (~rhs).begin() );
2191  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
2192  vector_.storeu( offset_+i , load(i ) * it.load() ); it += IT::size;
2193  vector_.storeu( offset_+i+IT::size , load(i+IT::size ) * it.load() ); it += IT::size;
2194  vector_.storeu( offset_+i+IT::size*2UL, load(i+IT::size*2UL) * it.load() ); it += IT::size;
2195  vector_.storeu( offset_+i+IT::size*3UL, load(i+IT::size*3UL) * it.load() ); it += IT::size;
2196  }
2197  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
2198  storeu( i, load(i) * it.load() );
2199  }
2200 }
2201 //*************************************************************************************************
2202 
2203 
2204 //*************************************************************************************************
2215 template< typename VT // Type of the dense vector
2216  , bool AF // Alignment flag
2217  , bool TF > // Transpose flag
2218 template< typename VT2 > // Type of the right-hand side dense vector
2220 {
2221  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2222 
2223  const ResultType tmp( serial( *this ) );
2224 
2225  reset();
2226 
2227  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2228  vector_[element->index()+offset_] = tmp[element->index()] * element->value();
2229 }
2230 //*************************************************************************************************
2231 
2232 
2233 
2234 
2235 
2236 
2237 
2238 
2239 //=================================================================================================
2240 //
2241 // CLASS TEMPLATE SPECIALIZATION FOR ALIGNED SUBVECTORS
2242 //
2243 //=================================================================================================
2244 
2245 //*************************************************************************************************
2253 template< typename VT // Type of the dense vector
2254  , bool TF > // Transpose flag
2255 class DenseSubvector<VT,aligned,TF> : public DenseVector< DenseSubvector<VT,aligned,TF>, TF >
2256  , private Subvector
2257 {
2258  private:
2259  //**Type definitions****************************************************************************
2261  typedef typename SelectType< IsExpression<VT>::value, VT, VT& >::Type Operand;
2262 
2265  //**********************************************************************************************
2266 
2267  //**********************************************************************************************
2269 
2275  enum { useConst = IsConst<VT>::value };
2276  //**********************************************************************************************
2277 
2278  public:
2279  //**Type definitions****************************************************************************
2280  typedef DenseSubvector<VT,aligned,TF> This;
2281  typedef typename SubvectorTrait<VT>::Type ResultType;
2282  typedef typename ResultType::TransposeType TransposeType;
2283  typedef typename VT::ElementType ElementType;
2284  typedef typename IT::Type IntrinsicType;
2285  typedef typename VT::ReturnType ReturnType;
2286  typedef const DenseSubvector& CompositeType;
2287 
2289  typedef typename VT::ConstReference ConstReference;
2290 
2292  typedef typename SelectType< useConst, ConstReference, typename VT::Reference >::Type Reference;
2293 
2295  typedef const ElementType* ConstPointer;
2296 
2298  typedef typename SelectType< useConst, ConstPointer, ElementType* >::Type Pointer;
2299 
2301  typedef typename VT::ConstIterator ConstIterator;
2302 
2304  typedef typename SelectType< useConst, ConstIterator, typename VT::Iterator >::Type Iterator;
2305  //**********************************************************************************************
2306 
2307  //**Compilation flags***************************************************************************
2309  enum { vectorizable = VT::vectorizable };
2310 
2312  enum { smpAssignable = VT::smpAssignable };
2313  //**********************************************************************************************
2314 
2315  //**Constructors********************************************************************************
2318  explicit inline DenseSubvector( Operand vector, size_t index, size_t n );
2319  // No explicitly declared copy constructor.
2321  //**********************************************************************************************
2322 
2323  //**Destructor**********************************************************************************
2324  // No explicitly declared destructor.
2325  //**********************************************************************************************
2326 
2327  //**Data access functions***********************************************************************
2330  inline Reference operator[]( size_t index );
2331  inline ConstReference operator[]( size_t index ) const;
2332  inline Pointer data ();
2333  inline ConstPointer data () const;
2334  inline Iterator begin ();
2335  inline ConstIterator begin () const;
2336  inline ConstIterator cbegin() const;
2337  inline Iterator end ();
2338  inline ConstIterator end () const;
2339  inline ConstIterator cend () const;
2341  //**********************************************************************************************
2342 
2343  //**Assignment operators************************************************************************
2346  inline DenseSubvector& operator= ( const ElementType& rhs );
2347  inline DenseSubvector& operator= ( const DenseSubvector& rhs );
2348  template< typename VT2 > inline DenseSubvector& operator= ( const Vector<VT2,TF>& rhs );
2349  template< typename VT2 > inline DenseSubvector& operator+=( const Vector<VT2,TF>& rhs );
2350  template< typename VT2 > inline DenseSubvector& operator-=( const Vector<VT2,TF>& rhs );
2351  template< typename VT2 > inline DenseSubvector& operator*=( const Vector<VT2,TF>& rhs );
2352 
2353  template< typename Other >
2354  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
2355  operator*=( Other rhs );
2356 
2357  template< typename Other >
2358  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
2359  operator/=( Other rhs );
2361  //**********************************************************************************************
2362 
2363  //**Utility functions***************************************************************************
2366  inline size_t size() const;
2367  inline size_t capacity() const;
2368  inline size_t nonZeros() const;
2369  inline void reset();
2370  template< typename Other > inline DenseSubvector& scale( const Other& scalar );
2372  //**********************************************************************************************
2373 
2374  private:
2375  //**********************************************************************************************
2377  template< typename VT2 >
2378  struct VectorizedAssign {
2379  enum { value = vectorizable && VT2::vectorizable &&
2380  IsSame<ElementType,typename VT2::ElementType>::value };
2381  };
2382  //**********************************************************************************************
2383 
2384  //**********************************************************************************************
2386  template< typename VT2 >
2387  struct VectorizedAddAssign {
2388  enum { value = vectorizable && VT2::vectorizable &&
2389  IsSame<ElementType,typename VT2::ElementType>::value &&
2390  IntrinsicTrait<ElementType>::addition };
2391  };
2392  //**********************************************************************************************
2393 
2394  //**********************************************************************************************
2396  template< typename VT2 >
2397  struct VectorizedSubAssign {
2398  enum { value = vectorizable && VT2::vectorizable &&
2399  IsSame<ElementType,typename VT2::ElementType>::value &&
2400  IntrinsicTrait<ElementType>::subtraction };
2401  };
2402  //**********************************************************************************************
2403 
2404  //**********************************************************************************************
2406  template< typename VT2 >
2407  struct VectorizedMultAssign {
2408  enum { value = vectorizable && VT2::vectorizable &&
2409  IsSame<ElementType,typename VT2::ElementType>::value &&
2410  IntrinsicTrait<ElementType>::multiplication };
2411  };
2412  //**********************************************************************************************
2413 
2414  public:
2415  //**Expression template evaluation functions****************************************************
2418  template< typename Other >
2419  inline bool canAlias( const Other* alias ) const;
2420 
2421  template< typename VT2, bool AF2, bool TF2 >
2422  inline bool canAlias( const DenseSubvector<VT2,AF2,TF2>* alias ) const;
2423 
2424  template< typename Other >
2425  inline bool isAliased( const Other* alias ) const;
2426 
2427  template< typename VT2, bool AF2, bool TF2 >
2428  inline bool isAliased( const DenseSubvector<VT2,AF2,TF2>* alias ) const;
2429 
2430  inline bool isAligned () const;
2431  inline bool canSMPAssign() const;
2432 
2433  inline IntrinsicType load ( size_t index ) const;
2434  inline IntrinsicType loadu ( size_t index ) const;
2435  inline void store ( size_t index, const IntrinsicType& value );
2436  inline void storeu( size_t index, const IntrinsicType& value );
2437  inline void stream( size_t index, const IntrinsicType& value );
2438 
2439  template< typename VT2 >
2440  inline typename DisableIf< VectorizedAssign<VT2> >::Type
2441  assign( const DenseVector <VT2,TF>& rhs );
2442 
2443  template< typename VT2 >
2444  inline typename EnableIf< VectorizedAssign<VT2> >::Type
2445  assign( const DenseVector <VT2,TF>& rhs );
2446 
2447  template< typename VT2 > inline void assign( const SparseVector<VT2,TF>& rhs );
2448 
2449  template< typename VT2 >
2450  inline typename DisableIf< VectorizedAddAssign<VT2> >::Type
2451  addAssign( const DenseVector <VT2,TF>& rhs );
2452 
2453  template< typename VT2 >
2454  inline typename EnableIf< VectorizedAddAssign<VT2> >::Type
2455  addAssign ( const DenseVector <VT2,TF>& rhs );
2456 
2457  template< typename VT2 > inline void addAssign( const SparseVector<VT2,TF>& rhs );
2458 
2459  template< typename VT2 >
2460  inline typename DisableIf< VectorizedSubAssign<VT2> >::Type
2461  subAssign ( const DenseVector <VT2,TF>& rhs );
2462 
2463  template< typename VT2 >
2464  inline typename EnableIf< VectorizedSubAssign<VT2> >::Type
2465  subAssign( const DenseVector <VT2,TF>& rhs );
2466 
2467  template< typename VT2 > inline void subAssign( const SparseVector<VT2,TF>& rhs );
2468 
2469  template< typename VT2 >
2470  inline typename DisableIf< VectorizedMultAssign<VT2> >::Type
2471  multAssign( const DenseVector <VT2,TF>& rhs );
2472 
2473  template< typename VT2 >
2474  inline typename EnableIf< VectorizedMultAssign<VT2> >::Type
2475  multAssign( const DenseVector <VT2,TF>& rhs );
2476 
2477  template< typename VT2 > inline void multAssign( const SparseVector<VT2,TF>& rhs );
2479  //**********************************************************************************************
2480 
2481  private:
2482  //**Member variables****************************************************************************
2485  Operand vector_;
2486  const size_t offset_;
2487  const size_t size_;
2488 
2489  //**********************************************************************************************
2490 
2491  //**Friend declarations*************************************************************************
2492  template< typename VT2, bool AF2, bool TF2 > friend class DenseSubvector;
2493 
2494  template< bool AF1, typename VT2, bool AF2, bool TF2 >
2495  friend const DenseSubvector<VT2,AF1,TF2>
2496  subvector( const DenseSubvector<VT2,AF2,TF2>& dv, size_t index, size_t size );
2497 
2498  template< typename VT2, bool AF2, bool TF2 >
2499  friend bool isSame( const DenseSubvector<VT2,AF2,TF2>& a, const DenseVector<VT2,TF2>& b );
2500 
2501  template< typename VT2, bool AF2, bool TF2 >
2502  friend bool isSame( const DenseVector<VT2,TF2>& a, const DenseSubvector<VT2,AF2,TF2>& b );
2503 
2504  template< typename VT2, bool AF2, bool TF2 >
2505  friend bool isSame( const DenseSubvector<VT2,AF2,TF2>& a, const DenseSubvector<VT2,AF2,TF2>& b );
2506  //**********************************************************************************************
2507 
2508  //**Compile time checks*************************************************************************
2514  //**********************************************************************************************
2515 };
2517 //*************************************************************************************************
2518 
2519 
2520 
2521 
2522 //=================================================================================================
2523 //
2524 // CONSTRUCTOR
2525 //
2526 //=================================================================================================
2527 
2528 //*************************************************************************************************
2541 template< typename VT // Type of the dense vector
2542  , bool TF > // Transpose flag
2543 inline DenseSubvector<VT,aligned,TF>::DenseSubvector( Operand vector, size_t index, size_t n )
2544  : vector_( vector ) // The vector containing the subvector
2545  , offset_( index ) // The offset of the subvector within the dense vector
2546  , size_ ( n ) // The size of the subvector
2547 {
2548  if( index + n > vector.size() )
2549  throw std::invalid_argument( "Invalid subvector specification" );
2550 
2551  if( offset_ % IT::size != 0UL || ( offset_ + size_ != vector_.size() && size_ % IT::size != 0UL ) )
2552  throw std::invalid_argument( "Invalid subvector alignment" );
2553 }
2555 //*************************************************************************************************
2556 
2557 
2558 
2559 
2560 //=================================================================================================
2561 //
2562 // DATA ACCESS FUNCTIONS
2563 //
2564 //=================================================================================================
2565 
2566 //*************************************************************************************************
2573 template< typename VT // Type of the dense vector
2574  , bool TF > // Transpose flag
2577 {
2578  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
2579  return vector_[offset_+index];
2580 }
2582 //*************************************************************************************************
2583 
2584 
2585 //*************************************************************************************************
2592 template< typename VT // Type of the dense vector
2593  , bool TF > // Transpose flag
2595  DenseSubvector<VT,aligned,TF>::operator[]( size_t index ) const
2596 {
2597  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
2598  return const_cast<const VT&>( vector_ )[offset_+index];
2599 }
2601 //*************************************************************************************************
2602 
2603 
2604 //*************************************************************************************************
2612 template< typename VT // Type of the dense vector
2613  , bool TF > // Transpose flag
2614 inline typename DenseSubvector<VT,aligned,TF>::Pointer DenseSubvector<VT,aligned,TF>::data()
2615 {
2616  return vector_.data() + offset_;
2617 }
2619 //*************************************************************************************************
2620 
2621 
2622 //*************************************************************************************************
2630 template< typename VT // Type of the dense vector
2631  , bool TF > // Transpose flag
2632 inline typename DenseSubvector<VT,aligned,TF>::ConstPointer DenseSubvector<VT,aligned,TF>::data() const
2633 {
2634  return vector_.data() + offset_;
2635 }
2637 //*************************************************************************************************
2638 
2639 
2640 //*************************************************************************************************
2648 template< typename VT // Type of the dense vector
2649  , bool TF > // Transpose flag
2651 {
2652  return ( vector_.begin() + offset_ );
2653 }
2655 //*************************************************************************************************
2656 
2657 
2658 //*************************************************************************************************
2666 template< typename VT // Type of the dense vector
2667  , bool TF > // Transpose flag
2670 {
2671  return ( vector_.cbegin() + offset_ );
2672 }
2674 //*************************************************************************************************
2675 
2676 
2677 //*************************************************************************************************
2685 template< typename VT // Type of the dense vector
2686  , bool TF > // Transpose flag
2689 {
2690  return ( vector_.cbegin() + offset_ );
2691 }
2693 //*************************************************************************************************
2694 
2695 
2696 //*************************************************************************************************
2704 template< typename VT // Type of the dense vector
2705  , bool TF > // Transpose flag
2707 {
2708  return ( vector_.begin() + offset_ + size_ );
2709 }
2711 //*************************************************************************************************
2712 
2713 
2714 //*************************************************************************************************
2722 template< typename VT // Type of the dense vector
2723  , bool TF > // Transpose flag
2726 {
2727  return ( vector_.cbegin() + offset_ + size_ );
2728 }
2730 //*************************************************************************************************
2731 
2732 
2733 //*************************************************************************************************
2741 template< typename VT // Type of the dense vector
2742  , bool TF > // Transpose flag
2745 {
2746  return ( vector_.cbegin() + offset_ + size_ );
2747 }
2749 //*************************************************************************************************
2750 
2751 
2752 
2753 
2754 //=================================================================================================
2755 //
2756 // ASSIGNMENT OPERATORS
2757 //
2758 //=================================================================================================
2759 
2760 //*************************************************************************************************
2767 template< typename VT // Type of the dense vector
2768  , bool TF > // Transpose flag
2769 inline DenseSubvector<VT,aligned,TF>&
2771 {
2772  const size_t iend( offset_ + size_ );
2773 
2774  for( size_t i=offset_; i<iend; ++i )
2775  vector_[i] = rhs;
2776 
2777  return *this;
2778 }
2780 //*************************************************************************************************
2781 
2782 
2783 //*************************************************************************************************
2794 template< typename VT // Type of the dense vector
2795  , bool TF > // Transpose flag
2796 inline DenseSubvector<VT,aligned,TF>&
2797  DenseSubvector<VT,aligned,TF>::operator=( const DenseSubvector& rhs )
2798 {
2801 
2802  if( &rhs == this || ( &vector_ == &rhs.vector_ && offset_ == rhs.offset_ ) )
2803  return *this;
2804 
2805  if( size() != rhs.size() )
2806  throw std::invalid_argument( "Subvector sizes do not match" );
2807 
2808  if( rhs.canAlias( &vector_ ) ) {
2809  const ResultType tmp( ~rhs );
2810  smpAssign( *this, tmp );
2811  }
2812  else {
2813  smpAssign( *this, rhs );
2814  }
2815 
2816  return *this;
2817 }
2819 //*************************************************************************************************
2820 
2821 
2822 //*************************************************************************************************
2833 template< typename VT // Type of the dense vector
2834  , bool TF > // Transpose flag
2835 template< typename VT2 > // Type of the right-hand side vector
2836 inline DenseSubvector<VT,aligned,TF>&
2837  DenseSubvector<VT,aligned,TF>::operator=( const Vector<VT2,TF>& rhs )
2838 {
2841 
2842  if( size() != (~rhs).size() )
2843  throw std::invalid_argument( "Vector sizes do not match" );
2844 
2845  if( (~rhs).canAlias( &vector_ ) ) {
2846  const typename VT2::ResultType tmp( ~rhs );
2847  smpAssign( *this, tmp );
2848  }
2849  else {
2850  if( IsSparseVector<VT2>::value )
2851  reset();
2852  smpAssign( *this, ~rhs );
2853  }
2854 
2855  return *this;
2856 }
2858 //*************************************************************************************************
2859 
2860 
2861 //*************************************************************************************************
2872 template< typename VT // Type of the dense vector
2873  , bool TF > // Transpose flag
2874 template< typename VT2 > // Type of the right-hand side vector
2875 inline DenseSubvector<VT,aligned,TF>&
2876  DenseSubvector<VT,aligned,TF>::operator+=( const Vector<VT2,TF>& rhs )
2877 {
2880 
2881  if( size() != (~rhs).size() )
2882  throw std::invalid_argument( "Vector sizes do not match" );
2883 
2884  if( (~rhs).canAlias( &vector_ ) ) {
2885  const typename VT2::ResultType tmp( ~rhs );
2886  smpAddAssign( *this, tmp );
2887  }
2888  else {
2889  smpAddAssign( *this, ~rhs );
2890  }
2891 
2892  return *this;
2893 }
2895 //*************************************************************************************************
2896 
2897 
2898 //*************************************************************************************************
2909 template< typename VT // Type of the dense vector
2910  , bool TF > // Transpose flag
2911 template< typename VT2 > // Type of the right-hand side vector
2912 inline DenseSubvector<VT,aligned,TF>&
2913  DenseSubvector<VT,aligned,TF>::operator-=( const Vector<VT2,TF>& rhs )
2914 {
2917 
2918  if( size() != (~rhs).size() )
2919  throw std::invalid_argument( "Vector sizes do not match" );
2920 
2921  if( (~rhs).canAlias( &vector_ ) ) {
2922  const typename VT2::ResultType tmp( ~rhs );
2923  smpSubAssign( *this, tmp );
2924  }
2925  else {
2926  smpSubAssign( *this, ~rhs );
2927  }
2928 
2929  return *this;
2930 }
2932 //*************************************************************************************************
2933 
2934 
2935 //*************************************************************************************************
2947 template< typename VT // Type of the dense vector
2948  , bool TF > // Transpose flag
2949 template< typename VT2 > // Type of the right-hand side vector
2950 inline DenseSubvector<VT,aligned,TF>&
2951  DenseSubvector<VT,aligned,TF>::operator*=( const Vector<VT2,TF>& rhs )
2952 {
2955 
2956  if( size() != (~rhs).size() )
2957  throw std::invalid_argument( "Vector sizes do not match" );
2958 
2959  if( (~rhs).canAlias( &vector_ ) || IsSparseVector<VT2>::value ) {
2960  const ResultType tmp( *this * (~rhs) );
2961  smpAssign( *this, tmp );
2962  }
2963  else {
2964  smpMultAssign( *this, ~rhs );
2965  }
2966 
2967  return *this;
2968 }
2970 //*************************************************************************************************
2971 
2972 
2973 //*************************************************************************************************
2981 template< typename VT // Type of the dense vector
2982  , bool TF > // Transpose flag
2983 template< typename Other > // Data type of the right-hand side scalar
2984 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,aligned,TF> >::Type&
2985  DenseSubvector<VT,aligned,TF>::operator*=( Other rhs )
2986 {
2987  smpAssign( *this, (*this) * rhs );
2988  return *this;
2989 }
2991 //*************************************************************************************************
2992 
2993 
2994 //*************************************************************************************************
3004 template< typename VT // Type of the dense vector
3005  , bool TF > // Transpose flag
3006 template< typename Other > // Data type of the right-hand side scalar
3007 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,aligned,TF> >::Type&
3008  DenseSubvector<VT,aligned,TF>::operator/=( Other rhs )
3009 {
3010  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3011 
3012  smpAssign( *this, (*this) / rhs );
3013  return *this;
3014 }
3016 //*************************************************************************************************
3017 
3018 
3019 
3020 
3021 //=================================================================================================
3022 //
3023 // UTILITY FUNCTIONS
3024 //
3025 //=================================================================================================
3026 
3027 //*************************************************************************************************
3033 template< typename VT // Type of the dense vector
3034  , bool TF > // Transpose flag
3035 inline size_t DenseSubvector<VT,aligned,TF>::size() const
3036 {
3037  return size_;
3038 }
3040 //*************************************************************************************************
3041 
3042 
3043 //*************************************************************************************************
3049 template< typename VT // Type of the dense vector
3050  , bool TF > // Transpose flag
3051 inline size_t DenseSubvector<VT,aligned,TF>::capacity() const
3052 {
3053  return vector_.capacity() - offset_;
3054 }
3056 //*************************************************************************************************
3057 
3058 
3059 //*************************************************************************************************
3068 template< typename VT // Type of the dense vector
3069  , bool TF > // Transpose flag
3070 inline size_t DenseSubvector<VT,aligned,TF>::nonZeros() const
3071 {
3072  size_t nonzeros( 0 );
3073 
3074  const size_t iend( offset_ + size_ );
3075  for( size_t i=offset_; i<iend; ++i ) {
3076  if( !isDefault( vector_[i] ) )
3077  ++nonzeros;
3078  }
3079 
3080  return nonzeros;
3081 }
3083 //*************************************************************************************************
3084 
3085 
3086 //*************************************************************************************************
3092 template< typename VT // Type of the dense vector
3093  , bool TF > // Transpose flag
3095 {
3096  using blaze::reset;
3097 
3098  const size_t iend( offset_ + size_ );
3099  for( size_t i=offset_; i<iend; ++i )
3100  reset( vector_[i] );
3101 }
3103 //*************************************************************************************************
3104 
3105 
3106 //*************************************************************************************************
3113 template< typename VT // Type of the dense vector
3114  , bool TF > // Transpose flag
3115 template< typename Other > // Data type of the scalar value
3116 inline DenseSubvector<VT,aligned,TF>& DenseSubvector<VT,aligned,TF>::scale( const Other& scalar )
3117 {
3118  const size_t iend( offset_ + size_ );
3119  for( size_t i=offset_; i<iend; ++i )
3120  vector_[i] *= scalar;
3121  return *this;
3122 }
3124 //*************************************************************************************************
3125 
3126 
3127 
3128 
3129 //=================================================================================================
3130 //
3131 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
3132 //
3133 //=================================================================================================
3134 
3135 //*************************************************************************************************
3146 template< typename VT // Type of the dense vector
3147  , bool TF > // Transpose flag
3148 template< typename Other > // Data type of the foreign expression
3149 inline bool DenseSubvector<VT,aligned,TF>::canAlias( const Other* alias ) const
3150 {
3151  return vector_.isAliased( alias );
3152 }
3154 //*************************************************************************************************
3155 
3156 
3157 //*************************************************************************************************
3168 template< typename VT // Type of the dense vector
3169  , bool TF > // Transpose flag
3170 template< typename VT2 // Data type of the foreign dense subvector
3171  , bool AF2 // Alignment flag of the foreign dense subvector
3172  , bool TF2 > // Transpose flag of the foreign dense subvector
3173 inline bool DenseSubvector<VT,aligned,TF>::canAlias( const DenseSubvector<VT2,AF2,TF2>* alias ) const
3174 {
3175  return ( vector_.isAliased( &alias->vector_ ) &&
3176  ( offset_ + size_ > alias->offset_ ) && ( offset_ < alias->offset_ + alias->size_ ) );
3177 }
3179 //*************************************************************************************************
3180 
3181 
3182 //*************************************************************************************************
3193 template< typename VT // Type of the dense vector
3194  , bool TF > // Transpose flag
3195 template< typename Other > // Data type of the foreign expression
3196 inline bool DenseSubvector<VT,aligned,TF>::isAliased( const Other* alias ) const
3197 {
3198  return vector_.isAliased( alias );
3199 }
3201 //*************************************************************************************************
3202 
3203 
3204 //*************************************************************************************************
3215 template< typename VT // Type of the dense vector
3216  , bool TF > // Transpose flag
3217 template< typename VT2 // Data type of the foreign dense subvector
3218  , bool AF2 // Alignment flag of the foreign dense subvector
3219  , bool TF2 > // Transpose flag of the foreign dense subvector
3220 inline bool DenseSubvector<VT,aligned,TF>::isAliased( const DenseSubvector<VT2,AF2,TF2>* alias ) const
3221 {
3222  return ( vector_.isAliased( &alias->vector_ ) &&
3223  ( offset_ + size_ > alias->offset_ ) && ( offset_ < alias->offset_ + alias->size_ ) );
3224 }
3226 //*************************************************************************************************
3227 
3228 
3229 //*************************************************************************************************
3239 template< typename VT // Type of the dense vector
3240  , bool TF > // Transpose flag
3241 inline bool DenseSubvector<VT,aligned,TF>::isAligned() const
3242 {
3243  return true;
3244 }
3246 //*************************************************************************************************
3247 
3248 
3249 //*************************************************************************************************
3260 template< typename VT // Type of the dense vector
3261  , bool TF > // Transpose flag
3263 {
3264  return ( size() > SMP_DVECASSIGN_THRESHOLD );
3265 }
3267 //*************************************************************************************************
3268 
3269 
3270 //*************************************************************************************************
3284 template< typename VT // Type of the dense vector
3285  , bool TF > // Transpose flag
3286 inline typename DenseSubvector<VT,aligned,TF>::IntrinsicType
3287  DenseSubvector<VT,aligned,TF>::load( size_t index ) const
3288 {
3290 
3291  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3292  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3293 
3294  return vector_.load( offset_+index );
3295 }
3297 //*************************************************************************************************
3298 
3299 
3300 //*************************************************************************************************
3314 template< typename VT // Type of the dense vector
3315  , bool TF > // Transpose flag
3316 inline typename DenseSubvector<VT,aligned,TF>::IntrinsicType
3317  DenseSubvector<VT,aligned,TF>::loadu( size_t index ) const
3318 {
3320 
3321  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3322  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3323 
3324  return vector_.loadu( offset_+index );
3325 }
3327 //*************************************************************************************************
3328 
3329 
3330 //*************************************************************************************************
3345 template< typename VT // Type of the dense vector
3346  , bool TF > // Transpose flag
3347 inline void DenseSubvector<VT,aligned,TF>::store( size_t index, const IntrinsicType& value )
3348 {
3350 
3351  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3352  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3353 
3354  vector_.store( offset_+index, value );
3355 }
3357 //*************************************************************************************************
3358 
3359 
3360 //*************************************************************************************************
3375 template< typename VT // Type of the dense vector
3376  , bool TF > // Transpose flag
3377 inline void DenseSubvector<VT,aligned,TF>::storeu( size_t index, const IntrinsicType& value )
3378 {
3380 
3381  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3382  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3383 
3384  vector_.storeu( offset_+index, value );
3385 }
3387 //*************************************************************************************************
3388 
3389 
3390 //*************************************************************************************************
3405 template< typename VT // Type of the dense vector
3406  , bool TF > // Transpose flag
3407 inline void DenseSubvector<VT,aligned,TF>::stream( size_t index, const IntrinsicType& value )
3408 {
3410 
3411  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3412  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3413 
3414  vector_.stream( offset_+index, value );
3415 }
3417 //*************************************************************************************************
3418 
3419 
3420 //*************************************************************************************************
3432 template< typename VT // Type of the dense vector
3433  , bool TF > // Transpose flag
3434 template< typename VT2 > // Type of the right-hand side dense vector
3435 inline typename DisableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
3436  DenseSubvector<VT,aligned,TF>::assign( const DenseVector<VT2,TF>& rhs )
3437 {
3438  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3439 
3440  const size_t iend( size() & size_t(-2) );
3441  for( size_t i=0UL; i<iend; i+=2UL ) {
3442  vector_[i+offset_ ] = (~rhs)[i ];
3443  vector_[i+offset_+1UL] = (~rhs)[i+1UL];
3444  }
3445  if( iend < size() ) {
3446  vector_[iend+offset_] = (~rhs)[iend];
3447  }
3448 }
3450 //*************************************************************************************************
3451 
3452 
3453 //*************************************************************************************************
3465 template< typename VT // Type of the dense vector
3466  , bool TF > // Transpose flag
3467 template< typename VT2 > // Type of the right-hand side dense vector
3468 inline typename EnableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
3469  DenseSubvector<VT,aligned,TF>::assign( const DenseVector<VT2,TF>& rhs )
3470 {
3471  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3472 
3474 
3475  if( useStreaming && size_ > ( cacheSize/( sizeof(ElementType) * 3UL ) ) && !(~rhs).isAliased( &vector_ ) )
3476  {
3477  for( size_t i=0UL; i<size(); i+=IT::size ) {
3478  vector_.stream( offset_+i, (~rhs).load(i) );
3479  }
3480  }
3481  else
3482  {
3483  const size_t iend( size_ & size_t(-IT::size*4) );
3484  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
3485 
3486  typename VT2::ConstIterator it( (~rhs).begin() );
3487  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
3488  store( i , it.load() ); it += IT::size;
3489  store( i+IT::size , it.load() ); it += IT::size;
3490  store( i+IT::size*2UL, it.load() ); it += IT::size;
3491  store( i+IT::size*3UL, it.load() ); it += IT::size;
3492  }
3493  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
3494  store( i, it.load() );
3495  }
3496  }
3497 }
3499 //*************************************************************************************************
3500 
3501 
3502 //*************************************************************************************************
3514 template< typename VT // Type of the dense vector
3515  , bool TF > // Transpose flag
3516 template< typename VT2 > // Type of the right-hand side dense vector
3517 inline void DenseSubvector<VT,aligned,TF>::assign( const SparseVector<VT2,TF>& rhs )
3518 {
3519  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3520 
3521  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3522  vector_[element->index()+offset_] = element->value();
3523 }
3525 //*************************************************************************************************
3526 
3527 
3528 //*************************************************************************************************
3540 template< typename VT // Type of the dense vector
3541  , bool TF > // Transpose flag
3542 template< typename VT2 > // Type of the right-hand side dense vector
3543 inline typename DisableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
3544  DenseSubvector<VT,aligned,TF>::addAssign( const DenseVector<VT2,TF>& rhs )
3545 {
3546  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3547 
3548  const size_t iend( size() & size_t(-2) );
3549  for( size_t i=0UL; i<iend; i+=2UL ) {
3550  vector_[i+offset_ ] += (~rhs)[i ];
3551  vector_[i+offset_+1UL] += (~rhs)[i+1UL];
3552  }
3553  if( iend < size() ) {
3554  vector_[iend+offset_] += (~rhs)[iend];
3555  }
3556 }
3558 //*************************************************************************************************
3559 
3560 
3561 //*************************************************************************************************
3573 template< typename VT // Type of the dense vector
3574  , bool TF > // Transpose flag
3575 template< typename VT2 > // Type of the right-hand side dense vector
3576 inline typename EnableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
3577  DenseSubvector<VT,aligned,TF>::addAssign( const DenseVector<VT2,TF>& rhs )
3578 {
3579  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3580 
3582 
3583  const size_t iend( size_ & size_t(-IT::size*4) );
3584  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
3585 
3586  typename VT2::ConstIterator it( (~rhs).begin() );
3587  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
3588  store( i , load(i ) + it.load() ); it += IT::size;
3589  store( i+IT::size , load(i+IT::size ) + it.load() ); it += IT::size;
3590  store( i+IT::size*2UL, load(i+IT::size*2UL) + it.load() ); it += IT::size;
3591  store( i+IT::size*3UL, load(i+IT::size*3UL) + it.load() ); it += IT::size;
3592  }
3593  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
3594  store( i, load(i) + it.load() );
3595  }
3596 }
3598 //*************************************************************************************************
3599 
3600 
3601 //*************************************************************************************************
3613 template< typename VT // Type of the dense vector
3614  , bool TF > // Transpose flag
3615 template< typename VT2 > // Type of the right-hand side dense vector
3616 inline void DenseSubvector<VT,aligned,TF>::addAssign( const SparseVector<VT2,TF>& rhs )
3617 {
3618  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3619 
3620  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3621  vector_[element->index()+offset_] += element->value();
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 DisableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
3643  DenseSubvector<VT,aligned,TF>::subAssign( const DenseVector<VT2,TF>& rhs )
3644 {
3645  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3646 
3647  const size_t iend( size() & size_t(-2) );
3648  for( size_t i=0UL; i<iend; i+=2UL ) {
3649  vector_[i+offset_ ] -= (~rhs)[i ];
3650  vector_[i+offset_+1UL] -= (~rhs)[i+1UL];
3651  }
3652  if( iend < size() ) {
3653  vector_[iend+offset_] -= (~rhs)[iend];
3654  }
3655 }
3657 //*************************************************************************************************
3658 
3659 
3660 //*************************************************************************************************
3672 template< typename VT // Type of the dense vector
3673  , bool TF > // Transpose flag
3674 template< typename VT2 > // Type of the right-hand side dense vector
3675 inline typename EnableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
3676  DenseSubvector<VT,aligned,TF>::subAssign( const DenseVector<VT2,TF>& rhs )
3677 {
3678  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3679 
3681 
3682  const size_t iend( size_ & size_t(-IT::size*4) );
3683  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
3684 
3685  typename VT2::ConstIterator it( (~rhs).begin() );
3686  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
3687  store( i , load(i ) - it.load() ); it += IT::size;
3688  store( i+IT::size , load(i+IT::size ) - it.load() ); it += IT::size;
3689  store( i+IT::size*2UL, load(i+IT::size*2UL) - it.load() ); it += IT::size;
3690  store( i+IT::size*3UL, load(i+IT::size*3UL) - it.load() ); it += IT::size;
3691  }
3692  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
3693  store( i, load(i) - it.load() );
3694  }
3695 }
3697 //*************************************************************************************************
3698 
3699 
3700 //*************************************************************************************************
3712 template< typename VT // Type of the dense vector
3713  , bool TF > // Transpose flag
3714 template< typename VT2 > // Type of the right-hand side dense vector
3715 inline void DenseSubvector<VT,aligned,TF>::subAssign( const SparseVector<VT2,TF>& rhs )
3716 {
3717  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3718 
3719  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3720  vector_[element->index()+offset_] -= element->value();
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 DisableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
3742  DenseSubvector<VT,aligned,TF>::multAssign( const DenseVector<VT2,TF>& rhs )
3743 {
3744  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3745 
3746  const size_t iend( size() & size_t(-2) );
3747  for( size_t i=0UL; i<iend; i+=2UL ) {
3748  vector_[i+offset_ ] *= (~rhs)[i ];
3749  vector_[i+offset_+1UL] *= (~rhs)[i+1UL];
3750  }
3751  if( iend < size() ) {
3752  vector_[iend+offset_] *= (~rhs)[iend];
3753  }
3754 }
3756 //*************************************************************************************************
3757 
3758 
3759 //*************************************************************************************************
3771 template< typename VT // Type of the dense vector
3772  , bool TF > // Transpose flag
3773 template< typename VT2 > // Type of the right-hand side dense vector
3774 inline typename EnableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
3775  DenseSubvector<VT,aligned,TF>::multAssign( const DenseVector<VT2,TF>& rhs )
3776 {
3777  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3778 
3780 
3781  const size_t iend( size_ & size_t(-IT::size*4) );
3782  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
3783 
3784  typename VT2::ConstIterator it( (~rhs).begin() );
3785  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
3786  store( i , load(i ) * it.load() ); it += IT::size;
3787  store( i+IT::size , load(i+IT::size ) * it.load() ); it += IT::size;
3788  store( i+IT::size*2UL, load(i+IT::size*2UL) * it.load() ); it += IT::size;
3789  store( i+IT::size*3UL, load(i+IT::size*3UL) * it.load() ); it += IT::size;
3790  }
3791  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
3792  store( i, load(i) * it.load() );
3793  }
3794 }
3796 //*************************************************************************************************
3797 
3798 
3799 //*************************************************************************************************
3811 template< typename VT // Type of the dense vector
3812  , bool TF > // Transpose flag
3813 template< typename VT2 > // Type of the right-hand side dense vector
3814 inline void DenseSubvector<VT,aligned,TF>::multAssign( const SparseVector<VT2,TF>& rhs )
3815 {
3816  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3817 
3818  const ResultType tmp( serial( *this ) );
3819 
3820  reset();
3821 
3822  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3823  vector_[element->index()+offset_] = tmp[element->index()] * element->value();
3824 }
3826 //*************************************************************************************************
3827 
3828 
3829 
3830 
3831 
3832 
3833 
3834 
3835 //=================================================================================================
3836 //
3837 // CLASS TEMPLATE SPECIALIZATION FOR DVECDVECCROSSEXPR
3838 //
3839 //=================================================================================================
3840 
3841 //*************************************************************************************************
3849 template< typename VT1 // Type of the left-hand side dense vector
3850  , typename VT2 > // Type of the right-hand side dense vector
3851 class DenseSubvector< DVecDVecCrossExpr<VT1,VT2>, unaligned, false >
3852  : public DenseVector< DenseSubvector< DVecDVecCrossExpr<VT1,VT2>, unaligned, false >, false >
3853  , private Subvector
3854 {
3855  private:
3856  //**Type definitions****************************************************************************
3857  typedef DVecDVecCrossExpr<VT1,VT2> CPE;
3858  typedef typename CPE::ResultType RT;
3859  //**********************************************************************************************
3860 
3861  public:
3862  //**Type definitions****************************************************************************
3863  typedef DenseSubvector<CPE,unaligned,false> This;
3864  typedef typename SubvectorTrait<RT>::Type ResultType;
3865  typedef typename ResultType::TransposeType TransposeType;
3866  typedef typename CPE::ElementType ElementType;
3867  typedef typename CPE::ReturnType ReturnType;
3868  typedef const ResultType CompositeType;
3869  //**********************************************************************************************
3870 
3871  //**Compilation flags***************************************************************************
3873  enum { vectorizable = 0 };
3874 
3876  enum { smpAssignable = 0 };
3877  //**********************************************************************************************
3878 
3879  //**Constructor*********************************************************************************
3886  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
3887  : vector_( vector ) // The dense vector/dense vector cross product expression
3888  , offset_( index ) // The offset of the subvector within the cross product expression
3889  , size_ ( n ) // The size of the subvector
3890  {}
3891  //**********************************************************************************************
3892 
3893  //**Subscript operator**************************************************************************
3899  inline ReturnType operator[]( size_t index ) const {
3900  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
3901  return vector_[offset_+index];
3902  }
3903  //**********************************************************************************************
3904 
3905  //**Size function*******************************************************************************
3910  inline size_t size() const {
3911  return size_;
3912  }
3913  //**********************************************************************************************
3914 
3915  //**********************************************************************************************
3921  template< typename T >
3922  inline bool canAlias( const T* alias ) const {
3923  return vector_.canAlias( alias );
3924  }
3925  //**********************************************************************************************
3926 
3927  //**********************************************************************************************
3933  template< typename T >
3934  inline bool isAliased( const T* alias ) const {
3935  return vector_.isAliased( alias );
3936  }
3937  //**********************************************************************************************
3938 
3939  private:
3940  //**Member variables****************************************************************************
3943  CPE vector_;
3944  const size_t offset_;
3945  const size_t size_;
3946 
3947  //**********************************************************************************************
3948 
3949  //**Friend declarations*************************************************************************
3950  template< bool AF1, typename VT, bool AF2, bool TF >
3951  friend const DenseSubvector<VT,AF1,TF>
3952  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size );
3953 
3954  template< typename VT3, bool AF3, bool TF3 >
3955  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseVector<VT3,TF3>& b );
3956 
3957  template< typename VT3, bool AF3, bool TF3 >
3958  friend bool isSame( const DenseVector<VT3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
3959 
3960  template< typename VT3, bool AF3, bool TF3 >
3961  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
3962  //**********************************************************************************************
3963 };
3965 //*************************************************************************************************
3966 
3967 
3968 
3969 
3970 
3971 
3972 
3973 
3974 //=================================================================================================
3975 //
3976 // CLASS TEMPLATE SPECIALIZATION FOR DVECSVECCROSSEXPR
3977 //
3978 //=================================================================================================
3979 
3980 //*************************************************************************************************
3988 template< typename VT1 // Type of the left-hand side dense vector
3989  , typename VT2 > // Type of the right-hand side sparse vector
3990 class DenseSubvector< DVecSVecCrossExpr<VT1,VT2>, unaligned, false >
3991  : public DenseVector< DenseSubvector< DVecSVecCrossExpr<VT1,VT2>, unaligned, false >, false >
3992  , private Subvector
3993 {
3994  private:
3995  //**Type definitions****************************************************************************
3996  typedef DVecSVecCrossExpr<VT1,VT2> CPE;
3997  typedef typename CPE::ResultType RT;
3998  //**********************************************************************************************
3999 
4000  public:
4001  //**Type definitions****************************************************************************
4002  typedef DenseSubvector<CPE,unaligned,false> This;
4003  typedef typename SubvectorTrait<RT>::Type ResultType;
4004  typedef typename ResultType::TransposeType TransposeType;
4005  typedef typename CPE::ElementType ElementType;
4006  typedef typename CPE::ReturnType ReturnType;
4007  typedef const ResultType CompositeType;
4008  //**********************************************************************************************
4009 
4010  //**Compilation flags***************************************************************************
4012  enum { vectorizable = 0 };
4013 
4015  enum { smpAssignable = 0 };
4016  //**********************************************************************************************
4017 
4018  //**Constructor*********************************************************************************
4025  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
4026  : vector_( vector ) // The dense vector/sparse vector cross product expression
4027  , offset_( index ) // The offset of the subvector within the cross product expression
4028  , size_ ( n ) // The size of the subvector
4029  {}
4030  //**********************************************************************************************
4031 
4032  //**Subscript operator**************************************************************************
4038  inline ReturnType operator[]( size_t index ) const {
4039  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4040  return vector_[offset_+index];
4041  }
4042  //**********************************************************************************************
4043 
4044  //**Size function*******************************************************************************
4049  inline size_t size() const {
4050  return size_;
4051  }
4052  //**********************************************************************************************
4053 
4054  //**********************************************************************************************
4060  template< typename T >
4061  inline bool canAlias( const T* alias ) const {
4062  return vector_.canAlias( alias );
4063  }
4064  //**********************************************************************************************
4065 
4066  //**********************************************************************************************
4072  template< typename T >
4073  inline bool isAliased( const T* alias ) const {
4074  return vector_.isAliased( alias );
4075  }
4076  //**********************************************************************************************
4077 
4078  private:
4079  //**Member variables****************************************************************************
4082  CPE vector_;
4083  const size_t offset_;
4084  const size_t size_;
4085 
4086  //**********************************************************************************************
4087 
4088  //**Friend declarations*************************************************************************
4089  template< bool AF1, typename VT, bool AF2, bool TF >
4090  friend const DenseSubvector<VT,AF1,TF>
4091  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size );
4092 
4093  template< typename VT3, bool AF3, bool TF3 >
4094  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseVector<VT3,TF3>& b );
4095 
4096  template< typename VT3, bool AF3, bool TF3 >
4097  friend bool isSame( const DenseVector<VT3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4098 
4099  template< typename VT3, bool AF3, bool TF3 >
4100  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4101  //**********************************************************************************************
4102 };
4104 //*************************************************************************************************
4105 
4106 
4107 
4108 
4109 
4110 
4111 
4112 
4113 //=================================================================================================
4114 //
4115 // CLASS TEMPLATE SPECIALIZATION FOR SVECDVECCROSSEXPR
4116 //
4117 //=================================================================================================
4118 
4119 //*************************************************************************************************
4127 template< typename VT1 // Type of the left-hand side sparse vector
4128  , typename VT2 > // Type of the right-hand side dense vector
4129 class DenseSubvector< SVecDVecCrossExpr<VT1,VT2>, unaligned, false >
4130  : public DenseVector< DenseSubvector< SVecDVecCrossExpr<VT1,VT2>, unaligned, false >, false >
4131  , private Subvector
4132 {
4133  private:
4134  //**Type definitions****************************************************************************
4135  typedef SVecDVecCrossExpr<VT1,VT2> CPE;
4136  typedef typename CPE::ResultType RT;
4137  //**********************************************************************************************
4138 
4139  public:
4140  //**Type definitions****************************************************************************
4141  typedef DenseSubvector<CPE,unaligned,false> This;
4142  typedef typename SubvectorTrait<RT>::Type ResultType;
4143  typedef typename ResultType::TransposeType TransposeType;
4144  typedef typename CPE::ElementType ElementType;
4145  typedef typename CPE::ReturnType ReturnType;
4146  typedef const ResultType CompositeType;
4147  //**********************************************************************************************
4148 
4149  //**Compilation flags***************************************************************************
4151  enum { vectorizable = 0 };
4152 
4154  enum { smpAssignable = 0 };
4155  //**********************************************************************************************
4156 
4157  //**Constructor*********************************************************************************
4164  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
4165  : vector_( vector ) // The sparse vector/dense vector cross product expression
4166  , offset_( index ) // The offset of the subvector within the cross product expression
4167  , size_ ( n ) // The size of the subvector
4168  {}
4169  //**********************************************************************************************
4170 
4171  //**Subscript operator**************************************************************************
4177  inline ReturnType operator[]( size_t index ) const {
4178  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4179  return vector_[offset_+index];
4180  }
4181  //**********************************************************************************************
4182 
4183  //**Size function*******************************************************************************
4188  inline size_t size() const {
4189  return size_;
4190  }
4191  //**********************************************************************************************
4192 
4193  //**********************************************************************************************
4199  template< typename T >
4200  inline bool canAlias( const T* alias ) const {
4201  return vector_.canAlias( alias );
4202  }
4203  //**********************************************************************************************
4204 
4205  //**********************************************************************************************
4211  template< typename T >
4212  inline bool isAliased( const T* alias ) const {
4213  return vector_.isAliased( alias );
4214  }
4215  //**********************************************************************************************
4216 
4217  private:
4218  //**Member variables****************************************************************************
4221  CPE vector_;
4222  const size_t offset_;
4223  const size_t size_;
4224 
4225  //**********************************************************************************************
4226 
4227  //**Friend declarations*************************************************************************
4228  template< bool AF1, typename VT, bool AF2, bool TF >
4229  friend const DenseSubvector<VT,AF1,TF>
4230  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size );
4231 
4232  template< typename VT3, bool AF3, bool TF3 >
4233  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseVector<VT3,TF3>& b );
4234 
4235  template< typename VT3, bool AF3, bool TF3 >
4236  friend bool isSame( const DenseVector<VT3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4237 
4238  template< typename VT3, bool AF3, bool TF3 >
4239  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4240  //**********************************************************************************************
4241 };
4243 //*************************************************************************************************
4244 
4245 
4246 
4247 
4248 
4249 
4250 
4251 
4252 //=================================================================================================
4253 //
4254 // CLASS TEMPLATE SPECIALIZATION FOR SVECSVECCROSSEXPR
4255 //
4256 //=================================================================================================
4257 
4258 //*************************************************************************************************
4266 template< typename VT1 // Type of the left-hand side sparse vector
4267  , typename VT2 > // Type of the right-hand side sparse vector
4268 class DenseSubvector< SVecSVecCrossExpr<VT1,VT2>, unaligned, false >
4269  : public DenseVector< DenseSubvector< SVecSVecCrossExpr<VT1,VT2>, unaligned, false >, false >
4270  , private Subvector
4271 {
4272  private:
4273  //**Type definitions****************************************************************************
4274  typedef SVecSVecCrossExpr<VT1,VT2> CPE;
4275  typedef typename CPE::ResultType RT;
4276  //**********************************************************************************************
4277 
4278  public:
4279  //**Type definitions****************************************************************************
4280  typedef DenseSubvector<CPE,unaligned,false> This;
4281  typedef typename SubvectorTrait<RT>::Type ResultType;
4282  typedef typename ResultType::TransposeType TransposeType;
4283  typedef typename CPE::ElementType ElementType;
4284  typedef typename CPE::ReturnType ReturnType;
4285  typedef const ResultType CompositeType;
4286  //**********************************************************************************************
4287 
4288  //**Compilation flags***************************************************************************
4290  enum { vectorizable = 0 };
4291 
4293  enum { smpAssignable = 0 };
4294  //**********************************************************************************************
4295 
4296  //**Constructor*********************************************************************************
4303  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
4304  : vector_( vector ) // The sparse vector/sparse vector cross product expression
4305  , offset_( index ) // The offset of the subvector within the cross product expression
4306  , size_ ( n ) // The size of the subvector
4307  {}
4308  //**********************************************************************************************
4309 
4310  //**Subscript operator**************************************************************************
4316  inline ReturnType operator[]( size_t index ) const {
4317  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4318  return vector_[offset_+index];
4319  }
4320  //**********************************************************************************************
4321 
4322  //**Size function*******************************************************************************
4327  inline size_t size() const {
4328  return size_;
4329  }
4330  //**********************************************************************************************
4331 
4332  //**********************************************************************************************
4338  template< typename T >
4339  inline bool canAlias( const T* alias ) const {
4340  return vector_.canAlias( alias );
4341  }
4342  //**********************************************************************************************
4343 
4344  //**********************************************************************************************
4350  template< typename T >
4351  inline bool isAliased( const T* alias ) const {
4352  return vector_.isAliased( alias );
4353  }
4354  //**********************************************************************************************
4355 
4356  private:
4357  //**Member variables****************************************************************************
4360  CPE vector_;
4361  const size_t offset_;
4362  const size_t size_;
4363 
4364  //**********************************************************************************************
4365 
4366  //**Friend declarations*************************************************************************
4367  template< bool AF1, typename VT, bool AF2, bool TF >
4368  friend const DenseSubvector<VT,AF1,TF>
4369  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size );
4370 
4371  template< typename VT3, bool AF3, bool TF3 >
4372  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseVector<VT3,TF3>& b );
4373 
4374  template< typename VT3, bool AF3, bool TF3 >
4375  friend bool isSame( const DenseVector<VT3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4376 
4377  template< typename VT3, bool AF3, bool TF3 >
4378  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4379  //**********************************************************************************************
4380 };
4382 //*************************************************************************************************
4383 
4384 
4385 
4386 
4387 
4388 
4389 
4390 
4391 //=================================================================================================
4392 //
4393 // DENSESUBVECTOR OPERATORS
4394 //
4395 //=================================================================================================
4396 
4397 //*************************************************************************************************
4400 template< typename VT, bool AF, bool TF >
4401 inline void reset( DenseSubvector<VT,AF,TF>& dv );
4402 
4403 template< typename VT, bool AF, bool TF >
4404 inline void clear( DenseSubvector<VT,AF,TF>& dv );
4405 
4406 template< typename VT, bool AF, bool TF >
4407 inline bool isDefault( const DenseSubvector<VT,AF,TF>& dv );
4408 
4409 template< typename VT, bool AF, bool TF >
4410 inline bool isSame( const DenseSubvector<VT,AF,TF>& a, const DenseVector<VT,TF>& b );
4411 
4412 template< typename VT, bool AF, bool TF >
4413 inline bool isSame( const DenseVector<VT,TF>& a, const DenseSubvector<VT,AF,TF>& b );
4414 
4415 template< typename VT, bool AF, bool TF >
4416 inline bool isSame( const DenseSubvector<VT,AF,TF>& a, const DenseSubvector<VT,AF,TF>& b );
4418 //*************************************************************************************************
4419 
4420 
4421 //*************************************************************************************************
4428 template< typename VT // Type of the dense vector
4429  , bool AF // Alignment flag
4430  , bool TF > // Transpose flag
4432 {
4433  dv.reset();
4434 }
4435 //*************************************************************************************************
4436 
4437 
4438 //*************************************************************************************************
4445 template< typename VT // Type of the dense vector
4446  , bool AF // Alignment flag
4447  , bool TF > // Transpose flag
4449 {
4450  dv.reset();
4451 }
4452 //*************************************************************************************************
4453 
4454 
4455 //*************************************************************************************************
4474 template< typename VT // Type of the dense vector
4475  , bool AF // Alignment flag
4476  , bool TF > // Transpose flag
4477 inline bool isDefault( const DenseSubvector<VT,AF,TF>& dv )
4478 {
4479  for( size_t i=0UL; i<dv.size(); ++i )
4480  if( !isDefault( dv[i] ) ) return false;
4481  return true;
4482 }
4483 //*************************************************************************************************
4484 
4485 
4486 //*************************************************************************************************
4498 template< typename VT, bool AF, bool TF >
4499 inline bool isSame( const DenseSubvector<VT,AF,TF>& a, const DenseVector<VT,TF>& b )
4500 {
4501  return ( isSame( a.vector_, ~b ) && ( a.size() == (~b).size() ) );
4502 }
4503 //*************************************************************************************************
4504 
4505 
4506 //*************************************************************************************************
4518 template< typename VT, bool AF, bool TF >
4519 inline bool isSame( const DenseVector<VT,TF>& a, const DenseSubvector<VT,AF,TF>& b )
4520 {
4521  return ( isSame( ~a, b.vector_ ) && ( (~a).size() == b.size() ) );
4522 }
4523 //*************************************************************************************************
4524 
4525 
4526 //*************************************************************************************************
4538 template< typename VT, bool AF, bool TF >
4540 {
4541  return ( isSame( a.vector_, b.vector_ ) && ( a.offset_ == b.offset_ ) && ( a.size_ == b.size_ ) );
4542 }
4543 //*************************************************************************************************
4544 
4545 
4546 
4547 
4548 //=================================================================================================
4549 //
4550 // GLOBAL RESTRUCTURING OPERATORS
4551 //
4552 //=================================================================================================
4553 
4554 //*************************************************************************************************
4567 template< bool AF1 // Required alignment flag
4568  , typename VT // Type of the dense vector
4569  , bool AF2 // Present alignment flag
4570  , bool TF > // Transpose flag
4571 inline const DenseSubvector<VT,AF1,TF>
4572  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size )
4573 {
4575 
4576  if( index + size > dv.size() )
4577  throw std::invalid_argument( "Invalid subvector specification" );
4578 
4579  return DenseSubvector<VT,AF1,TF>( dv.vector_, dv.offset_ + index, size );
4580 }
4582 //*************************************************************************************************
4583 
4584 
4585 
4586 
4587 //=================================================================================================
4588 //
4589 // SUBVECTORTRAIT SPECIALIZATIONS
4590 //
4591 //=================================================================================================
4592 
4593 //*************************************************************************************************
4595 template< typename VT, bool AF, bool TF >
4596 struct SubvectorTrait< DenseSubvector<VT,AF,TF> >
4597 {
4599 };
4601 //*************************************************************************************************
4602 
4603 
4604 
4605 
4606 //=================================================================================================
4607 //
4608 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
4609 //
4610 //=================================================================================================
4611 
4612 //*************************************************************************************************
4614 template< typename VT, bool AF1, bool TF, bool AF2 >
4615 struct SubvectorExprTrait< DenseSubvector<VT,AF1,TF>, AF2 >
4616 {
4617  typedef DenseSubvector<VT,AF2,TF> Type;
4618 };
4620 //*************************************************************************************************
4621 
4622 
4623 //*************************************************************************************************
4625 template< typename VT, bool AF1, bool TF, bool AF2 >
4626 struct SubvectorExprTrait< const DenseSubvector<VT,AF1,TF>, AF2 >
4627 {
4628  typedef DenseSubvector<VT,AF2,TF> Type;
4629 };
4631 //*************************************************************************************************
4632 
4633 
4634 //*************************************************************************************************
4636 template< typename VT, bool AF1, bool TF, bool AF2 >
4637 struct SubvectorExprTrait< volatile DenseSubvector<VT,AF1,TF>, AF2 >
4638 {
4639  typedef DenseSubvector<VT,AF2,TF> Type;
4640 };
4642 //*************************************************************************************************
4643 
4644 
4645 //*************************************************************************************************
4647 template< typename VT, bool AF1, bool TF, bool AF2 >
4648 struct SubvectorExprTrait< const volatile DenseSubvector<VT,AF1,TF>, AF2 >
4649 {
4650  typedef DenseSubvector<VT,AF2,TF> Type;
4651 };
4653 //*************************************************************************************************
4654 
4655 
4656 //*************************************************************************************************
4658 template< typename VT1, typename VT2, bool AF >
4659 struct SubvectorExprTrait< DVecDVecCrossExpr<VT1,VT2>, AF >
4660 {
4661  public:
4662  //**********************************************************************************************
4663  typedef DenseSubvector< DVecDVecCrossExpr<VT1,VT2>, unaligned, false > Type;
4664  //**********************************************************************************************
4665 };
4667 //*************************************************************************************************
4668 
4669 
4670 //*************************************************************************************************
4672 template< typename VT1, typename VT2, bool AF >
4673 struct SubvectorExprTrait< DVecSVecCrossExpr<VT1,VT2>, AF >
4674 {
4675  public:
4676  //**********************************************************************************************
4677  typedef DenseSubvector< DVecSVecCrossExpr<VT1,VT2>, unaligned, false > Type;
4678  //**********************************************************************************************
4679 };
4681 //*************************************************************************************************
4682 
4683 
4684 //*************************************************************************************************
4686 template< typename VT1, typename VT2, bool AF >
4687 struct SubvectorExprTrait< SVecDVecCrossExpr<VT1,VT2>, AF >
4688 {
4689  public:
4690  //**********************************************************************************************
4691  typedef DenseSubvector< SVecDVecCrossExpr<VT1,VT2>, unaligned, false > Type;
4692  //**********************************************************************************************
4693 };
4695 //*************************************************************************************************
4696 
4697 
4698 //*************************************************************************************************
4700 template< typename VT1, typename VT2, bool AF >
4701 struct SubvectorExprTrait< SVecSVecCrossExpr<VT1,VT2>, AF >
4702 {
4703  public:
4704  //**********************************************************************************************
4705  typedef DenseSubvector< SVecSVecCrossExpr<VT1,VT2>, unaligned, false > Type;
4706  //**********************************************************************************************
4707 };
4709 //*************************************************************************************************
4710 
4711 } // namespace blaze
4712 
4713 #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:909
Constraint on the data type.
bool canAlias(const Other *alias) const
Returns whether the dense subvector can alias with the given address alias.
Definition: DenseSubvector.h:1561
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4599
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:223
EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
Header file for the subvector/submatrix alignment flag values.
const size_t rest_
The number of remaining elements in an unaligned intrinsic operation.
Definition: DenseSubvector.h:908
void smpSubAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:152
IT::Type IntrinsicType
Intrinsic type of the subvector elements.
Definition: DenseSubvector.h:405
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4642
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:199
#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
void smpMultAssign(DenseVector< 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:179
ReferenceType reference
Reference return type.
Definition: DenseSubvector.h:449
EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:219
Header file for the IsSame and IsStrictlySame type traits.
size_t nonZeros() const
Returns the number of non-zero elements in the subvector.
Definition: DenseSubvector.h:1485
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:706
Header file for the IsRowVector type trait.
const DenseSubvector & CompositeType
Data type for composite expression templates.
Definition: DenseSubvector.h:407
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:690
Header file for the Computation base class.
IntrinsicType loadu() const
Unaligned load of an intrinsic element of the dense subvector.
Definition: DenseSubvector.h:570
#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:594
DenseSubvector(Operand vector, size_t index, size_t n)
The constructor for DenseSubvector.
Definition: DenseSubvector.h:982
IntrinsicTrait< typename VT::ElementType > IT
Intrinsic trait for the vector element type.
Definition: DenseSubvector.h:385
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4615
const size_t offset_
The offset of the subvector within the dense vector.
Definition: DenseSubvector.h:906
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:409
size_t capacity() const
Returns the maximum capacity of the dense subvector.
Definition: DenseSubvector.h:1467
SubvectorIterator(IteratorType iterator, IteratorType final, size_t rest, bool isAligned)
Constructor for the SubvectorIterator class.
Definition: DenseSubvector.h:461
Iterator begin()
Returns an iterator to the first element of the subvector.
Definition: DenseSubvector.h:1085
DenseSubvector & operator=(const ElementType &rhs)
Homogenous assignment to all subvector elements.
Definition: DenseSubvector.h:1200
const bool aligned
Alignment flag for aligned subvectors and submatrices.
Definition: AlignmentFlag.h:83
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:122
void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the subvector.
Definition: DenseSubvector.h:1827
Constraint on the data type.
void reset()
Reset to the default initial values.
Definition: DenseSubvector.h:1508
Pointer data()
Low-level data access to the subvector elements.
Definition: DenseSubvector.h:1051
DifferenceType difference_type
Difference between two iterators.
Definition: DenseSubvector.h:450
void smpAddAssign(DenseMatrix< 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:122
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:1761
Operand vector_
The dense vector containing the subvector.
Definition: DenseSubvector.h:905
const SubvectorIterator operator--(int)
Post-decrement operator.
Definition: DenseSubvector.h:530
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:1015
SubvectorIterator & operator++()
Pre-increment operator.
Definition: DenseSubvector.h:498
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2412
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:696
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:1121
DifferenceType operator-(const SubvectorIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DenseSubvector.h:660
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
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:271
friend const SubvectorIterator operator+(size_t inc, const SubvectorIterator &it)
Addition between an integral value and a SubvectorIterator.
Definition: DenseSubvector.h:684
bool operator!=(const SubvectorIterator &rhs) const
Inequality comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:605
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:519
IteratorType iterator_
Iterator to the current subvector element.
Definition: DenseSubvector.h:703
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
Constraint on the data type.
size_t size() const
Returns the current size/dimension of the dense subvector.
Definition: DenseSubvector.h:1452
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2406
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:361
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:2410
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.
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:216
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.
void smpAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:92
Header file for the IsNumeric type trait.
size_t rest_
The number of remaining elements beyond the final iterator.
Definition: DenseSubvector.h:705
SelectType< useConst, ConstIterator, SubvectorIterator< typename VT::Iterator > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseSubvector.h:716
Header file for the IsSparseVector type trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2407
Header file for the IsConst type trait.
Iterator end()
Returns an iterator just past the last element of the subvector.
Definition: DenseSubvector.h:1139
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:748
Header file for run time assertion macros.
Base class for all subvectors.The Subvector class serves as a tag for all subvectors (i...
Definition: Subvector.h:64
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:301
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:475
bool operator>(const SubvectorIterator &rhs) const
Greater-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:627
bool isAligned() const
Returns whether the subvector is properly aligned in memory.
Definition: DenseSubvector.h:1649
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
Header file for the reset shim.
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.
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:331
bool canSMPAssign() const
Returns whether the subvector can be used in SMP assignments.
Definition: DenseSubvector.h:1669
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2411
Header file for the isDefault shim.
ReferenceType operator*() const
Direct access to the element at the current iterator position.
Definition: DenseSubvector.h:540
const size_t size_
The size of the subvector.
Definition: DenseSubvector.h:907
#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:555
const SubvectorIterator operator++(int)
Post-increment operator.
Definition: DenseSubvector.h:509
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
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:713
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:1717
friend const SubvectorIterator operator+(const SubvectorIterator &it, size_t inc)
Addition between a SubvectorIterator and an integral value.
Definition: DenseSubvector.h:672
bool isAliased(const Other *alias) const
Returns whether the dense subvector is aliased with the given address alias.
Definition: DenseSubvector.h:1606
#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:914
IteratorType final_
The final iterator for intrinsic operations.
Definition: DenseSubvector.h:704
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:1693
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:250
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:649
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2403
ConstIterator cend() const
Returns an iterator just past the last element of the subvector.
Definition: DenseSubvector.h:1175
Header file for basic type definitions.
Header file for the SubvectorExprTrait class template.
SubvectorIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DenseSubvector.h:487
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:2409
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 plain dense ve...
Definition: Thresholds.h:207
void storeu(size_t index, const IntrinsicType &value)
Unaligned store of an intrinsic element of the subvector.
Definition: DenseSubvector.h:1785
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
bool operator<(const SubvectorIterator &rhs) const
Less-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:616
bool operator<=(const SubvectorIterator &rhs) const
Less-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:638
#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